Makefile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. #
  2. # Copyright (C) 2006-2011 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.10
  11. PKG_RELEASE:=2
  12. PKG_MD5SUM:=f382fe693f0b59d87bd47bea65eca198
  13. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
  14. PKG_SOURCE_URL:=http://www.netfilter.org/projects/iptables/files \
  15. ftp://ftp.be.netfilter.org/pub/netfilter/iptables/ \
  16. ftp://ftp.de.netfilter.org/pub/netfilter/iptables/ \
  17. ftp://ftp.no.netfilter.org/pub/netfilter/iptables/
  18. PKG_FIXUP:=autoreconf
  19. PKG_INSTALL:=1
  20. PKG_BUILD_PARALLEL:=1
  21. include $(INCLUDE_DIR)/package.mk
  22. ifeq ($(DUMP),)
  23. -include $(LINUX_DIR)/.config
  24. include $(INCLUDE_DIR)/netfilter.mk
  25. STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell $(SH_FUNC) grep 'NETFILTER' $(LINUX_DIR)/.config | md5s)
  26. endif
  27. define Package/iptables/Default
  28. SECTION:=net
  29. CATEGORY:=Network
  30. SUBMENU:=Firewall
  31. URL:=http://netfilter.org/
  32. endef
  33. define Package/iptables/Module
  34. $(call Package/iptables/Default)
  35. DEPENDS:=iptables $(1)
  36. endef
  37. define Package/iptables
  38. $(call Package/iptables/Default)
  39. TITLE:=IPv4 firewall administration tool
  40. MENU:=1
  41. DEPENDS+= +kmod-ipt-core +libip4tc +libxtables
  42. endef
  43. define Package/iptables/description
  44. IPv4 firewall administration tool.
  45. Includes support for:
  46. - comment
  47. - limit
  48. - LOG
  49. - mac
  50. - multiport
  51. - REJECT
  52. - TCPMSS
  53. endef
  54. define Package/iptables-mod-conntrack
  55. $(call Package/iptables/Module, +kmod-ipt-conntrack)
  56. TITLE:=Basic connection tracking extensions
  57. endef
  58. define Package/iptables-mod-conntrack/description
  59. Basic iptables extensions for connection tracking.
  60. Includes:
  61. - state
  62. - raw
  63. - NOTRACK
  64. endef
  65. define Package/iptables-mod-conntrack-extra
  66. $(call Package/iptables/Module, +kmod-ipt-conntrack-extra)
  67. TITLE:=Extra connection tracking extensions
  68. endef
  69. define Package/iptables-mod-conntrack-extra/description
  70. Extra iptables extensions for connection tracking.
  71. Includes:
  72. - libipt_conntrack
  73. - libipt_helper
  74. - libipt_connmark/CONNMARK
  75. endef
  76. define Package/iptables-mod-filter
  77. $(call Package/iptables/Module, +kmod-ipt-filter)
  78. TITLE:=Content inspection extensions
  79. endef
  80. define Package/iptables-mod-filter/description
  81. iptables extensions for packet content inspection.
  82. Includes:
  83. - libipt_string
  84. - libipt_layer7
  85. endef
  86. define Package/iptables-mod-ipopt
  87. $(call Package/iptables/Module, +kmod-ipt-ipopt)
  88. TITLE:=IP/Packet option extensions
  89. endef
  90. define Package/iptables-mod-ipopt/description
  91. iptables extensions for matching/changing IP packet options.
  92. Includes:
  93. - libipt_CLASSIFY
  94. - libipt_dscp/DSCP
  95. - libipt_ecn/ECN
  96. - libipt_length
  97. - libipt_mac
  98. - libipt_mark/MARK
  99. - libipt_statistic
  100. - libipt_tcpmms
  101. - libipt_tos/TOS
  102. - libipt_ttl/TTL
  103. - libipt_unclean
  104. endef
  105. define Package/iptables-mod-ipsec
  106. $(call Package/iptables/Module, +kmod-ipt-ipsec)
  107. TITLE:=IPsec extensions
  108. endef
  109. define Package/iptables-mod-ipsec/description
  110. iptables extensions for matching ipsec traffic.
  111. Includes:
  112. - libipt_ah
  113. - libipt_esp
  114. - libipt_policy
  115. endef
  116. define Package/iptables-mod-ipset
  117. $(call Package/iptables/Module,)
  118. TITLE:=IPset iptables extensions
  119. endef
  120. define Package/iptables-mod-ipset/description
  121. IPset iptables extensions.
  122. Includes:
  123. - libipt_set
  124. - libipt_SET
  125. endef
  126. define Package/iptables-mod-nat
  127. $(call Package/iptables/Module, +kmod-ipt-nat)
  128. TITLE:=Basic NAT extensions
  129. endef
  130. define Package/iptables-mod-nat/description
  131. iptables extensions for basic NAT targets.
  132. Includes:
  133. - MASQUERADE
  134. - SNAT
  135. - DNAT
  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. Includes:
  144. - REDIRECT
  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. Includes:
  153. - libipt_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. Includes:
  162. - libipt_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. Includes:
  171. - libipt_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. Includes:
  180. - libipt_owner
  181. - libipt_physdev
  182. - libipt_pkttype
  183. - libipt_recent
  184. endef
  185. define Package/iptables-mod-tproxy
  186. $(call Package/iptables/Module, +kmod-ipt-tproxy)
  187. TITLE:=Transparent proxy iptables extensions
  188. endef
  189. define Package/iptables-mod-tproxy/description
  190. Transparent proxy iptables extensions.
  191. Includes:
  192. - libxt_socket
  193. - libxt_TPROXY
  194. endef
  195. define Package/iptables-mod-tee
  196. $(call Package/iptables/Module, +kmod-ipt-tee)
  197. TITLE:=TEE iptables extensions
  198. endef
  199. define Package/iptables-mod-tee/description
  200. TEE iptables extensions.
  201. Includes:
  202. - libxt_TEE
  203. endef
  204. define Package/iptables-mod-u32
  205. $(call Package/iptables/Module, +kmod-ipt-u32)
  206. TITLE:=U32 iptables extensions
  207. endef
  208. define Package/iptables-mod-u32/description
  209. U32 iptables extensions.
  210. Includes:
  211. - libxt_u32
  212. endef
  213. define Package/iptables-utils
  214. $(call Package/iptables/Module, )
  215. TITLE:=iptables save and restore utilities
  216. endef
  217. define Package/ip6tables
  218. $(call Package/iptables/Default)
  219. DEPENDS:=+kmod-ip6tables +libip6tc +libxtables
  220. CATEGORY:=IPv6
  221. TITLE:=IPv6 firewall administration tool
  222. MENU:=1
  223. endef
  224. define Package/ip6tables-utils
  225. $(call Package/iptables/Default)
  226. DEPENDS:=ip6tables
  227. CATEGORY:=IPv6
  228. TITLE:=ip6tables save and restore utilities
  229. endef
  230. define Package/libiptc
  231. $(call Package/iptables/Default)
  232. SECTION:=libs
  233. CATEGORY:=Libraries
  234. DEPENDS:=+libip4tc +libip6tc
  235. TITLE:=IPv4/IPv6 firewall - shared libiptc library (compatibility stub)
  236. endef
  237. define Package/libip4tc
  238. $(call Package/iptables/Default)
  239. SECTION:=libs
  240. CATEGORY:=Libraries
  241. TITLE:=IPv4 firewall - shared libiptc library
  242. endef
  243. define Package/libip6tc
  244. $(call Package/iptables/Default)
  245. SECTION:=libs
  246. CATEGORY:=Libraries
  247. TITLE:=IPv6 firewall - shared libiptc library
  248. endef
  249. define Package/libxtables
  250. $(call Package/iptables/Default)
  251. SECTION:=libs
  252. CATEGORY:=Libraries
  253. TITLE:=IPv4/IPv6 firewall - shared xtables library
  254. endef
  255. define Package/libipq
  256. $(call Package/iptables/Default)
  257. SECTION:=libs
  258. CATEGORY:=Libraries
  259. TITLE:=IPv4/IPv6 firewall - shared libipq library
  260. endef
  261. TARGET_CPPFLAGS := \
  262. -I$(PKG_BUILD_DIR)/include \
  263. -I$(LINUX_DIR)/arch/$(LINUX_KARCH)/include \
  264. $(TARGET_CPPFLAGS)
  265. TARGET_CFLAGS += \
  266. -I$(PKG_BUILD_DIR)/include \
  267. -I$(LINUX_DIR)/arch/$(LINUX_KARCH)/include
  268. CONFIGURE_ARGS += \
  269. --enable-shared \
  270. --enable-devel \
  271. --enable-ipv6 \
  272. --enable-libipq \
  273. --with-kernel="$(LINUX_DIR)" \
  274. --with-xtlibdir=/usr/lib/iptables
  275. MAKE_FLAGS := \
  276. $(TARGET_CONFIGURE_OPTS) \
  277. COPT_FLAGS="$(TARGET_CFLAGS)" \
  278. LDFLAGS="-rdynamic" \
  279. KERNEL_DIR="$(LINUX_DIR)" PREFIX=/usr \
  280. KBUILD_OUTPUT="$(LINUX_DIR)" \
  281. define Build/InstallDev
  282. $(INSTALL_DIR) $(1)/usr/include
  283. $(INSTALL_DIR) $(1)/usr/include/iptables
  284. $(INSTALL_DIR) $(1)/usr/include/net/netfilter
  285. # XXX: iptables header fixup, some headers are not installed by iptables anymore
  286. $(CP) $(PKG_BUILD_DIR)/include/net/netfilter/*.h $(1)/usr/include/net/netfilter/
  287. $(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
  288. $(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
  289. $(CP) $(PKG_BUILD_DIR)/include/libipq/libipq.h $(1)/usr/include/
  290. $(CP) $(PKG_BUILD_DIR)/include/libipulog $(1)/usr/include/
  291. $(CP) $(PKG_BUILD_DIR)/include/libiptc $(1)/usr/include/
  292. $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
  293. $(INSTALL_DIR) $(1)/usr/lib
  294. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  295. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip*tc.so* $(1)/usr/lib/
  296. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libipq.so* $(1)/usr/lib/
  297. $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
  298. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/xtables.pc $(1)/usr/lib/pkgconfig/
  299. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libiptc.pc $(1)/usr/lib/pkgconfig/
  300. endef
  301. define Package/iptables/install
  302. $(INSTALL_DIR) $(1)/usr/sbin
  303. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iptables $(1)/usr/sbin/
  304. $(INSTALL_DIR) $(1)/usr/lib/iptables
  305. (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
  306. for m in $(patsubst xt_%,ipt_%,$(IPT_BUILTIN)) $(patsubst ipt_%,xt_%,$(IPT_BUILTIN)); do \
  307. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$${m}.so ]; then \
  308. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$${m}.so $(1)/usr/lib/iptables/ ;\
  309. fi; \
  310. done \
  311. )
  312. endef
  313. define Package/iptables-utils/install
  314. $(INSTALL_DIR) $(1)/usr/sbin
  315. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iptables-{save,restore} $(1)/usr/sbin/
  316. endef
  317. define Package/ip6tables/install
  318. $(INSTALL_DIR) $(1)/usr/sbin
  319. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables $(1)/usr/sbin/
  320. $(INSTALL_DIR) $(1)/usr/lib/iptables
  321. (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
  322. $(CP) libip6t_*.so $(1)/usr/lib/iptables/ \
  323. )
  324. endef
  325. define Package/ip6tables-utils/install
  326. $(INSTALL_DIR) $(1)/usr/sbin
  327. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables-{save,restore} $(1)/usr/sbin/
  328. endef
  329. define Package/libiptc/install
  330. $(INSTALL_DIR) $(1)/usr/lib
  331. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.so* $(1)/usr/lib/
  332. endef
  333. define Package/libip4tc/install
  334. $(INSTALL_DIR) $(1)/usr/lib
  335. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip4tc.so* $(1)/usr/lib/
  336. endef
  337. define Package/libip6tc/install
  338. $(INSTALL_DIR) $(1)/usr/lib
  339. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libip6tc.so* $(1)/usr/lib/
  340. endef
  341. define Package/libxtables/install
  342. $(INSTALL_DIR) $(1)/usr/lib
  343. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  344. endef
  345. define Package/libipq/install
  346. $(INSTALL_DIR) $(1)/usr/lib
  347. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libipq.so* $(1)/usr/lib/
  348. endef
  349. define BuildPlugin
  350. define Package/$(1)/install
  351. $(INSTALL_DIR) $$(1)/usr/lib/iptables
  352. for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)); do \
  353. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
  354. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
  355. fi; \
  356. done
  357. $(3)
  358. endef
  359. $$(eval $$(call BuildPackage,$(1)))
  360. endef
  361. L7_INSTALL:=\
  362. $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
  363. $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
  364. $(eval $(call BuildPackage,iptables))
  365. $(eval $(call BuildPackage,iptables-utils))
  366. $(eval $(call BuildPlugin,iptables-mod-conntrack,$(IPT_CONNTRACK-m)))
  367. $(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
  368. $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
  369. $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
  370. $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
  371. $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
  372. $(eval $(call BuildPlugin,iptables-mod-ipset,ipt_set ipt_SET))
  373. $(eval $(call BuildPlugin,iptables-mod-nat,$(IPT_NAT-m)))
  374. $(eval $(call BuildPlugin,iptables-mod-nat-extra,$(IPT_NAT_EXTRA-m)))
  375. $(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
  376. $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
  377. $(eval $(call BuildPlugin,iptables-mod-hashlimit,$(IPT_HASHLIMIT-m)))
  378. $(eval $(call BuildPlugin,iptables-mod-tproxy,$(IPT_TPROXY-m)))
  379. $(eval $(call BuildPlugin,iptables-mod-tee,$(IPT_TEE-m)))
  380. $(eval $(call BuildPlugin,iptables-mod-u32,$(IPT_U32-m)))
  381. $(eval $(call BuildPackage,ip6tables))
  382. $(eval $(call BuildPackage,ip6tables-utils))
  383. $(eval $(call BuildPackage,libiptc))
  384. $(eval $(call BuildPackage,libip4tc))
  385. $(eval $(call BuildPackage,libip6tc))
  386. $(eval $(call BuildPackage,libxtables))
  387. $(eval $(call BuildPackage,libipq))