1 # uncomment this to get a fully statically linked version
4 # uncomment this to disable IPv6 support
7 ######################################################################
8 # YOU SHOULD NOT NEED TO TOUCH ANYTHING BELOW THIS LINE
9 ######################################################################
11 # Standard part of Makefile for topdir.
15 KERNEL_DIR="/lib/modules/$(shell uname -r)/build"
17 IPTABLES_VERSION:=1.3.7
18 OLD_IPTABLES_VERSION:=1.3.6
22 BINDIR:=$(PREFIX)/sbin
24 INCDIR:=$(PREFIX)/include
26 # directory for new iptables releases
29 # Need libc6 for this. FIXME: Should covert to autoconf.
30 ifeq ($(shell [ -f /usr/include/netinet/ip6.h ] && echo YES), YES)
34 # Enable linking to libselinux via enviornment 'DO_SELINUX=1'
40 CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KERNEL_DIR)/include -Iinclude/ -DIPTABLES_VERSION=\"$(IPTABLES_VERSION)\" #-g -DDEBUG #-pg # -DIPTC_DEBUG
43 CFLAGS += -DNO_SHARED_LIBS=1
46 EXTRAS+=iptables iptables.o iptables.8
47 EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables $(DESTDIR)$(MANDIR)/man8/iptables.8
49 # No longer experimental.
50 ifneq ($(DO_MULTI), 1)
51 EXTRAS+=iptables-save iptables-restore iptables-xml
53 EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables-save $(DESTDIR)$(BINDIR)/iptables-restore $(DESTDIR)$(BINDIR)/iptables-xml $(DESTDIR)$(MANDIR)/man8/iptables-restore.8 $(DESTDIR)$(MANDIR)/man8/iptables-save.8
56 EXTRAS+=ip6tables ip6tables.o ip6tables.8
57 EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/ip6tables $(DESTDIR)$(MANDIR)/man8/ip6tables.8
58 EXTRAS_EXP+=ip6tables-save ip6tables-restore
59 EXTRA_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
63 ifeq ($(shell uname -m),sparc64)
65 32bituser := $(shell echo -e "\#include <stdio.h>\n\#if !defined(__sparcv9) && !defined(__arch64__) && !defined(_LP64)\nuserspace_is_32bit\n\#endif" | $(CC) $(CFLAGS) -E - | grep userspace_is_32bit)
67 # The kernel is 64-bit, even though userspace is 32.
68 CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
70 EXT_LDFLAGS+=-Wl,-m,elf64_sparc
74 # Alpha only has 64bit userspace and fails the test below
75 ifeq ($(shell uname -m), alpha)
79 # Generic test if arch wasn't found above
80 ifneq ($(POINTERTEST),1)
81 # Try to determine if kernel is 64bit and we are compiling for 32bit
82 ifeq ($(shell [ -a $(KERNEL_DIR)/include/asm ] && echo YES), YES)
83 64bitkernel := $(shell echo -e "\#include <asm/types.h>\n\#if BITS_PER_LONG == 64\nkernel_is_64bits\n\#endif" | $(CC) $(CFLAGS) -D__KERNEL__ -E - | grep kernel_is_64bits)
85 32bituser := $(shell echo -e "\#include <stdio.h>\n\#if !defined(__arch64__) && !defined(_LP64)\nuserspace_is_32bit\n\#endif" | $(CC) $(CFLAGS) -E - | grep userspace_is_32bit)
87 CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
91 CFLAGS+=-D_UNKNOWN_KERNEL_POINTER_SIZE
96 IPT_LIBDIR:=$(LIBDIR)/iptables
100 DEPFILES = $(SHARED_LIBS:%.so=%.d)
101 DEPFILES += $(SHARED_SE_LIBS:%.so=%.d)
102 SH_CFLAGS:=$(CFLAGS) -fPIC
107 ifeq ($(DO_SELINUX), 1)
111 DEPFILES = $(EXT_OBJS:%.o=%.d)
112 STATIC_LIBS = extensions/libext.a
113 STATIC6_LIBS = extensions/libext6.a
116 ifeq ($(DO_SELINUX), 1)
122 default: print-extensions all
124 .PHONY: print-extensions
126 @[ -n "$(OPTIONALS)" ] && echo Extensions found: $(OPTIONALS)
128 iptables.o: iptables.c
129 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
131 ifeq ($(DO_MULTI), 1)
132 iptables: iptables-multi.c iptables-save.c iptables-restore.c iptables-xml.c iptables-standalone.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
133 $(CC) $(CFLAGS) -DIPTABLES_MULTI -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
135 iptables: iptables-standalone.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
136 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
139 $(DESTDIR)$(BINDIR)/iptables: iptables
140 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
143 iptables-save: iptables-save.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
144 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
146 ifeq ($(DO_MULTI), 1)
147 $(DESTDIR)$(BINDIR)/iptables-save: iptables
148 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
151 $(DESTDIR)$(BINDIR)/iptables-save: iptables-save
152 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
156 iptables-restore: iptables-restore.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
157 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
159 ifeq ($(DO_MULTI), 1)
160 $(DESTDIR)$(BINDIR)/iptables-restore: iptables
161 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
164 $(DESTDIR)$(BINDIR)/iptables-restore: iptables-restore
165 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
169 iptables-xml: iptables-xml.c #iptables.o # $(STATIC_LIBS) libiptc/libiptc.a
170 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
172 ifeq ($(DO_MULTI), 1)
173 $(DESTDIR)$(BINDIR)/iptables-xml: iptables-xml
174 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
177 $(DESTDIR)$(BINDIR)/iptables-xml: iptables-xml
178 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
182 ip6tables.o: ip6tables.c
183 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
185 ip6tables: ip6tables-standalone.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
186 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
188 $(DESTDIR)$(BINDIR)/ip6tables: ip6tables
189 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
192 ip6tables-save: ip6tables-save.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
193 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
195 $(DESTDIR)$(BINDIR)/ip6tables-save: ip6tables-save
196 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
199 ip6tables-restore: ip6tables-restore.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
200 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
202 $(DESTDIR)$(BINDIR)/ip6tables-restore: ip6tables-restore
203 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
206 $(DESTDIR)$(MANDIR)/man8/%.8: %.8
207 @[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
210 EXTRA_DEPENDS+=iptables-standalone.d iptables.d
212 iptables-standalone.d iptables.d: %.d: %.c
213 @-$(CC) -M -MG $(CFLAGS) $< | sed -e 's@^.*\.o:@$*.d $*.o:@' > $@
215 iptables.8: iptables.8.in extensions/libipt_matches.man extensions/libipt_targets.man
216 sed -e '/@MATCH@/ r extensions/libipt_matches.man' -e '/@TARGET@/ r extensions/libipt_targets.man' iptables.8.in >iptables.8
218 ip6tables.8: ip6tables.8.in extensions/libip6t_matches.man extensions/libip6t_targets.man
219 sed -e '/@MATCH@/ r extensions/libip6t_matches.man' -e '/@TARGET@/ r extensions/libip6t_targets.man' ip6tables.8.in >ip6tables.8
221 # Development Targets
222 .PHONY: install-devel-man3
223 install-devel-man3: $(DEVEL_MAN3)
224 @[ -d $(DESTDIR)$(MANDIR)/man3 ] || mkdir -p $(DESTDIR)$(MANDIR)/man3
225 @cp -v $(DEVEL_MAN3) $(DESTDIR)$(MANDIR)/man3
227 .PHONY: install-devel-headers
228 install-devel-headers: $(DEVEL_HEADERS)
229 @[ -d $(DESTDIR)$(INCDIR) ] || mkdir -p $(DESTDIR)$(INCDIR)
230 @cp -v $(DEVEL_HEADERS) $(DESTDIR)$(INCDIR)
232 .PHONY: install-devel-libs
233 install-devel-libs: $(DEVEL_LIBS)
234 @[ -d $(DESTDIR)$(LIBDIR) ] || mkdir -p $(DESTDIR)$(LIBDIR)
235 @cp -v $(DEVEL_LIBS) $(DESTDIR)$(LIBDIR)
237 .PHONY: install-devel
238 install-devel: all install-devel-man3 install-devel-headers install-devel-libs
242 @rm -f TAGS `find . -name '*~' -o -name '.*~'` `find . -name '*.rej'` `find . -name '*.d'` .makefirst
244 # Rusty's distro magic.
246 distrib: check distclean delrelease $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2 diff md5sums # nowhitespace
248 # Makefile must not define:
249 # -g -pg -DIPTC_DEBUG
252 @if echo $(CFLAGS) | egrep -e '-g|-pg|IPTC_DEBUG' >/dev/null; then echo Remove debugging flags; exit 1; else exit 0; fi
256 @if grep -n '[ ]$$' `find . -name 'Makefile' -o -name '*.[ch]'`; then exit 1; else exit 0; fi
260 rm -f $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2
262 $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2:
263 cd .. && ln -sf iptables iptables-$(IPTABLES_VERSION) && tar cvf - --exclude .svn iptables-$(IPTABLES_VERSION)/. | bzip2 -9 > $@ && rm iptables-$(IPTABLES_VERSION)
266 diff: $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2
268 @cd /tmp/diffdir && tar -x --bzip2 -f $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2
269 @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
274 cd $(RELEASE_DIR)/ && md5sum patch-iptables-*-$(IPTABLES_VERSION).bz2 iptables-$(IPTABLES_VERSION).tar.bz2
276 # $(wildcard) fails wierdly with make v.3.78.1.
277 include $(shell echo */Makefile)