Makefile 8.1 KB

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