blob: 238c34a02a1fe4dc44cc6f75fbbed159e1f5a7c0 [file] [log] [blame]
Marc Bouchere6869a82000-03-20 06:03:29 +00001# Standard part of Makefile for topdir.
2TOPLEVEL_INCLUDED=YES
3
Harald Welte3efb6ea2001-08-06 18:50:21 +00004# uncomment this to get a fully statically linked version
5# NO_SHARED_LIBS = 1
6
Marc Bouchere6869a82000-03-20 06:03:29 +00007ifndef KERNEL_DIR
8KERNEL_DIR=/usr/src/linux
9endif
Harald Welte2584acf2001-04-30 04:21:40 +000010NETFILTER_VERSION:=1.2.2
11OLD_NETFILTER_VERSION:=1.2.1a
Marc Bouchere6869a82000-03-20 06:03:29 +000012
Rusty Russell50a8efe2001-02-03 10:50:04 +000013# Waiting for inclusions in the kernel tree.
Rusty Russell42926dc2001-05-01 09:44:16 +000014PENDING_PATCHES:=
Rusty Russell50a8efe2001-02-03 10:50:04 +000015# These went in previous kernels.
Marc Boucher2acb25b2001-08-02 11:17:12 +000016PENDING_PATCHES+=2.4.1.patch tos-fix.patch tcp-MSS.patch 2.4.4.patch ip6tables-export-symbols.patch tcp_manip_pkt.patch
Rusty Russell50a8efe2001-02-03 10:50:04 +000017
Marc Bouchere6869a82000-03-20 06:03:29 +000018LIBDIR:=/usr/local/lib
Rusty Russell7fef1942001-01-08 07:44:46 +000019BINDIR:=/usr/local/sbin
Marc Bouchere6869a82000-03-20 06:03:29 +000020MANDIR:=/usr/local/man
James Morrisc82e9ac2000-11-24 14:34:02 +000021INCDIR:=/usr/local/include
Marc Bouchere6869a82000-03-20 06:03:29 +000022
Rusty Russell209820b2001-01-08 08:14:33 +000023# Need libc6 for this. FIXME: Should covert to autoconf.
Rusty Russell4d2afbf2001-05-01 02:06:08 +000024ifeq ($(shell [ -f /usr/include/netinet/ip6.h ] && echo YES), YES)
Rusty Russell8e07bd72000-12-19 03:11:00 +000025DO_IPV6=1
26endif
27
Rusty Russell8c245b52000-07-14 08:01:22 +000028COPT_FLAGS:=-O2 -DNDEBUG
Rusty Russell008a83f2001-02-28 11:21:53 +000029CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KERNEL_DIR)/include -Iinclude/ -DNETFILTER_VERSION=\"$(NETFILTER_VERSION)\" #-g #-pg
Marc Bouchere6869a82000-03-20 06:03:29 +000030
Harald Welte3efb6ea2001-08-06 18:50:21 +000031ifdef NO_SHARED_LIBS
32CFLAGS += -DNO_SHARED_LIBS=1
33endif
34
35ifndef NO_SHARED_LIBS
Rusty Russell5622f212000-05-02 16:42:09 +000036DEPFILES = $(SHARED_LIBS:%.so=%.d)
Marc Bouchere6869a82000-03-20 06:03:29 +000037SH_CFLAGS:=$(CFLAGS) -fPIC
Harald Welte3efb6ea2001-08-06 18:50:21 +000038STATIC_LIBS =
39STATIC6_LIBS =
40LDFLAGS = -rdynamic
41LDLIBS = -ldl
42else
43DEPFILES = $(EXT_OBJS:%.o=%.d)
44STATIC_LIBS = extensions/libext.a
45STATIC6_LIBS = extensions/libext6.a
46LDFLAGS =
47LDLIBS =
48endif
Marc Bouchere6869a82000-03-20 06:03:29 +000049
Rusty Russell2e5f9532001-01-07 09:37:02 +000050EXTRAS+=iptables iptables.o
Rusty Russell01c45202001-01-07 06:50:31 +000051EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables $(DESTDIR)$(MANDIR)/man8/iptables.8
52
53# Still experimental.
Harald Welte8a6831a2001-03-15 15:33:56 +000054EXTRAS_EXP+=iptables-save iptables-restore
Harald Welte46d4d0a2001-03-16 15:48:56 +000055EXTRA_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 +000056
57ifdef DO_IPV6
58EXTRAS+=ip6tables ip6tables.o
Rusty Russell2e5f9532001-01-07 09:37:02 +000059EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/ip6tables
Harald Welte8a6831a2001-03-15 15:33:56 +000060EXTRAS_EXP+=ip6tables-save ip6tables-restore
Harald Welte46d4d0a2001-03-16 15:48:56 +000061EXTRA_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 +000062endif
Marc Bouchere6869a82000-03-20 06:03:29 +000063
Rusty Russell09b9a412000-04-27 10:16:47 +000064# Sparc64 hack
65ifeq ($(shell uname -m),sparc64)
66# The kernel is 64-bit, even though userspace is 32.
Rusty Russellc8d7d892000-09-19 07:01:00 +000067CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
Rusty Russell09b9a412000-04-27 10:16:47 +000068endif
69
Rusty Russellda707152001-04-21 04:25:09 +000070# HPPA hack
71ifeq ($(shell uname -m),parisc64)
72# The kernel is 64-bit, even though userspace is 32.
73CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
74endif
75
Marc Bouchere6869a82000-03-20 06:03:29 +000076ifndef IPT_LIBDIR
77IPT_LIBDIR:=$(LIBDIR)/iptables
78endif
79
Harald Welte7505d612001-07-31 13:06:17 +000080.PHONY: default
Rusty Russell52451822000-08-27 07:47:46 +000081default: print-extensions all
82
Harald Welte7505d612001-07-31 13:06:17 +000083.PHONY: print-extensions
Rusty Russell52451822000-08-27 07:47:46 +000084print-extensions:
Rusty Russellc8d7d892000-09-19 07:01:00 +000085 @[ -n "$(OPTIONALS)" ] && echo Extensions found: $(OPTIONALS)
Marc Bouchere6869a82000-03-20 06:03:29 +000086
Harald Welte7505d612001-07-31 13:06:17 +000087.PHONY: pending-patches
Rusty Russell50a8efe2001-02-03 10:50:04 +000088pending-patches:
89 @cd patch-o-matic && KERNEL_DIR=$(KERNEL_DIR) ./runme $(PENDING_PATCHES)
90
Marc Bouchere6869a82000-03-20 06:03:29 +000091iptables.o: iptables.c
92 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
93
Harald Welte3efb6ea2001-08-06 18:50:21 +000094iptables: iptables-standalone.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
95 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
Marc Bouchere6869a82000-03-20 06:03:29 +000096
97$(DESTDIR)$(BINDIR)/iptables: iptables
98 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
99 cp $< $@
100
Harald Welte3efb6ea2001-08-06 18:50:21 +0000101iptables-save: iptables-save.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
102 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
Marc Bouchere6869a82000-03-20 06:03:29 +0000103
104$(DESTDIR)$(BINDIR)/iptables-save: iptables-save
105 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
106 cp $< $@
107
Harald Welte3efb6ea2001-08-06 18:50:21 +0000108iptables-restore: iptables-restore.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
109 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
Marc Bouchere6869a82000-03-20 06:03:29 +0000110
111$(DESTDIR)$(BINDIR)/iptables-restore: iptables-restore
112 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
113 cp $< $@
114
Philip Blundell8c700902000-05-15 02:17:52 +0000115ip6tables.o: ip6tables.c
Harald Welte0aefbd32001-05-11 21:41:47 +0000116 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
Philip Blundell8c700902000-05-15 02:17:52 +0000117
Harald Welte3efb6ea2001-08-06 18:50:21 +0000118ip6tables: ip6tables-standalone.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
119 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ $(LD_LIBS)
Philip Blundell8c700902000-05-15 02:17:52 +0000120
121$(DESTDIR)$(BINDIR)/ip6tables: ip6tables
122 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
123 cp $< $@
124
Harald Welte3efb6ea2001-08-06 18:50:21 +0000125ip6tables-save: ip6tables-save.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
126 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ $(LD_LIBS)
Philip Blundell8c700902000-05-15 02:17:52 +0000127
128$(DESTDIR)$(BINDIR)/ip6tables-save: ip6tables-save
129 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
130 cp $< $@
131
Harald Welte3efb6ea2001-08-06 18:50:21 +0000132ip6tables-restore: ip6tables-restore.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
133 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ $(LD_LIBS)
Philip Blundell8c700902000-05-15 02:17:52 +0000134
135$(DESTDIR)$(BINDIR)/ip6tables-restore: ip6tables-restore
136 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
137 cp $< $@
138
Rusty Russell01c45202001-01-07 06:50:31 +0000139$(DESTDIR)$(MANDIR)/man8/%.8: %.8
Marc Bouchere6869a82000-03-20 06:03:29 +0000140 @[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
141 cp $< $@
142
143EXTRA_DEPENDS+=iptables-standalone.d iptables.d
144
145iptables-standalone.d iptables.d: %.d: %.c
146 @-$(CC) -M -MG $(CFLAGS) $< | sed -e 's@^.*\.o:@$*.d $*.o:@' > $@
147
James Morrisc82e9ac2000-11-24 14:34:02 +0000148
149# Development Targets
Harald Welte7505d612001-07-31 13:06:17 +0000150.PHONY: install-devel-man3
James Morrisc82e9ac2000-11-24 14:34:02 +0000151install-devel-man3: $(DEVEL_MAN3)
152 @[ -d $(DESTDIR)$(MANDIR)/man3 ] || mkdir -p $(DESTDIR)$(MANDIR)/man3
153 @cp -v $(DEVEL_MAN3) $(DESTDIR)$(MANDIR)/man3
154
Harald Welte7505d612001-07-31 13:06:17 +0000155.PHONY: install-devel-headers
James Morrisc82e9ac2000-11-24 14:34:02 +0000156install-devel-headers: $(DEVEL_HEADERS)
157 @[ -d $(DESTDIR)$(INCDIR) ] || mkdir -p $(DESTDIR)$(INCDIR)
158 @cp -v $(DEVEL_HEADERS) $(DESTDIR)$(INCDIR)
159
Harald Welte7505d612001-07-31 13:06:17 +0000160.PHONY: install-devel-libs
James Morrisc82e9ac2000-11-24 14:34:02 +0000161install-devel-libs: $(DEVEL_LIBS)
162 @[ -d $(DESTDIR)$(LIBDIR) ] || mkdir -p $(DESTDIR)$(LIBDIR)
163 @cp -v $(DEVEL_LIBS) $(DESTDIR)$(LIBDIR)
164
Harald Welte7505d612001-07-31 13:06:17 +0000165.PHONY: install-devel
James Morrisc82e9ac2000-11-24 14:34:02 +0000166install-devel: all install-devel-man3 install-devel-headers install-devel-libs
167
Harald Welte7505d612001-07-31 13:06:17 +0000168.PHONY: distclean
Rusty Russell905795c2000-04-19 11:22:03 +0000169distclean: clean
Rusty Russella470f332000-11-07 04:08:34 +0000170 @rm -f TAGS `find . -name '*~' -o -name '.*~'` `find . -name '*.rej'` `find . -name '*.d'` .makefirst
Rusty Russell175f6412000-03-24 09:32:20 +0000171
Rusty Russell52451822000-08-27 07:47:46 +0000172.PHONY: patch-o-matic
Rusty Russella470f332000-11-07 04:08:34 +0000173patch-o-matic/ patch-o-matic:
Rusty Russell52451822000-08-27 07:47:46 +0000174 @cd $@ && KERNEL_DIR=$(KERNEL_DIR) ./runme
175
Rusty Russell175f6412000-03-24 09:32:20 +0000176# Rusty's distro magic.
Harald Welte7505d612001-07-31 13:06:17 +0000177.PHONY: distrib
Rusty Russell2e5f9532001-01-07 09:37:02 +0000178distrib: check distclean delrelease /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 diff md5sums # nowhitespace
Rusty Russell175f6412000-03-24 09:32:20 +0000179
180# Makefile must not define:
181# -g -pg
Rusty Russell849779c2000-04-23 15:51:51 +0000182# And must define -NDEBUG
Harald Welte7505d612001-07-31 13:06:17 +0000183.PHONY: check
Rusty Russell175f6412000-03-24 09:32:20 +0000184check:
Rusty Russell849779c2000-04-23 15:51:51 +0000185 @if echo $(CFLAGS) | egrep -e '-g|-pg' >/dev/null; then echo Remove debugging flags; exit 1; else exit 0; fi
186 @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 +0000187
Harald Welte7505d612001-07-31 13:06:17 +0000188.PHONY: nowhitespace
Rusty Russell175f6412000-03-24 09:32:20 +0000189nowhitespace:
Rusty Russell2e5f9532001-01-07 09:37:02 +0000190 @if grep -n '[ ]$$' `find . -name 'Makefile' -o -name '*.[ch]'`; then exit 1; else exit 0; fi
Rusty Russell175f6412000-03-24 09:32:20 +0000191
Harald Welte7505d612001-07-31 13:06:17 +0000192.PHONY: delrelease
Rusty Russell175f6412000-03-24 09:32:20 +0000193delrelease:
194 rm -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
195
196/home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2:
Rusty Russell905795c2000-04-19 11:22:03 +0000197 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 +0000198
Harald Welte7505d612001-07-31 13:06:17 +0000199.PHONY: diff
Rusty Russell175f6412000-03-24 09:32:20 +0000200diff: /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
201 @mkdir /tmp/diffdir
Rusty Russell01c45202001-01-07 06:50:31 +0000202 @cd /tmp/diffdir && tar -x --bzip2 -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
203 @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 +0000204 @rm -rf /tmp/diffdir
205
Harald Welte7505d612001-07-31 13:06:17 +0000206.PHONY: md5sums
Rusty Russell175f6412000-03-24 09:32:20 +0000207md5sums:
208 cd /home/public/netfilter/ && md5sum patch-iptables-*-$(NETFILTER_VERSION).bz2 iptables-$(NETFILTER_VERSION).tar.bz2
209
Marc Bouchere6869a82000-03-20 06:03:29 +0000210# $(wildcard) fails wierdly with make v.3.78.1.
211include $(shell echo */Makefile)
212include Rules.make