-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
99 lines (67 loc) · 1.96 KB
/
Makefile
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
.PHONY: default build test
-include local.mak
default: build
SO=nfq.so nfct.so
BIN=conntracker nfct-expect-create-userspace expect-create-userspace
LIB=exptrack.lua
LUA=lua5.1
build: build-core build-conntracker
build-core: $(SO)
build-conntracker: $(BIN) $(LIB)
prefix=/usr/local
SODIR = $(DESTDIR)$(prefix)/lib/lua/5.1/
LIBDIR = $(DESTDIR)$(prefix)/share/lua/5.1/
BINDIR = $(DESTDIR)$(prefix)/bin/
.PHONY: install install-core install-conntracker
install: install-core install-conntracker
install-core: $(SO)
mkdir -p $(SODIR) && install -t $(SODIR) $(SO)
install-conntracker: $(BIN) $(LIB)
mkdir -p $(BINDIR) && install -t $(BINDIR) $(BIN)
mkdir -p $(LIBDIR) && install -t $(LIBDIR) $(LIB)
CLUA=$(shell pkg-config --cflags ${LUA})
LLUA=$(shell pkg-config --libs ${LUA})
FLAGS.SO=-fPIC -fno-common -shared
CWARNS = -Wall \
-std=c99 \
-pedantic \
-Wcast-align \
-Wnested-externs \
-Wpointer-arith \
-Wshadow \
-Wwrite-strings
COPT=-O2 -DNDEBUG -g
CFLAGS=$(CWARNS) $(CDEFS) $(LDFLAGS)
CC.SO := $(CC) $(COPT) $(CFLAGS)
%.so: %.c
$(CC.SO) $(FLAGS.SO) $(CLUA) -o $@ $^ $(LDLIBS) $(LLUA)
nfq.so: nfq.c nflua.h
nfq.so: LDLIBS+=-lnetfilter_queue
nfct.so: nfct.c nflua.h
nfct.so: LDLIBS+=-lnetfilter_conntrack
expect-create-userspace: CFLAGS+=-std=c99
expect-create-userspace: LDLIBS+=-lnetfilter_conntrack
expect-create-userspace: expect-create-userspace.c
options:
./luaopts PF /usr/include/bits/socket.h > _pf.c
./luaopts IPPROTO /usr/include/netinet/in.h > _ipproto.c
-./luaopts ATTR /usr/include/libnetfilter_conntrack/libnetfilter_conntrack.h > _attr.c
-./luaopts NFCT_Q /usr/include/libnetfilter_conntrack/libnetfilter_conntrack.h > _nfct_q.c
TNET=$(wildcard test-*.lua)
TOUT=$(TNET:.lua=.test)
echo:
echo $(TOUT)
test: $(TOUT)
%.test: %.lua net.so
lua $<
touch $@
%.test: %-test %.so
lua $<
touch $@
%.test: %-test net.so
lua $<
touch $@
doc: README.txt
README.txt: README.txt.in nfq.c nfct.c
cp README.txt.in $@
luadoc nfq.c nfct.c >> $@