blob: be85576b59a242946edfb89ea0cf4adbc086bb63 [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 Welte2584acf2001-04-30 04:21:40 +00007NETFILTER_VERSION:=1.2.2
8OLD_NETFILTER_VERSION:=1.2.1a
Marc Bouchere6869a82000-03-20 06:03:29 +00009
Rusty Russell50a8efe2001-02-03 10:50:04 +000010# Waiting for inclusions in the kernel tree.
Rusty Russell42926dc2001-05-01 09:44:16 +000011PENDING_PATCHES:=
Rusty Russell50a8efe2001-02-03 10:50:04 +000012# These went in previous kernels.
Harald Weltef4a39732001-07-31 12:21:05 +000013PENDING_PATCHES+=2.4.1.patch tos-fix.patch tcp-MSS.patch 2.4.4.patch ip6tables-export-symbols
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.
Rusty Russell4d2afbf2001-05-01 02:06:08 +000021ifeq ($(shell [ -f /usr/include/netinet/ip6.h ] && echo YES), YES)
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
Harald Welte7505d612001-07-31 13:06:17 +000061.PHONY: default
Rusty Russell52451822000-08-27 07:47:46 +000062default: print-extensions all
63
Harald Welte7505d612001-07-31 13:06:17 +000064.PHONY: print-extensions
Rusty Russell52451822000-08-27 07:47:46 +000065print-extensions:
Rusty Russellc8d7d892000-09-19 07:01:00 +000066 @[ -n "$(OPTIONALS)" ] && echo Extensions found: $(OPTIONALS)
Marc Bouchere6869a82000-03-20 06:03:29 +000067
Harald Welte7505d612001-07-31 13:06:17 +000068.PHONY: pending-patches
Rusty Russell50a8efe2001-02-03 10:50:04 +000069pending-patches:
70 @cd patch-o-matic && KERNEL_DIR=$(KERNEL_DIR) ./runme $(PENDING_PATCHES)
71
Marc Bouchere6869a82000-03-20 06:03:29 +000072iptables.o: iptables.c
73 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
74
75iptables: iptables-standalone.c iptables.o libiptc/libiptc.a
76 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
77
78$(DESTDIR)$(BINDIR)/iptables: iptables
79 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
80 cp $< $@
81
82iptables-save: iptables-save.c iptables.o libiptc/libiptc.a
83 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
84
85$(DESTDIR)$(BINDIR)/iptables-save: iptables-save
86 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
87 cp $< $@
88
89iptables-restore: iptables-restore.c iptables.o libiptc/libiptc.a
90 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
91
92$(DESTDIR)$(BINDIR)/iptables-restore: iptables-restore
93 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
94 cp $< $@
95
Philip Blundell8c700902000-05-15 02:17:52 +000096ip6tables.o: ip6tables.c
Harald Welte0aefbd32001-05-11 21:41:47 +000097 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
Philip Blundell8c700902000-05-15 02:17:52 +000098
99ip6tables: ip6tables-standalone.c ip6tables.o libiptc/libiptc.a
Harald Welte0aefbd32001-05-11 21:41:47 +0000100 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
Philip Blundell8c700902000-05-15 02:17:52 +0000101
102$(DESTDIR)$(BINDIR)/ip6tables: ip6tables
103 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
104 cp $< $@
105
106ip6tables-save: ip6tables-save.c ip6tables.o libiptc/libiptc.a
Harald Welte0aefbd32001-05-11 21:41:47 +0000107 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
Philip Blundell8c700902000-05-15 02:17:52 +0000108
109$(DESTDIR)$(BINDIR)/ip6tables-save: ip6tables-save
110 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
111 cp $< $@
112
113ip6tables-restore: ip6tables-restore.c ip6tables.o libiptc/libiptc.a
Harald Welte0aefbd32001-05-11 21:41:47 +0000114 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
Philip Blundell8c700902000-05-15 02:17:52 +0000115
116$(DESTDIR)$(BINDIR)/ip6tables-restore: ip6tables-restore
117 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
118 cp $< $@
119
Rusty Russell01c45202001-01-07 06:50:31 +0000120$(DESTDIR)$(MANDIR)/man8/%.8: %.8
Marc Bouchere6869a82000-03-20 06:03:29 +0000121 @[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
122 cp $< $@
123
124EXTRA_DEPENDS+=iptables-standalone.d iptables.d
125
126iptables-standalone.d iptables.d: %.d: %.c
127 @-$(CC) -M -MG $(CFLAGS) $< | sed -e 's@^.*\.o:@$*.d $*.o:@' > $@
128
James Morrisc82e9ac2000-11-24 14:34:02 +0000129
130# Development Targets
Harald Welte7505d612001-07-31 13:06:17 +0000131.PHONY: install-devel-man3
James Morrisc82e9ac2000-11-24 14:34:02 +0000132install-devel-man3: $(DEVEL_MAN3)
133 @[ -d $(DESTDIR)$(MANDIR)/man3 ] || mkdir -p $(DESTDIR)$(MANDIR)/man3
134 @cp -v $(DEVEL_MAN3) $(DESTDIR)$(MANDIR)/man3
135
Harald Welte7505d612001-07-31 13:06:17 +0000136.PHONY: install-devel-headers
James Morrisc82e9ac2000-11-24 14:34:02 +0000137install-devel-headers: $(DEVEL_HEADERS)
138 @[ -d $(DESTDIR)$(INCDIR) ] || mkdir -p $(DESTDIR)$(INCDIR)
139 @cp -v $(DEVEL_HEADERS) $(DESTDIR)$(INCDIR)
140
Harald Welte7505d612001-07-31 13:06:17 +0000141.PHONY: install-devel-libs
James Morrisc82e9ac2000-11-24 14:34:02 +0000142install-devel-libs: $(DEVEL_LIBS)
143 @[ -d $(DESTDIR)$(LIBDIR) ] || mkdir -p $(DESTDIR)$(LIBDIR)
144 @cp -v $(DEVEL_LIBS) $(DESTDIR)$(LIBDIR)
145
Harald Welte7505d612001-07-31 13:06:17 +0000146.PHONY: install-devel
James Morrisc82e9ac2000-11-24 14:34:02 +0000147install-devel: all install-devel-man3 install-devel-headers install-devel-libs
148
Harald Welte7505d612001-07-31 13:06:17 +0000149.PHONY: distclean
Rusty Russell905795c2000-04-19 11:22:03 +0000150distclean: clean
Rusty Russella470f332000-11-07 04:08:34 +0000151 @rm -f TAGS `find . -name '*~' -o -name '.*~'` `find . -name '*.rej'` `find . -name '*.d'` .makefirst
Rusty Russell175f6412000-03-24 09:32:20 +0000152
Rusty Russell52451822000-08-27 07:47:46 +0000153.PHONY: patch-o-matic
Rusty Russella470f332000-11-07 04:08:34 +0000154patch-o-matic/ patch-o-matic:
Rusty Russell52451822000-08-27 07:47:46 +0000155 @cd $@ && KERNEL_DIR=$(KERNEL_DIR) ./runme
156
Rusty Russell175f6412000-03-24 09:32:20 +0000157# Rusty's distro magic.
Harald Welte7505d612001-07-31 13:06:17 +0000158.PHONY: distrib
Rusty Russell2e5f9532001-01-07 09:37:02 +0000159distrib: check distclean delrelease /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 diff md5sums # nowhitespace
Rusty Russell175f6412000-03-24 09:32:20 +0000160
161# Makefile must not define:
162# -g -pg
Rusty Russell849779c2000-04-23 15:51:51 +0000163# And must define -NDEBUG
Harald Welte7505d612001-07-31 13:06:17 +0000164.PHONY: check
Rusty Russell175f6412000-03-24 09:32:20 +0000165check:
Rusty Russell849779c2000-04-23 15:51:51 +0000166 @if echo $(CFLAGS) | egrep -e '-g|-pg' >/dev/null; then echo Remove debugging flags; exit 1; else exit 0; fi
167 @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 +0000168
Harald Welte7505d612001-07-31 13:06:17 +0000169.PHONY: nowhitespace
Rusty Russell175f6412000-03-24 09:32:20 +0000170nowhitespace:
Rusty Russell2e5f9532001-01-07 09:37:02 +0000171 @if grep -n '[ ]$$' `find . -name 'Makefile' -o -name '*.[ch]'`; then exit 1; else exit 0; fi
Rusty Russell175f6412000-03-24 09:32:20 +0000172
Harald Welte7505d612001-07-31 13:06:17 +0000173.PHONY: delrelease
Rusty Russell175f6412000-03-24 09:32:20 +0000174delrelease:
175 rm -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
176
177/home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2:
Rusty Russell905795c2000-04-19 11:22:03 +0000178 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 +0000179
Harald Welte7505d612001-07-31 13:06:17 +0000180.PHONY: diff
Rusty Russell175f6412000-03-24 09:32:20 +0000181diff: /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
182 @mkdir /tmp/diffdir
Rusty Russell01c45202001-01-07 06:50:31 +0000183 @cd /tmp/diffdir && tar -x --bzip2 -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
184 @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 +0000185 @rm -rf /tmp/diffdir
186
Harald Welte7505d612001-07-31 13:06:17 +0000187.PHONY: md5sums
Rusty Russell175f6412000-03-24 09:32:20 +0000188md5sums:
189 cd /home/public/netfilter/ && md5sum patch-iptables-*-$(NETFILTER_VERSION).bz2 iptables-$(NETFILTER_VERSION).tar.bz2
190
Marc Bouchere6869a82000-03-20 06:03:29 +0000191# $(wildcard) fails wierdly with make v.3.78.1.
192include $(shell echo */Makefile)
193include Rules.make