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