ina260-zmq-publisher/Makefile
2024-02-01 15:25:11 +01:00

36 lines
882 B
Makefile

CONF=$(PWD)/config.mk
include $(CONF)
CC="gcc"
CFLAGS=-lzmq
MACROS=\
-DZMQ_TOKEN=\"$(ZMQ_TOKEN)\" \
-DZMQ_MSG_SIZE=$(ZMQ_MSG_SIZE) \
-DLOG_DELAY=$(LOG_DELAY) \
-DMAX_QUEUE=$(MAX_QUEUE) \
-DRCV_CMD=":"
all: publisher subscriber
publisher: src/publisher.c src/utils.c config.mk
$(CC) $(filter-out config.mk,$^) -o $@ $(MACROS) $(CFLAGS) -lpthread
subscriber: src/subscriber.c src/utils.c config.mk
$(CC) $(filter-out config.mk,$^) -o $@ $(MACROS) $(CFLAGS)
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