Makefile 11 KB

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