[packages] iptables: add an iptables-mod-ipset package (closes: #6327)
[openwrt.git] / package / iptables / Makefile
1 #
2 # Copyright (C) 2006-2009 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.4
13 PKG_RELEASE:=3
14
15 PKG_MD5SUM:=08cd9196881657ea0615d926334cb7e9
16 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
17 PKG_SOURCE_URL:=http://www.netfilter.org/projects/iptables/files \
18         ftp://ftp.be.netfilter.org/pub/netfilter/iptables/ \
19         ftp://ftp.de.netfilter.org/pub/netfilter/iptables/ \
20         ftp://ftp.no.netfilter.org/pub/netfilter/iptables/
21
22 PATCH_DIR:=./patches/$(PKG_VERSION)
23
24 PKG_FIXUP = libtool
25
26 include $(INCLUDE_DIR)/package.mk
27 ifeq ($(DUMP),)
28   -include $(LINUX_DIR)/.config
29   include $(INCLUDE_DIR)/netfilter.mk
30   STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep 'NETFILTER' $(LINUX_DIR)/.config | md5s)
31 endif
32
33
34 define Package/iptables/Default
35   SECTION:=net
36   CATEGORY:=Network
37   URL:=http://netfilter.org/
38 endef
39
40 define Package/iptables/Module
41 $(call Package/iptables/Default)
42   DEPENDS:=iptables $(1)
43 endef
44
45 define Package/iptables
46 $(call Package/iptables/Default)
47   TITLE:=IPv4 firewall administration tool
48   MENU:=1
49   DEPENDS+= +kmod-ipt-core +libiptc +libxtables
50 endef
51
52 define Package/iptables/description
53  IPv4 firewall administration tool.
54  Includes support for:
55  - comment
56  - limit
57  - LOG
58  - mac
59  - multiport
60  - REJECT
61  - TCPMSS
62 endef
63
64 define Package/iptables-mod-conntrack
65 $(call Package/iptables/Module, +kmod-ipt-conntrack)
66   TITLE:=Basic connection tracking extensions
67 endef
68
69 define Package/iptables-mod-conntrack/description
70  Basic iptables extensions for connection tracking.
71  Includes:
72  - state
73 endef
74
75 define Package/iptables-mod-conntrack-extra
76 $(call Package/iptables/Module, +kmod-ipt-conntrack-extra)
77   TITLE:=Extra connection tracking extensions
78 endef
79
80 define Package/iptables-mod-conntrack-extra/description
81  Extra iptables extensions for connection tracking.
82  Includes:
83  - libipt_conntrack
84  - libipt_helper
85  - libipt_connmark/CONNMARK
86 endef
87
88 define Package/iptables-mod-filter
89 $(call Package/iptables/Module, +kmod-ipt-filter)
90   TITLE:=Content inspection extensions
91 endef
92
93 define Package/iptables-mod-filter/description
94  iptables extensions for packet content inspection.
95  Includes:
96  - libipt_string
97  - libipt_layer7
98 endef
99
100 define Package/iptables-mod-imq
101 $(call Package/iptables/Module, +kmod-ipt-imq)
102   TITLE:=IMQ support
103 endef
104
105 define Package/iptables-mod-imq/description
106  iptables extension for IMQ support.
107  Includes:
108  - libipt_IMQ
109 endef
110
111 define Package/iptables-mod-ipopt
112 $(call Package/iptables/Module, +kmod-ipt-ipopt)
113   TITLE:=IP/Packet option extensions
114 endef
115
116 define Package/iptables-mod-ipopt/description
117  iptables extensions for matching/changing IP packet options.
118  Includes:
119  - libipt_CLASSIFY
120  - libipt_dscp/DSCP
121  - libipt_ecn/ECN
122  - libipt_length
123  - libipt_mac
124  - libipt_mark/MARK
125  - libipt_statistic
126  - libipt_tcpmms
127  - libipt_tos/TOS
128  - libipt_ttl/TTL
129  - libipt_unclean
130 endef
131
132 define Package/iptables-mod-ipsec
133 $(call Package/iptables/Module, +kmod-ipt-ipsec)
134   TITLE:=IPsec extensions
135 endef
136
137 define Package/iptables-mod-ipsec/description
138  iptables extensions for matching ipsec traffic.
139  Includes:
140  - libipt_ah
141  - libipt_esp
142  - libipt_policy
143 endef
144
145 define Package/iptables-mod-ipset
146 $(call Package/iptables/Module, @LINUX_2_6)
147   TITLE:=IPset iptables extensions
148 endef
149
150 define Package/iptables-mod-ipset/description
151  IPset iptables extensions.
152  Includes:
153  - libipt_set
154  - libipt_SET
155 endef
156
157 define Package/iptables-mod-nat
158 $(call Package/iptables/Module, +kmod-ipt-nat)
159   TITLE:=Basic NAT extensions
160 endef
161
162 define Package/iptables-mod-nat/description
163  iptables extensions for basic NAT targets.
164  Includes:
165  - MASQUERADE
166  - SNAT
167  - DNAT
168 endef
169
170 define Package/iptables-mod-nat-extra
171 $(call Package/iptables/Module, +kmod-ipt-nat-extra)
172   TITLE:=Extra NAT extensions
173 endef
174
175 define Package/iptables-mod-nat-extra/description
176  iptables extensions for extra NAT targets.
177  Includes:
178  - REDIRECT
179 endef
180
181 define Package/iptables-mod-ulog
182 $(call Package/iptables/Module, +kmod-ipt-ulog)
183   TITLE:=user-space packet logging
184 endef
185
186 define Package/iptables-mod-ulog/description
187  iptables extensions for user-space packet logging.
188  Includes:
189  - libipt_ULOG
190 endef
191
192 define Package/iptables-mod-iprange
193 $(call Package/iptables/Module, +kmod-ipt-iprange)
194   TITLE:=IP range extension
195 endef
196
197 define Package/iptables-mod-iprange/description
198  iptables extensions for matching ip ranges.
199  Includes:
200  - libipt_iprange
201 endef
202
203 define Package/iptables-mod-extra
204 $(call Package/iptables/Module, +kmod-ipt-extra)
205   TITLE:=Other extra iptables extensions
206 endef
207
208 define Package/iptables-mod-extra/description
209  other extra iptables extensions.
210  Includes:
211  - libipt_owner
212  - libipt_physdev
213  - libipt_pkttype
214  - libipt_recent
215  - iptable_raw
216  - libipt_NOTRACK
217 endef
218
219 define Package/iptables-utils
220 $(call Package/iptables/Module, )
221   TITLE:=iptables save and restore utilities
222 endef
223
224 define Package/ip6tables
225 $(call Package/iptables/Default)
226   DEPENDS:=+kmod-ip6tables
227   CATEGORY:=IPv6
228   TITLE:=IPv6 firewall administration tool
229   MENU:=1
230 endef
231
232 define Package/ip6tables-utils
233 $(call Package/iptables/Default)
234   DEPENDS:=ip6tables
235   CATEGORY:=IPv6
236   TITLE:=ip6tables save and restore utilities
237 endef
238
239 define Package/libiptc
240 $(call Package/iptables/Default)
241   SECTION:=libs
242   CATEGORY:=Libraries
243   TITLE:=IPv4/IPv6 firewall - shared libiptc library
244 endef
245
246 define Package/libxtables
247  $(call Package/iptables/Default)
248  SECTION:=libs
249  CATEGORY:=Libraries
250  TITLE:=IPv4/IPv6 firewall - shared xtables library
251 endef
252
253
254 TARGET_CPPFLAGS := \
255         -I$(PKG_BUILD_DIR)/include \
256         -I$(LINUX_DIR)/arch/$(LINUX_KARCH)/include \
257         $(TARGET_CPPFLAGS)
258
259 CONFIGURE_ARGS += \
260         --enable-shared \
261         --enable-static \
262         --enable-devel \
263         --enable-ipv6 \
264         --with-kernel="$(LINUX_DIR)" \
265         --with-xtlibdir=/usr/lib/iptables
266
267 IPTABLES_MAKEOPTS = \
268                 $(TARGET_CONFIGURE_OPTS) \
269                 COPT_FLAGS="$(TARGET_CFLAGS)" \
270                 LDFLAGS="-rdynamic -static-libgcc" \
271                 KERNEL_DIR="$(LINUX_DIR)" PREFIX=/usr \
272                 KBUILD_OUTPUT="$(LINUX_DIR)" \
273                 DESTDIR="$(PKG_INSTALL_DIR)" \
274                 all install $(MAKE_TARGETS)
275
276 define Build/Compile
277         mkdir -p $(PKG_INSTALL_DIR)
278         $(MAKE) -C $(PKG_BUILD_DIR) $(IPTABLES_MAKEOPTS)
279         $(MAKE) -C $(PKG_BUILD_DIR)/libipq $(IPTABLES_MAKEOPTS)
280 endef
281
282 define Build/InstallDev
283         mkdir -p $(1)/usr/include
284         mkdir -p $(1)/usr/include/iptables
285         mkdir -p $(1)/usr/include/net/netfilter
286
287         # XXX: iptables header fixup, some headers are not installed by iptables anymore
288         $(CP) $(PKG_BUILD_DIR)/include/net/netfilter/*.h $(1)/usr/include/net/netfilter/
289         $(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
290         $(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
291         $(CP) $(PKG_BUILD_DIR)/include/libipq/libipq.h $(1)/usr/include/
292         $(CP) $(PKG_BUILD_DIR)/include/libipulog $(1)/usr/include/
293         $(CP) $(PKG_BUILD_DIR)/include/libiptc $(1)/usr/include/
294
295         $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
296         mkdir -p $(1)/usr/lib
297         $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.{a,so*} $(1)/usr/lib/
298         $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.{a,so*} $(1)/usr/lib/
299         $(CP) $(PKG_INSTALL_DIR)/usr/lib/libipq.a $(1)/usr/lib/
300         mkdir -p $(1)/usr/lib/pkgconfig
301         $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/xtables.pc $(1)/usr/lib/pkgconfig/
302         $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libiptc.pc $(1)/usr/lib/pkgconfig/
303 endef
304
305 define Package/iptables/install
306         $(INSTALL_DIR) $(1)/usr/sbin
307         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iptables $(1)/usr/sbin/
308         $(INSTALL_DIR) $(1)/usr/lib/iptables
309         (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
310                 for m in $(patsubst xt_%,ipt_%,$(IPT_BUILTIN)) $(patsubst ipt_%,xt_%,$(IPT_BUILTIN)); do \
311                         if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$${m}.so ]; then \
312                                 $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$${m}.so $(1)/usr/lib/iptables/ ;\
313                         fi; \
314                 done \
315         )
316 endef
317
318 define Package/iptables-utils/install
319         $(INSTALL_DIR) $(1)/usr/sbin
320         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iptables-{save,restore} $(1)/usr/sbin/
321 endef
322
323 define Package/ip6tables/install
324         $(INSTALL_DIR) $(1)/usr/sbin
325         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables $(1)/usr/sbin/
326         $(INSTALL_DIR) $(1)/usr/lib/iptables
327         (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
328                 $(CP) libip6t_*.so $(1)/usr/lib/iptables/ \
329         )
330 endef
331
332 define Package/ip6tables-utils/install
333         $(INSTALL_DIR) $(1)/usr/sbin
334         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables-{save,restore} $(1)/usr/sbin/
335 endef
336
337 define Package/libiptc/install
338         $(INSTALL_DIR) $(1)/usr/lib
339         $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.so* $(1)/usr/lib/
340 endef
341
342 define Package/libxtables/install
343         $(INSTALL_DIR) $(1)/usr/lib
344         $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
345 endef
346
347 define BuildPlugin
348   define Package/$(1)/install
349         $(INSTALL_DIR) $$(1)/usr/lib/iptables
350         for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)); do \
351                 if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
352                         $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
353                 fi; \
354         done
355         $(3)
356   endef
357
358   $$(eval $$(call BuildPackage,$(1)))
359 endef
360
361 L7_INSTALL:=\
362         $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
363         $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
364
365
366 $(eval $(call BuildPackage,iptables))
367 $(eval $(call BuildPackage,iptables-utils))
368 $(eval $(call BuildPlugin,iptables-mod-conntrack,$(IPT_CONNTRACK-m)))
369 $(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
370 $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
371 $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
372 $(eval $(call BuildPlugin,iptables-mod-imq,$(IPT_IMQ-m)))
373 $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
374 $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
375 $(eval $(call BuildPlugin,iptables-mod-ipset,ipt_set ipt_SET))
376 $(eval $(call BuildPlugin,iptables-mod-nat,$(IPT_NAT-m)))
377 $(eval $(call BuildPlugin,iptables-mod-nat-extra,$(IPT_NAT_EXTRA-m)))
378 $(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
379 $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
380 $(eval $(call BuildPackage,ip6tables))
381 $(eval $(call BuildPackage,ip6tables-utils))
382 $(eval $(call BuildPackage,libiptc))
383 $(eval $(call BuildPackage,libxtables))