1: # $Id: Makefile,v 1.1.1.3 2013/07/22 00:32:35 misho Exp $
2: CFLAGS?=-Wall -g -D_GNU_SOURCE -DDEBUG -Wstrict-prototypes -Wdeclaration-after-statement -ansi
3: CC = gcc
4:
5: #LIBS = -liptc
6: LIBS = -lip4tc
7:
8: ARCH := $(shell uname -m | grep -q "x86_64" && echo 64)
9: ifdef IPTABLESPATH
10: CFLAGS := $(CFLAGS) -I$(IPTABLESPATH)/include/
11: LDFLAGS := $(LDFLAFGS) -L$(IPTABLESPATH)/libiptc/
12: # get iptables version and set IPTABLES_143 macro if needed
13: IPTABLESVERSION := $(shell grep "\#define VERSION" $(IPTABLESPATH)/config.h | tr -d \" |cut -d" " -f3 )
14: IPTABLESVERSION1 := $(shell echo $(IPTABLESVERSION) | cut -d. -f1 )
15: IPTABLESVERSION2 := $(shell echo $(IPTABLESVERSION) | cut -d. -f2 )
16: IPTABLESVERSION3 := $(shell echo $(IPTABLESVERSION) | cut -d. -f3 )
17: # test if iptables version >= 1.4.3
18: TEST := $(shell [ \( \( $(IPTABLESVERSION1) -ge 1 \) -a \( $(IPTABLESVERSION2) -ge 4 \) \) -a \( $(IPTABLESVERSION3) -ge 3 \) ] && echo 1 )
19: ifeq ($(TEST), 1)
20: CFLAGS := $(CFLAGS) -DIPTABLES_143
21: # the following sucks, but works
22: LIBS = $(IPTABLESPATH)/libiptc/.libs/libip4tc.o
23: #LIBS = $(IPTABLESPATH)/libiptc/.libs/libiptc.a
24: else
25: LIBS = $(IPTABLESPATH)/libiptc/libiptc.a
26: endif
27: else
28: # check for system-wide iptables files. Test if iptables version >= 1.4.3
29: #TEST := $(shell test -f /usr/include/iptables/internal.h && grep -q "\#define IPTABLES_VERSION" /usr/include/iptables/internal.h && echo 1)
30: TEST := $(shell test -f /usr/include/xtables.h && grep -q "XTABLES_VERSION_CODE" /usr/include/xtables.h && echo 1)
31: ifeq ($(TEST), 1)
32: CFLAGS := $(CFLAGS) -DIPTABLES_143
33: LIBS = -liptc
34: TEST_LIB := $(shell test -f /usr/lib$(ARCH)/libiptc.a && echo 1)
35: ifeq ($(TEST_LIB), 1)
36: LIBS = -liptc /usr/lib$(ARCH)/libiptc.a
37: endif
38: endif
39: endif
40:
41: all: iptcrdr.o testiptcrdr iptpinhole.o testiptpinhole
42:
43: clean:
44: $(RM) *.o testiptcrdr testiptpinhole
45:
46: testiptcrdr: testiptcrdr.o iptcrdr.o upnpglobalvars.o $(LIBS)
47:
48: testiptpinhole: testiptpinhole.o iptpinhole.o upnpglobalvars.o $(LIBS)
49:
50: iptcrdr.o: iptcrdr.c iptcrdr.h
51:
52: iptpinhole.o: iptpinhole.c iptpinhole.h
53:
54: upnpglobalvars.o: ../upnpglobalvars.c ../upnpglobalvars.h
55: $(CC) -c -o $@ $<
56:
57:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>