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.19.1
  11. PKG_RELEASE:=1
  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:=be97ce9007fa42c867901b496c935a0a
  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. - conntrack
  54. - limit
  55. - mac
  56. - mark
  57. - multiport
  58. - set
  59. - state
  60. - time
  61. Targets:
  62. - ACCEPT
  63. - CT
  64. - DNAT
  65. - DROP
  66. - REJECT
  67. - LOG
  68. - MARK
  69. - MASQUERADE
  70. - REDIRECT
  71. - SET
  72. - SNAT
  73. - TCPMSS
  74. Tables:
  75. - filter
  76. - mangle
  77. - nat
  78. - raw
  79. endef
  80. define Package/iptables-mod-conntrack-extra
  81. $(call Package/iptables/Module, +kmod-ipt-conntrack-extra)
  82. TITLE:=Extra connection tracking extensions
  83. endef
  84. define Package/iptables-mod-conntrack-extra/description
  85. Extra iptables extensions for connection tracking.
  86. Matches:
  87. - connbytes
  88. - connmark
  89. - recent
  90. - helper
  91. Targets:
  92. - CONNMARK
  93. endef
  94. define Package/iptables-mod-filter
  95. $(call Package/iptables/Module, +kmod-ipt-filter)
  96. TITLE:=Content inspection extensions
  97. endef
  98. define Package/iptables-mod-filter/description
  99. iptables extensions for packet content inspection.
  100. Includes support for:
  101. Matches:
  102. - layer7
  103. - string
  104. endef
  105. define Package/iptables-mod-ipopt
  106. $(call Package/iptables/Module, +kmod-ipt-ipopt)
  107. TITLE:=IP/Packet option extensions
  108. endef
  109. define Package/iptables-mod-ipopt/description
  110. iptables extensions for matching/changing IP packet options.
  111. Matches:
  112. - dscp
  113. - ecn
  114. - length
  115. - statistic
  116. - tcpmss
  117. - unclean
  118. - hl
  119. Targets:
  120. - DSCP
  121. - CLASSIFY
  122. - ECN
  123. - HL
  124. endef
  125. define Package/iptables-mod-ipsec
  126. $(call Package/iptables/Module, +kmod-ipt-ipsec)
  127. TITLE:=IPsec extensions
  128. endef
  129. define Package/iptables-mod-ipsec/description
  130. iptables extensions for matching ipsec traffic.
  131. Matches:
  132. - ah
  133. - esp
  134. - policy
  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. 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. Targets:
  153. - 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. Matches:
  162. - 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. Matches:
  171. - 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. Matches:
  180. - addrtype
  181. - condition
  182. - owner
  183. - physdev (if ebtables is enabled)
  184. - pkttype
  185. - quota
  186. endef
  187. define Package/iptables-mod-led
  188. $(call Package/iptables/Module, +kmod-ipt-led)
  189. TITLE:=LED trigger iptables extension
  190. endef
  191. define Package/iptables-mod-led/description
  192. iptables extension for triggering a LED.
  193. Targets:
  194. - LED
  195. endef
  196. define Package/iptables-mod-tproxy
  197. $(call Package/iptables/Module, +kmod-ipt-tproxy)
  198. TITLE:=Transparent proxy iptables extensions
  199. endef
  200. define Package/iptables-mod-tproxy/description
  201. Transparent proxy iptables extensions.
  202. Matches:
  203. - socket
  204. Targets:
  205. - TPROXY
  206. endef
  207. define Package/iptables-mod-tee
  208. $(call Package/iptables/Module, +kmod-ipt-tee)
  209. TITLE:=TEE iptables extensions
  210. endef
  211. define Package/iptables-mod-tee/description
  212. TEE iptables extensions.
  213. Targets:
  214. - TEE
  215. endef
  216. define Package/iptables-mod-u32
  217. $(call Package/iptables/Module, +kmod-ipt-u32)
  218. TITLE:=U32 iptables extensions
  219. endef
  220. define Package/iptables-mod-u32/description
  221. U32 iptables extensions.
  222. Matches:
  223. - u32
  224. endef
  225. define Package/ip6tables
  226. $(call Package/iptables/Default)
  227. DEPENDS:=@IPV6 +kmod-ip6tables +iptables
  228. CATEGORY:=Network
  229. TITLE:=IPv6 firewall administration tool
  230. MENU:=1
  231. endef
  232. define Package/libiptc
  233. $(call Package/iptables/Default)
  234. SECTION:=libs
  235. CATEGORY:=Libraries
  236. DEPENDS:=+libip4tc +libip6tc
  237. TITLE:=IPv4/IPv6 firewall - shared libiptc library (compatibility stub)
  238. endef
  239. define Package/libip4tc
  240. $(call Package/iptables/Default)
  241. SECTION:=libs
  242. CATEGORY:=Libraries
  243. TITLE:=IPv4 firewall - shared libiptc library
  244. endef
  245. define Package/libip6tc
  246. $(call Package/iptables/Default)
  247. SECTION:=libs
  248. CATEGORY:=Libraries
  249. TITLE:=IPv6 firewall - shared libiptc library
  250. endef
  251. define Package/libxtables
  252. $(call Package/iptables/Default)
  253. SECTION:=libs
  254. CATEGORY:=Libraries
  255. TITLE:=IPv4/IPv6 firewall - shared xtables library
  256. endef
  257. TARGET_CPPFLAGS := \
  258. -I$(PKG_BUILD_DIR)/include \
  259. -I$(LINUX_DIR)/user_headers/include \
  260. $(TARGET_CPPFLAGS)
  261. TARGET_CFLAGS += \
  262. -I$(PKG_BUILD_DIR)/include \
  263. -I$(LINUX_DIR)/user_headers/include \
  264. -ffunction-sections -fdata-sections
  265. TARGET_LDFLAGS += \
  266. -Wl,--gc-sections
  267. CONFIGURE_ARGS += \
  268. --enable-shared \
  269. --enable-devel \
  270. --with-kernel="$(LINUX_DIR)/user_headers" \
  271. --with-xtlibdir=/usr/lib/iptables \
  272. --enable-static
  273. MAKE_FLAGS := \
  274. $(TARGET_CONFIGURE_OPTS) \
  275. COPT_FLAGS="$(TARGET_CFLAGS)" \
  276. KERNEL_DIR="$(LINUX_DIR)/user_headers/" PREFIX=/usr \
  277. KBUILD_OUTPUT="$(LINUX_DIR)" \
  278. BUILTIN_MODULES="$(patsubst ip6t_%,%,$(patsubst ipt_%,%,$(patsubst xt_%,%,$(IPT_BUILTIN) $(IPT_CONNTRACK-m) $(IPT_NAT-m))))"
  279. define Build/InstallDev
  280. $(INSTALL_DIR) $(1)/usr/include
  281. $(INSTALL_DIR) $(1)/usr/include/iptables
  282. $(INSTALL_DIR) $(1)/usr/include/net/netfilter
  283. # XXX: iptables header fixup, some headers are not installed by iptables anymore
  284. $(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
  285. $(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
  286. $(CP) $(PKG_BUILD_DIR)/include/ip6tables.h $(1)/usr/include/
  287. $(CP) $(PKG_BUILD_DIR)/include/libipulog $(1)/usr/include/
  288. $(CP) $(PKG_BUILD_DIR)/include/libiptc $(1)/usr/include/
  289. $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
  290. $(INSTALL_DIR) $(1)/usr/lib
  291. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  292. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip*tc.so* $(1)/usr/lib/
  293. $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
  294. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/xtables.pc $(1)/usr/lib/pkgconfig/
  295. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libip*tc.pc $(1)/usr/lib/pkgconfig/
  296. # XXX: needed by firewall3
  297. $(INSTALL_DIR) $(1)/usr/lib/iptables
  298. $(CP) $(PKG_BUILD_DIR)/extensions/libext*.a $(1)/usr/lib/iptables/
  299. endef
  300. define Package/iptables/install
  301. $(INSTALL_DIR) $(1)/usr/sbin
  302. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/xtables-multi $(1)/usr/sbin/
  303. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables{,-restore,-save} $(1)/usr/sbin/
  304. $(INSTALL_DIR) $(1)/usr/lib/iptables
  305. endef
  306. define Package/ip6tables/install
  307. $(INSTALL_DIR) $(1)/usr/sbin
  308. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables{,-restore,-save} $(1)/usr/sbin/
  309. endef
  310. define Package/libiptc/install
  311. $(INSTALL_DIR) $(1)/usr/lib
  312. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.so* $(1)/usr/lib/
  313. endef
  314. define Package/libip4tc/install
  315. $(INSTALL_DIR) $(1)/usr/lib
  316. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip4tc.so* $(1)/usr/lib/
  317. endef
  318. define Package/libip6tc/install
  319. $(INSTALL_DIR) $(1)/usr/lib
  320. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip6tc.so* $(1)/usr/lib/
  321. endef
  322. define Package/libxtables/install
  323. $(INSTALL_DIR) $(1)/usr/lib
  324. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  325. endef
  326. define BuildPlugin
  327. define Package/$(1)/install
  328. $(INSTALL_DIR) $$(1)/usr/lib/iptables
  329. for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)) $(patsubst xt_%,ip6t_%,$(2)) $(patsubst ip6t_%,xt_%,$(2)); do \
  330. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
  331. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
  332. fi; \
  333. done
  334. $(3)
  335. endef
  336. $$(eval $$(call BuildPackage,$(1)))
  337. endef
  338. L7_INSTALL:=\
  339. $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
  340. $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
  341. $(eval $(call BuildPackage,iptables))
  342. $(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
  343. $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
  344. $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
  345. $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
  346. $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-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-led,$(IPT_LED-m)))
  352. $(eval $(call BuildPlugin,iptables-mod-tproxy,$(IPT_TPROXY-m)))
  353. $(eval $(call BuildPlugin,iptables-mod-tee,$(IPT_TEE-m)))
  354. $(eval $(call BuildPlugin,iptables-mod-u32,$(IPT_U32-m)))
  355. $(eval $(call BuildPackage,ip6tables))
  356. $(eval $(call BuildPackage,libiptc))
  357. $(eval $(call BuildPackage,libip4tc))
  358. $(eval $(call BuildPackage,libip6tc))
  359. $(eval $(call BuildPackage,libxtables))