libsodium: updated to 1.0.10
[tomato.git] / release / src / router / iptables / Makefile
blob2f3affbe1fe0c09c9006c87d952fddd759cf4b51
1 # uncomment this to get a fully statically linked version
2 # NO_SHARED_LIBS = 1
4 ifeq ($(TCONFIG_IPV6),y)
5 DO_IPV6 = 1
6 else
7 DO_IPV6 = 0
8 endif
10 # uncomment this to disable IPv6 support
11 # DO_IPV6 = 0
13 DO_MULTI = 1
15 DO_SAVE = 1
17 ######################################################################
18 # YOU SHOULD NOT NEED TO TOUCH ANYTHING BELOW THIS LINE
19 ######################################################################
21 # Standard part of Makefile for topdir.
22 TOPLEVEL_INCLUDED=YES
24 ifndef KERNEL_DIR
25 KERNEL_DIR="/lib/modules/$(shell uname -r)/build"
26 endif
27 IPTABLES_VERSION:=1.3.8
28 OLD_IPTABLES_VERSION:=1.3.7
30 PREFIX:=/usr/local
31 LIBDIR:=$(PREFIX)/lib
32 BINDIR:=$(PREFIX)/sbin
33 MANDIR:=$(PREFIX)/man
34 INCDIR:=$(PREFIX)/include
36 # directory for new iptables releases
37 RELEASE_DIR:=/tmp
39 # Need libc6 for this. FIXME: Should covert to autoconf.
40 ifndef DO_IPV6
41 ifeq ($(shell [ -f /usr/include/netinet/ip6.h ] && echo YES), YES)
42 DO_IPV6:=1
43 endif
44 endif
46 # Enable linking to libselinux via enviornment 'DO_SELINUX=1'
47 ifndef DO_SELINUX
48 DO_SELINUX=0
49 endif
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
54 ifdef NO_SHARED_LIBS
55 CFLAGS += -DNO_SHARED_LIBS=1
56 endif
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
64 endif
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
67 ifeq ($(DO_IPV6), 1)
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
72 endif
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
74 endif
76 # Sparc64 hack
77 # ifeq ($(shell uname -m),sparc64)
78 # POINTERTEST:=1
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)
80 # ifdef 32bituser
81 # # The kernel is 64-bit, even though userspace is 32.
82 # CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
83 # else
84 # EXT_LDFLAGS+=-Wl,-m,elf64_sparc
85 # endif
86 # endif
88 # Alpha only has 64bit userspace and fails the test below
89 # ifeq ($(shell uname -m), alpha)
90 # POINTERTEST:=1
91 # endif
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)
98 # ifdef 64bitkernel
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)
100 # ifdef 32bituser
101 # CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
102 # endif
103 # endif
104 # else
105 # CFLAGS+=-D_UNKNOWN_KERNEL_POINTER_SIZE
106 # endif
107 # endif
109 ifndef IPT_LIBDIR
110 IPT_LIBDIR:=$(LIBDIR)/iptables
111 endif
113 ifndef NO_SHARED_LIBS
114 DEPFILES = $(SHARED_LIBS:%.so=%.d)
115 DEPFILES += $(SHARED_SE_LIBS:%.so=%.d)
116 SH_CFLAGS:=$(CFLAGS) -fPIC
117 STATIC_LIBS =
118 STATIC6_LIBS =
119 LDFLAGS = -rdynamic
120 LDLIBS = -ldl
121 ifeq ($(DO_SELINUX), 1)
122 LDLIBS += -lselinux
123 endif
124 else
125 DEPFILES = $(EXT_OBJS:%.o=%.d)
126 STATIC_LIBS = extensions/libext.a
127 STATIC6_LIBS = extensions/libext6.a
128 LDFLAGS = -static
129 LDLIBS =
130 ifeq ($(DO_SELINUX), 1)
131 LDLIBS += -lselinux
132 endif
133 endif
135 STATIC6_LIBS += libiptc/libip6tc.a
136 LDLIBS += -L. -liptc
138 .PHONY: default
139 default: libiptc.so all
141 .PHONY: print-extensions
142 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)
154 ifeq ($(DO_SAVE), 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)
157 else
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)
160 endif
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)
165 else
166 iptables: iptables-standalone.c iptables.o $(STATIC_LIBS)
167 $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
168 endif
171 $(DESTDIR)$(BINDIR)/iptables: iptables
172 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
173 cp $< $@
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)
181 ln -sf $< $@
182 else
183 $(DESTDIR)$(BINDIR)/iptables-save: iptables-save
184 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
185 cp $< $@
186 endif
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)
194 ln -sf $< $@
195 else
196 $(DESTDIR)$(BINDIR)/iptables-restore: iptables-restore
197 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
198 cp $< $@
199 endif
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)
207 ln -sf $< $@
208 else
209 $(DESTDIR)$(BINDIR)/iptables-xml: iptables-xml
210 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
211 cp $< $@
212 endif
214 ip6tables.o: ip6tables.c
215 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
217 ifeq ($(DO_MULTI), 1)
218 ifeq ($(DO_SAVE), 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)
221 else
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)
224 endif
225 else
226 ip6tables: ip6tables-standalone.c ip6tables.o $(STATIC6_LIBS)
227 $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
228 endif
230 $(DESTDIR)$(BINDIR)/ip6tables: ip6tables
231 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
232 cp $< $@
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)
240 ln -sf $< $@
241 else
242 $(DESTDIR)$(BINDIR)/ip6tables-save: ip6tables-save
243 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
244 cp $< $@
245 endif
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)
253 ln -sf $< $@
254 else
255 $(DESTDIR)$(BINDIR)/ip6tables-restore: ip6tables-restore
256 @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
257 cp $< $@
258 endif
260 $(DESTDIR)$(MANDIR)/man8/%.8: %.8
261 @[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
262 cp $< $@
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
294 .PHONY: distclean
295 distclean: clean
296 @rm -f TAGS `find . -name '*~' -o -name '.*~'` `find . -name '*.rej'` `find . -name '*.d'` .makefirst
298 # Rusty's distro magic.
299 .PHONY: distrib
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
304 .PHONY: check
305 check:
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
308 .PHONY: nowhitespace
309 nowhitespace:
310 @if grep -n '[ ]$$' `find . -name 'Makefile' -o -name '*.[ch]'`; then exit 1; else exit 0; fi
312 .PHONY: delrelease
313 delrelease:
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)
319 .PHONY: diff
320 diff: $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2
321 @mkdir /tmp/diffdir
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
324 @rm -rf /tmp/diffdir
326 .PHONY: md5sums
327 md5sums:
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)
332 include Rules.make