2023-01-18 20:09:38 +01:00
|
|
|
CC=gcc
|
|
|
|
CFLAGS=-Wall -Wextra #-Wno-implicit-function-declaration
|
|
|
|
LDFLAGS=-I build/ -L build/ -lipc
|
|
|
|
|
2023-01-20 03:50:47 +01:00
|
|
|
bin: build.zig apps/*.zig src/*.zig
|
|
|
|
$(ZIGC) build
|
2023-01-18 20:09:38 +01:00
|
|
|
|
2023-01-20 03:50:47 +01:00
|
|
|
lib: build.zig src/*.zig
|
2023-01-18 20:09:38 +01:00
|
|
|
$(ZIGC) build
|
|
|
|
|
|
|
|
stop-ipcd:
|
|
|
|
-pkill -1 ipcd
|
|
|
|
|
|
|
|
stop-tcpd:
|
|
|
|
-pkill -1 tcpd
|
|
|
|
|
2023-01-20 03:50:47 +01:00
|
|
|
run-ipcd:
|
2023-01-18 20:09:38 +01:00
|
|
|
-rm /tmp/libipc-run/ipc 2>/dev/null || true
|
|
|
|
$(VALGRIND) ./ipcd
|
|
|
|
|
2023-01-20 03:50:47 +01:00
|
|
|
run-pongd:
|
2023-01-18 20:09:38 +01:00
|
|
|
-rm /tmp/libipc-run/pong 2>/dev/null || true
|
|
|
|
$(VALGRIND) ./pongd
|
|
|
|
|
2023-01-20 03:50:47 +01:00
|
|
|
run-tcpd:
|
2023-01-18 20:09:38 +01:00
|
|
|
@-rm /tmp/libipc-run/tcp 2>/dev/null || true
|
|
|
|
$(VALGRIND) ./tcpd
|
|
|
|
|
|
|
|
TCP_SERVICE_ALT ?= 127.0.0.1:9898
|
2023-01-20 03:50:47 +01:00
|
|
|
run-tcpd-alternative:
|
2023-01-18 20:09:38 +01:00
|
|
|
-rm /tmp/libipc-run/tcpdup 2>/dev/null || true
|
|
|
|
IPC_SERVICE_NAME=tcpdup ADDRESS=$(TCP_SERVICE_ALT) $(VALGRIND) ./tcpd
|
|
|
|
|
|
|
|
SERVICE_NAME ?= p
|
2023-01-18 23:56:23 +01:00
|
|
|
IPC_NETWORK ?= p unix://pong
|
2023-01-20 03:50:47 +01:00
|
|
|
run-pong:
|
2023-01-18 20:09:38 +01:00
|
|
|
@#Force pong to contact IPCd.
|
|
|
|
@#SERVICE is the service to contact and IPC_NETWORK is the IPCd
|
|
|
|
@#configuration to translate "p" into "pong" (still using UNIX
|
|
|
|
@#sockets on the same computer).
|
|
|
|
SERVICE="$(SERVICE_NAME)" IPC_NETWORK="$(IPC_NETWORK)" $(VALGRIND) ./pong
|
|
|
|
|
2023-01-20 03:50:47 +01:00
|
|
|
run-pong-test-tcpd:
|
2023-01-18 20:09:38 +01:00
|
|
|
SERVICE="pong" IPC_NETWORK="pong tcp://$(TCP_SERVICE_ALT)/pong" $(VALGRIND) ./pong
|
|
|
|
|
|
|
|
ifeq ($(SRC),)
|
|
|
|
test-src:
|
|
|
|
@echo SRC must be set via command line.
|
|
|
|
@exit 1
|
|
|
|
else
|
|
|
|
test-src:
|
|
|
|
endif
|
|
|
|
|
2023-01-20 03:50:47 +01:00
|
|
|
comp: bin test-bindings-pong test-bindings-pongd
|
2023-01-18 20:09:38 +01:00
|
|
|
|
|
|
|
list-obj-files: test-src
|
|
|
|
@# List all .o included in a .a archive.
|
|
|
|
ar t $(SRC)
|
|
|
|
list-symbols: test-src
|
|
|
|
@# List all symbols in a .so.
|
|
|
|
nm -D $(SRC)
|
|
|
|
list-symbols-alt: test-src
|
|
|
|
@# Alternative: grep .text section in an objdump output.
|
|
|
|
objdump -T $(SRC) | grep text
|
|
|
|
|
|
|
|
bindings-compile-pong: test-bindings/pong.c
|
|
|
|
@-mkdir bin-bindings 2>/dev/null || true
|
|
|
|
$(CC) -o bin-bindings/pong build/libipc.so $(CFLAGS) $^ $(LDFLAGS)
|
|
|
|
|
|
|
|
bindings-compile-pongd: test-bindings/pongd.c
|
|
|
|
@-mkdir bin-bindings 2>/dev/null || true
|
|
|
|
$(CC) -o bin-bindings/pongd build/libipc.so $(CFLAGS) $^ $(LDFLAGS)
|
|
|
|
|
|
|
|
bindings-test-pong:
|
|
|
|
LD_LIBRARY_PATH=build/ $(VALGRIND) ./bin-bindings/pong
|
|
|
|
|
|
|
|
bindings-test-pongd:
|
|
|
|
-rm /tmp/libipc-run/pong 2>/dev/null || true
|
|
|
|
LD_LIBRARY_PATH=build/ $(VALGRIND) ./bin-bindings/pongd
|
|
|
|
|
|
|
|
WS_SERVICE ?= 127.0.0.1:8080
|
|
|
|
TCP_SERVICE ?= 127.0.0.1:9000
|
|
|
|
init-websocket-tcpd:
|
|
|
|
@# '-b' binary, '-E' quit on end-of-file, 'ws-l' websocket URI to listen
|
|
|
|
@# each connection is redirected to last parameter
|
|
|
|
websocat -b -E ws-l:$(WS_SERVICE) tcp:$(TCP_SERVICE)
|
|
|
|
|
|
|
|
init-websocket-client:
|
2023-01-20 03:50:47 +01:00
|
|
|
@# websocat -b -E tcp-l:127.0.0.1:9000 ws://127.0.0.1:9999
|
2023-01-18 20:09:38 +01:00
|
|
|
websocat -b -E ws://$(WS_SERVICE)
|
|
|
|
|
2023-01-20 03:50:47 +01:00
|
|
|
.PHONY: bin lib
|