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