summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile25
1 files changed, 12 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 46ad715..31dd09c 100644
--- a/Makefile
+++ b/Makefile
@@ -6,30 +6,29 @@ CFLAGS=
MACROS=\
-DZMQ_TOKEN=\"$(ZMQ_TOKEN)\" \
-DZMQ_MSG_SIZE=$(ZMQ_MSG_SIZE) \
--DLOGGERS_DELAY=$(LOGGERS_DELAY)
+-DLOG_DELAY=$(LOG_DELAY)
-all: publisher subscriber logger
+all: publisher subscriber
publisher: src/publisher.c src/utils.c config.mk
- $(CC) -lzmq $(filter-out config.mk,$^) -o $@ $(MACROS)
+ $(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)
-logger: src/logger.c src/utils.c config.mk
- $(CC) -lzmq -lpthread $(filter-out config.mk,$^) -o $@ $(MACROS)
-
-publish: publisher logger
- for client in $$(basename -a /sys/kernel/ina260/*); \
+publish: publisher
+ [ -f pid ] && { cat pid|xargs kill -INT; rm pid; } || exit 0
+ for client in $$(ls /sys/kernel/ina260/|xargs basename -a); \
do \
- ./logger $(LOGGERS_DIR) $$client $(LOG_INTERVAL) $(SUBSCRIBER_ADDR) $(ZMQ_PORT) $(KEY) ; \
- done
-# [ -f pid ] && { kill -INT $(shell cat pid); rm pid; }
+ ./$^ $$client $(LOG_INTERVAL) $(SUBSCRIBER_ADDR) $(ZMQ_PORT) $(KEY) > publisher_$${client}.log 2>&1 & \
+ echo $$! >> pid; \
+ done ;\
+ wait
subscribe: subscriber
- ./subscriber $(ZMQ_PORT) $(SUBSCRIBER_DIR)
+ ./$^ $(ZMQ_PORT) $(SUBSCRIBER_DIR)
clean:
- rm -f logger subscriber publisher
+ rm -f subscriber publisher
.PHONY: clean publish subscribe