blob: cf747e024299bb4232aa19c1e57da971fa540c08 [file] [log] [blame]
Harald Welte3efb6ea2001-08-06 18:50:21 +00001# uncomment this to get a fully statically linked version
2# NO_SHARED_LIBS = 1
3
Harald Welte2354d922003-03-04 23:15:42 +00004# uncomment this to disable IPv6 support
5# DO_IPV6 = 0
6
Harald Welte3a5026f2001-09-02 16:07:33 +00007######################################################################
8# YOU SHOULD NOT NEED TO TOUCH ANYTHING BELOW THIS LINE
9######################################################################
10
11# Standard part of Makefile for topdir.
12TOPLEVEL_INCLUDED=YES
13
Marc Bouchere6869a82000-03-20 06:03:29 +000014ifndef KERNEL_DIR
15KERNEL_DIR=/usr/src/linux
16endif
Harald Weltefe7a1212003-04-13 15:28:23 +000017IPTABLES_VERSION:=1.2.8
18OLD_IPTABLES_VERSION:=1.2.7a
Marc Bouchere6869a82000-03-20 06:03:29 +000019
Harald Welteba6d0122002-02-17 19:49:26 +000020PREFIX:=/usr/local
21LIBDIR:=$(PREFIX)/lib
22BINDIR:=$(PREFIX)/sbin
23MANDIR:=$(PREFIX)/man
24INCDIR:=$(PREFIX)/include
Marc Bouchere6869a82000-03-20 06:03:29 +000025
Harald Welte3a5026f2001-09-02 16:07:33 +000026# directory for new iptables releases
27RELEASE_DIR:=/tmp
28
Rusty Russell209820b2001-01-08 08:14:33 +000029# Need libc6 for this. FIXME: Should covert to autoconf.
Rusty Russell4d2afbf2001-05-01 02:06:08 +000030ifeq ($(shell [ -f /usr/include/netinet/ip6.h ] && echo YES), YES)
Harald Welte2354d922003-03-04 23:15:42 +000031DO_IPV6:=1
Rusty Russell8e07bd72000-12-19 03:11:00 +000032endif
33
Harald Welte380ba5f2002-02-13 16:19:55 +000034COPT_FLAGS:=-O2
Harald Welte80fe35d2002-05-29 13:08:15 +000035CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KERNEL_DIR)/include -Iinclude/ -DIPTABLES_VERSION=\"$(IPTABLES_VERSION)\" #-g -DDEBUG #-pg # -DIPTC_DEBUG
Marc Bouchere6869a82000-03-20 06:03:29 +000036
Harald Welte3efb6ea2001-08-06 18:50:21 +000037ifdef NO_SHARED_LIBS
38CFLAGS += -DNO_SHARED_LIBS=1
39endif
40
41ifndef NO_SHARED_LIBS
Rusty Russell5622f212000-05-02 16:42:09 +000042DEPFILES = $(SHARED_LIBS:%.so=%.d)
Marc Bouchere6869a82000-03-20 06:03:29 +000043SH_CFLAGS:=$(CFLAGS) -fPIC
Harald Welte3efb6ea2001-08-06 18:50:21 +000044STATIC_LIBS =
45STATIC6_LIBS =
46LDFLAGS = -rdynamic
Harald Welte2354d922003-03-04 23:15:42 +000047LDLIBS = -ldl -lnsl
Harald Welte3efb6ea2001-08-06 18:50:21 +000048else
49DEPFILES = $(EXT_OBJS:%.o=%.d)
50STATIC_LIBS = extensions/libext.a
51STATIC6_LIBS = extensions/libext6.a
Harald Welte2a7116e2002-08-26 13:09:40 +000052LDFLAGS = -static
Harald Welte3efb6ea2001-08-06 18:50:21 +000053LDLIBS =
54endif
Marc Bouchere6869a82000-03-20 06:03:29 +000055
Rusty Russell2e5f9532001-01-07 09:37:02 +000056EXTRAS+=iptables iptables.o
Rusty Russell01c45202001-01-07 06:50:31 +000057EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables $(DESTDIR)$(MANDIR)/man8/iptables.8
58
Harald Welteeba774d2001-10-16 08:22:40 +000059# No longer experimental.
60EXTRAS+=iptables-save iptables-restore
61EXTRA_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 +000062
Harald Welte2354d922003-03-04 23:15:42 +000063ifeq ($(DO_IPV6), 1)
Rusty Russell8e07bd72000-12-19 03:11:00 +000064EXTRAS+=ip6tables ip6tables.o
András Kis-Szabó06129432001-10-14 13:27:03 +000065EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/ip6tables $(DESTDIR)$(MANDIR)/man8/ip6tables.8
Harald Welte8a6831a2001-03-15 15:33:56 +000066EXTRAS_EXP+=ip6tables-save ip6tables-restore
Harald Welte46d4d0a2001-03-16 15:48:56 +000067EXTRA_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 +000068endif
Marc Bouchere6869a82000-03-20 06:03:29 +000069
Rusty Russell09b9a412000-04-27 10:16:47 +000070# Sparc64 hack
71ifeq ($(shell uname -m),sparc64)
72# The kernel is 64-bit, even though userspace is 32.
Rusty Russellc8d7d892000-09-19 07:01:00 +000073CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
Rusty Russell09b9a412000-04-27 10:16:47 +000074endif
75
Rusty Russellda707152001-04-21 04:25:09 +000076# HPPA hack
77ifeq ($(shell uname -m),parisc64)
78# The kernel is 64-bit, even though userspace is 32.
79CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
80endif
81
Marc Bouchere6869a82000-03-20 06:03:29 +000082ifndef IPT_LIBDIR
83IPT_LIBDIR:=$(LIBDIR)/iptables
84endif
85
Harald Welte7505d612001-07-31 13:06:17 +000086.PHONY: default
Rusty Russell52451822000-08-27 07:47:46 +000087default: print-extensions all
88
Harald Welte7505d612001-07-31 13:06:17 +000089.PHONY: print-extensions
Rusty Russell52451822000-08-27 07:47:46 +000090print-extensions:
Rusty Russellc8d7d892000-09-19 07:01:00 +000091 @[ -n "$(OPTIONALS)" ] && echo Extensions found: $(OPTIONALS)
Marc Bouchere6869a82000-03-20 06:03:29 +000092
93iptables.o: iptables.c
94 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
95
Harald Welte3efb6ea2001-08-06 18:50:21 +000096iptables: iptables-standalone.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
97 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
Marc Bouchere6869a82000-03-20 06:03:29 +000098
99$(DESTDIR)$(BINDIR)/iptables: iptables
100 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
101 cp $< $@
102
Harald Welte3efb6ea2001-08-06 18:50:21 +0000103iptables-save: iptables-save.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
104 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
Marc Bouchere6869a82000-03-20 06:03:29 +0000105
106$(DESTDIR)$(BINDIR)/iptables-save: iptables-save
107 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
108 cp $< $@
109
Harald Welte3efb6ea2001-08-06 18:50:21 +0000110iptables-restore: iptables-restore.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
111 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
Marc Bouchere6869a82000-03-20 06:03:29 +0000112
113$(DESTDIR)$(BINDIR)/iptables-restore: iptables-restore
114 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
115 cp $< $@
116
Philip Blundell8c700902000-05-15 02:17:52 +0000117ip6tables.o: ip6tables.c
Harald Welte0aefbd32001-05-11 21:41:47 +0000118 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
Philip Blundell8c700902000-05-15 02:17:52 +0000119
Harald Welte3efb6ea2001-08-06 18:50:21 +0000120ip6tables: ip6tables-standalone.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
Harald Welte2a7116e2002-08-26 13:09:40 +0000121 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
Philip Blundell8c700902000-05-15 02:17:52 +0000122
123$(DESTDIR)$(BINDIR)/ip6tables: ip6tables
124 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
125 cp $< $@
126
Harald Welte3efb6ea2001-08-06 18:50:21 +0000127ip6tables-save: ip6tables-save.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
Harald Welte2a7116e2002-08-26 13:09:40 +0000128 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
Philip Blundell8c700902000-05-15 02:17:52 +0000129
130$(DESTDIR)$(BINDIR)/ip6tables-save: ip6tables-save
131 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
132 cp $< $@
133
Harald Welte3efb6ea2001-08-06 18:50:21 +0000134ip6tables-restore: ip6tables-restore.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
Harald Welte2a7116e2002-08-26 13:09:40 +0000135 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
Philip Blundell8c700902000-05-15 02:17:52 +0000136
137$(DESTDIR)$(BINDIR)/ip6tables-restore: ip6tables-restore
138 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
139 cp $< $@
140
Rusty Russell01c45202001-01-07 06:50:31 +0000141$(DESTDIR)$(MANDIR)/man8/%.8: %.8
Marc Bouchere6869a82000-03-20 06:03:29 +0000142 @[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
143 cp $< $@
144
145EXTRA_DEPENDS+=iptables-standalone.d iptables.d
146
147iptables-standalone.d iptables.d: %.d: %.c
148 @-$(CC) -M -MG $(CFLAGS) $< | sed -e 's@^.*\.o:@$*.d $*.o:@' > $@
149
James Morrisc82e9ac2000-11-24 14:34:02 +0000150
151# Development Targets
Harald Welte7505d612001-07-31 13:06:17 +0000152.PHONY: install-devel-man3
James Morrisc82e9ac2000-11-24 14:34:02 +0000153install-devel-man3: $(DEVEL_MAN3)
154 @[ -d $(DESTDIR)$(MANDIR)/man3 ] || mkdir -p $(DESTDIR)$(MANDIR)/man3
155 @cp -v $(DEVEL_MAN3) $(DESTDIR)$(MANDIR)/man3
156
Harald Welte7505d612001-07-31 13:06:17 +0000157.PHONY: install-devel-headers
James Morrisc82e9ac2000-11-24 14:34:02 +0000158install-devel-headers: $(DEVEL_HEADERS)
159 @[ -d $(DESTDIR)$(INCDIR) ] || mkdir -p $(DESTDIR)$(INCDIR)
160 @cp -v $(DEVEL_HEADERS) $(DESTDIR)$(INCDIR)
161
Harald Welte7505d612001-07-31 13:06:17 +0000162.PHONY: install-devel-libs
James Morrisc82e9ac2000-11-24 14:34:02 +0000163install-devel-libs: $(DEVEL_LIBS)
164 @[ -d $(DESTDIR)$(LIBDIR) ] || mkdir -p $(DESTDIR)$(LIBDIR)
165 @cp -v $(DEVEL_LIBS) $(DESTDIR)$(LIBDIR)
166
Harald Welte7505d612001-07-31 13:06:17 +0000167.PHONY: install-devel
James Morrisc82e9ac2000-11-24 14:34:02 +0000168install-devel: all install-devel-man3 install-devel-headers install-devel-libs
169
Harald Welte7505d612001-07-31 13:06:17 +0000170.PHONY: distclean
Rusty Russell905795c2000-04-19 11:22:03 +0000171distclean: clean
Rusty Russella470f332000-11-07 04:08:34 +0000172 @rm -f TAGS `find . -name '*~' -o -name '.*~'` `find . -name '*.rej'` `find . -name '*.d'` .makefirst
Rusty Russell175f6412000-03-24 09:32:20 +0000173
174# Rusty's distro magic.
Harald Welte7505d612001-07-31 13:06:17 +0000175.PHONY: distrib
Harald Welte80fe35d2002-05-29 13:08:15 +0000176distrib: check distclean delrelease $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2 diff md5sums # nowhitespace
Rusty Russell175f6412000-03-24 09:32:20 +0000177
178# Makefile must not define:
Harald Welte380ba5f2002-02-13 16:19:55 +0000179# -g -pg -DIPTC_DEBUG
Harald Welte7505d612001-07-31 13:06:17 +0000180.PHONY: check
Rusty Russell175f6412000-03-24 09:32:20 +0000181check:
Harald Welte380ba5f2002-02-13 16:19:55 +0000182 @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 +0000183
Harald Welte7505d612001-07-31 13:06:17 +0000184.PHONY: nowhitespace
Rusty Russell175f6412000-03-24 09:32:20 +0000185nowhitespace:
Rusty Russell2e5f9532001-01-07 09:37:02 +0000186 @if grep -n '[ ]$$' `find . -name 'Makefile' -o -name '*.[ch]'`; then exit 1; else exit 0; fi
Rusty Russell175f6412000-03-24 09:32:20 +0000187
Harald Welte7505d612001-07-31 13:06:17 +0000188.PHONY: delrelease
Rusty Russell175f6412000-03-24 09:32:20 +0000189delrelease:
Harald Welte80fe35d2002-05-29 13:08:15 +0000190 rm -f $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2
Rusty Russell175f6412000-03-24 09:32:20 +0000191
Harald Welte80fe35d2002-05-29 13:08:15 +0000192$(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2:
193 cd .. && ln -sf userspace iptables-$(IPTABLES_VERSION) && tar cvf - --exclude CVS iptables-$(IPTABLES_VERSION)/. | bzip2 -9 > $@ && rm iptables-$(IPTABLES_VERSION)
Rusty Russell175f6412000-03-24 09:32:20 +0000194
Harald Welte7505d612001-07-31 13:06:17 +0000195.PHONY: diff
Harald Welte80fe35d2002-05-29 13:08:15 +0000196diff: $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2
Rusty Russell175f6412000-03-24 09:32:20 +0000197 @mkdir /tmp/diffdir
Harald Welte80fe35d2002-05-29 13:08:15 +0000198 @cd /tmp/diffdir && tar -x --bzip2 -f $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2
199 @set -e; cd /tmp/diffdir; tar -x --bzip2 -f $(RELEASE_DIR)/iptables-$(OLD_IPTABLES_VERSION).tar.bz2; echo Creating patch-iptables-$(OLD_IPTABLES_VERSION)-$(IPTABLES_VERSION).bz2; diff -urN iptables-$(OLD_IPTABLES_VERSION) iptables-$(IPTABLES_VERSION) | bzip2 -9 > $(RELEASE_DIR)/patch-iptables-$(OLD_IPTABLES_VERSION)-$(IPTABLES_VERSION).bz2
Rusty Russell175f6412000-03-24 09:32:20 +0000200 @rm -rf /tmp/diffdir
201
Harald Welte7505d612001-07-31 13:06:17 +0000202.PHONY: md5sums
Rusty Russell175f6412000-03-24 09:32:20 +0000203md5sums:
Harald Welte80fe35d2002-05-29 13:08:15 +0000204 cd $(RELEASE_DIR)/ && md5sum patch-iptables-*-$(IPTABLES_VERSION).bz2 iptables-$(IPTABLES_VERSION).tar.bz2
Rusty Russell175f6412000-03-24 09:32:20 +0000205
Marc Bouchere6869a82000-03-20 06:03:29 +0000206# $(wildcard) fails wierdly with make v.3.78.1.
207include $(shell echo */Makefile)
208include Rules.make