Makefile 9.8 KB

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