1 # uncomment this to get a fully statically linked version
4 ifeq ($(TCONFIG_IPV6
),y
)
10 # uncomment this to disable IPv6 support
17 ######################################################################
18 # YOU SHOULD NOT NEED TO TOUCH ANYTHING BELOW THIS LINE
19 ######################################################################
21 # Standard part of Makefile for topdir.
25 KERNEL_DIR
="/lib/modules/$(shell uname -r)/build"
27 IPTABLES_VERSION
:=1.3.8
28 OLD_IPTABLES_VERSION
:=1.3.7
32 BINDIR
:=$(PREFIX
)/sbin
34 INCDIR
:=$(PREFIX
)/include
36 # directory for new iptables releases
39 # Need libc6 for this. FIXME: Should covert to autoconf.
41 ifeq ($(shell [ -f
/usr
/include/netinet
/ip6.h
] && echo YES
), YES
)
46 # Enable linking to libselinux via enviornment 'DO_SELINUX=1'
51 #COPT_FLAGS:=-Os #-mips32
52 CFLAGS
:=$(COPT_FLAGS
) -Wall
-Wunused
-I
$(KERNEL_DIR
)/include -Iinclude
/ -DIPTABLES_VERSION
=\"$(IPTABLES_VERSION
)\" #-g -DDEBUG #-pg # -DIPTC_DEBUG
55 CFLAGS
+= -DNO_SHARED_LIBS
=1
58 EXTRAS
+=iptables iptables.o iptables
.8
59 EXTRA_INSTALLS
+=$(DESTDIR
)$(BINDIR
)/iptables
$(DESTDIR
)$(MANDIR
)/man8
/iptables
.8
61 # No longer experimental.
62 ifneq ($(DO_MULTI
), 1)
63 EXTRAS
+=iptables-save iptables-restore iptables-xml
65 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
68 EXTRAS
+=ip6tables ip6tables.o ip6tables
.8
69 EXTRA_INSTALLS
+=$(DESTDIR
)$(BINDIR
)/ip6tables
$(DESTDIR
)$(MANDIR
)/man8
/ip6tables
.8
70 ifneq ($(DO_MULTI
), 1)
71 EXTRAS_
+=ip6tables-save ip6tables-restore
73 EXTRA_INSTALLS
+=$(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
77 # ifeq ($(shell uname -m),sparc64)
79 # 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)
81 # # The kernel is 64-bit, even though userspace is 32.
82 # CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
84 # EXT_LDFLAGS+=-Wl,-m,elf64_sparc
88 # Alpha only has 64bit userspace and fails the test below
89 # ifeq ($(shell uname -m), alpha)
93 # Generic test if arch wasn't found above
94 # ifneq ($(POINTERTEST),1)
95 # # Try to determine if kernel is 64bit and we are compiling for 32bit
96 # ifeq ($(shell [ -d $(KERNEL_DIR)/include/asm ] && echo YES), YES)
97 # 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)
99 # 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)
101 # CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
105 # CFLAGS+=-D_UNKNOWN_KERNEL_POINTER_SIZE
110 IPT_LIBDIR
:=$(LIBDIR
)/iptables
113 ifndef NO_SHARED_LIBS
114 DEPFILES
= $(SHARED_LIBS
:%.so
=%.d
)
115 DEPFILES
+= $(SHARED_SE_LIBS
:%.so
=%.d
)
116 SH_CFLAGS
:=$(CFLAGS
) -fPIC
121 ifeq ($(DO_SELINUX
), 1)
125 DEPFILES
= $(EXT_OBJS
:%.o
=%.d
)
126 STATIC_LIBS
= extensions
/libext.a
127 STATIC6_LIBS
= extensions
/libext6.a
130 ifeq ($(DO_SELINUX
), 1)
135 STATIC6_LIBS
+= libiptc
/libip6tc.a
139 default
: libiptc.so
all
141 .PHONY
: print-extensions
143 @
[ -n
"$(OPTIONALS)" ] && echo Extensions found
: $(OPTIONALS
)
145 iptables.o
: iptables.c
146 $(CC
) $(CFLAGS
) -DIPT_LIB_DIR
=\"$(IPT_LIBDIR
)\" -c
-o
$@
$<
148 libiptc.so
: libiptc
/libiptc.a
149 $(LD
) -shared
-o
$@
--whole-archive
-Llibiptc
-liptc
152 ifeq ($(DO_MULTI
), 1)
155 iptables
: iptables-multi.c iptables-save.c iptables-restore.c iptables-standalone.c iptables.o
$(STATIC_LIBS
)
156 $(CC
) $(CFLAGS
) -DIPTABLES_MULTI
-DIPTABLES_SAVE
-DIPT_LIB_DIR
=\"$(IPT_LIBDIR
)\" $(LDFLAGS
) -o
$@
$^
$(LDLIBS
)
158 iptables
: iptables-multi.c iptables-restore.c iptables-standalone.c iptables.o
$(STATIC_LIBS
)
159 $(CC
) $(CFLAGS
) -DIPTABLES_MULTI
-DIPT_LIB_DIR
=\"$(IPT_LIBDIR
)\" $(LDFLAGS
) -o
$@
$^
$(LDLIBS
)
162 # iptables: iptables-multi.c iptables-save.c iptables-restore.c iptables-xml.c iptables-standalone.c iptables.o $(STATIC_LIBS)
163 # $(CC) $(CFLAGS) -DIPTABLES_MULTI -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
166 iptables
: iptables-standalone.c iptables.o
$(STATIC_LIBS
)
167 $(CC
) $(CFLAGS
) -DIPT_LIB_DIR
=\"$(IPT_LIBDIR
)\" $(LDFLAGS
) -o
$@
$^
$(LDLIBS
)
171 $(DESTDIR
)$(BINDIR
)/iptables
: iptables
172 @
[ -d
$(DESTDIR
)$(BINDIR
) ] || mkdir
-p
$(DESTDIR
)$(BINDIR
)
175 iptables-save
: iptables-save.c iptables.o
$(STATIC_LIBS
)
176 $(CC
) $(CFLAGS
) -DIPT_LIB_DIR
=\"$(IPT_LIBDIR
)\" $(LDFLAGS
) -o
$@
$^
$(LDLIBS
)
178 ifeq ($(DO_MULTI
), 1)
179 $(DESTDIR
)$(BINDIR
)/iptables-save
: iptables
180 @
[ -d
$(DESTDIR
)$(BINDIR
) ] || mkdir
-p
$(DESTDIR
)$(BINDIR
)
183 $(DESTDIR
)$(BINDIR
)/iptables-save
: iptables-save
184 @
[ -d
$(DESTDIR
)$(BINDIR
) ] || mkdir
-p
$(DESTDIR
)$(BINDIR
)
188 iptables-restore
: iptables-restore.c iptables.o
$(STATIC_LIBS
)
189 $(CC
) $(CFLAGS
) -DIPT_LIB_DIR
=\"$(IPT_LIBDIR
)\" $(LDFLAGS
) -o
$@
$^
$(LDLIBS
)
191 ifeq ($(DO_MULTI
), 1)
192 $(DESTDIR
)$(BINDIR
)/iptables-restore
: iptables
193 @
[ -d
$(DESTDIR
)$(BINDIR
) ] || mkdir
-p
$(DESTDIR
)$(BINDIR
)
196 $(DESTDIR
)$(BINDIR
)/iptables-restore
: iptables-restore
197 @
[ -d
$(DESTDIR
)$(BINDIR
) ] || mkdir
-p
$(DESTDIR
)$(BINDIR
)
201 iptables-xml
: iptables-xml.c
#iptables.o # $(STATIC_LIBS)
202 $(CC
) $(CFLAGS
) $(LDFLAGS
) -o
$@
$^
$(LDLIBS
)
204 ifeq ($(DO_MULTI
), 1)
205 $(DESTDIR
)$(BINDIR
)/iptables-xml
: iptables
206 @
[ -d
$(DESTDIR
)$(BINDIR
) ] || mkdir
-p
$(DESTDIR
)$(BINDIR
)
209 $(DESTDIR
)$(BINDIR
)/iptables-xml
: iptables-xml
210 @
[ -d
$(DESTDIR
)$(BINDIR
) ] || mkdir
-p
$(DESTDIR
)$(BINDIR
)
214 ip6tables.o
: ip6tables.c
215 $(CC
) $(CFLAGS
) -DIP6T_LIB_DIR
=\"$(IPT_LIBDIR
)\" -c
-o
$@
$<
217 ifeq ($(DO_MULTI
), 1)
219 ip6tables
: ip6tables-multi.c ip6tables-save.c ip6tables-restore.c ip6tables-standalone.c ip6tables.o
$(STATIC6_LIBS
)
220 $(CC
) $(CFLAGS
) -DIPTABLES_MULTI
-DIPTABLES_SAVE
-DIP6T_LIB_DIR
=\"$(IPT_LIBDIR
)\" $(LDFLAGS
) -o
$@
$^
$(LDLIBS
)
222 ip6tables
: ip6tables-multi.c ip6tables-restore.c ip6tables-standalone.c ip6tables.o
$(STATIC6_LIBS
)
223 $(CC
) $(CFLAGS
) -DIPTABLES_MULTI
-DIP6T_LIB_DIR
=\"$(IPT_LIBDIR
)\" $(LDFLAGS
) -o
$@
$^
$(LDLIBS
)
226 ip6tables
: ip6tables-standalone.c ip6tables.o
$(STATIC6_LIBS
)
227 $(CC
) $(CFLAGS
) -DIP6T_LIB_DIR
=\"$(IPT_LIBDIR
)\" $(LDFLAGS
) -o
$@
$^
$(LDLIBS
)
230 $(DESTDIR
)$(BINDIR
)/ip6tables
: ip6tables
231 @
[ -d
$(DESTDIR
)$(BINDIR
) ] || mkdir
-p
$(DESTDIR
)$(BINDIR
)
234 ip6tables-save
: ip6tables-save.c ip6tables.o
$(STATIC6_LIBS
)
235 $(CC
) $(CFLAGS
) -DIP6T_LIB_DIR
=\"$(IPT_LIBDIR
)\" $(LDFLAGS
) -o
$@
$^
$(LDLIBS
)
237 ifeq ($(DO_MULTI
), 1)
238 $(DESTDIR
)$(BINDIR
)/ip6tables-save
: ip6tables
239 @
[ -d
$(DESTDIR
)$(BINDIR
) ] || mkdir
-p
$(DESTDIR
)$(BINDIR
)
242 $(DESTDIR
)$(BINDIR
)/ip6tables-save
: ip6tables-save
243 @
[ -d
$(DESTDIR
)$(BINDIR
) ] || mkdir
-p
$(DESTDIR
)$(BINDIR
)
247 ip6tables-restore
: ip6tables-restore.c ip6tables.o
$(STATIC6_LIBS
)
248 $(CC
) $(CFLAGS
) -DIP6T_LIB_DIR
=\"$(IPT_LIBDIR
)\" $(LDFLAGS
) -o
$@
$^
$(LDLIBS
)
250 ifeq ($(DO_MULTI
), 1)
251 $(DESTDIR
)$(BINDIR
)/ip6tables-restore
: ip6tables
252 @
[ -d
$(DESTDIR
)$(BINDIR
) ] || mkdir
-p
$(DESTDIR
)$(BINDIR
)
255 $(DESTDIR
)$(BINDIR
)/ip6tables-restore
: ip6tables-restore
256 @
[ -d
$(DESTDIR
)$(BINDIR
) ] || mkdir
-p
$(DESTDIR
)$(BINDIR
)
260 $(DESTDIR
)$(MANDIR
)/man8
/%.8: %.8
261 @
[ -d
$(DESTDIR
)$(MANDIR
)/man8
] || mkdir
-p
$(DESTDIR
)$(MANDIR
)/man8
264 EXTRA_DEPENDS
+=iptables-standalone.d iptables.d
266 iptables-standalone.d iptables.d
: %.d
: %.c
267 @
-$(CC
) -M
-MG
$(CFLAGS
) $< | sed
-e
's@^.*\.o:@$*.d $*.o:@' > $@
269 iptables
.8: iptables
.8.in extensions
/libipt_matches.man extensions
/libipt_targets.man
270 sed
-e
'/@MATCH@/ r extensions/libipt_matches.man' -e
'/@TARGET@/ r extensions/libipt_targets.man' iptables
.8.in
>iptables
.8
272 ip6tables
.8: ip6tables
.8.in extensions
/libip6t_matches.man extensions
/libip6t_targets.man
273 sed
-e
'/@MATCH@/ r extensions/libip6t_matches.man' -e
'/@TARGET@/ r extensions/libip6t_targets.man' ip6tables
.8.in
>ip6tables
.8
275 # Development Targets
276 .PHONY
: install-devel-man3
277 install-devel-man3
: $(DEVEL_MAN3
)
278 @
[ -d
$(DESTDIR
)$(MANDIR
)/man3
] || mkdir
-p
$(DESTDIR
)$(MANDIR
)/man3
279 @cp
-v
$(DEVEL_MAN3
) $(DESTDIR
)$(MANDIR
)/man3
281 .PHONY
: install-devel-headers
282 install-devel-headers
: $(DEVEL_HEADERS
)
283 @
[ -d
$(DESTDIR
)$(INCDIR
) ] || mkdir
-p
$(DESTDIR
)$(INCDIR
)
284 @cp
-v
$(DEVEL_HEADERS
) $(DESTDIR
)$(INCDIR
)
286 .PHONY
: install-devel-libs
287 install-devel-libs
: $(DEVEL_LIBS
)
288 @
[ -d
$(DESTDIR
)$(LIBDIR
) ] || mkdir
-p
$(DESTDIR
)$(LIBDIR
)
289 @cp
-v
$(DEVEL_LIBS
) $(DESTDIR
)$(LIBDIR
)
291 .PHONY
: install-devel
292 install-devel
: all install-devel-man3 install-devel-headers install-devel-libs
296 @
rm -f TAGS
`find . -name '*~' -o -name '.*~'` `find . -name '*.rej'` `find . -name '*.d'` .makefirst
298 # Rusty's distro magic.
300 distrib
: check distclean delrelease
$(RELEASE_DIR
)/iptables-
$(IPTABLES_VERSION
).
tar.bz2 diff md5sums
# nowhitespace
302 # Makefile must not define:
303 # -g -pg -DIPTC_DEBUG
306 @if echo
$(CFLAGS
) | egrep
-e
'(^|[[:space:]])(-g|-pg|-DIPTC_DEBUG)([[:space:]]|$)' >/dev
/null
; then echo Remove debugging flags
; exit
1; else exit
0; fi
310 @if grep
-n
'[ ]$$' `find . -name 'Makefile' -o -name '*.[ch]'`; then exit
1; else exit
0; fi
314 rm -f
$(RELEASE_DIR
)/iptables-
$(IPTABLES_VERSION
).
tar.bz2
316 $(RELEASE_DIR
)/iptables-
$(IPTABLES_VERSION
).
tar.bz2
:
317 cd ..
&& ln
-sf iptables iptables-
$(IPTABLES_VERSION
) && tar cvf
- --exclude .svn iptables-
$(IPTABLES_VERSION
)/. | bzip2
-9 > $@
&& rm iptables-
$(IPTABLES_VERSION
)
320 diff
: $(RELEASE_DIR
)/iptables-
$(IPTABLES_VERSION
).
tar.bz2
322 @cd
/tmp
/diffdir
&& tar -x
--bzip2
-f
$(RELEASE_DIR
)/iptables-
$(IPTABLES_VERSION
).
tar.bz2
323 @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
328 cd
$(RELEASE_DIR
)/ && md5sum patch-iptables-
*-$(IPTABLES_VERSION
).bz2 iptables-
$(IPTABLES_VERSION
).
tar.bz2
330 # $(wildcard) fails wierdly with make v.3.78.1.
331 include $(shell echo
*/Makefile
)