iptables: pass --disable-ipv6 is CONFIG_IPV6 is unset
[openwrt/staging/yousong.git] / package / network / utils / iptables / Makefile
1 #
2 # Copyright (C) 2006-2013 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9 include $(INCLUDE_DIR)/kernel.mk
10
11 PKG_NAME:=iptables
12 PKG_VERSION:=1.4.21
13 PKG_RELEASE:=1
14
15 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
16 PKG_SOURCE_URL:=http://www.netfilter.org/projects/iptables/files \
17 ftp://ftp.be.netfilter.org/pub/netfilter/iptables/ \
18 ftp://ftp.de.netfilter.org/pub/netfilter/iptables/ \
19 ftp://ftp.no.netfilter.org/pub/netfilter/iptables/
20 PKG_MD5SUM:=536d048c8e8eeebcd9757d0863ebb0c0
21
22 PKG_FIXUP:=autoreconf
23 PKG_INSTALL:=1
24 PKG_BUILD_PARALLEL:=1
25
26 ifneq ($(CONFIG_EXTERNAL_KERNEL_TREE),"")
27 PATCH_DIR:=
28 endif
29
30 include $(INCLUDE_DIR)/package.mk
31 ifeq ($(DUMP),)
32 -include $(LINUX_DIR)/.config
33 include $(INCLUDE_DIR)/netfilter.mk
34 STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell $(SH_FUNC) grep 'NETFILTER' $(LINUX_DIR)/.config | md5s)
35 endif
36
37
38 define Package/iptables/Default
39 SECTION:=net
40 CATEGORY:=Network
41 SUBMENU:=Firewall
42 URL:=http://netfilter.org/
43 endef
44
45 define Package/iptables/Module
46 $(call Package/iptables/Default)
47 DEPENDS:=iptables $(1)
48 endef
49
50 define Package/iptables
51 $(call Package/iptables/Default)
52 TITLE:=IP firewall administration tool
53 MENU:=1
54 DEPENDS+= +kmod-ipt-core +libip4tc +IPV6:libip6tc +libxtables
55 endef
56
57 define Package/iptables/description
58 IP firewall administration tool.
59
60 Matches:
61 - icmp
62 - tcp
63 - udp
64 - comment
65 - conntrack
66 - limit
67 - mac
68 - mark
69 - multiport
70 - set
71 - state
72 - time
73
74 Targets:
75 - ACCEPT
76 - CT
77 - DNAT
78 - DROP
79 - REJECT
80 - LOG
81 - MARK
82 - MASQUERADE
83 - REDIRECT
84 - SET
85 - SNAT
86 - TCPMSS
87
88 Tables:
89 - filter
90 - mangle
91 - nat
92 - raw
93
94 endef
95
96 define Package/iptables-mod-conntrack-extra
97 $(call Package/iptables/Module, +kmod-ipt-conntrack-extra)
98 TITLE:=Extra connection tracking extensions
99 endef
100
101 define Package/iptables-mod-conntrack-extra/description
102 Extra iptables extensions for connection tracking.
103
104 Matches:
105 - connbytes
106 - connlimit
107 - connmark
108 - recent
109 - helper
110
111 Targets:
112 - CONNMARK
113
114 endef
115
116 define Package/iptables-mod-filter
117 $(call Package/iptables/Module, +kmod-ipt-filter)
118 TITLE:=Content inspection extensions
119 endef
120
121 define Package/iptables-mod-filter/description
122 iptables extensions for packet content inspection.
123 Includes support for:
124
125 Matches:
126 - layer7
127 - string
128
129 endef
130
131 define Package/iptables-mod-ipopt
132 $(call Package/iptables/Module, +kmod-ipt-ipopt)
133 TITLE:=IP/Packet option extensions
134 endef
135
136 define Package/iptables-mod-ipopt/description
137 iptables extensions for matching/changing IP packet options.
138
139 Matches:
140 - dscp
141 - ecn
142 - length
143 - statistic
144 - tcpmss
145 - unclean
146 - hl
147
148 Targets:
149 - DSCP
150 - CLASSIFY
151 - ECN
152 - HL
153
154 endef
155
156 define Package/iptables-mod-ipsec
157 $(call Package/iptables/Module, +kmod-ipt-ipsec)
158 TITLE:=IPsec extensions
159 endef
160
161 define Package/iptables-mod-ipsec/description
162 iptables extensions for matching ipsec traffic.
163
164 Matches:
165 - ah
166 - esp
167 - policy
168
169 endef
170
171 define Package/iptables-mod-nat-extra
172 $(call Package/iptables/Module, +kmod-ipt-nat-extra)
173 TITLE:=Extra NAT extensions
174 endef
175
176 define Package/iptables-mod-nat-extra/description
177 iptables extensions for extra NAT targets.
178
179 Targets:
180 - MIRROR
181 - NETMAP
182 endef
183
184 define Package/iptables-mod-ulog
185 $(call Package/iptables/Module, +kmod-ipt-ulog)
186 TITLE:=user-space packet logging
187 endef
188
189 define Package/iptables-mod-ulog/description
190 iptables extensions for user-space packet logging.
191
192 Targets:
193 - ULOG
194
195 endef
196
197 define Package/iptables-mod-hashlimit
198 $(call Package/iptables/Module, +kmod-ipt-hashlimit)
199 TITLE:=hashlimit matching
200 endef
201
202 define Package/iptables-mod-hashlimit/description
203 iptables extensions for hashlimit matching
204
205 Matches:
206 - hashlimit
207
208 endef
209
210 define Package/iptables-mod-iprange
211 $(call Package/iptables/Module, +kmod-ipt-iprange)
212 TITLE:=IP range extension
213 endef
214
215 define Package/iptables-mod-iprange/description
216 iptables extensions for matching ip ranges.
217
218 Matches:
219 - iprange
220
221 endef
222
223 define Package/iptables-mod-extra
224 $(call Package/iptables/Module, +kmod-ipt-extra)
225 TITLE:=Other extra iptables extensions
226 endef
227
228 define Package/iptables-mod-extra/description
229 Other extra iptables extensions.
230
231 Matches:
232 - addrtype
233 - condition
234 - owner
235 - physdev (if ebtables is enabled)
236 - pkttype
237 - quota
238
239 endef
240
241 define Package/iptables-mod-led
242 $(call Package/iptables/Module, +kmod-ipt-led)
243 TITLE:=LED trigger iptables extension
244 endef
245
246 define Package/iptables-mod-led/description
247 iptables extension for triggering a LED.
248
249 Targets:
250 - LED
251
252 endef
253
254 define Package/iptables-mod-tproxy
255 $(call Package/iptables/Module, +kmod-ipt-tproxy)
256 TITLE:=Transparent proxy iptables extensions
257 endef
258
259 define Package/iptables-mod-tproxy/description
260 Transparent proxy iptables extensions.
261
262 Matches:
263 - socket
264
265 Targets:
266 - TPROXY
267
268 endef
269
270 define Package/iptables-mod-tee
271 $(call Package/iptables/Module, +kmod-ipt-tee)
272 TITLE:=TEE iptables extensions
273 endef
274
275 define Package/iptables-mod-tee/description
276 TEE iptables extensions.
277
278 Targets:
279 - TEE
280
281 endef
282
283 define Package/iptables-mod-u32
284 $(call Package/iptables/Module, +kmod-ipt-u32)
285 TITLE:=U32 iptables extensions
286 endef
287
288 define Package/iptables-mod-u32/description
289 U32 iptables extensions.
290
291 Matches:
292 - u32
293
294 endef
295
296 define Package/ip6tables
297 $(call Package/iptables/Default)
298 DEPENDS:=@IPV6 +kmod-ip6tables +iptables
299 CATEGORY:=Network
300 TITLE:=IPv6 firewall administration tool
301 MENU:=1
302 endef
303
304
305 define Package/ip6tables-extra
306 $(call Package/iptables/Default)
307 DEPENDS:=ip6tables +kmod-ip6tables-extra
308 TITLE:=IPv6 header matching modules
309 endef
310
311 define Package/ip6tables-mod-extra/description
312 iptables header matching modules for IPv6
313 endef
314
315 define Package/ip6tables-mod-nat
316 $(call Package/iptables/Default)
317 DEPENDS:=ip6tables +kmod-ipt-nat6
318 TITLE:=IPv6 NAT extensions
319 endef
320
321 define Package/ip6tables-mod-nat/description
322 iptables extensions for IPv6-NAT targets.
323 endef
324
325 define Package/libiptc
326 $(call Package/iptables/Default)
327 SECTION:=libs
328 CATEGORY:=Libraries
329 DEPENDS:=+libip4tc +IPV6:libip6tc
330 TITLE:=IPv4/IPv6 firewall - shared libiptc library (compatibility stub)
331 endef
332
333 define Package/libip4tc
334 $(call Package/iptables/Default)
335 SECTION:=libs
336 CATEGORY:=Libraries
337 TITLE:=IPv4 firewall - shared libiptc library
338 endef
339
340 define Package/libip6tc
341 $(call Package/iptables/Default)
342 SECTION:=libs
343 CATEGORY:=Libraries
344 TITLE:=IPv6 firewall - shared libiptc library
345 endef
346
347 define Package/libxtables
348 $(call Package/iptables/Default)
349 SECTION:=libs
350 CATEGORY:=Libraries
351 TITLE:=IPv4/IPv6 firewall - shared xtables library
352 endef
353
354 TARGET_CPPFLAGS := \
355 -I$(PKG_BUILD_DIR)/include \
356 -I$(LINUX_DIR)/user_headers/include \
357 $(TARGET_CPPFLAGS)
358
359 TARGET_CFLAGS += \
360 -I$(PKG_BUILD_DIR)/include \
361 -I$(LINUX_DIR)/user_headers/include \
362 -ffunction-sections -fdata-sections
363
364 TARGET_LDFLAGS += \
365 -Wl,--gc-sections
366
367 CONFIGURE_ARGS += \
368 --enable-shared \
369 --enable-devel \
370 --with-kernel="$(LINUX_DIR)/user_headers" \
371 --with-xtlibdir=/usr/lib/iptables \
372 --enable-static \
373 $(if $(CONFIG_IPV6),,--disable-ipv6)
374
375 MAKE_FLAGS := \
376 $(TARGET_CONFIGURE_OPTS) \
377 COPT_FLAGS="$(TARGET_CFLAGS)" \
378 KERNEL_DIR="$(LINUX_DIR)/user_headers/" PREFIX=/usr \
379 KBUILD_OUTPUT="$(LINUX_DIR)" \
380 BUILTIN_MODULES="$(patsubst ip6t_%,%,$(patsubst ipt_%,%,$(patsubst xt_%,%,$(IPT_BUILTIN) $(IPT_CONNTRACK-m) $(IPT_NAT-m))))"
381
382 define Build/InstallDev
383 $(INSTALL_DIR) $(1)/usr/include
384 $(INSTALL_DIR) $(1)/usr/include/iptables
385 $(INSTALL_DIR) $(1)/usr/include/net/netfilter
386
387 # XXX: iptables header fixup, some headers are not installed by iptables anymore
388 $(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
389 $(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
390 $(CP) $(PKG_BUILD_DIR)/include/ip6tables.h $(1)/usr/include/
391 $(CP) $(PKG_BUILD_DIR)/include/libipulog $(1)/usr/include/
392 $(CP) $(PKG_BUILD_DIR)/include/libiptc $(1)/usr/include/
393
394 $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
395 $(INSTALL_DIR) $(1)/usr/lib
396 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
397 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip*tc.so* $(1)/usr/lib/
398 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
399 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/xtables.pc $(1)/usr/lib/pkgconfig/
400 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libip*tc.pc $(1)/usr/lib/pkgconfig/
401
402 # XXX: needed by firewall3
403 $(INSTALL_DIR) $(1)/usr/lib/iptables
404 $(CP) $(PKG_BUILD_DIR)/extensions/libext*.a $(1)/usr/lib/iptables/
405 endef
406
407 define Package/iptables/install
408 $(INSTALL_DIR) $(1)/usr/sbin
409 $(CP) $(PKG_INSTALL_DIR)/usr/sbin/xtables-multi $(1)/usr/sbin/
410 $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables{,-restore,-save} $(1)/usr/sbin/
411 $(INSTALL_DIR) $(1)/usr/lib/iptables
412 endef
413
414 define Package/ip6tables/install
415 $(INSTALL_DIR) $(1)/usr/sbin
416 $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables{,-restore,-save} $(1)/usr/sbin/
417 endef
418
419 define Package/libiptc/install
420 $(INSTALL_DIR) $(1)/usr/lib
421 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.so* $(1)/usr/lib/
422 endef
423
424 define Package/libip4tc/install
425 $(INSTALL_DIR) $(1)/usr/lib
426 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip4tc.so* $(1)/usr/lib/
427 endef
428
429 define Package/libip6tc/install
430 $(INSTALL_DIR) $(1)/usr/lib
431 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip6tc.so* $(1)/usr/lib/
432 endef
433
434 define Package/libxtables/install
435 $(INSTALL_DIR) $(1)/usr/lib
436 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
437 endef
438
439 define BuildPlugin
440 define Package/$(1)/install
441 $(INSTALL_DIR) $$(1)/usr/lib/iptables
442 for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)) $(patsubst xt_%,ip6t_%,$(2)) $(patsubst ip6t_%,xt_%,$(2)); do \
443 if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
444 $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
445 fi; \
446 done
447 $(3)
448 endef
449
450 $$(eval $$(call BuildPackage,$(1)))
451 endef
452
453 L7_INSTALL:=\
454 $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
455 $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
456
457
458 $(eval $(call BuildPackage,iptables))
459 $(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
460 $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
461 $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
462 $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
463 $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
464 $(eval $(call BuildPlugin,iptables-mod-nat-extra,$(IPT_NAT_EXTRA-m)))
465 $(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
466 $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
467 $(eval $(call BuildPlugin,iptables-mod-hashlimit,$(IPT_HASHLIMIT-m)))
468 $(eval $(call BuildPlugin,iptables-mod-led,$(IPT_LED-m)))
469 $(eval $(call BuildPlugin,iptables-mod-tproxy,$(IPT_TPROXY-m)))
470 $(eval $(call BuildPlugin,iptables-mod-tee,$(IPT_TEE-m)))
471 $(eval $(call BuildPlugin,iptables-mod-u32,$(IPT_U32-m)))
472 $(eval $(call BuildPackage,ip6tables))
473 $(eval $(call BuildPlugin,ip6tables-extra,$(IPT_IPV6_EXTRA-m)))
474 $(eval $(call BuildPlugin,ip6tables-mod-nat,$(IPT_NAT6-m)))
475 $(eval $(call BuildPackage,libiptc))
476 $(eval $(call BuildPackage,libip4tc))
477 $(eval $(call BuildPackage,libip6tc))
478 $(eval $(call BuildPackage,libxtables))