Makefile 8.1 KB

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