Makefile 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. #
  2. # Copyright (C) 2006-2009 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.4
  11. PKG_RELEASE:=3
  12. PKG_MD5SUM:=08cd9196881657ea0615d926334cb7e9
  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. PATCH_DIR:=./patches/$(PKG_VERSION)
  19. PKG_FIXUP = libtool
  20. include $(INCLUDE_DIR)/package.mk
  21. ifeq ($(DUMP),)
  22. -include $(LINUX_DIR)/.config
  23. include $(INCLUDE_DIR)/netfilter.mk
  24. STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep 'NETFILTER' $(LINUX_DIR)/.config | md5s)
  25. endif
  26. define Package/iptables/Default
  27. SECTION:=net
  28. CATEGORY:=Network
  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:=IPv4 firewall administration tool
  38. MENU:=1
  39. DEPENDS+= +kmod-ipt-core +libiptc +libxtables
  40. endef
  41. define Package/iptables/description
  42. IPv4 firewall administration tool.
  43. Includes support for:
  44. - comment
  45. - limit
  46. - LOG
  47. - mac
  48. - multiport
  49. - REJECT
  50. - TCPMSS
  51. endef
  52. define Package/iptables-mod-conntrack
  53. $(call Package/iptables/Module, +kmod-ipt-conntrack)
  54. TITLE:=Basic connection tracking extensions
  55. endef
  56. define Package/iptables-mod-conntrack/description
  57. Basic iptables extensions for connection tracking.
  58. Includes:
  59. - state
  60. endef
  61. define Package/iptables-mod-conntrack-extra
  62. $(call Package/iptables/Module, +kmod-ipt-conntrack-extra)
  63. TITLE:=Extra connection tracking extensions
  64. endef
  65. define Package/iptables-mod-conntrack-extra/description
  66. Extra iptables extensions for connection tracking.
  67. Includes:
  68. - libipt_conntrack
  69. - libipt_helper
  70. - libipt_connmark/CONNMARK
  71. endef
  72. define Package/iptables-mod-filter
  73. $(call Package/iptables/Module, +kmod-ipt-filter)
  74. TITLE:=Content inspection extensions
  75. endef
  76. define Package/iptables-mod-filter/description
  77. iptables extensions for packet content inspection.
  78. Includes:
  79. - libipt_string
  80. - libipt_layer7
  81. endef
  82. define Package/iptables-mod-imq
  83. $(call Package/iptables/Module, +kmod-ipt-imq)
  84. TITLE:=IMQ support
  85. endef
  86. define Package/iptables-mod-imq/description
  87. iptables extension for IMQ support.
  88. Includes:
  89. - libipt_IMQ
  90. endef
  91. define Package/iptables-mod-ipopt
  92. $(call Package/iptables/Module, +kmod-ipt-ipopt)
  93. TITLE:=IP/Packet option extensions
  94. endef
  95. define Package/iptables-mod-ipopt/description
  96. iptables extensions for matching/changing IP packet options.
  97. Includes:
  98. - libipt_CLASSIFY
  99. - libipt_dscp/DSCP
  100. - libipt_ecn/ECN
  101. - libipt_length
  102. - libipt_mac
  103. - libipt_mark/MARK
  104. - libipt_statistic
  105. - libipt_tcpmms
  106. - libipt_tos/TOS
  107. - libipt_ttl/TTL
  108. - libipt_unclean
  109. endef
  110. define Package/iptables-mod-ipsec
  111. $(call Package/iptables/Module, +kmod-ipt-ipsec)
  112. TITLE:=IPsec extensions
  113. endef
  114. define Package/iptables-mod-ipsec/description
  115. iptables extensions for matching ipsec traffic.
  116. Includes:
  117. - libipt_ah
  118. - libipt_esp
  119. - libipt_policy
  120. endef
  121. define Package/iptables-mod-ipset
  122. $(call Package/iptables/Module, @LINUX_2_6)
  123. TITLE:=IPset iptables extensions
  124. endef
  125. define Package/iptables-mod-ipset/description
  126. IPset iptables extensions.
  127. Includes:
  128. - libipt_set
  129. - libipt_SET
  130. endef
  131. define Package/iptables-mod-nat
  132. $(call Package/iptables/Module, +kmod-ipt-nat)
  133. TITLE:=Basic NAT extensions
  134. endef
  135. define Package/iptables-mod-nat/description
  136. iptables extensions for basic NAT targets.
  137. Includes:
  138. - MASQUERADE
  139. - SNAT
  140. - DNAT
  141. endef
  142. define Package/iptables-mod-nat-extra
  143. $(call Package/iptables/Module, +kmod-ipt-nat-extra)
  144. TITLE:=Extra NAT extensions
  145. endef
  146. define Package/iptables-mod-nat-extra/description
  147. iptables extensions for extra NAT targets.
  148. Includes:
  149. - REDIRECT
  150. endef
  151. define Package/iptables-mod-ulog
  152. $(call Package/iptables/Module, +kmod-ipt-ulog)
  153. TITLE:=user-space packet logging
  154. endef
  155. define Package/iptables-mod-ulog/description
  156. iptables extensions for user-space packet logging.
  157. Includes:
  158. - libipt_ULOG
  159. endef
  160. define Package/iptables-mod-iprange
  161. $(call Package/iptables/Module, +kmod-ipt-iprange)
  162. TITLE:=IP range extension
  163. endef
  164. define Package/iptables-mod-iprange/description
  165. iptables extensions for matching ip ranges.
  166. Includes:
  167. - libipt_iprange
  168. endef
  169. define Package/iptables-mod-extra
  170. $(call Package/iptables/Module, +kmod-ipt-extra)
  171. TITLE:=Other extra iptables extensions
  172. endef
  173. define Package/iptables-mod-extra/description
  174. other extra iptables extensions.
  175. Includes:
  176. - libipt_owner
  177. - libipt_physdev
  178. - libipt_pkttype
  179. - libipt_recent
  180. - iptable_raw
  181. - libipt_NOTRACK
  182. endef
  183. define Package/iptables-utils
  184. $(call Package/iptables/Module, )
  185. TITLE:=iptables save and restore utilities
  186. endef
  187. define Package/ip6tables
  188. $(call Package/iptables/Default)
  189. DEPENDS:=+kmod-ip6tables
  190. CATEGORY:=IPv6
  191. TITLE:=IPv6 firewall administration tool
  192. MENU:=1
  193. endef
  194. define Package/ip6tables-utils
  195. $(call Package/iptables/Default)
  196. DEPENDS:=ip6tables
  197. CATEGORY:=IPv6
  198. TITLE:=ip6tables save and restore utilities
  199. endef
  200. define Package/libiptc
  201. $(call Package/iptables/Default)
  202. SECTION:=libs
  203. CATEGORY:=Libraries
  204. TITLE:=IPv4/IPv6 firewall - shared libiptc library
  205. endef
  206. define Package/libxtables
  207. $(call Package/iptables/Default)
  208. SECTION:=libs
  209. CATEGORY:=Libraries
  210. TITLE:=IPv4/IPv6 firewall - shared xtables library
  211. endef
  212. TARGET_CPPFLAGS := \
  213. -I$(PKG_BUILD_DIR)/include \
  214. -I$(LINUX_DIR)/arch/$(LINUX_KARCH)/include \
  215. $(TARGET_CPPFLAGS)
  216. CONFIGURE_ARGS += \
  217. --enable-shared \
  218. --enable-static \
  219. --enable-devel \
  220. --enable-ipv6 \
  221. --with-kernel="$(LINUX_DIR)" \
  222. --with-xtlibdir=/usr/lib/iptables
  223. IPTABLES_MAKEOPTS = \
  224. $(TARGET_CONFIGURE_OPTS) \
  225. COPT_FLAGS="$(TARGET_CFLAGS)" \
  226. LDFLAGS="-rdynamic -static-libgcc" \
  227. KERNEL_DIR="$(LINUX_DIR)" PREFIX=/usr \
  228. KBUILD_OUTPUT="$(LINUX_DIR)" \
  229. DESTDIR="$(PKG_INSTALL_DIR)" \
  230. all install $(MAKE_TARGETS)
  231. define Build/Compile
  232. mkdir -p $(PKG_INSTALL_DIR)
  233. $(MAKE) -C $(PKG_BUILD_DIR) $(IPTABLES_MAKEOPTS)
  234. $(MAKE) -C $(PKG_BUILD_DIR)/libipq $(IPTABLES_MAKEOPTS)
  235. endef
  236. define Build/InstallDev
  237. mkdir -p $(1)/usr/include
  238. mkdir -p $(1)/usr/include/iptables
  239. mkdir -p $(1)/usr/include/net/netfilter
  240. # XXX: iptables header fixup, some headers are not installed by iptables anymore
  241. $(CP) $(PKG_BUILD_DIR)/include/net/netfilter/*.h $(1)/usr/include/net/netfilter/
  242. $(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
  243. $(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
  244. $(CP) $(PKG_BUILD_DIR)/include/libipq/libipq.h $(1)/usr/include/
  245. $(CP) $(PKG_BUILD_DIR)/include/libipulog $(1)/usr/include/
  246. $(CP) $(PKG_BUILD_DIR)/include/libiptc $(1)/usr/include/
  247. $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
  248. mkdir -p $(1)/usr/lib
  249. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.{a,so*} $(1)/usr/lib/
  250. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.{a,so*} $(1)/usr/lib/
  251. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libipq.a $(1)/usr/lib/
  252. mkdir -p $(1)/usr/lib/pkgconfig
  253. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/xtables.pc $(1)/usr/lib/pkgconfig/
  254. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libiptc.pc $(1)/usr/lib/pkgconfig/
  255. endef
  256. define Package/iptables/install
  257. $(INSTALL_DIR) $(1)/usr/sbin
  258. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iptables $(1)/usr/sbin/
  259. $(INSTALL_DIR) $(1)/usr/lib/iptables
  260. (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
  261. for m in $(patsubst xt_%,ipt_%,$(IPT_BUILTIN)) $(patsubst ipt_%,xt_%,$(IPT_BUILTIN)); do \
  262. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$${m}.so ]; then \
  263. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$${m}.so $(1)/usr/lib/iptables/ ;\
  264. fi; \
  265. done \
  266. )
  267. endef
  268. define Package/iptables-utils/install
  269. $(INSTALL_DIR) $(1)/usr/sbin
  270. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iptables-{save,restore} $(1)/usr/sbin/
  271. endef
  272. define Package/ip6tables/install
  273. $(INSTALL_DIR) $(1)/usr/sbin
  274. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables $(1)/usr/sbin/
  275. $(INSTALL_DIR) $(1)/usr/lib/iptables
  276. (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
  277. $(CP) libip6t_*.so $(1)/usr/lib/iptables/ \
  278. )
  279. endef
  280. define Package/ip6tables-utils/install
  281. $(INSTALL_DIR) $(1)/usr/sbin
  282. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables-{save,restore} $(1)/usr/sbin/
  283. endef
  284. define Package/libiptc/install
  285. $(INSTALL_DIR) $(1)/usr/lib
  286. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.so* $(1)/usr/lib/
  287. endef
  288. define Package/libxtables/install
  289. $(INSTALL_DIR) $(1)/usr/lib
  290. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  291. endef
  292. define BuildPlugin
  293. define Package/$(1)/install
  294. $(INSTALL_DIR) $$(1)/usr/lib/iptables
  295. for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)); do \
  296. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
  297. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
  298. fi; \
  299. done
  300. $(3)
  301. endef
  302. $$(eval $$(call BuildPackage,$(1)))
  303. endef
  304. L7_INSTALL:=\
  305. $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
  306. $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
  307. $(eval $(call BuildPackage,iptables))
  308. $(eval $(call BuildPackage,iptables-utils))
  309. $(eval $(call BuildPlugin,iptables-mod-conntrack,$(IPT_CONNTRACK-m)))
  310. $(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
  311. $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
  312. $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
  313. $(eval $(call BuildPlugin,iptables-mod-imq,$(IPT_IMQ-m)))
  314. $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
  315. $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
  316. $(eval $(call BuildPlugin,iptables-mod-ipset,ipt_set ipt_SET))
  317. $(eval $(call BuildPlugin,iptables-mod-nat,$(IPT_NAT-m)))
  318. $(eval $(call BuildPlugin,iptables-mod-nat-extra,$(IPT_NAT_EXTRA-m)))
  319. $(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
  320. $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
  321. $(eval $(call BuildPackage,ip6tables))
  322. $(eval $(call BuildPackage,ip6tables-utils))
  323. $(eval $(call BuildPackage,libiptc))
  324. $(eval $(call BuildPackage,libxtables))