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=/usr/src/linux
17 IPTABLES_VERSION:=1.3.2
18 OLD_IPTABLES_VERSION:=1.3.1
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)
35 CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KERNEL_DIR)/include -Iinclude/ -DIPTABLES_VERSION=\"$(IPTABLES_VERSION)\" #-g -DDEBUG #-pg # -DIPTC_DEBUG
38 CFLAGS += -DNO_SHARED_LIBS=1
41 EXTRAS+=iptables iptables.o iptables.8
42 EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables $(DESTDIR)$(MANDIR)/man8/iptables.8
44 # No longer experimental.
45 ifneq ($(DO_MULTI), 1)
46 EXTRAS+=iptables-save iptables-restore
48 EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables-save $(DESTDIR)$(BINDIR)/iptables-restore $(DESTDIR)$(MANDIR)/man8/iptables-restore.8 $(DESTDIR)$(MANDIR)/man8/iptables-save.8
51 EXTRAS+=ip6tables ip6tables.o ip6tables.8
52 EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/ip6tables $(DESTDIR)$(MANDIR)/man8/ip6tables.8
53 EXTRAS_EXP+=ip6tables-save ip6tables-restore
54 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
58 ifeq ($(shell uname -m),sparc64)
60 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)
62 # The kernel is 64-bit, even though userspace is 32.
63 CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
65 EXT_LDFLAGS=-m elf64_sparc
69 # Alpha only has 64bit userspace and fails the test below
70 ifeq ($(shell uname -m), alpha)
74 # Generic test if arch wasn't found above
75 ifneq ($(POINTERTEST),1)
76 # Try to determine if kernel is 64bit and we are compiling for 32bit
77 ifeq ($(shell [ -a $(KERNEL_DIR)/include/asm ] && echo YES), YES)
78 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)
80 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)
82 CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
86 CFLAGS+=-D_UNKNOWN_KERNEL_POINTER_SIZE
91 IPT_LIBDIR:=$(LIBDIR)/iptables
95 DEPFILES = $(SHARED_LIBS:%.so=%.d)
96 SH_CFLAGS:=$(CFLAGS) -fPIC
102 DEPFILES = $(EXT_OBJS:%.o=%.d)
103 STATIC_LIBS = extensions/libext.a
104 STATIC6_LIBS = extensions/libext6.a
110 default: print-extensions all
112 .PHONY: print-extensions
114 @[ -n "$(OPTIONALS)" ] && echo Extensions found: $(OPTIONALS)
116 iptables.o: iptables.c
117 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
119 ifeq ($(DO_MULTI), 1)
120 iptables: iptables-multi.c iptables-save.c iptables-restore.c iptables-standalone.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
121 $(CC) $(CFLAGS) -DIPTABLES_MULTI -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
123 iptables: iptables-standalone.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
124 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
127 $(DESTDIR)$(BINDIR)/iptables: iptables
128 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
131 iptables-save: iptables-save.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
132 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
134 ifeq ($(DO_MULTI), 1)
135 $(DESTDIR)$(BINDIR)/iptables-save: iptables
136 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
139 $(DESTDIR)$(BINDIR)/iptables-save: iptables-save
140 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
144 iptables-restore: iptables-restore.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
145 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
147 ifeq ($(DO_MULTI), 1)
148 $(DESTDIR)$(BINDIR)/iptables-restore: iptables
149 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
152 $(DESTDIR)$(BINDIR)/iptables-restore: iptables-restore
153 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
157 ip6tables.o: ip6tables.c
158 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
160 ip6tables: ip6tables-standalone.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
161 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
163 $(DESTDIR)$(BINDIR)/ip6tables: ip6tables
164 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
167 ip6tables-save: ip6tables-save.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
168 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
170 $(DESTDIR)$(BINDIR)/ip6tables-save: ip6tables-save
171 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
174 ip6tables-restore: ip6tables-restore.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
175 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
177 $(DESTDIR)$(BINDIR)/ip6tables-restore: ip6tables-restore
178 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
181 $(DESTDIR)$(MANDIR)/man8/%.8: %.8
182 @[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
185 EXTRA_DEPENDS+=iptables-standalone.d iptables.d
187 iptables-standalone.d iptables.d: %.d: %.c
188 @-$(CC) -M -MG $(CFLAGS) $< | sed -e 's@^.*\.o:@$*.d $*.o:@' > $@
190 iptables.8: iptables.8.in extensions/libipt_matches.man extensions/libipt_targets.man
191 sed -e '/@MATCH@/ r extensions/libipt_matches.man' -e '/@TARGET@/ r extensions/libipt_targets.man' iptables.8.in >iptables.8
193 ip6tables.8: ip6tables.8.in extensions/libip6t_matches.man extensions/libip6t_targets.man
194 sed -e '/@MATCH@/ r extensions/libip6t_matches.man' -e '/@TARGET@/ r extensions/libip6t_targets.man' ip6tables.8.in >ip6tables.8
196 # Development Targets
197 .PHONY: install-devel-man3
198 install-devel-man3: $(DEVEL_MAN3)
199 @[ -d $(DESTDIR)$(MANDIR)/man3 ] || mkdir -p $(DESTDIR)$(MANDIR)/man3
200 @cp -v $(DEVEL_MAN3) $(DESTDIR)$(MANDIR)/man3
202 .PHONY: install-devel-headers
203 install-devel-headers: $(DEVEL_HEADERS)
204 @[ -d $(DESTDIR)$(INCDIR) ] || mkdir -p $(DESTDIR)$(INCDIR)
205 @cp -v $(DEVEL_HEADERS) $(DESTDIR)$(INCDIR)
207 .PHONY: install-devel-libs
208 install-devel-libs: $(DEVEL_LIBS)
209 @[ -d $(DESTDIR)$(LIBDIR) ] || mkdir -p $(DESTDIR)$(LIBDIR)
210 @cp -v $(DEVEL_LIBS) $(DESTDIR)$(LIBDIR)
212 .PHONY: install-devel
213 install-devel: all install-devel-man3 install-devel-headers install-devel-libs
217 @rm -f TAGS `find . -name '*~' -o -name '.*~'` `find . -name '*.rej'` `find . -name '*.d'` .makefirst
219 # Rusty's distro magic.
221 distrib: check distclean delrelease $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2 diff md5sums # nowhitespace
223 # Makefile must not define:
224 # -g -pg -DIPTC_DEBUG
227 @if echo $(CFLAGS) | egrep -e '-g|-pg|IPTC_DEBUG' >/dev/null; then echo Remove debugging flags; exit 1; else exit 0; fi
231 @if grep -n '[ ]$$' `find . -name 'Makefile' -o -name '*.[ch]'`; then exit 1; else exit 0; fi
235 rm -f $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2
237 $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2:
238 cd .. && ln -sf iptables iptables-$(IPTABLES_VERSION) && tar cvf - --exclude .svn iptables-$(IPTABLES_VERSION)/. | bzip2 -9 > $@ && rm iptables-$(IPTABLES_VERSION)
241 diff: $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2
243 @cd /tmp/diffdir && tar -x --bzip2 -f $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2
244 @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
249 cd $(RELEASE_DIR)/ && md5sum patch-iptables-*-$(IPTABLES_VERSION).bz2 iptables-$(IPTABLES_VERSION).tar.bz2
251 # $(wildcard) fails wierdly with make v.3.78.1.
252 include $(shell echo */Makefile)