blob: 640e5b8d2371804cd23f6914a87069c3f6218424 [file] [log] [blame]
Marc Bouchere6869a82000-03-20 06:03:29 +00001# Standard part of Makefile for topdir.
2TOPLEVEL_INCLUDED=YES
3
4ifndef KERNEL_DIR
5KERNEL_DIR=/usr/src/linux
6endif
Rusty Russell849779c2000-04-23 15:51:51 +00007NETFILTER_VERSION:=1.0.1
8OLD_NETFILTER_VERSION:=1.0.0
Marc Bouchere6869a82000-03-20 06:03:29 +00009
10LIBDIR:=/usr/local/lib
11BINDIR:=/usr/local/bin
12MANDIR:=/usr/local/man
13
Rusty Russell849779c2000-04-23 15:51:51 +000014COPT_FLAGS:=-O #-O2
15CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -Iinclude/ -I$(KERNEL_DIR)/include -DNETFILTER_VERSION=\"$(NETFILTER_VERSION)\" -g #-pg # -DNDEBUG
Marc Bouchere6869a82000-03-20 06:03:29 +000016
17DEPFILES := $(SHARED_LIBS:%.so=%.d)
18SH_CFLAGS:=$(CFLAGS) -fPIC
19DEPFILES := $(SHARED_LIBS:%.so=%.d)
20
21EXTRAS+=iptables iptables.o #iptables-save iptables-restore
22EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables $(DESTDIR)$(MANDIR)/man8/iptables.8 #$(DESTDIR)$(BINDIR)/iptables-save $(DESTDIR)$(BINDIR)/iptables-restore
23
Rusty Russell09b9a412000-04-27 10:16:47 +000024# Sparc64 hack
25ifeq ($(shell uname -m),sparc64)
26# The kernel is 64-bit, even though userspace is 32.
27CFLAGS+=-DIPT_MIN_MATCH_ALIGN=8 -DIPT_MIN_ENTRY_ALIGN=8
28endif
29
Marc Bouchere6869a82000-03-20 06:03:29 +000030ifndef IPT_LIBDIR
31IPT_LIBDIR:=$(LIBDIR)/iptables
32endif
33
34default: all
35
36iptables.o: iptables.c
37 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
38
39iptables: iptables-standalone.c iptables.o libiptc/libiptc.a
40 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
41
42$(DESTDIR)$(BINDIR)/iptables: iptables
43 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
44 cp $< $@
45
46iptables-save: iptables-save.c iptables.o libiptc/libiptc.a
47 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
48
49$(DESTDIR)$(BINDIR)/iptables-save: iptables-save
50 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
51 cp $< $@
52
53iptables-restore: iptables-restore.c iptables.o libiptc/libiptc.a
54 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
55
56$(DESTDIR)$(BINDIR)/iptables-restore: iptables-restore
57 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
58 cp $< $@
59
60$(DESTDIR)$(MANDIR)/man8/iptables.8: iptables.8
61 @[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
62 cp $< $@
63
64EXTRA_DEPENDS+=iptables-standalone.d iptables.d
65
66iptables-standalone.d iptables.d: %.d: %.c
67 @-$(CC) -M -MG $(CFLAGS) $< | sed -e 's@^.*\.o:@$*.d $*.o:@' > $@
68
Rusty Russell905795c2000-04-19 11:22:03 +000069distclean: clean
70 @rm -f TAGS `find . -name '*~'` `find . -name '*.rej'` `find . -name '*.d'` .makefirst
Rusty Russell175f6412000-03-24 09:32:20 +000071
72# Rusty's distro magic.
73distrib: check nowhitespace distclean delrelease /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 diff md5sums
74
75# Makefile must not define:
76# -g -pg
Rusty Russell849779c2000-04-23 15:51:51 +000077# And must define -NDEBUG
Rusty Russell175f6412000-03-24 09:32:20 +000078check:
Rusty Russell849779c2000-04-23 15:51:51 +000079 @if echo $(CFLAGS) | egrep -e '-g|-pg' >/dev/null; then echo Remove debugging flags; exit 1; else exit 0; fi
80 @if echo $(CFLAGS) | egrep -e NDEBUG >/dev/null; then exit 0; else echo Define -DNDEBUG; exit 1; fi
Rusty Russell175f6412000-03-24 09:32:20 +000081
82nowhitespace:
83 @if grep -n ' $$' `find . -name 'Makefile' -o -name '*.[ch]'`; then exit 1; else exit 0; fi
84
85delrelease:
86 rm -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
87
88/home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2:
Rusty Russell905795c2000-04-19 11:22:03 +000089 cd .. && ln -sf userspace iptables-$(NETFILTER_VERSION) && tar cvf - --exclude CVS iptables-$(NETFILTER_VERSION)/. | bzip2 -9 > $@ && rm iptables-$(NETFILTER_VERSION)
Rusty Russell175f6412000-03-24 09:32:20 +000090
91diff: /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
92 @mkdir /tmp/diffdir
93 @cd /tmp/diffdir && tar xfI /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
94 @set -e; cd /tmp/diffdir; tar xfI /home/public/netfilter/iptables-$(OLD_NETFILTER_VERSION).tar.bz2; echo Creating patch-iptables-$(OLD_NETFILTER_VERSION)-$(NETFILTER_VERSION).bz2; diff -urN iptables-$(OLD_NETFILTER_VERSION) iptables-$(NETFILTER_VERSION) | bzip2 -9 > /home/public/netfilter/patch-iptables-$(OLD_NETFILTER_VERSION)-$(NETFILTER_VERSION).bz2
95 @rm -rf /tmp/diffdir
96
97md5sums:
98 cd /home/public/netfilter/ && md5sum patch-iptables-*-$(NETFILTER_VERSION).bz2 iptables-$(NETFILTER_VERSION).tar.bz2
99
Marc Bouchere6869a82000-03-20 06:03:29 +0000100# $(wildcard) fails wierdly with make v.3.78.1.
101include $(shell echo */Makefile)
102include Rules.make