Makefile 12 KB

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