Makefile 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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-nat
  122. $(call Package/iptables/Module, +kmod-ipt-nat)
  123. TITLE:=Basic NAT extensions
  124. endef
  125. define Package/iptables-mod-nat/description
  126. iptables extensions for basic NAT targets.
  127. Includes:
  128. - MASQUERADE
  129. - SNAT
  130. - DNAT
  131. endef
  132. define Package/iptables-mod-nat-extra
  133. $(call Package/iptables/Module, +kmod-ipt-nat-extra)
  134. TITLE:=Extra NAT extensions
  135. endef
  136. define Package/iptables-mod-nat-extra/description
  137. iptables extensions for extra NAT targets.
  138. Includes:
  139. - REDIRECT
  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. Includes:
  148. - libipt_ULOG
  149. endef
  150. define Package/iptables-mod-iprange
  151. $(call Package/iptables/Module, +kmod-ipt-iprange)
  152. TITLE:=IP range extension
  153. endef
  154. define Package/iptables-mod-iprange/description
  155. iptables extensions for matching ip ranges.
  156. Includes:
  157. - libipt_iprange
  158. endef
  159. define Package/iptables-mod-extra
  160. $(call Package/iptables/Module, +kmod-ipt-extra)
  161. TITLE:=Other extra iptables extensions
  162. endef
  163. define Package/iptables-mod-extra/description
  164. other extra iptables extensions.
  165. Includes:
  166. - libipt_owner
  167. - libipt_physdev
  168. - libipt_pkttype
  169. - libipt_recent
  170. - iptable_raw
  171. - libipt_NOTRACK
  172. endef
  173. define Package/iptables-utils
  174. $(call Package/iptables/Module, )
  175. TITLE:=iptables save and restore utilities
  176. endef
  177. define Package/ip6tables
  178. $(call Package/iptables/Default)
  179. DEPENDS:=+kmod-ip6tables
  180. CATEGORY:=IPv6
  181. TITLE:=IPv6 firewall administration tool
  182. MENU:=1
  183. endef
  184. define Package/ip6tables-utils
  185. $(call Package/iptables/Default)
  186. DEPENDS:=ip6tables
  187. CATEGORY:=IPv6
  188. TITLE:=ip6tables save and restore utilities
  189. endef
  190. define Package/libiptc
  191. $(call Package/iptables/Default)
  192. SECTION:=libs
  193. CATEGORY:=Libraries
  194. TITLE:=IPv4/IPv6 firewall - shared libiptc library
  195. endef
  196. define Package/libxtables
  197. $(call Package/iptables/Default)
  198. SECTION:=libs
  199. CATEGORY:=Libraries
  200. TITLE:=IPv4/IPv6 firewall - shared xtables library
  201. endef
  202. TARGET_CPPFLAGS := \
  203. -I$(PKG_BUILD_DIR)/include \
  204. -I$(LINUX_DIR)/arch/$(LINUX_KARCH)/include \
  205. $(TARGET_CPPFLAGS)
  206. CONFIGURE_ARGS += \
  207. --enable-shared \
  208. --enable-static \
  209. --enable-devel \
  210. --enable-ipv6 \
  211. --with-kernel="$(LINUX_DIR)" \
  212. --with-xtlibdir=/usr/lib/iptables
  213. IPTABLES_MAKEOPTS = \
  214. $(TARGET_CONFIGURE_OPTS) \
  215. COPT_FLAGS="$(TARGET_CFLAGS)" \
  216. LDFLAGS="-rdynamic -static-libgcc" \
  217. KERNEL_DIR="$(LINUX_DIR)" PREFIX=/usr \
  218. KBUILD_OUTPUT="$(LINUX_DIR)" \
  219. DESTDIR="$(PKG_INSTALL_DIR)" \
  220. all install $(MAKE_TARGETS)
  221. define Build/Compile
  222. mkdir -p $(PKG_INSTALL_DIR)
  223. $(MAKE) -C $(PKG_BUILD_DIR) $(IPTABLES_MAKEOPTS)
  224. $(MAKE) -C $(PKG_BUILD_DIR)/libipq $(IPTABLES_MAKEOPTS)
  225. endef
  226. define Build/InstallDev
  227. mkdir -p $(1)/usr/include
  228. mkdir -p $(1)/usr/include/iptables
  229. mkdir -p $(1)/usr/include/net/netfilter
  230. # XXX: iptables header fixup, some headers are not installed by iptables anymore
  231. $(CP) $(PKG_BUILD_DIR)/include/net/netfilter/*.h $(1)/usr/include/net/netfilter/
  232. $(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
  233. $(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
  234. $(CP) $(PKG_BUILD_DIR)/include/libipq/libipq.h $(1)/usr/include/
  235. $(CP) $(PKG_BUILD_DIR)/include/libipulog $(1)/usr/include/
  236. $(CP) $(PKG_BUILD_DIR)/include/libiptc $(1)/usr/include/
  237. $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
  238. mkdir -p $(1)/usr/lib
  239. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.{a,so*} $(1)/usr/lib/
  240. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.{a,so*} $(1)/usr/lib/
  241. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libipq.a $(1)/usr/lib/
  242. mkdir -p $(1)/usr/lib/pkgconfig
  243. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/xtables.pc $(1)/usr/lib/pkgconfig/
  244. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libiptc.pc $(1)/usr/lib/pkgconfig/
  245. endef
  246. define Package/iptables/install
  247. $(INSTALL_DIR) $(1)/usr/sbin
  248. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iptables $(1)/usr/sbin/
  249. $(INSTALL_DIR) $(1)/usr/lib/iptables
  250. (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
  251. for m in $(patsubst xt_%,ipt_%,$(IPT_BUILTIN)) $(patsubst ipt_%,xt_%,$(IPT_BUILTIN)); do \
  252. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$${m}.so ]; then \
  253. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$${m}.so $(1)/usr/lib/iptables/ ;\
  254. fi; \
  255. done \
  256. )
  257. endef
  258. define Package/iptables-utils/install
  259. $(INSTALL_DIR) $(1)/usr/sbin
  260. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iptables-{save,restore} $(1)/usr/sbin/
  261. endef
  262. define Package/ip6tables/install
  263. $(INSTALL_DIR) $(1)/usr/sbin
  264. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables $(1)/usr/sbin/
  265. $(INSTALL_DIR) $(1)/usr/lib/iptables
  266. (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
  267. $(CP) libip6t_*.so $(1)/usr/lib/iptables/ \
  268. )
  269. endef
  270. define Package/ip6tables-utils/install
  271. $(INSTALL_DIR) $(1)/usr/sbin
  272. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables-{save,restore} $(1)/usr/sbin/
  273. endef
  274. define Package/libiptc/install
  275. $(INSTALL_DIR) $(1)/usr/lib
  276. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.so* $(1)/usr/lib/
  277. endef
  278. define Package/libxtables/install
  279. $(INSTALL_DIR) $(1)/usr/lib
  280. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
  281. endef
  282. define BuildPlugin
  283. define Package/$(1)/install
  284. $(INSTALL_DIR) $$(1)/usr/lib/iptables
  285. for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)); do \
  286. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
  287. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
  288. fi; \
  289. done
  290. $(3)
  291. endef
  292. $$(eval $$(call BuildPackage,$(1)))
  293. endef
  294. L7_INSTALL:=\
  295. $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
  296. $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
  297. $(eval $(call BuildPackage,iptables))
  298. $(eval $(call BuildPackage,iptables-utils))
  299. $(eval $(call BuildPlugin,iptables-mod-conntrack,$(IPT_CONNTRACK-m)))
  300. $(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
  301. $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
  302. $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
  303. $(eval $(call BuildPlugin,iptables-mod-imq,$(IPT_IMQ-m)))
  304. $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
  305. $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
  306. $(eval $(call BuildPlugin,iptables-mod-nat,$(IPT_NAT-m)))
  307. $(eval $(call BuildPlugin,iptables-mod-nat-extra,$(IPT_NAT_EXTRA-m)))
  308. $(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
  309. $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
  310. $(eval $(call BuildPackage,ip6tables))
  311. $(eval $(call BuildPackage,ip6tables-utils))
  312. $(eval $(call BuildPackage,libiptc))
  313. $(eval $(call BuildPackage,libxtables))