blob: 9b340f0ebb752c8c7218e8de2a8f4ca4ff686d10 [file] [log] [blame]
Harald Welte3a5026f2001-09-02 16:07:33 +00001
Marc Bouchere6869a82000-03-20 06:03:29 +00002
Harald Welte3efb6ea2001-08-06 18:50:21 +00003# uncomment this to get a fully statically linked version
4# NO_SHARED_LIBS = 1
5
Harald Welte3a5026f2001-09-02 16:07:33 +00006######################################################################
7# YOU SHOULD NOT NEED TO TOUCH ANYTHING BELOW THIS LINE
8######################################################################
9
10# Standard part of Makefile for topdir.
11TOPLEVEL_INCLUDED=YES
12
Marc Bouchere6869a82000-03-20 06:03:29 +000013ifndef KERNEL_DIR
14KERNEL_DIR=/usr/src/linux
15endif
Harald Welte81d5d4f2002-02-13 23:13:54 +000016NETFILTER_VERSION:=1.2.6
Harald Welteba6d0122002-02-17 19:49:26 +000017OLD_NETFILTER_VERSION:=1.2.5
Marc Bouchere6869a82000-03-20 06:03:29 +000018
Harald Welteba6d0122002-02-17 19:49:26 +000019PREFIX:=/usr/local
20LIBDIR:=$(PREFIX)/lib
21BINDIR:=$(PREFIX)/sbin
22MANDIR:=$(PREFIX)/man
23INCDIR:=$(PREFIX)/include
Marc Bouchere6869a82000-03-20 06:03:29 +000024
Harald Welte3a5026f2001-09-02 16:07:33 +000025# directory for new iptables releases
26RELEASE_DIR:=/tmp
27
Rusty Russell209820b2001-01-08 08:14:33 +000028# Need libc6 for this. FIXME: Should covert to autoconf.
Rusty Russell4d2afbf2001-05-01 02:06:08 +000029ifeq ($(shell [ -f /usr/include/netinet/ip6.h ] && echo YES), YES)
Rusty Russell8e07bd72000-12-19 03:11:00 +000030DO_IPV6=1
31endif
32
Harald Welte380ba5f2002-02-13 16:19:55 +000033COPT_FLAGS:=-O2
34CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KERNEL_DIR)/include -Iinclude/ -DNETFILTER_VERSION=\"$(NETFILTER_VERSION)\" #-g #-pg # -DIPTC_DEBUG
Marc Bouchere6869a82000-03-20 06:03:29 +000035
Harald Welte3efb6ea2001-08-06 18:50:21 +000036ifdef NO_SHARED_LIBS
37CFLAGS += -DNO_SHARED_LIBS=1
38endif
39
40ifndef NO_SHARED_LIBS
Rusty Russell5622f212000-05-02 16:42:09 +000041DEPFILES = $(SHARED_LIBS:%.so=%.d)
Marc Bouchere6869a82000-03-20 06:03:29 +000042SH_CFLAGS:=$(CFLAGS) -fPIC
Harald Welte3efb6ea2001-08-06 18:50:21 +000043STATIC_LIBS =
44STATIC6_LIBS =
45LDFLAGS = -rdynamic
46LDLIBS = -ldl
47else
48DEPFILES = $(EXT_OBJS:%.o=%.d)
49STATIC_LIBS = extensions/libext.a
50STATIC6_LIBS = extensions/libext6.a
51LDFLAGS =
52LDLIBS =
53endif
Marc Bouchere6869a82000-03-20 06:03:29 +000054
Rusty Russell2e5f9532001-01-07 09:37:02 +000055EXTRAS+=iptables iptables.o
Rusty Russell01c45202001-01-07 06:50:31 +000056EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables $(DESTDIR)$(MANDIR)/man8/iptables.8
57
Harald Welteeba774d2001-10-16 08:22:40 +000058# No longer experimental.
59EXTRAS+=iptables-save iptables-restore
60EXTRA_INSTALLS+=$(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 +000061
62ifdef DO_IPV6
63EXTRAS+=ip6tables ip6tables.o
András Kis-Szabó06129432001-10-14 13:27:03 +000064EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/ip6tables $(DESTDIR)$(MANDIR)/man8/ip6tables.8
Harald Welte8a6831a2001-03-15 15:33:56 +000065EXTRAS_EXP+=ip6tables-save ip6tables-restore
Harald Welte46d4d0a2001-03-16 15:48:56 +000066EXTRA_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 +000067endif
Marc Bouchere6869a82000-03-20 06:03:29 +000068
Rusty Russell09b9a412000-04-27 10:16:47 +000069# Sparc64 hack
70ifeq ($(shell uname -m),sparc64)
71# The kernel is 64-bit, even though userspace is 32.
Rusty Russellc8d7d892000-09-19 07:01:00 +000072CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
Rusty Russell09b9a412000-04-27 10:16:47 +000073endif
74
Rusty Russellda707152001-04-21 04:25:09 +000075# HPPA hack
76ifeq ($(shell uname -m),parisc64)
77# The kernel is 64-bit, even though userspace is 32.
78CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
79endif
80
Marc Bouchere6869a82000-03-20 06:03:29 +000081ifndef IPT_LIBDIR
82IPT_LIBDIR:=$(LIBDIR)/iptables
83endif
84
Harald Welte7505d612001-07-31 13:06:17 +000085.PHONY: default
Rusty Russell52451822000-08-27 07:47:46 +000086default: print-extensions all
87
Harald Welte7505d612001-07-31 13:06:17 +000088.PHONY: print-extensions
Rusty Russell52451822000-08-27 07:47:46 +000089print-extensions:
Rusty Russellc8d7d892000-09-19 07:01:00 +000090 @[ -n "$(OPTIONALS)" ] && echo Extensions found: $(OPTIONALS)
Marc Bouchere6869a82000-03-20 06:03:29 +000091
Harald Welte7505d612001-07-31 13:06:17 +000092.PHONY: pending-patches
Rusty Russell50a8efe2001-02-03 10:50:04 +000093pending-patches:
Harald Welte02f17e92001-11-12 08:20:12 +000094 @cd patch-o-matic && KERNEL_DIR=$(KERNEL_DIR) ./runme pending
Rusty Russell50a8efe2001-02-03 10:50:04 +000095
Marc Bouchere6869a82000-03-20 06:03:29 +000096iptables.o: iptables.c
97 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
98
Harald Welte3efb6ea2001-08-06 18:50:21 +000099iptables: iptables-standalone.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
100 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
Marc Bouchere6869a82000-03-20 06:03:29 +0000101
102$(DESTDIR)$(BINDIR)/iptables: iptables
103 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
104 cp $< $@
105
Harald Welte3efb6ea2001-08-06 18:50:21 +0000106iptables-save: iptables-save.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
107 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
Marc Bouchere6869a82000-03-20 06:03:29 +0000108
109$(DESTDIR)$(BINDIR)/iptables-save: iptables-save
110 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
111 cp $< $@
112
Harald Welte3efb6ea2001-08-06 18:50:21 +0000113iptables-restore: iptables-restore.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
114 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
Marc Bouchere6869a82000-03-20 06:03:29 +0000115
116$(DESTDIR)$(BINDIR)/iptables-restore: iptables-restore
117 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
118 cp $< $@
119
Philip Blundell8c700902000-05-15 02:17:52 +0000120ip6tables.o: ip6tables.c
Harald Welte0aefbd32001-05-11 21:41:47 +0000121 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
Philip Blundell8c700902000-05-15 02:17:52 +0000122
Harald Welte3efb6ea2001-08-06 18:50:21 +0000123ip6tables: ip6tables-standalone.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
Harald Weltea7e5b8f2001-08-07 16:19:14 +0000124 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ $(LDLIBS)
Philip Blundell8c700902000-05-15 02:17:52 +0000125
126$(DESTDIR)$(BINDIR)/ip6tables: ip6tables
127 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
128 cp $< $@
129
Harald Welte3efb6ea2001-08-06 18:50:21 +0000130ip6tables-save: ip6tables-save.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
Harald Weltea7e5b8f2001-08-07 16:19:14 +0000131 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ $(LDLIBS)
Philip Blundell8c700902000-05-15 02:17:52 +0000132
133$(DESTDIR)$(BINDIR)/ip6tables-save: ip6tables-save
134 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
135 cp $< $@
136
Harald Welte3efb6ea2001-08-06 18:50:21 +0000137ip6tables-restore: ip6tables-restore.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
Harald Weltea7e5b8f2001-08-07 16:19:14 +0000138 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ $(LDLIBS)
Philip Blundell8c700902000-05-15 02:17:52 +0000139
140$(DESTDIR)$(BINDIR)/ip6tables-restore: ip6tables-restore
141 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
142 cp $< $@
143
Rusty Russell01c45202001-01-07 06:50:31 +0000144$(DESTDIR)$(MANDIR)/man8/%.8: %.8
Marc Bouchere6869a82000-03-20 06:03:29 +0000145 @[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
146 cp $< $@
147
148EXTRA_DEPENDS+=iptables-standalone.d iptables.d
149
150iptables-standalone.d iptables.d: %.d: %.c
151 @-$(CC) -M -MG $(CFLAGS) $< | sed -e 's@^.*\.o:@$*.d $*.o:@' > $@
152
James Morrisc82e9ac2000-11-24 14:34:02 +0000153
154# Development Targets
Harald Welte7505d612001-07-31 13:06:17 +0000155.PHONY: install-devel-man3
James Morrisc82e9ac2000-11-24 14:34:02 +0000156install-devel-man3: $(DEVEL_MAN3)
157 @[ -d $(DESTDIR)$(MANDIR)/man3 ] || mkdir -p $(DESTDIR)$(MANDIR)/man3
158 @cp -v $(DEVEL_MAN3) $(DESTDIR)$(MANDIR)/man3
159
Harald Welte7505d612001-07-31 13:06:17 +0000160.PHONY: install-devel-headers
James Morrisc82e9ac2000-11-24 14:34:02 +0000161install-devel-headers: $(DEVEL_HEADERS)
162 @[ -d $(DESTDIR)$(INCDIR) ] || mkdir -p $(DESTDIR)$(INCDIR)
163 @cp -v $(DEVEL_HEADERS) $(DESTDIR)$(INCDIR)
164
Harald Welte7505d612001-07-31 13:06:17 +0000165.PHONY: install-devel-libs
James Morrisc82e9ac2000-11-24 14:34:02 +0000166install-devel-libs: $(DEVEL_LIBS)
167 @[ -d $(DESTDIR)$(LIBDIR) ] || mkdir -p $(DESTDIR)$(LIBDIR)
168 @cp -v $(DEVEL_LIBS) $(DESTDIR)$(LIBDIR)
169
Harald Welte7505d612001-07-31 13:06:17 +0000170.PHONY: install-devel
James Morrisc82e9ac2000-11-24 14:34:02 +0000171install-devel: all install-devel-man3 install-devel-headers install-devel-libs
172
Harald Welte7505d612001-07-31 13:06:17 +0000173.PHONY: distclean
Rusty Russell905795c2000-04-19 11:22:03 +0000174distclean: clean
Rusty Russella470f332000-11-07 04:08:34 +0000175 @rm -f TAGS `find . -name '*~' -o -name '.*~'` `find . -name '*.rej'` `find . -name '*.d'` .makefirst
Rusty Russell175f6412000-03-24 09:32:20 +0000176
Rusty Russell52451822000-08-27 07:47:46 +0000177.PHONY: patch-o-matic
Rusty Russella470f332000-11-07 04:08:34 +0000178patch-o-matic/ patch-o-matic:
Harald Welte02f17e92001-11-12 08:20:12 +0000179 @echo "Are your sure you didn't want to use make most-of-pom?"
180 @cd $@ && KERNEL_DIR=$(KERNEL_DIR) ./runme extra
Rusty Russell52451822000-08-27 07:47:46 +0000181
Harald Weltece4957f2001-09-02 14:55:14 +0000182.PHONY: most-of-pom
183most-of-pom:
Harald Welte02f17e92001-11-12 08:20:12 +0000184 @cd patch-o-matic && KERNEL_DIR=$(KERNEL_DIR) ./runme base
Harald Weltece4957f2001-09-02 14:55:14 +0000185
Rusty Russell175f6412000-03-24 09:32:20 +0000186# Rusty's distro magic.
Harald Welte7505d612001-07-31 13:06:17 +0000187.PHONY: distrib
Harald Welte3a5026f2001-09-02 16:07:33 +0000188distrib: check distclean delrelease $(RELEASE_DIR)/iptables-$(NETFILTER_VERSION).tar.bz2 diff md5sums # nowhitespace
Rusty Russell175f6412000-03-24 09:32:20 +0000189
190# Makefile must not define:
Harald Welte380ba5f2002-02-13 16:19:55 +0000191# -g -pg -DIPTC_DEBUG
Harald Welte7505d612001-07-31 13:06:17 +0000192.PHONY: check
Rusty Russell175f6412000-03-24 09:32:20 +0000193check:
Harald Welte380ba5f2002-02-13 16:19:55 +0000194 @if echo $(CFLAGS) | egrep -e '-g|-pg|IPTC_DEBUG' >/dev/null; then echo Remove debugging flags; exit 1; else exit 0; fi
Rusty Russell175f6412000-03-24 09:32:20 +0000195
Harald Welte7505d612001-07-31 13:06:17 +0000196.PHONY: nowhitespace
Rusty Russell175f6412000-03-24 09:32:20 +0000197nowhitespace:
Rusty Russell2e5f9532001-01-07 09:37:02 +0000198 @if grep -n '[ ]$$' `find . -name 'Makefile' -o -name '*.[ch]'`; then exit 1; else exit 0; fi
Rusty Russell175f6412000-03-24 09:32:20 +0000199
Harald Welte7505d612001-07-31 13:06:17 +0000200.PHONY: delrelease
Rusty Russell175f6412000-03-24 09:32:20 +0000201delrelease:
Harald Welte3a5026f2001-09-02 16:07:33 +0000202 rm -f $(RELEASE_DIR)/iptables-$(NETFILTER_VERSION).tar.bz2
Rusty Russell175f6412000-03-24 09:32:20 +0000203
Harald Welte3a5026f2001-09-02 16:07:33 +0000204$(RELEASE_DIR)/iptables-$(NETFILTER_VERSION).tar.bz2:
Rusty Russell905795c2000-04-19 11:22:03 +0000205 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 +0000206
Harald Welte7505d612001-07-31 13:06:17 +0000207.PHONY: diff
Harald Welte3a5026f2001-09-02 16:07:33 +0000208diff: $(RELEASE_DIR)/iptables-$(NETFILTER_VERSION).tar.bz2
Rusty Russell175f6412000-03-24 09:32:20 +0000209 @mkdir /tmp/diffdir
Harald Welte3a5026f2001-09-02 16:07:33 +0000210 @cd /tmp/diffdir && tar -x --bzip2 -f $(RELEASE_DIR)/iptables-$(NETFILTER_VERSION).tar.bz2
211 @set -e; cd /tmp/diffdir; tar -x --bzip2 -f $(RELEASE_DIR)/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 > $(RELEASE_DIR)/patch-iptables-$(OLD_NETFILTER_VERSION)-$(NETFILTER_VERSION).bz2
Rusty Russell175f6412000-03-24 09:32:20 +0000212 @rm -rf /tmp/diffdir
213
Harald Welte7505d612001-07-31 13:06:17 +0000214.PHONY: md5sums
Rusty Russell175f6412000-03-24 09:32:20 +0000215md5sums:
Harald Welte3a5026f2001-09-02 16:07:33 +0000216 cd $(RELEASE_DIR)/ && md5sum patch-iptables-*-$(NETFILTER_VERSION).bz2 iptables-$(NETFILTER_VERSION).tar.bz2
Rusty Russell175f6412000-03-24 09:32:20 +0000217
Marc Bouchere6869a82000-03-20 06:03:29 +0000218# $(wildcard) fails wierdly with make v.3.78.1.
219include $(shell echo */Makefile)
220include Rules.make