Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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.21
  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:=536d048c8e8eeebcd9757d0863ebb0c0
  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. - connlimit
  89. - connmark
  90. - recent
  91. - helper
  92. Targets:
  93. - CONNMARK
  94. endef
  95. define Package/iptables-mod-filter
  96. $(call Package/iptables/Module, +kmod-ipt-filter)
  97. TITLE:=Content inspection extensions
  98. endef
  99. define Package/iptables-mod-filter/description
  100. iptables extensions for packet content inspection.
  101. Includes support for:
  102. Matches:
  103. - layer7
  104. - string
  105. endef
  106. define Package/iptables-mod-ipopt
  107. $(call Package/iptables/Module, +kmod-ipt-ipopt)
  108. TITLE:=IP/Packet option extensions
  109. endef
  110. define Package/iptables-mod-ipopt/description
  111. iptables extensions for matching/changing IP packet options.
  112. Matches:
  113. - dscp
  114. - ecn
  115. - length
  116. - statistic
  117. - tcpmss
  118. - unclean
  119. - hl
  120. Targets:
  121. - DSCP
  122. - CLASSIFY
  123. - ECN
  124. - HL
  125. endef
  126. define Package/iptables-mod-ipsec
  127. $(call Package/iptables/Module, +kmod-ipt-ipsec)
  128. TITLE:=IPsec extensions
  129. endef
  130. define Package/iptables-mod-ipsec/description
  131. iptables extensions for matching ipsec traffic.
  132. Matches:
  133. - ah
  134. - esp
  135. - policy
  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. Targets:
  144. - MIRROR
  145. - NETMAP
  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:=Network
  230. TITLE:=IPv6 firewall administration tool
  231. MENU:=1
  232. endef
  233. define Package/ip6tables-extra
  234. $(call Package/iptables/Default)
  235. DEPENDS:=ip6tables +kmod-ip6tables-extra
  236. TITLE:=IPv6 header matching modules
  237. endef
  238. define Package/ip6tables-mod-extra/description
  239. iptables header matching modules for IPv6
  240. endef
  241. define Package/ip6tables-mod-nat
  242. $(call Package/iptables/Default)
  243. DEPENDS:=ip6tables +kmod-ipt-nat6
  244. TITLE:=IPv6 NAT extensions
  245. endef
  246. define Package/ip6tables-mod-nat/description
  247. iptables extensions for IPv6-NAT targets.
  248. endef
  249. define Package/libiptc
  250. $(call Package/iptables/Default)
  251. SECTION:=libs
  252. CATEGORY:=Libraries
  253. DEPENDS:=+libip4tc +IPV6:libip6tc
  254. TITLE:=IPv4/IPv6 firewall - shared libiptc library (compatibility stub)
  255. endef
  256. define Package/libip4tc
  257. $(call Package/iptables/Default)
  258. SECTION:=libs
  259. CATEGORY:=Libraries
  260. TITLE:=IPv4 firewall - shared libiptc library
  261. endef
  262. define Package/libip6tc
  263. $(call Package/iptables/Default)
  264. SECTION:=libs
  265. CATEGORY:=Libraries
  266. TITLE:=IPv6 firewall - shared libiptc library
  267. endef
  268. define Package/libxtables
  269. $(call Package/iptables/Default)
  270. SECTION:=libs
  271. CATEGORY:=Libraries
  272. TITLE:=IPv4/IPv6 firewall - shared xtables library
  273. endef
  274. TARGET_CPPFLAGS := \
  275. -I$(PKG_BUILD_DIR)/include \
  276. -I$(LINUX_DIR)/user_headers/include \
  277. $(TARGET_CPPFLAGS)
  278. TARGET_CFLAGS += \
  279. -I$(PKG_BUILD_DIR)/include \
  280. -I$(LINUX_DIR)/user_headers/include \
  281. -ffunction-sections -fdata-sections
  282. TARGET_LDFLAGS += \
  283. -Wl,--gc-sections
  284. CONFIGURE_ARGS += \
  285. --enable-shared \
  286. --enable-devel \
  287. --with-kernel="$(LINUX_DIR)/user_headers" \
  288. --with-xtlibdir=/usr/lib/iptables \
  289. --enable-static
  290. MAKE_FLAGS := \
  291. $(TARGET_CONFIGURE_OPTS) \
  292. COPT_FLAGS="$(TARGET_CFLAGS)" \
  293. KERNEL_DIR="$(LINUX_DIR)/user_headers/" PREFIX=/usr \
  294. KBUILD_OUTPUT="$(LINUX_DIR)" \
  295. BUILTIN_MODULES="$(patsubst ip6t_%,%,$(patsubst ipt_%,%,$(patsubst xt_%,%,$(IPT_BUILTIN) $(IPT_CONNTRACK-m) $(IPT_NAT-m))))"
  296. define Build/InstallDev
  297. $(INSTALL_DIR) $(1)/usr/include
  298. $(INSTALL_DIR) $(1)/usr/include/iptables
  299. $(INSTALL_DIR) $(1)/usr/include/net/netfilter
  300. # XXX: iptables header fixup, some headers are not installed by iptables anymore
  301. $(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
  302. $(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
  303. $(CP) $(PKG_BUILD_DIR)/include/ip6tables.h $(1)/usr/include/
  304. $(CP) $(PKG_BUILD_DIR)/include/libipulog $(1)/usr/include/
  305. $(CP) $(PKG_BUILD_DIR)/include/libiptc $(1)/usr/include/
  306. $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
  307. $(INSTALL_DIR) $(1)/usr/lib
  308. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  309. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip*tc.so* $(1)/usr/lib/
  310. $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
  311. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/xtables.pc $(1)/usr/lib/pkgconfig/
  312. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libip*tc.pc $(1)/usr/lib/pkgconfig/
  313. # XXX: needed by firewall3
  314. $(INSTALL_DIR) $(1)/usr/lib/iptables
  315. $(CP) $(PKG_BUILD_DIR)/extensions/libext*.a $(1)/usr/lib/iptables/
  316. endef
  317. define Package/iptables/install
  318. $(INSTALL_DIR) $(1)/usr/sbin
  319. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/xtables-multi $(1)/usr/sbin/
  320. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables{,-restore,-save} $(1)/usr/sbin/
  321. $(INSTALL_DIR) $(1)/usr/lib/iptables
  322. endef
  323. define Package/ip6tables/install
  324. $(INSTALL_DIR) $(1)/usr/sbin
  325. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables{,-restore,-save} $(1)/usr/sbin/
  326. endef
  327. define Package/libiptc/install
  328. $(INSTALL_DIR) $(1)/usr/lib
  329. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.so* $(1)/usr/lib/
  330. endef
  331. define Package/libip4tc/install
  332. $(INSTALL_DIR) $(1)/usr/lib
  333. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip4tc.so* $(1)/usr/lib/
  334. endef
  335. define Package/libip6tc/install
  336. $(INSTALL_DIR) $(1)/usr/lib
  337. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip6tc.so* $(1)/usr/lib/
  338. endef
  339. define Package/libxtables/install
  340. $(INSTALL_DIR) $(1)/usr/lib
  341. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  342. endef
  343. define BuildPlugin
  344. define Package/$(1)/install
  345. $(INSTALL_DIR) $$(1)/usr/lib/iptables
  346. for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)) $(patsubst xt_%,ip6t_%,$(2)) $(patsubst ip6t_%,xt_%,$(2)); do \
  347. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
  348. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
  349. fi; \
  350. done
  351. $(3)
  352. endef
  353. $$(eval $$(call BuildPackage,$(1)))
  354. endef
  355. L7_INSTALL:=\
  356. $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
  357. $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
  358. $(eval $(call BuildPackage,iptables))
  359. $(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
  360. $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
  361. $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
  362. $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
  363. $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
  364. $(eval $(call BuildPlugin,iptables-mod-nat-extra,$(IPT_NAT_EXTRA-m)))
  365. $(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
  366. $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
  367. $(eval $(call BuildPlugin,iptables-mod-hashlimit,$(IPT_HASHLIMIT-m)))
  368. $(eval $(call BuildPlugin,iptables-mod-led,$(IPT_LED-m)))
  369. $(eval $(call BuildPlugin,iptables-mod-tproxy,$(IPT_TPROXY-m)))
  370. $(eval $(call BuildPlugin,iptables-mod-tee,$(IPT_TEE-m)))
  371. $(eval $(call BuildPlugin,iptables-mod-u32,$(IPT_U32-m)))
  372. $(eval $(call BuildPackage,ip6tables))
  373. $(eval $(call BuildPlugin,ip6tables-extra,$(IPT_IPV6_EXTRA-m)))
  374. $(eval $(call BuildPlugin,ip6tables-mod-nat,$(IPT_NAT6-m)))
  375. $(eval $(call BuildPackage,libiptc))
  376. $(eval $(call BuildPackage,libip4tc))
  377. $(eval $(call BuildPackage,libip6tc))
  378. $(eval $(call BuildPackage,libxtables))