-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathMakefile
79 lines (54 loc) · 1.2 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
.PHONY: default build test
-include local.mak
default: build
UNAME=$(shell uname)
include $(UNAME).mak
BINDING=pcap.so
build: $(BINDING)
prefix=/usr/local
SODIR = $(DESTDIR)/$(prefix)/lib/lua/5.1/
LIBDIR = $(DESTDIR)/$(prefix)/share/lua/5.1/
BINDIR = $(DESTDIR)/$(prefix)/bin/
.PHONY: install
install: $(BINDING)
mkdir -p $(SODIR)
install -t $(SODIR) $(BINDING)
.PHONY: install-all
install-all: install
mkdir -p $(LIBDIR)
mkdir -p $(BINDIR)
install -t $(LIBDIR) pcapx.lua
install -t $(BINDIR) pcap-recode pcap-dump pcap-split
CWARNS = -Wall \
-pedantic \
-Wcast-align \
-Wnested-externs \
-Wpointer-arith \
-Wshadow \
-Wwrite-strings
COPT=-O2 -DNDEBUG
CFLAGS=$(CWARNS) $(CDEFS) $(CLUA) $(LDFLAGS) $(shell pcap-config --cflags)
LDLIBS=$(LLUA) $(shell pcap-config --libs)
CC.SO := $(CC) $(COPT) $(CFLAGS)
%.so: %.c
$(CC.SO) -o $@ $^ $(LDLIBS)
pcap.so: pcap.c
TNET=$(wildcard test-*.lua)
TOUT=$(TNET:.lua=.test)
echo:
echo $(TOUT)
test: pcap.test $(TOUT)
%.test: %.lua net.so
$(LUA) $<
touch $@
%.test: %-test %.so
$(LUA) $<
touch $@
%.test: %-test net.so
$(LUA) $<
touch $@
doc: README.txt
.PHONY: README.txt
README.txt: README.txt.in pcap.c
cp README.txt.in $@
luadoc pcap.c >> $@