Makefile 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. #
  2. # Copyright (C) 2006-2013 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.18
  11. PKG_RELEASE:=2
  12. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
  13. PKG_SOURCE_URL:=http://www.netfilter.org/projects/iptables/files \
  14. ftp://ftp.be.netfilter.org/pub/netfilter/iptables/ \
  15. ftp://ftp.de.netfilter.org/pub/netfilter/iptables/ \
  16. ftp://ftp.no.netfilter.org/pub/netfilter/iptables/
  17. PKG_MD5SUM:=a819199d5ec013b82da13a8ffbba857e
  18. PKG_FIXUP:=autoreconf
  19. PKG_INSTALL:=1
  20. PKG_BUILD_PARALLEL:=1
  21. ifneq ($(CONFIG_EXTERNAL_KERNEL_TREE),"")
  22. PATCH_DIR:=
  23. endif
  24. include $(INCLUDE_DIR)/package.mk
  25. ifeq ($(DUMP),)
  26. -include $(LINUX_DIR)/.config
  27. include $(INCLUDE_DIR)/netfilter.mk
  28. STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell $(SH_FUNC) grep 'NETFILTER' $(LINUX_DIR)/.config | md5s)
  29. endif
  30. define Package/iptables/Default
  31. SECTION:=net
  32. CATEGORY:=Network
  33. SUBMENU:=Firewall
  34. URL:=http://netfilter.org/
  35. endef
  36. define Package/iptables/Module
  37. $(call Package/iptables/Default)
  38. DEPENDS:=iptables $(1)
  39. endef
  40. define Package/iptables
  41. $(call Package/iptables/Default)
  42. TITLE:=IP firewall administration tool
  43. MENU:=1
  44. DEPENDS+= +kmod-ipt-core +libip4tc +IPV6:libip6tc +libxtables
  45. endef
  46. define Package/iptables/description
  47. IP firewall administration tool.
  48. Matches:
  49. - icmp
  50. - tcp
  51. - udp
  52. - comment
  53. - limit
  54. - mac
  55. - multiport
  56. Targets:
  57. - ACCEPT
  58. - DROP
  59. - REJECT
  60. - LOG
  61. - TCPMSS
  62. Tables:
  63. - filter
  64. - mangle
  65. endef
  66. define Package/iptables-mod-conntrack-extra
  67. $(call Package/iptables/Module, +kmod-ipt-conntrack-extra)
  68. TITLE:=Extra connection tracking extensions
  69. endef
  70. define Package/iptables-mod-conntrack-extra/description
  71. Extra iptables extensions for connection tracking.
  72. Matches:
  73. - connbytes
  74. - connmark
  75. - recent
  76. - helper
  77. Targets:
  78. - CONNMARK
  79. endef
  80. define Package/iptables-mod-filter
  81. $(call Package/iptables/Module, +kmod-ipt-filter)
  82. TITLE:=Content inspection extensions
  83. endef
  84. define Package/iptables-mod-filter/description
  85. iptables extensions for packet content inspection.
  86. Includes support for:
  87. Matches:
  88. - layer7
  89. - string
  90. endef
  91. define Package/iptables-mod-ipopt
  92. $(call Package/iptables/Module, +kmod-ipt-ipopt)
  93. TITLE:=IP/Packet option extensions
  94. endef
  95. define Package/iptables-mod-ipopt/description
  96. iptables extensions for matching/changing IP packet options.
  97. Matches:
  98. - dscp
  99. - ecn
  100. - length
  101. - mark
  102. - statistic
  103. - tcpmss
  104. - time
  105. - unclean
  106. - hl
  107. Targets:
  108. - DSCP
  109. - CLASSIFY
  110. - ECN
  111. - MARK
  112. - HL
  113. endef
  114. define Package/iptables-mod-ipsec
  115. $(call Package/iptables/Module, +kmod-ipt-ipsec)
  116. TITLE:=IPsec extensions
  117. endef
  118. define Package/iptables-mod-ipsec/description
  119. iptables extensions for matching ipsec traffic.
  120. Matches:
  121. - ah
  122. - esp
  123. - policy
  124. endef
  125. define Package/iptables-mod-ipset
  126. $(call Package/iptables/Module,)
  127. TITLE:=IPset iptables extensions
  128. endef
  129. define Package/iptables-mod-ipset/description
  130. IPset iptables extensions.
  131. Matches:
  132. - set
  133. Targets:
  134. - SET
  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. Targets:
  143. - MIRROR
  144. - NETMAP
  145. - REDIRECT
  146. endef
  147. define Package/iptables-mod-ulog
  148. $(call Package/iptables/Module, +kmod-ipt-ulog)
  149. TITLE:=user-space packet logging
  150. endef
  151. define Package/iptables-mod-ulog/description
  152. iptables extensions for user-space packet logging.
  153. Targets:
  154. - ULOG
  155. endef
  156. define Package/iptables-mod-hashlimit
  157. $(call Package/iptables/Module, +kmod-ipt-hashlimit)
  158. TITLE:=hashlimit matching
  159. endef
  160. define Package/iptables-mod-hashlimit/description
  161. iptables extensions for hashlimit matching
  162. Matches:
  163. - hashlimit
  164. endef
  165. define Package/iptables-mod-iprange
  166. $(call Package/iptables/Module, +kmod-ipt-iprange)
  167. TITLE:=IP range extension
  168. endef
  169. define Package/iptables-mod-iprange/description
  170. iptables extensions for matching ip ranges.
  171. Matches:
  172. - iprange
  173. endef
  174. define Package/iptables-mod-extra
  175. $(call Package/iptables/Module, +kmod-ipt-extra)
  176. TITLE:=Other extra iptables extensions
  177. endef
  178. define Package/iptables-mod-extra/description
  179. Other extra iptables extensions.
  180. Matches:
  181. - addrtype
  182. - condition
  183. - owner
  184. - physdev (if ebtables is enabled)
  185. - pkttype
  186. - quota
  187. endef
  188. define Package/iptables-mod-led
  189. $(call Package/iptables/Module, +kmod-ipt-led)
  190. TITLE:=LED trigger iptables extension
  191. endef
  192. define Package/iptables-mod-led/description
  193. iptables extension for triggering a LED.
  194. Targets:
  195. - LED
  196. endef
  197. define Package/iptables-mod-tproxy
  198. $(call Package/iptables/Module, +kmod-ipt-tproxy)
  199. TITLE:=Transparent proxy iptables extensions
  200. endef
  201. define Package/iptables-mod-tproxy/description
  202. Transparent proxy iptables extensions.
  203. Matches:
  204. - socket
  205. Targets:
  206. - TPROXY
  207. endef
  208. define Package/iptables-mod-tee
  209. $(call Package/iptables/Module, +kmod-ipt-tee)
  210. TITLE:=TEE iptables extensions
  211. endef
  212. define Package/iptables-mod-tee/description
  213. TEE iptables extensions.
  214. Targets:
  215. - TEE
  216. endef
  217. define Package/iptables-mod-u32
  218. $(call Package/iptables/Module, +kmod-ipt-u32)
  219. TITLE:=U32 iptables extensions
  220. endef
  221. define Package/iptables-mod-u32/description
  222. U32 iptables extensions.
  223. Matches:
  224. - u32
  225. endef
  226. define Package/ip6tables
  227. $(call Package/iptables/Default)
  228. DEPENDS:=@IPV6 +kmod-ip6tables +iptables
  229. CATEGORY:=IPv6
  230. TITLE:=IPv6 firewall administration tool
  231. MENU:=1
  232. endef
  233. define Package/libiptc
  234. $(call Package/iptables/Default)
  235. SECTION:=libs
  236. CATEGORY:=Libraries
  237. DEPENDS:=+libip4tc +libip6tc
  238. TITLE:=IPv4/IPv6 firewall - shared libiptc library (compatibility stub)
  239. endef
  240. define Package/libip4tc
  241. $(call Package/iptables/Default)
  242. SECTION:=libs
  243. CATEGORY:=Libraries
  244. TITLE:=IPv4 firewall - shared libiptc library
  245. endef
  246. define Package/libip6tc
  247. $(call Package/iptables/Default)
  248. SECTION:=libs
  249. CATEGORY:=Libraries
  250. TITLE:=IPv6 firewall - shared libiptc library
  251. endef
  252. define Package/libxtables
  253. $(call Package/iptables/Default)
  254. SECTION:=libs
  255. CATEGORY:=Libraries
  256. TITLE:=IPv4/IPv6 firewall - shared xtables library
  257. endef
  258. TARGET_CPPFLAGS := \
  259. -I$(PKG_BUILD_DIR)/include \
  260. -I$(LINUX_DIR)/user_headers/include \
  261. $(TARGET_CPPFLAGS)
  262. TARGET_CFLAGS += \
  263. -I$(PKG_BUILD_DIR)/include \
  264. -I$(LINUX_DIR)/user_headers/include
  265. CONFIGURE_ARGS += \
  266. --enable-shared \
  267. --enable-devel \
  268. $(if $(CONFIG_IPV6),--enable-ipv6,--disable-ipv6) \
  269. --with-kernel="$(LINUX_DIR)/user_headers" \
  270. --with-xtlibdir=/usr/lib/iptables \
  271. --enable-static
  272. MAKE_FLAGS := \
  273. $(TARGET_CONFIGURE_OPTS) \
  274. COPT_FLAGS="$(TARGET_CFLAGS)" \
  275. KERNEL_DIR="$(LINUX_DIR)/user_headers/" PREFIX=/usr \
  276. KBUILD_OUTPUT="$(LINUX_DIR)" \
  277. BUILTIN_MODULES="$(patsubst ip6t_%,%,$(patsubst ipt_%,%,$(patsubst xt_%,%,$(IPT_BUILTIN) $(IPT_CONNTRACK-m) $(IPT_NAT-m))))"
  278. define Build/InstallDev
  279. $(INSTALL_DIR) $(1)/usr/include
  280. $(INSTALL_DIR) $(1)/usr/include/iptables
  281. $(INSTALL_DIR) $(1)/usr/include/net/netfilter
  282. # XXX: iptables header fixup, some headers are not installed by iptables anymore
  283. $(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
  284. $(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
  285. $(CP) $(PKG_BUILD_DIR)/include/ip6tables.h $(1)/usr/include/
  286. $(CP) $(PKG_BUILD_DIR)/include/libipulog $(1)/usr/include/
  287. $(CP) $(PKG_BUILD_DIR)/include/libiptc $(1)/usr/include/
  288. $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
  289. $(INSTALL_DIR) $(1)/usr/lib
  290. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  291. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip*tc.so* $(1)/usr/lib/
  292. $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
  293. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/xtables.pc $(1)/usr/lib/pkgconfig/
  294. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libiptc.pc $(1)/usr/lib/pkgconfig/
  295. endef
  296. define Package/iptables/install
  297. $(INSTALL_DIR) $(1)/usr/sbin
  298. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/xtables-multi $(1)/usr/sbin/
  299. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables{,-restore,-save} $(1)/usr/sbin/
  300. $(INSTALL_DIR) $(1)/usr/lib/iptables
  301. endef
  302. define Package/ip6tables/install
  303. $(INSTALL_DIR) $(1)/usr/sbin
  304. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables{,-restore,-save} $(1)/usr/sbin/
  305. endef
  306. define Package/libiptc/install
  307. $(INSTALL_DIR) $(1)/usr/lib
  308. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.so* $(1)/usr/lib/
  309. endef
  310. define Package/libip4tc/install
  311. $(INSTALL_DIR) $(1)/usr/lib
  312. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip4tc.so* $(1)/usr/lib/
  313. endef
  314. define Package/libip6tc/install
  315. $(INSTALL_DIR) $(1)/usr/lib
  316. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip6tc.so* $(1)/usr/lib/
  317. endef
  318. define Package/libxtables/install
  319. $(INSTALL_DIR) $(1)/usr/lib
  320. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  321. endef
  322. define BuildPlugin
  323. define Package/$(1)/install
  324. $(INSTALL_DIR) $$(1)/usr/lib/iptables
  325. for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)) $(patsubst xt_%,ip6t_%,$(2)) $(patsubst ip6t_%,xt_%,$(2)); do \
  326. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
  327. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
  328. fi; \
  329. done
  330. $(3)
  331. endef
  332. $$(eval $$(call BuildPackage,$(1)))
  333. endef
  334. L7_INSTALL:=\
  335. $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
  336. $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
  337. $(eval $(call BuildPackage,iptables))
  338. $(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
  339. $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
  340. $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
  341. $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
  342. $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
  343. $(eval $(call BuildPlugin,iptables-mod-ipset,ipt_set ipt_SET))
  344. $(eval $(call BuildPlugin,iptables-mod-nat-extra,$(IPT_NAT_EXTRA-m)))
  345. $(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
  346. $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
  347. $(eval $(call BuildPlugin,iptables-mod-hashlimit,$(IPT_HASHLIMIT-m)))
  348. $(eval $(call BuildPlugin,iptables-mod-led,$(IPT_LED-m)))
  349. $(eval $(call BuildPlugin,iptables-mod-tproxy,$(IPT_TPROXY-m)))
  350. $(eval $(call BuildPlugin,iptables-mod-tee,$(IPT_TEE-m)))
  351. $(eval $(call BuildPlugin,iptables-mod-u32,$(IPT_U32-m)))
  352. $(eval $(call BuildPackage,ip6tables))
  353. $(eval $(call BuildPackage,libiptc))
  354. $(eval $(call BuildPackage,libip4tc))
  355. $(eval $(call BuildPackage,libip6tc))
  356. $(eval $(call BuildPackage,libxtables))