summaryrefslogtreecommitdiff
path: root/Makefile
blob: 7259e15dae22d770a7cf85a776f37da5a016c231 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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