blob: 88ea7091c4af4bd3094209bd55d99b231c2ce615 [file] [log] [blame]
Minos Galanakis2c824b42025-03-20 09:28:45 +00001CFLAGS ?= -Wall -std=c99
2INCLUDE := -I./include/
3DESTDIR ?= /usr/local
4PREFIX := libpsaff
5BUILDDIR ?= bin
6
7.PHONY: all install test uninstall run docker ci
8
9all: libpsaff.so
10
11libpsaff.so:
12 $(CC) $(INCLUDE) $(CFLAGS) -c -fpic src/common.c -o common.o
13 $(CC) $(INCLUDE) $(CFLAGS) -c -fpic src/client.c -o client.o
14 $(CC) $(INCLUDE) $(CFLAGS) -c -fpic src/service.c -o server.o
15 $(CC) -shared -o libpsaff.so common.o client.o server.o
16
17ifeq ($(DEBUG),1)
18 CFLAGS += -DDEBUG -g
19endif
20
21clean:
22 rm -rf $(BUILDDIR)
23 rm -f *.so *.o
24 rm -rf test/*dSYM
25 cd test && make clean
26
27test:
28 cd test && make
29
30test/partition:
31 cd test && make
32
33run: test/partition
34 pkill partition || true
35 pkill client || true
36 ipcs | grep q | awk '{ printf " -q " $$2 }' | xargs ipcrm > /dev/null 2>&1 || true
37 (sleep 3 && ./test/client)&
38 ./test/partition
39
40ci:
41 pkill client || true
42 ipcs | grep q | awk '{ printf " -q " $$2 }' | xargs ipcrm > /dev/null 2>&1 || true
43 ./test/partition 2>&1 &
44 sleep 3 && ./test/client
45 pkill partition || true
46
47docker:
48 @docker run --rm -ti -v $$PWD:/opt --entrypoint /bin/bash ubuntu \
49 -c "cd /opt && ls && apt-get update -qq && apt install \
50 -y gcc make gdb python -qq && make clean && make install && make test && ldconfig && make run"
51
52install: libpsaff.so
53 mkdir -p $(DESTDIR)/lib
54 mkdir -p $(DESTDIR)/include
55 cp libpsaff.so $(DESTDIR)/lib/
56 cp -r include/* $(DESTDIR)/include/
57 cp tools/psa_autogen /usr/local/bin/
58
59uninstall:
60 rm $(DESTDIR)/lib/libpsaff.so
61 rm -rf $(DESTDIR)/include/psa
62 rm -rf $(DESTDIR)/include/psasim
63 rm -f /usr/local/bin/psa_autogen
64