2
0

Makefile 13 KB

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