Package ip6tables-utils as well (#2318)
[openwrt.git] / package / iptables / Makefile
1
2 # Copyright (C) 2006 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 PKG_VERSION:=1.3.8
14 PKG_RELEASE:=1
15
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 PKG_MD5SUM:=0a9209f928002e5eee9cdff8fef4d4b3
22
23 include $(INCLUDE_DIR)/package.mk
24 ifeq ($(DUMP),)
25   -include $(LINUX_DIR)/.config
26   include $(INCLUDE_DIR)/netfilter.mk
27   STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep 'NETFILTER' $(LINUX_DIR)/.config | md5s)
28 endif
29
30 define Package/iptables/Default
31   SECTION:=net
32   CATEGORY:=Base system
33   URL:=http://netfilter.org/
34 endef
35
36 define Package/iptables
37   $(call Package/iptables/Default)
38   TITLE:=IPv4 firewall administration tool
39   MENU:=1
40 endef
41
42 define Package/iptables/conffiles
43 /etc/config/firewall
44 /etc/firewall.user
45 endef
46
47 define Package/iptables-mod-conntrack
48   $(call Package/iptables/Default)
49   DEPENDS:=iptables +kmod-ipt-conntrack
50   TITLE:=connection tracking modules
51   DESCRIPTION:=\
52         iptables extensions for connection tracking.\\\
53         \\\
54         Includes: \\\
55         - libipt_conntrack \\\
56         - libipt_helper \\\
57         - libipt_connmark/CONNMARK
58 endef
59
60 define Package/iptables-mod-filter
61   $(call Package/iptables/Default)
62   DEPENDS:=iptables +kmod-ipt-filter
63   TITLE:=filter modules
64   DESCRIPTION:=\
65         iptables extensions for packet content inspection.\\\
66         \\\
67         Includes: \\\
68         - libipt_ipp2p \\\
69         - libipt_layer7 
70 endef
71
72 define Package/iptables-mod-imq
73   $(call Package/iptables/Default)
74   DEPENDS:=iptables +kmod-ipt-imq
75   TITLE:=IMQ support
76   DESCRIPTION:=\
77         iptables extension for IMQ support.\\\
78         \\\
79         Includes: \\\
80         - libipt_IMQ
81 endef
82
83 define Package/iptables-mod-ipopt
84   $(call Package/iptables/Default)
85   DEPENDS:=iptables +kmod-ipt-ipopt
86   TITLE:=IP/Packet option modules
87   DESCRIPTION:=\
88         iptables extensions for matching/changing IP packet options.\\\
89         \\\
90         Includes: \\\
91         - libipt_CLASSIFY \\\
92         - libipt_dscp/DSCP \\\
93         - libipt_ecn/ECN \\\
94         - libipt_length \\\
95         - libipt_mac \\\
96         - libipt_tos/TOS \\\
97         - libipt_tcpmms \\\
98         - libipt_ttl/TTL \\\
99         - libipt_unclean 
100 endef
101
102 define Package/iptables-mod-ipsec
103   $(call Package/iptables/Default)
104   DEPENDS:=iptables +kmod-ipt-ipsec
105   TITLE:=IPSec extensions
106   DESCRIPTION:=\
107         iptables extensions for matching ipsec traffic.\\\
108         \\\
109         Includes: \\\
110         - libipt_ah \\\
111         - libipt_esp
112 endef
113
114 define Package/iptables-mod-nat
115   $(call Package/iptables/Default)
116   DEPENDS:=iptables +kmod-ipt-nat
117   TITLE:=extra NAT targets
118   DESCRIPTION:=\
119         iptables extensions for different NAT targets.\\\
120         \\\
121         Includes: \\\
122         - libipt_REDIRECT
123 endef
124
125 define Package/iptables-mod-ulog
126   $(call Package/iptables/Default)
127   DEPENDS:=iptables +kmod-ipt-ulog
128   TITLE:=user-space packet logging
129   DESCRIPTION:=\
130         iptables extensions for user-space packet logging.\\\
131         \\\
132         Includes: \\\
133         - libipt_ULOG
134 endef
135
136 define Package/iptables-mod-iprange
137   $(call Package/iptables/Default)
138   DEPENDS:=iptables +kmod-ipt-iprange
139   TITLE:=ip range module
140   DESCRIPTION:=\
141         iptables extensions for matching ip ranges.\\\
142         \\\
143         Includes: \\\
144         - libipt_iprange
145 endef
146
147 define Package/iptables-mod-extra
148   $(call Package/iptables/Default)
149   DEPENDS:=iptables +kmod-ipt-extra
150   TITLE:=other extra iptables extensions
151   DESCRIPTION:=\
152         other extra iptables extensions.\\\
153         \\\
154         Includes: \\\
155         - libipt_limit \\\
156         - libipt_owner \\\
157         - libipt_physdev \\\
158         - libipt_pkttype \\\
159         - libipt_recent \\\
160         - libipt_NOTRACK
161 endef
162
163 define Package/iptables-mod-ipset
164   $(call Package/iptables/Default)
165   DEPENDS:=iptables +kmod-ipt-ipset
166   TITLE:=ipset iptables extension
167   DESCRIPTION:=\
168     ipset
169 endef
170
171 define Package/iptables-utils
172   $(call Package/iptables/Default)
173   DEPENDS:=iptables
174   TITLE:=iptables save and restore utilities
175 endef
176
177 define Package/ip6tables
178   $(call Package/iptables/Default)
179   DEPENDS:=+kmod-ipv6
180   CATEGORY:=Network
181   TITLE:=IPv6 firewall administration tool
182 endef
183
184 define Package/ip6tables-utils
185  $(call Package/iptables/Default)
186  DEPENDS:=ip6tables
187  CATEGORY:=Network
188  TITLE:=ip6tables save and restore utilities
189 endef
190
191 define Build/Configure
192         rm -f $(PKG_BUILD_DIR)/.configured*
193         $(MAKE) -C $(PKG_BUILD_DIR) \
194                 clean
195 endef
196
197 define Build/Compile
198         chmod a+x $(PKG_BUILD_DIR)/extensions/.*-test*
199         mkdir -p $(PKG_INSTALL_DIR)
200         $(MAKE) -C $(PKG_BUILD_DIR) \
201                 $(TARGET_CONFIGURE_OPTS) \
202                 COPT_FLAGS="$(TARGET_CFLAGS)" \
203                 LDFLAGS="-rdynamic -static-libgcc" \
204                 KERNEL_DIR="$(LINUX_DIR)" PREFIX=/usr \
205                 DESTDIR="$(PKG_INSTALL_DIR)" \
206                 all experimental install install-experimental
207 endef
208
209 define Build/InstallDev
210         $(MAKE) -C $(PKG_BUILD_DIR) \
211                 $(TARGET_CONFIGURE_OPTS) \
212                 COPT_FLAGS="$(TARGET_CFLAGS)" \
213                 KERNEL_DIR="$(LINUX_DIR)" PREFIX=/usr \
214                 DESTDIR="$(STAGING_DIR)" \
215                 install-devel
216         $(CP) $(PKG_BUILD_DIR)/include $(STAGING_DIR)/usr
217         $(CP) $(PKG_BUILD_DIR)/libiptc/libiptc.a $(STAGING_DIR)/usr/lib
218 endef
219
220 define Build/UninstallDev
221         rm -rf $(STAGING_DIR)/usr/include/libipq.h
222         rm -rf $(STAGING_DIR)/usr/include/libipulog
223         rm -rf $(STAGING_DIR)/usr/include/libipq
224         rm -rf $(STAGING_DIR)/usr/include/libiptc
225         rm -rf $(STAGING_DIR)/usr/include/linux/netfilter*
226         rm -rf $(STAGING_DIR)/usr/include/iptables*
227         rm -rf $(STAGING_DIR)/usr/include/ip6tables*
228         rm -rf $(STAGING_DIR)/usr/lib/libipq.a
229         rm -rf $(STAGING_DIR)/usr/lib/libiptc.a
230 endef
231
232 define Package/iptables/install
233         $(INSTALL_DIR) $(1)/etc/config
234         $(INSTALL_DATA) ./files/firewall.config $(1)/etc/config/firewall
235         $(INSTALL_DIR) $(1)/etc/init.d
236         $(INSTALL_BIN) ./files/firewall.init $(1)/etc/init.d/firewall
237         $(INSTALL_BIN) ./files/firewall.user $(1)/etc/
238         $(INSTALL_DIR) $(1)/usr/lib
239         $(INSTALL_DATA) ./files/firewall.awk $(1)/usr/lib
240         $(INSTALL_DIR) $(1)/usr/sbin
241         $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables $(1)/usr/sbin/
242         $(INSTALL_DIR) $(1)/usr/lib/iptables
243         (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
244                 $(CP) $(patsubst %,lib%.so,$(IPT_BUILTIN:xt_%=ipt_%)) $(1)/usr/lib/iptables/ \
245         )
246 endef
247
248 define Package/iptables-utils/install
249         $(INSTALL_DIR) $(1)/usr/sbin
250         $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables-{save,restore} $(1)/usr/sbin/
251 endef
252
253 define Package/ip6tables/install
254         $(INSTALL_DIR) $(1)/usr/sbin
255         $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables $(1)/usr/sbin/
256         $(INSTALL_DIR) $(1)/usr/lib/iptables
257         (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
258                 $(CP) libip6t_*.so $(1)/usr/lib/iptables/ \
259         )
260 endef
261
262 define Package/ip6tables-utils/install
263         $(INSTALL_DIR) $(1)/usr/sbin
264         $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables-{save,restore} $(1)/usr/sbin/
265 endef
266
267 define BuildPlugin
268   define Package/$(1)/install
269         $(INSTALL_DIR) $$(1)/usr/lib/iptables
270         for m in $$(patsubst xt_%,ipt_%,$(2)); do \
271                 $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
272         done
273         $(3)
274   endef
275
276   $$(eval $$(call BuildPackage,$(1)))
277 endef
278
279 L7_INSTALL:=\
280         $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
281         $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
282
283 $(eval $(call BuildPackage,iptables))
284 $(eval $(call BuildPackage,iptables-utils))
285 $(eval $(call BuildPlugin,iptables-mod-conntrack,$(IPT_CONNTRACK-m)))
286 $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
287 $(eval $(call BuildPlugin,iptables-mod-ipset,$(IPT_IPSET-m)))
288 $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
289 $(eval $(call BuildPlugin,iptables-mod-imq,$(IPT_IMQ-m)))
290 $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
291 $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
292 $(eval $(call BuildPlugin,iptables-mod-nat,$(IPT_NAT-m)))
293 $(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
294 $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
295 $(eval $(call BuildPackage,ip6tables))
296 $(eval $(call BuildPackage,ip6tables-utils))