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