Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. #
  2. # Copyright (C) 2006-2010 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. PKG_VERSION:=1.4.9.1
  11. PKG_RELEASE:=1
  12. PKG_MD5SUM:=fbadfb0b5f2dbda49e0ad06a798898e3
  13. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
  14. PKG_SOURCE_URL:=http://www.netfilter.org/projects/iptables/files \
  15. ftp://ftp.be.netfilter.org/pub/netfilter/iptables/ \
  16. ftp://ftp.de.netfilter.org/pub/netfilter/iptables/ \
  17. ftp://ftp.no.netfilter.org/pub/netfilter/iptables/
  18. PKG_FIXUP:=libtool
  19. PKG_INSTALL:=1
  20. include $(INCLUDE_DIR)/package.mk
  21. ifeq ($(DUMP),)
  22. -include $(LINUX_DIR)/.config
  23. include $(INCLUDE_DIR)/netfilter.mk
  24. STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep 'NETFILTER' $(LINUX_DIR)/.config | md5s)
  25. endif
  26. define Package/iptables/Default
  27. SECTION:=net
  28. CATEGORY:=Network
  29. URL:=http://netfilter.org/
  30. endef
  31. define Package/iptables/Module
  32. $(call Package/iptables/Default)
  33. DEPENDS:=iptables $(1)
  34. endef
  35. define Package/iptables
  36. $(call Package/iptables/Default)
  37. TITLE:=IPv4 firewall administration tool
  38. MENU:=1
  39. DEPENDS+= +kmod-ipt-core +libiptc +libxtables
  40. endef
  41. define Package/iptables/description
  42. IPv4 firewall administration tool.
  43. Includes support for:
  44. - comment
  45. - limit
  46. - LOG
  47. - mac
  48. - multiport
  49. - REJECT
  50. - TCPMSS
  51. endef
  52. define Package/iptables-mod-conntrack
  53. $(call Package/iptables/Module, +kmod-ipt-conntrack)
  54. TITLE:=Basic connection tracking extensions
  55. endef
  56. define Package/iptables-mod-conntrack/description
  57. Basic iptables extensions for connection tracking.
  58. Includes:
  59. - state
  60. - raw
  61. - NOTRACK
  62. endef
  63. define Package/iptables-mod-conntrack-extra
  64. $(call Package/iptables/Module, +kmod-ipt-conntrack-extra)
  65. TITLE:=Extra connection tracking extensions
  66. endef
  67. define Package/iptables-mod-conntrack-extra/description
  68. Extra iptables extensions for connection tracking.
  69. Includes:
  70. - libipt_conntrack
  71. - libipt_helper
  72. - libipt_connmark/CONNMARK
  73. endef
  74. define Package/iptables-mod-filter
  75. $(call Package/iptables/Module, +kmod-ipt-filter)
  76. TITLE:=Content inspection extensions
  77. endef
  78. define Package/iptables-mod-filter/description
  79. iptables extensions for packet content inspection.
  80. Includes:
  81. - libipt_string
  82. - libipt_layer7
  83. endef
  84. define Package/iptables-mod-imq
  85. $(call Package/iptables/Module, +kmod-ipt-imq)
  86. TITLE:=IMQ support
  87. endef
  88. define Package/iptables-mod-imq/description
  89. iptables extension for IMQ support.
  90. Includes:
  91. - libipt_IMQ
  92. endef
  93. define Package/iptables-mod-ipopt
  94. $(call Package/iptables/Module, +kmod-ipt-ipopt)
  95. TITLE:=IP/Packet option extensions
  96. endef
  97. define Package/iptables-mod-ipopt/description
  98. iptables extensions for matching/changing IP packet options.
  99. Includes:
  100. - libipt_CLASSIFY
  101. - libipt_dscp/DSCP
  102. - libipt_ecn/ECN
  103. - libipt_length
  104. - libipt_mac
  105. - libipt_mark/MARK
  106. - libipt_statistic
  107. - libipt_tcpmms
  108. - libipt_tos/TOS
  109. - libipt_ttl/TTL
  110. - libipt_unclean
  111. endef
  112. define Package/iptables-mod-ipsec
  113. $(call Package/iptables/Module, +kmod-ipt-ipsec)
  114. TITLE:=IPsec extensions
  115. endef
  116. define Package/iptables-mod-ipsec/description
  117. iptables extensions for matching ipsec traffic.
  118. Includes:
  119. - libipt_ah
  120. - libipt_esp
  121. - libipt_policy
  122. endef
  123. define Package/iptables-mod-ipset
  124. $(call Package/iptables/Module,)
  125. TITLE:=IPset iptables extensions
  126. endef
  127. define Package/iptables-mod-ipset/description
  128. IPset iptables extensions.
  129. Includes:
  130. - libipt_set
  131. - libipt_SET
  132. endef
  133. define Package/iptables-mod-nat
  134. $(call Package/iptables/Module, +kmod-ipt-nat)
  135. TITLE:=Basic NAT extensions
  136. endef
  137. define Package/iptables-mod-nat/description
  138. iptables extensions for basic NAT targets.
  139. Includes:
  140. - MASQUERADE
  141. - SNAT
  142. - DNAT
  143. endef
  144. define Package/iptables-mod-nat-extra
  145. $(call Package/iptables/Module, +kmod-ipt-nat-extra)
  146. TITLE:=Extra NAT extensions
  147. endef
  148. define Package/iptables-mod-nat-extra/description
  149. iptables extensions for extra NAT targets.
  150. Includes:
  151. - REDIRECT
  152. endef
  153. define Package/iptables-mod-ulog
  154. $(call Package/iptables/Module, +kmod-ipt-ulog)
  155. TITLE:=user-space packet logging
  156. endef
  157. define Package/iptables-mod-ulog/description
  158. iptables extensions for user-space packet logging.
  159. Includes:
  160. - libipt_ULOG
  161. endef
  162. define Package/iptables-mod-hashlimit
  163. $(call Package/iptables/Module, +kmod-ipt-hashlimit)
  164. TITLE:=hashlimit matching
  165. endef
  166. define Package/iptables-mod-hashlimit/description
  167. iptables extensions for hashlimit matching
  168. Includes:
  169. - libipt_hashlimit
  170. endef
  171. define Package/iptables-mod-iprange
  172. $(call Package/iptables/Module, +kmod-ipt-iprange)
  173. TITLE:=IP range extension
  174. endef
  175. define Package/iptables-mod-iprange/description
  176. iptables extensions for matching ip ranges.
  177. Includes:
  178. - libipt_iprange
  179. endef
  180. define Package/iptables-mod-extra
  181. $(call Package/iptables/Module, +kmod-ipt-extra)
  182. TITLE:=Other extra iptables extensions
  183. endef
  184. define Package/iptables-mod-extra/description
  185. Other extra iptables extensions.
  186. Includes:
  187. - libipt_owner
  188. - libipt_physdev
  189. - libipt_pkttype
  190. - libipt_recent
  191. endef
  192. define Package/iptables-mod-tproxy
  193. $(call Package/iptables/Module, +kmod-ipt-tproxy)
  194. TITLE:=Transparent proxy iptables extensions
  195. endef
  196. define Package/iptables-mod-tproxy/description
  197. Transparent proxy iptables extensions.
  198. Includes:
  199. - libxt_socket
  200. - libxt_TPROXY
  201. endef
  202. define Package/iptables-utils
  203. $(call Package/iptables/Module, )
  204. TITLE:=iptables save and restore utilities
  205. endef
  206. define Package/ip6tables
  207. $(call Package/iptables/Default)
  208. DEPENDS:=+kmod-ip6tables +libiptc +libxtables
  209. CATEGORY:=IPv6
  210. TITLE:=IPv6 firewall administration tool
  211. MENU:=1
  212. endef
  213. define Package/ip6tables-utils
  214. $(call Package/iptables/Default)
  215. DEPENDS:=ip6tables
  216. CATEGORY:=IPv6
  217. TITLE:=ip6tables save and restore utilities
  218. endef
  219. define Package/libiptc
  220. $(call Package/iptables/Default)
  221. SECTION:=libs
  222. CATEGORY:=Libraries
  223. TITLE:=IPv4/IPv6 firewall - shared libiptc library
  224. endef
  225. define Package/libxtables
  226. $(call Package/iptables/Default)
  227. SECTION:=libs
  228. CATEGORY:=Libraries
  229. TITLE:=IPv4/IPv6 firewall - shared xtables library
  230. endef
  231. define Package/libipq
  232. $(call Package/iptables/Default)
  233. SECTION:=libs
  234. CATEGORY:=Libraries
  235. TITLE:=IPv4/IPv6 firewall - shared libipq library
  236. endef
  237. TARGET_CPPFLAGS := \
  238. -I$(PKG_BUILD_DIR)/include \
  239. -I$(LINUX_DIR)/arch/$(LINUX_KARCH)/include \
  240. $(TARGET_CPPFLAGS)
  241. TARGET_CFLAGS += \
  242. -I$(PKG_BUILD_DIR)/include \
  243. -I$(LINUX_DIR)/arch/$(LINUX_KARCH)/include
  244. CONFIGURE_ARGS += \
  245. --enable-shared \
  246. --enable-devel \
  247. --enable-ipv6 \
  248. --enable-libipq \
  249. --with-kernel="$(LINUX_DIR)" \
  250. --with-xtlibdir=/usr/lib/iptables
  251. MAKE_FLAGS := \
  252. $(TARGET_CONFIGURE_OPTS) \
  253. COPT_FLAGS="$(TARGET_CFLAGS)" \
  254. LDFLAGS="-rdynamic -static-libgcc" \
  255. KERNEL_DIR="$(LINUX_DIR)" PREFIX=/usr \
  256. KBUILD_OUTPUT="$(LINUX_DIR)" \
  257. define Build/Prepare
  258. $(call Build/Prepare/Default)
  259. (cd $(PKG_BUILD_DIR); ./autogen.sh)
  260. endef
  261. define Build/InstallDev
  262. $(INSTALL_DIR) $(1)/usr/include
  263. $(INSTALL_DIR) $(1)/usr/include/iptables
  264. $(INSTALL_DIR) $(1)/usr/include/net/netfilter
  265. # XXX: iptables header fixup, some headers are not installed by iptables anymore
  266. $(CP) $(PKG_BUILD_DIR)/include/net/netfilter/*.h $(1)/usr/include/net/netfilter/
  267. $(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
  268. $(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
  269. $(CP) $(PKG_BUILD_DIR)/include/libipq/libipq.h $(1)/usr/include/
  270. $(CP) $(PKG_BUILD_DIR)/include/libipulog $(1)/usr/include/
  271. $(CP) $(PKG_BUILD_DIR)/include/libiptc $(1)/usr/include/
  272. $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
  273. $(INSTALL_DIR) $(1)/usr/lib
  274. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.{a,so*} $(1)/usr/lib/
  275. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip*tc.{a,so*} $(1)/usr/lib/
  276. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libipq.{a,so*} $(1)/usr/lib/
  277. $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
  278. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/xtables.pc $(1)/usr/lib/pkgconfig/
  279. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libiptc.pc $(1)/usr/lib/pkgconfig/
  280. endef
  281. define Package/iptables/install
  282. $(INSTALL_DIR) $(1)/usr/sbin
  283. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iptables $(1)/usr/sbin/
  284. $(INSTALL_DIR) $(1)/usr/lib/iptables
  285. (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
  286. for m in $(patsubst xt_%,ipt_%,$(IPT_BUILTIN)) $(patsubst ipt_%,xt_%,$(IPT_BUILTIN)); do \
  287. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$${m}.so ]; then \
  288. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$${m}.so $(1)/usr/lib/iptables/ ;\
  289. fi; \
  290. done \
  291. )
  292. endef
  293. define Package/iptables-utils/install
  294. $(INSTALL_DIR) $(1)/usr/sbin
  295. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iptables-{save,restore} $(1)/usr/sbin/
  296. endef
  297. define Package/ip6tables/install
  298. $(INSTALL_DIR) $(1)/usr/sbin
  299. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables $(1)/usr/sbin/
  300. $(INSTALL_DIR) $(1)/usr/lib/iptables
  301. (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
  302. $(CP) libip6t_*.so $(1)/usr/lib/iptables/ \
  303. )
  304. endef
  305. define Package/ip6tables-utils/install
  306. $(INSTALL_DIR) $(1)/usr/sbin
  307. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables-{save,restore} $(1)/usr/sbin/
  308. endef
  309. define Package/libiptc/install
  310. $(INSTALL_DIR) $(1)/usr/lib
  311. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip*tc.so* $(1)/usr/lib/
  312. endef
  313. define Package/libxtables/install
  314. $(INSTALL_DIR) $(1)/usr/lib
  315. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  316. endef
  317. define Package/libipq/install
  318. $(INSTALL_DIR) $(1)/usr/lib
  319. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libipq.so* $(1)/usr/lib/
  320. endef
  321. define BuildPlugin
  322. define Package/$(1)/install
  323. $(INSTALL_DIR) $$(1)/usr/lib/iptables
  324. for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)); do \
  325. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
  326. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
  327. fi; \
  328. done
  329. $(3)
  330. endef
  331. $$(eval $$(call BuildPackage,$(1)))
  332. endef
  333. L7_INSTALL:=\
  334. $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
  335. $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
  336. $(eval $(call BuildPackage,iptables))
  337. $(eval $(call BuildPackage,iptables-utils))
  338. $(eval $(call BuildPlugin,iptables-mod-conntrack,$(IPT_CONNTRACK-m)))
  339. $(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
  340. $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
  341. $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
  342. $(eval $(call BuildPlugin,iptables-mod-imq,$(IPT_IMQ-m)))
  343. $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
  344. $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
  345. $(eval $(call BuildPlugin,iptables-mod-ipset,ipt_set ipt_SET))
  346. $(eval $(call BuildPlugin,iptables-mod-nat,$(IPT_NAT-m)))
  347. $(eval $(call BuildPlugin,iptables-mod-nat-extra,$(IPT_NAT_EXTRA-m)))
  348. $(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
  349. $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
  350. $(eval $(call BuildPlugin,iptables-mod-hashlimit,$(IPT_HASHLIMIT-m)))
  351. $(eval $(call BuildPlugin,iptables-mod-tproxy,$(IPT_TPROXY-m)))
  352. $(eval $(call BuildPackage,ip6tables))
  353. $(eval $(call BuildPackage,ip6tables-utils))
  354. $(eval $(call BuildPackage,libiptc))
  355. $(eval $(call BuildPackage,libxtables))
  356. $(eval $(call BuildPackage,libipq))