ina260-zmq-publisher/Makefile
2023-08-10 14:21:39 +02:00

35 lines
853 B
Makefile

CONF=$(PWD)/config.mk
include $(CONF)
CC="gcc"
CFLAGS=
MACROS=\
-DZMQ_TOKEN=\"$(ZMQ_TOKEN)\" \
-DZMQ_MSG_SIZE=$(ZMQ_MSG_SIZE) \
-DLOG_DELAY=$(LOG_DELAY) \
-DMAX_QUEUE=$(MAX_QUEUE)
all: publisher subscriber
publisher: src/publisher.c src/utils.c config.mk
$(CC) -lzmq -lpthread $(filter-out config.mk,$^) -o $@ $(MACROS)
subscriber: src/subscriber.c src/utils.c config.mk
$(CC) -lzmq $(filter-out config.mk,$^) -o $@ $(MACROS)
publish: publisher
[ -f pid ] && { cat pid|xargs kill -INT; rm pid; } || exit 0
for client in $$(ls /sys/kernel/ina260/|xargs basename -a); \
do \
./$^ $$client $(LOG_INTERVAL) $(SUBSCRIBER_ADDR) $(ZMQ_PORT) $(KEY) > publisher_$${client}.log 2>&1 & \
echo $$! >> pid; \
done ;\
wait
subscribe: subscriber
./$^ $(ZMQ_PORT) $(SUBSCRIBER_DIR)
clean:
rm -f subscriber publisher
.PHONY: clean publish subscribe