blob: b7ca0212095e7f843d920c46138529650e0b5b5a [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
Harald Weltefeb41542001-03-19 17:41:45 +00007NETFILTER_VERSION:=1.2.1a
Harald Welte10c68882001-03-16 13:40:51 +00008OLD_NETFILTER_VERSION:=1.2
Marc Bouchere6869a82000-03-20 06:03:29 +00009
Rusty Russell50a8efe2001-02-03 10:50:04 +000010# Waiting for inclusions in the kernel tree.
Harald Weltefeb41542001-03-19 17:41:45 +000011PENDING_PATCHES:=dropped-table.patch seqoffset.patch irc-conntrack-nat.patch
Rusty Russell50a8efe2001-02-03 10:50:04 +000012# These went in previous kernels.
Svenning Soerensen19b6b612001-04-12 16:06:53 +000013PENDING_PATCHES+=ipv6-fixes.patch.ipv6 masquerade+fwmark.patch nat-overlap.patch ppc-sparc-mangle.patch tos-fix.patch masq-dynaddr.patch
Rusty Russell50a8efe2001-02-03 10:50:04 +000014
Marc Bouchere6869a82000-03-20 06:03:29 +000015LIBDIR:=/usr/local/lib
Rusty Russell7fef1942001-01-08 07:44:46 +000016BINDIR:=/usr/local/sbin
Marc Bouchere6869a82000-03-20 06:03:29 +000017MANDIR:=/usr/local/man
James Morrisc82e9ac2000-11-24 14:34:02 +000018INCDIR:=/usr/local/include
Marc Bouchere6869a82000-03-20 06:03:29 +000019
Rusty Russell209820b2001-01-08 08:14:33 +000020# Need libc6 for this. FIXME: Should covert to autoconf.
21ifneq ($(shell ldd --version 2>/dev/null | fgrep 2.2),)
Rusty Russell8e07bd72000-12-19 03:11:00 +000022DO_IPV6=1
23endif
24
Rusty Russell8c245b52000-07-14 08:01:22 +000025COPT_FLAGS:=-O2 -DNDEBUG
Rusty Russell008a83f2001-02-28 11:21:53 +000026CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KERNEL_DIR)/include -Iinclude/ -DNETFILTER_VERSION=\"$(NETFILTER_VERSION)\" #-g #-pg
Marc Bouchere6869a82000-03-20 06:03:29 +000027
Rusty Russell5622f212000-05-02 16:42:09 +000028DEPFILES = $(SHARED_LIBS:%.so=%.d)
Marc Bouchere6869a82000-03-20 06:03:29 +000029SH_CFLAGS:=$(CFLAGS) -fPIC
Marc Bouchere6869a82000-03-20 06:03:29 +000030
Rusty Russell2e5f9532001-01-07 09:37:02 +000031EXTRAS+=iptables iptables.o
Rusty Russell01c45202001-01-07 06:50:31 +000032EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables $(DESTDIR)$(MANDIR)/man8/iptables.8
33
34# Still experimental.
Harald Welte8a6831a2001-03-15 15:33:56 +000035EXTRAS_EXP+=iptables-save iptables-restore
Harald Welte46d4d0a2001-03-16 15:48:56 +000036EXTRA_INSTALLS_EXP+=$(DESTDIR)$(BINDIR)/iptables-save $(DESTDIR)$(BINDIR)/iptables-restore $(DESTDIR)$(MANDIR)/man8/iptables-restore.8 $(DESTDIR)$(MANDIR)/man8/iptables-save.8
Rusty Russell8e07bd72000-12-19 03:11:00 +000037
38ifdef DO_IPV6
39EXTRAS+=ip6tables ip6tables.o
Rusty Russell2e5f9532001-01-07 09:37:02 +000040EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/ip6tables
Harald Welte8a6831a2001-03-15 15:33:56 +000041EXTRAS_EXP+=ip6tables-save ip6tables-restore
Harald Welte46d4d0a2001-03-16 15:48:56 +000042EXTRA_INSTALLS_EXP+=$(DESTDIR)$(BINDIR)/ip6tables-save $(DESTDIR)$(BINDIR)/ip6tables-restore # $(DESTDIR)$(MANDIR)/man8/iptables-restore.8 $(DESTDIR)$(MANDIR)/man8/iptables-save.8 $(DESTDIR)$(MANDIR)/man8/ip6tables-save.8 $(DESTDIR)$(MANDIR)/man8/ip6tables-restore.8
Rusty Russell8e07bd72000-12-19 03:11:00 +000043endif
Marc Bouchere6869a82000-03-20 06:03:29 +000044
Rusty Russell09b9a412000-04-27 10:16:47 +000045# Sparc64 hack
46ifeq ($(shell uname -m),sparc64)
47# The kernel is 64-bit, even though userspace is 32.
Rusty Russellc8d7d892000-09-19 07:01:00 +000048CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
Rusty Russell09b9a412000-04-27 10:16:47 +000049endif
50
Rusty Russellda707152001-04-21 04:25:09 +000051# HPPA hack
52ifeq ($(shell uname -m),parisc64)
53# The kernel is 64-bit, even though userspace is 32.
54CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
55endif
56
Marc Bouchere6869a82000-03-20 06:03:29 +000057ifndef IPT_LIBDIR
58IPT_LIBDIR:=$(LIBDIR)/iptables
59endif
60
Rusty Russell52451822000-08-27 07:47:46 +000061default: print-extensions all
62
63print-extensions:
Rusty Russellc8d7d892000-09-19 07:01:00 +000064 @[ -n "$(OPTIONALS)" ] && echo Extensions found: $(OPTIONALS)
Marc Bouchere6869a82000-03-20 06:03:29 +000065
Rusty Russell50a8efe2001-02-03 10:50:04 +000066pending-patches:
67 @cd patch-o-matic && KERNEL_DIR=$(KERNEL_DIR) ./runme $(PENDING_PATCHES)
68
Marc Bouchere6869a82000-03-20 06:03:29 +000069iptables.o: iptables.c
70 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
71
72iptables: iptables-standalone.c iptables.o libiptc/libiptc.a
73 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
74
75$(DESTDIR)$(BINDIR)/iptables: iptables
76 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
77 cp $< $@
78
79iptables-save: iptables-save.c iptables.o libiptc/libiptc.a
80 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
81
82$(DESTDIR)$(BINDIR)/iptables-save: iptables-save
83 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
84 cp $< $@
85
86iptables-restore: iptables-restore.c iptables.o libiptc/libiptc.a
87 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
88
89$(DESTDIR)$(BINDIR)/iptables-restore: iptables-restore
90 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
91 cp $< $@
92
Philip Blundell8c700902000-05-15 02:17:52 +000093ip6tables.o: ip6tables.c
94 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
95
96ip6tables: ip6tables-standalone.c ip6tables.o libiptc/libiptc.a
97 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
98
99$(DESTDIR)$(BINDIR)/ip6tables: ip6tables
100 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
101 cp $< $@
102
103ip6tables-save: ip6tables-save.c ip6tables.o libiptc/libiptc.a
104 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
105
106$(DESTDIR)$(BINDIR)/ip6tables-save: ip6tables-save
107 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
108 cp $< $@
109
110ip6tables-restore: ip6tables-restore.c ip6tables.o libiptc/libiptc.a
111 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
112
113$(DESTDIR)$(BINDIR)/ip6tables-restore: ip6tables-restore
114 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
115 cp $< $@
116
Rusty Russell01c45202001-01-07 06:50:31 +0000117$(DESTDIR)$(MANDIR)/man8/%.8: %.8
Marc Bouchere6869a82000-03-20 06:03:29 +0000118 @[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
119 cp $< $@
120
121EXTRA_DEPENDS+=iptables-standalone.d iptables.d
122
123iptables-standalone.d iptables.d: %.d: %.c
124 @-$(CC) -M -MG $(CFLAGS) $< | sed -e 's@^.*\.o:@$*.d $*.o:@' > $@
125
James Morrisc82e9ac2000-11-24 14:34:02 +0000126
127# Development Targets
128install-devel-man3: $(DEVEL_MAN3)
129 @[ -d $(DESTDIR)$(MANDIR)/man3 ] || mkdir -p $(DESTDIR)$(MANDIR)/man3
130 @cp -v $(DEVEL_MAN3) $(DESTDIR)$(MANDIR)/man3
131
132install-devel-headers: $(DEVEL_HEADERS)
133 @[ -d $(DESTDIR)$(INCDIR) ] || mkdir -p $(DESTDIR)$(INCDIR)
134 @cp -v $(DEVEL_HEADERS) $(DESTDIR)$(INCDIR)
135
136install-devel-libs: $(DEVEL_LIBS)
137 @[ -d $(DESTDIR)$(LIBDIR) ] || mkdir -p $(DESTDIR)$(LIBDIR)
138 @cp -v $(DEVEL_LIBS) $(DESTDIR)$(LIBDIR)
139
140install-devel: all install-devel-man3 install-devel-headers install-devel-libs
141
Rusty Russell905795c2000-04-19 11:22:03 +0000142distclean: clean
Rusty Russella470f332000-11-07 04:08:34 +0000143 @rm -f TAGS `find . -name '*~' -o -name '.*~'` `find . -name '*.rej'` `find . -name '*.d'` .makefirst
Rusty Russell175f6412000-03-24 09:32:20 +0000144
Rusty Russell52451822000-08-27 07:47:46 +0000145.PHONY: patch-o-matic
Rusty Russella470f332000-11-07 04:08:34 +0000146patch-o-matic/ patch-o-matic:
Rusty Russell52451822000-08-27 07:47:46 +0000147 @cd $@ && KERNEL_DIR=$(KERNEL_DIR) ./runme
148
Rusty Russell175f6412000-03-24 09:32:20 +0000149# Rusty's distro magic.
Rusty Russell2e5f9532001-01-07 09:37:02 +0000150distrib: check distclean delrelease /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 diff md5sums # nowhitespace
Rusty Russell175f6412000-03-24 09:32:20 +0000151
152# Makefile must not define:
153# -g -pg
Rusty Russell849779c2000-04-23 15:51:51 +0000154# And must define -NDEBUG
Rusty Russell175f6412000-03-24 09:32:20 +0000155check:
Rusty Russell849779c2000-04-23 15:51:51 +0000156 @if echo $(CFLAGS) | egrep -e '-g|-pg' >/dev/null; then echo Remove debugging flags; exit 1; else exit 0; fi
157 @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 +0000158
159nowhitespace:
Rusty Russell2e5f9532001-01-07 09:37:02 +0000160 @if grep -n '[ ]$$' `find . -name 'Makefile' -o -name '*.[ch]'`; then exit 1; else exit 0; fi
Rusty Russell175f6412000-03-24 09:32:20 +0000161
162delrelease:
163 rm -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
164
165/home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2:
Rusty Russell905795c2000-04-19 11:22:03 +0000166 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 +0000167
168diff: /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
169 @mkdir /tmp/diffdir
Rusty Russell01c45202001-01-07 06:50:31 +0000170 @cd /tmp/diffdir && tar -x --bzip2 -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
171 @set -e; cd /tmp/diffdir; tar -x --bzip2 -f /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
Rusty Russell175f6412000-03-24 09:32:20 +0000172 @rm -rf /tmp/diffdir
173
174md5sums:
175 cd /home/public/netfilter/ && md5sum patch-iptables-*-$(NETFILTER_VERSION).bz2 iptables-$(NETFILTER_VERSION).tar.bz2
176
Marc Bouchere6869a82000-03-20 06:03:29 +0000177# $(wildcard) fails wierdly with make v.3.78.1.
178include $(shell echo */Makefile)
179include Rules.make