Makefile 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. include $(TOPDIR)/rules.mk
  8. include $(INCLUDE_DIR)/kernel.mk
  9. PKG_NAME:=iptables
  10. ifeq ($(CONFIG_LINUX_2_4),y)
  11. PKG_VERSION:=1.3.8
  12. PKG_RELEASE:=4
  13. PKG_MD5SUM:=0a9209f928002e5eee9cdff8fef4d4b3
  14. MAKE_TARGETS:=experimental install-experimental install-devel
  15. endif
  16. ifeq ($(CONFIG_LINUX_2_6),y)
  17. PKG_VERSION:=1.4.3.2
  18. PKG_RELEASE:=1
  19. PKG_MD5SUM:=545698693b636cfc844aafc6729fd48a
  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. DEPENDS+= +kmod-ipt-core
  48. endef
  49. define Package/iptables/description
  50. IPv4 firewall administration tool.
  51. Includes support for:
  52. - limit
  53. - LOG
  54. - mac
  55. - multiport
  56. - REJECT
  57. - TCPMSS
  58. endef
  59. define Package/iptables-mod-conntrack
  60. $(call Package/iptables/Module, +kmod-ipt-conntrack)
  61. TITLE:=Basic connection tracking extensions
  62. endef
  63. define Package/iptables-mod-conntrack/description
  64. Basic iptables extensions for connection tracking.
  65. Includes:
  66. - state
  67. endef
  68. define Package/iptables-mod-conntrack-extra
  69. $(call Package/iptables/Module, +kmod-ipt-conntrack-extra)
  70. TITLE:=Extra connection tracking extensions
  71. endef
  72. define Package/iptables-mod-conntrack-extra/description
  73. Extra iptables extensions for connection tracking.
  74. Includes:
  75. - libipt_conntrack
  76. - libipt_helper
  77. - libipt_connmark/CONNMARK
  78. endef
  79. define Package/iptables-mod-filter
  80. $(call Package/iptables/Module, +kmod-ipt-filter)
  81. TITLE:=Content inspection extensions
  82. endef
  83. define Package/iptables-mod-filter/description
  84. iptables extensions for packet content inspection.
  85. Includes:
  86. - libipt_string
  87. - libipt_layer7
  88. endef
  89. define Package/iptables-mod-imq
  90. $(call Package/iptables/Module, +kmod-ipt-imq @!LINUX_2_6_27)
  91. TITLE:=IMQ support
  92. endef
  93. define Package/iptables-mod-imq/description
  94. iptables extension for IMQ support.
  95. Includes:
  96. - libipt_IMQ
  97. endef
  98. define Package/iptables-mod-ipopt
  99. $(call Package/iptables/Module, +kmod-ipt-ipopt)
  100. TITLE:=IP/Packet option extensions
  101. endef
  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. define Package/iptables-mod-ipsec
  118. $(call Package/iptables/Module, +kmod-ipt-ipsec)
  119. TITLE:=IPsec extensions
  120. endef
  121. define Package/iptables-mod-ipsec/description
  122. iptables extensions for matching ipsec traffic.
  123. Includes:
  124. - libipt_ah
  125. - libipt_esp
  126. - libipt_policy
  127. endef
  128. define Package/iptables-mod-nat
  129. $(call Package/iptables/Module, +kmod-ipt-nat)
  130. TITLE:=Basic NAT extensions
  131. endef
  132. define Package/iptables-mod-nat/description
  133. iptables extensions for basic NAT targets.
  134. Includes:
  135. - MASQUERADE
  136. - SNAT
  137. - DNAT
  138. endef
  139. define Package/iptables-mod-nat-extra
  140. $(call Package/iptables/Module, +kmod-ipt-nat-extra)
  141. TITLE:=Extra NAT extensions
  142. endef
  143. define Package/iptables-mod-nat-extra/description
  144. iptables extensions for extra NAT targets.
  145. Includes:
  146. - REDIRECT
  147. endef
  148. define Package/iptables-mod-ulog
  149. $(call Package/iptables/Module, +kmod-ipt-ulog)
  150. TITLE:=user-space packet logging
  151. endef
  152. define Package/iptables-mod-ulog/description
  153. iptables extensions for user-space packet logging.
  154. Includes:
  155. - libipt_ULOG
  156. endef
  157. define Package/iptables-mod-iprange
  158. $(call Package/iptables/Module, +kmod-ipt-iprange)
  159. TITLE:=IP range extension
  160. endef
  161. define Package/iptables-mod-iprange/description
  162. iptables extensions for matching ip ranges.
  163. Includes:
  164. - libipt_iprange
  165. endef
  166. define Package/iptables-mod-extra
  167. $(call Package/iptables/Module, +kmod-ipt-extra)
  168. TITLE:=Other extra iptables extensions
  169. endef
  170. define Package/iptables-mod-extra/description
  171. other extra iptables extensions.
  172. Includes:
  173. - libipt_owner
  174. - libipt_physdev
  175. - libipt_pkttype
  176. - libipt_recent
  177. - iptable_raw
  178. - libipt_NOTRACK
  179. endef
  180. define Package/iptables-mod-ipset
  181. $(call Package/iptables/Module, +kmod-ipt-ipset)
  182. TITLE:=IPset extension
  183. endef
  184. define Package/iptables-utils
  185. $(call Package/iptables/Module, )
  186. TITLE:=iptables save and restore utilities
  187. endef
  188. define Package/ip6tables
  189. $(call Package/iptables/Default)
  190. DEPENDS:=+kmod-ip6tables
  191. CATEGORY:=IPv6
  192. TITLE:=IPv6 firewall administration tool
  193. MENU:=1
  194. endef
  195. define Package/ip6tables-utils
  196. $(call Package/iptables/Default)
  197. DEPENDS:=ip6tables
  198. CATEGORY:=IPv6
  199. TITLE:=ip6tables save and restore utilities
  200. endef
  201. define Build/Prepare
  202. $(call Build/Prepare/Default)
  203. endef
  204. ifeq ($(KERNEL),2.4)
  205. define Build/Configure
  206. chmod a+x $(PKG_BUILD_DIR)/extensions/.*-test*
  207. rm -f $(PKG_BUILD_DIR)/.configured*
  208. $(MAKE) -C $(PKG_BUILD_DIR) \
  209. clean
  210. endef
  211. endif
  212. TARGET_CPPFLAGS := -I$(PKG_BUILD_DIR)/include $(TARGET_CPPFLAGS)
  213. TARGET_CFLAGS += $(FPIC)
  214. CONFIGURE_ARGS += \
  215. --enable-devel \
  216. --with-kernel="$(LINUX_DIR)" \
  217. --with-xtlibdir=/usr/lib/iptables
  218. define Build/Compile
  219. mkdir -p $(PKG_INSTALL_DIR)
  220. $(MAKE) -C $(PKG_BUILD_DIR) \
  221. $(TARGET_CONFIGURE_OPTS) \
  222. COPT_FLAGS="$(TARGET_CFLAGS)" \
  223. LDFLAGS="-rdynamic -static-libgcc" \
  224. KERNEL_DIR="$(LINUX_DIR)" PREFIX=/usr \
  225. KBUILD_OUTPUT="$(LINUX_DIR)" \
  226. DESTDIR="$(PKG_INSTALL_DIR)" \
  227. all install $(MAKE_TARGETS)
  228. endef
  229. define Build/InstallDev
  230. $(INSTALL_DIR) $(1)/usr/lib
  231. $(CP) $(PKG_BUILD_DIR)/include $(1)/usr
  232. endef
  233. define Package/iptables/install
  234. $(INSTALL_DIR) $(1)/usr/sbin
  235. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iptables $(1)/usr/sbin/
  236. $(INSTALL_DIR) $(1)/usr/lib/iptables
  237. (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
  238. for m in $(patsubst xt_%,ipt_%,$(IPT_BUILTIN)) $(patsubst ipt_%,xt_%,$(IPT_BUILTIN)); do \
  239. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$${m}.so ]; then \
  240. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$${m}.so $(1)/usr/lib/iptables/ ;\
  241. fi; \
  242. done \
  243. )
  244. endef
  245. define Package/iptables-utils/install
  246. $(INSTALL_DIR) $(1)/usr/sbin
  247. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iptables-{save,restore} $(1)/usr/sbin/
  248. endef
  249. define Package/ip6tables/install
  250. $(INSTALL_DIR) $(1)/usr/sbin
  251. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables $(1)/usr/sbin/
  252. $(INSTALL_DIR) $(1)/usr/lib/iptables
  253. (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
  254. $(CP) libip6t_*.so $(1)/usr/lib/iptables/ \
  255. )
  256. endef
  257. define Package/ip6tables-utils/install
  258. $(INSTALL_DIR) $(1)/usr/sbin
  259. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables-{save,restore} $(1)/usr/sbin/
  260. endef
  261. define BuildPlugin
  262. define Package/$(1)/install
  263. $(INSTALL_DIR) $$(1)/usr/lib/iptables
  264. for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)); do \
  265. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
  266. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
  267. fi; \
  268. done
  269. $(3)
  270. endef
  271. $$(eval $$(call BuildPackage,$(1)))
  272. endef
  273. L7_INSTALL:=\
  274. $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
  275. $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
  276. $(eval $(call BuildPackage,iptables))
  277. $(eval $(call BuildPackage,iptables-utils))
  278. $(eval $(call BuildPlugin,iptables-mod-conntrack,$(IPT_CONNTRACK-m)))
  279. $(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
  280. $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
  281. $(eval $(call BuildPlugin,iptables-mod-ipset,$(IPT_IPSET-m)))
  282. $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
  283. $(eval $(call BuildPlugin,iptables-mod-imq,$(IPT_IMQ-m)))
  284. $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
  285. $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
  286. $(eval $(call BuildPlugin,iptables-mod-nat,$(IPT_NAT-m)))
  287. $(eval $(call BuildPlugin,iptables-mod-nat-extra,$(IPT_NAT_EXTRA-m)))
  288. $(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
  289. $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
  290. $(eval $(call BuildPackage,ip6tables))
  291. $(eval $(call BuildPackage,ip6tables-utils))