Makefile 11 KB

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