[kernel] upgrade to latest kernel versions (2.6.25.4; 2.6.24.7; 2.6.23.17; 2.6.22.19)
[openwrt.git] / package / iptables / Makefile
1 #
2 # Copyright (C) 2006-2008 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 # $Id$
8
9 include $(TOPDIR)/rules.mk
10 include $(INCLUDE_DIR)/kernel.mk
11
12 PKG_NAME:=iptables
13
14 ifeq ($(CONFIG_LINUX_2_4),y)
15   PKG_VERSION:=1.3.8
16   PKG_RELEASE:=3
17   PKG_MD5SUM:=0a9209f928002e5eee9cdff8fef4d4b3
18 endif
19
20 ifeq ($(CONFIG_LINUX_2_6),y)
21   PKG_VERSION:=1.4.0
22   PKG_RELEASE:=1
23   PKG_MD5SUM:=90cfa8a554a29b0b859a625e701af2a7
24 endif
25
26 PKG_VERSION?=<IPTABLES_VERSION>
27
28 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
29 PKG_SOURCE_URL:=http://www.netfilter.org/projects/iptables/files \
30         ftp://ftp.be.netfilter.org/pub/netfilter/iptables/ \
31         ftp://ftp.de.netfilter.org/pub/netfilter/iptables/ \
32         ftp://ftp.no.netfilter.org/pub/netfilter/iptables/
33
34 PATCH_DIR:=./patches/$(PKG_VERSION)
35
36 include $(INCLUDE_DIR)/package.mk
37 ifeq ($(DUMP),)
38   -include $(LINUX_DIR)/.config
39   include $(INCLUDE_DIR)/netfilter.mk
40   STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep 'NETFILTER' $(LINUX_DIR)/.config | md5s)
41 endif
42
43 define Package/iptables/Default
44   SECTION:=net
45   CATEGORY:=Base system
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:=IPv4 firewall administration tool
57   MENU:=1
58 endef
59
60 define Package/iptables/conffiles
61 /etc/firewall.config
62 /etc/firewall.user
63 endef
64
65 define Package/iptables-mod-conntrack
66 $(call Package/iptables/Module, +kmod-ipt-conntrack)
67   TITLE:=connection tracking modules
68 endef
69
70 define Package/iptables-mod-conntrack/description
71  iptables extensions for connection tracking.
72  Includes:
73  - libipt_conntrack
74  - libipt_helper
75  - libipt_connmark/CONNMARK
76 endef
77
78 define Package/iptables-mod-filter
79 $(call Package/iptables/Module, +kmod-ipt-filter)
80   TITLE:=filter modules
81 endef
82
83 define Package/iptables-mod-filter/description
84  iptables extensions for packet content inspection.
85  Includes:
86  - libipt_ipp2p
87  - libipt_layer7
88 endef
89
90 define Package/iptables-mod-imq
91 $(call Package/iptables/Module, +kmod-ipt-imq @!LINUX_2_6_25)
92   TITLE:=IMQ support
93 endef
94
95 define Package/iptables-mod-imq/description
96  iptables extension for IMQ support.
97  Includes:
98  - libipt_IMQ
99 endef
100
101 define Package/iptables-mod-ipopt
102 $(call Package/iptables/Module, +kmod-ipt-ipopt)
103   TITLE:=IP/Packet option modules
104 endef
105
106 define Package/iptables-mod-ipopt/description
107  iptables extensions for matching/changing IP packet options.\\\
108  Includes:
109  - libipt_CLASSIFY
110  - libipt_dscp/DSCP
111  - libipt_ecn/ECN
112  - libipt_length
113  - libipt_mac
114  - libipt_mark/MARK
115  - libipt_statistic
116  - libipt_tcpmms
117  - libipt_tos/TOS
118  - libipt_ttl/TTL
119  - libipt_unclean
120 endef
121
122 define Package/iptables-mod-ipsec
123 $(call Package/iptables/Module, +kmod-ipt-ipsec)
124   TITLE:=IPSec extensions
125 endef
126
127 define Package/iptables-mod-ipsec/description
128  iptables extensions for matching ipsec traffic.
129  Includes:
130  - libipt_ah
131  - libipt_esp
132  - libipt_policy
133 endef
134
135 define Package/iptables-mod-nat
136 $(call Package/iptables/Module, +kmod-ipt-nat)
137   TITLE:=extra NAT targets
138 endef
139
140 define Package/iptables-mod-nat/description
141  iptables extensions for different NAT targets.
142  Includes:
143  - libipt_REDIRECT
144 endef
145
146 define Package/iptables-mod-ulog
147 $(call Package/iptables/Module, +kmod-ipt-ulog)
148   TITLE:=user-space packet logging
149 endef
150
151 define Package/iptables-mod-ulog/description
152  iptables extensions for user-space packet logging.
153  Includes:
154  - libipt_ULOG
155 endef
156
157 define Package/iptables-mod-iprange
158 $(call Package/iptables/Module, +kmod-ipt-iprange)
159   TITLE:=ip range module
160 endef
161
162 define Package/iptables-mod-iprange/description
163  iptables extensions for matching ip ranges.
164  Includes:
165  - libipt_iprange
166 endef
167
168 define Package/iptables-mod-extra
169 $(call Package/iptables/Module, +kmod-ipt-extra)
170   TITLE:=other extra iptables extensions
171 endef
172
173 define Package/iptables-mod-extra/description
174  other extra iptables extensions.
175  Includes:
176  - libipt_limit
177  - libipt_owner
178  - libipt_physdev
179  - libipt_pkttype
180  - libipt_recent
181  - iptable_raw
182  - libipt_NOTRACK
183  - libipt_TARPIT
184  - libipt_DELUDE
185  - libipt_CHAOS
186 endef
187
188 define Package/iptables-mod-ipset
189 $(call Package/iptables/Module, +kmod-ipt-ipset)
190   TITLE:=ipset iptables extension
191 endef
192
193 define Package/iptables-utils
194 $(call Package/iptables/Module, )
195   TITLE:=iptables save and restore utilities
196 endef
197
198 define Package/ip6tables
199 $(call Package/iptables/Default)
200   DEPENDS:=+kmod-ip6tables
201   CATEGORY:=IPv6
202   TITLE:=IPv6 firewall administration tool
203   MENU:=1
204 endef
205
206 define Package/ip6tables-utils
207  $(call Package/iptables/Default)
208  DEPENDS:=ip6tables
209  CATEGORY:=IPv6
210  TITLE:=ip6tables save and restore utilities
211 endef
212
213 define Build/Prepare
214         $(call Build/Prepare/Default)
215 endef
216
217 define Build/Configure
218         chmod a+x $(PKG_BUILD_DIR)/extensions/.*-test*
219         rm -f $(PKG_BUILD_DIR)/.configured*
220         $(MAKE) -C $(PKG_BUILD_DIR) \
221                 clean
222 endef
223
224 define Build/Compile
225         mkdir -p $(PKG_INSTALL_DIR)
226         $(MAKE) -C $(PKG_BUILD_DIR) \
227                 $(TARGET_CONFIGURE_OPTS) \
228                 COPT_FLAGS="$(TARGET_CFLAGS)" \
229                 LDFLAGS="-rdynamic -static-libgcc" \
230                 KERNEL_DIR="$(LINUX_DIR)" PREFIX=/usr \
231                 KBUILD_OUTPUT="$(LINUX_DIR)" \
232                 DESTDIR="$(PKG_INSTALL_DIR)" \
233                 all experimental install install-experimental
234 endef
235
236 define Build/InstallDev
237         $(MAKE) -C $(PKG_BUILD_DIR) \
238                 $(TARGET_CONFIGURE_OPTS) \
239                 COPT_FLAGS="$(TARGET_CFLAGS)" \
240                 KERNEL_DIR="$(LINUX_DIR)" PREFIX=/usr \
241                 KBUILD_OUTPUT="$(LINUX_DIR)" \
242                 DESTDIR="$(1)" \
243                 install-devel
244         $(CP) $(PKG_BUILD_DIR)/include $(1)/usr
245         $(CP) $(PKG_BUILD_DIR)/libiptc/libiptc.a $(1)/usr/lib
246 endef
247
248 define Package/iptables/install
249         $(INSTALL_DIR) $(1)/etc/config
250         $(INSTALL_DATA) ./files/firewall.config $(1)/etc/
251         $(INSTALL_DIR) $(1)/etc/init.d
252         $(INSTALL_BIN) ./files/firewall.init $(1)/etc/init.d/firewall
253         $(INSTALL_BIN) ./files/firewall.user $(1)/etc/
254         $(INSTALL_DIR) $(1)/usr/lib
255         $(INSTALL_DATA) ./files/firewall.awk $(1)/usr/lib
256         $(INSTALL_DIR) $(1)/usr/sbin
257         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iptables $(1)/usr/sbin/
258         $(INSTALL_DIR) $(1)/usr/lib/iptables
259         (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
260                 for m in $(patsubst xt_%,ipt_%,$(IPT_BUILTIN)) $(patsubst ipt_%,xt_%,$(IPT_BUILTIN)); do \
261                         if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$${m}.so ]; then \
262                                 $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$${m}.so $(1)/usr/lib/iptables/ ;\
263                         fi; \
264                 done \
265         )
266 endef
267
268 define Package/iptables-utils/install
269         $(INSTALL_DIR) $(1)/usr/sbin
270         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iptables-{save,restore} $(1)/usr/sbin/
271 endef
272
273 define Package/ip6tables/install
274         $(INSTALL_DIR) $(1)/usr/sbin
275         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables $(1)/usr/sbin/
276         $(INSTALL_DIR) $(1)/usr/lib/iptables
277         (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
278                 $(CP) libip6t_*.so $(1)/usr/lib/iptables/ \
279         )
280 endef
281
282 define Package/ip6tables-utils/install
283         $(INSTALL_DIR) $(1)/usr/sbin
284         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables-{save,restore} $(1)/usr/sbin/
285 endef
286
287 define BuildPlugin
288   define Package/$(1)/install
289         $(INSTALL_DIR) $$(1)/usr/lib/iptables
290         for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)); do \
291                 if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
292                         $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
293                 fi; \
294         done
295         $(3)
296   endef
297
298   $$(eval $$(call BuildPackage,$(1)))
299 endef
300
301 L7_INSTALL:=\
302         $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
303         $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
304
305 $(eval $(call BuildPackage,iptables))
306 $(eval $(call BuildPackage,iptables-utils))
307 $(eval $(call BuildPlugin,iptables-mod-conntrack,$(IPT_CONNTRACK-m)))
308 $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
309 $(eval $(call BuildPlugin,iptables-mod-ipset,$(IPT_IPSET-m)))
310 $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
311 $(eval $(call BuildPlugin,iptables-mod-imq,$(IPT_IMQ-m)))
312 $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
313 $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
314 $(eval $(call BuildPlugin,iptables-mod-nat,$(IPT_NAT-m)))
315 $(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
316 $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
317 $(eval $(call BuildPackage,ip6tables))
318 $(eval $(call BuildPackage,ip6tables-utils))