Makefile 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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.3.2
  11. PKG_RELEASE:=1
  12. PKG_MD5SUM:=545698693b636cfc844aafc6729fd48a
  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:=Base system
  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. - limit
  45. - LOG
  46. - mac
  47. - multiport
  48. - REJECT
  49. - TCPMSS
  50. endef
  51. define Package/iptables-mod-conntrack
  52. $(call Package/iptables/Module, +kmod-ipt-conntrack)
  53. TITLE:=Basic connection tracking extensions
  54. endef
  55. define Package/iptables-mod-conntrack/description
  56. Basic iptables extensions for connection tracking.
  57. Includes:
  58. - state
  59. endef
  60. define Package/iptables-mod-conntrack-extra
  61. $(call Package/iptables/Module, +kmod-ipt-conntrack-extra)
  62. TITLE:=Extra connection tracking extensions
  63. endef
  64. define Package/iptables-mod-conntrack-extra/description
  65. Extra iptables extensions for connection tracking.
  66. Includes:
  67. - libipt_conntrack
  68. - libipt_helper
  69. - libipt_connmark/CONNMARK
  70. endef
  71. define Package/iptables-mod-filter
  72. $(call Package/iptables/Module, +kmod-ipt-filter)
  73. TITLE:=Content inspection extensions
  74. endef
  75. define Package/iptables-mod-filter/description
  76. iptables extensions for packet content inspection.
  77. Includes:
  78. - libipt_string
  79. - libipt_layer7
  80. endef
  81. define Package/iptables-mod-imq
  82. $(call Package/iptables/Module, +kmod-ipt-imq)
  83. TITLE:=IMQ support
  84. endef
  85. define Package/iptables-mod-imq/description
  86. iptables extension for IMQ support.
  87. Includes:
  88. - libipt_IMQ
  89. endef
  90. define Package/iptables-mod-ipopt
  91. $(call Package/iptables/Module, +kmod-ipt-ipopt)
  92. TITLE:=IP/Packet option extensions
  93. endef
  94. define Package/iptables-mod-ipopt/description
  95. iptables extensions for matching/changing IP packet options.
  96. Includes:
  97. - libipt_CLASSIFY
  98. - libipt_dscp/DSCP
  99. - libipt_ecn/ECN
  100. - libipt_length
  101. - libipt_mac
  102. - libipt_mark/MARK
  103. - libipt_statistic
  104. - libipt_tcpmms
  105. - libipt_tos/TOS
  106. - libipt_ttl/TTL
  107. - libipt_unclean
  108. endef
  109. define Package/iptables-mod-ipsec
  110. $(call Package/iptables/Module, +kmod-ipt-ipsec)
  111. TITLE:=IPsec extensions
  112. endef
  113. define Package/iptables-mod-ipsec/description
  114. iptables extensions for matching ipsec traffic.
  115. Includes:
  116. - libipt_ah
  117. - libipt_esp
  118. - libipt_policy
  119. endef
  120. define Package/iptables-mod-nat
  121. $(call Package/iptables/Module, +kmod-ipt-nat)
  122. TITLE:=Basic NAT extensions
  123. endef
  124. define Package/iptables-mod-nat/description
  125. iptables extensions for basic NAT targets.
  126. Includes:
  127. - MASQUERADE
  128. - SNAT
  129. - DNAT
  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. Includes:
  138. - REDIRECT
  139. endef
  140. define Package/iptables-mod-ulog
  141. $(call Package/iptables/Module, +kmod-ipt-ulog)
  142. TITLE:=user-space packet logging
  143. endef
  144. define Package/iptables-mod-ulog/description
  145. iptables extensions for user-space packet logging.
  146. Includes:
  147. - libipt_ULOG
  148. endef
  149. define Package/iptables-mod-iprange
  150. $(call Package/iptables/Module, +kmod-ipt-iprange)
  151. TITLE:=IP range extension
  152. endef
  153. define Package/iptables-mod-iprange/description
  154. iptables extensions for matching ip ranges.
  155. Includes:
  156. - libipt_iprange
  157. endef
  158. define Package/iptables-mod-extra
  159. $(call Package/iptables/Module, +kmod-ipt-extra)
  160. TITLE:=Other extra iptables extensions
  161. endef
  162. define Package/iptables-mod-extra/description
  163. other extra iptables extensions.
  164. Includes:
  165. - libipt_owner
  166. - libipt_physdev
  167. - libipt_pkttype
  168. - libipt_recent
  169. - iptable_raw
  170. - libipt_NOTRACK
  171. endef
  172. define Package/iptables-mod-ipset
  173. $(call Package/iptables/Module, +kmod-ipt-ipset)
  174. TITLE:=IPset extension
  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 := -I$(PKG_BUILD_DIR)/include $(TARGET_CPPFLAGS)
  206. TARGET_CFLAGS += $(FPIC)
  207. CONFIGURE_ARGS += \
  208. --enable-shared \
  209. --enable-static \
  210. --enable-devel \
  211. --with-kernel="$(LINUX_DIR)" \
  212. --with-xtlibdir=/usr/lib/iptables
  213. define Build/Compile
  214. mkdir -p $(PKG_INSTALL_DIR)
  215. $(MAKE) -C $(PKG_BUILD_DIR) \
  216. $(TARGET_CONFIGURE_OPTS) \
  217. COPT_FLAGS="$(TARGET_CFLAGS)" \
  218. LDFLAGS="-rdynamic -static-libgcc" \
  219. KERNEL_DIR="$(LINUX_DIR)" PREFIX=/usr \
  220. KBUILD_OUTPUT="$(LINUX_DIR)" \
  221. DESTDIR="$(PKG_INSTALL_DIR)" \
  222. all install $(MAKE_TARGETS)
  223. endef
  224. define Build/InstallDev
  225. mkdir -p $(1)/usr/include
  226. mkdir -p $(1)/usr/include/iptables
  227. mkdir -p $(1)/usr/include/net/netfilter
  228. # XXX: iptables header fixup, some headers are not installed by iptables anymore
  229. $(CP) $(PKG_BUILD_DIR)/include/net/netfilter/*.h $(1)/usr/include/net/netfilter/
  230. $(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
  231. $(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
  232. $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
  233. mkdir -p $(1)/usr/lib
  234. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.{a,so*} $(1)/usr/lib/
  235. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libiptc.{a,so*} $(1)/usr/lib/
  236. mkdir -p $(1)/usr/lib/pkgconfig
  237. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/xtables.pc $(1)/usr/lib/pkgconfig/
  238. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libiptc.pc $(1)/usr/lib/pkgconfig/
  239. endef
  240. define Package/iptables/install
  241. $(INSTALL_DIR) $(1)/usr/sbin
  242. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iptables $(1)/usr/sbin/
  243. $(INSTALL_DIR) $(1)/usr/lib/iptables
  244. (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
  245. for m in $(patsubst xt_%,ipt_%,$(IPT_BUILTIN)) $(patsubst ipt_%,xt_%,$(IPT_BUILTIN)); do \
  246. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$${m}.so ]; then \
  247. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$${m}.so $(1)/usr/lib/iptables/ ;\
  248. fi; \
  249. done \
  250. )
  251. endef
  252. define Package/iptables-utils/install
  253. $(INSTALL_DIR) $(1)/usr/sbin
  254. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/iptables-{save,restore} $(1)/usr/sbin/
  255. endef
  256. define Package/ip6tables/install
  257. $(INSTALL_DIR) $(1)/usr/sbin
  258. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables $(1)/usr/sbin/
  259. $(INSTALL_DIR) $(1)/usr/lib/iptables
  260. (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
  261. $(CP) libip6t_*.so $(1)/usr/lib/iptables/ \
  262. )
  263. endef
  264. define Package/ip6tables-utils/install
  265. $(INSTALL_DIR) $(1)/usr/sbin
  266. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables-{save,restore} $(1)/usr/sbin/
  267. endef
  268. define Package/libiptc/install
  269. $(INSTALL_DIR) $(1)/usr/lib
  270. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/libiptc.so.* $(1)/usr/lib/
  271. endef
  272. define Package/libxtables/install
  273. $(INSTALL_DIR) $(1)/usr/lib
  274. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so.* $(1)/usr/lib/
  275. endef
  276. define BuildPlugin
  277. define Package/$(1)/install
  278. $(INSTALL_DIR) $$(1)/usr/lib/iptables
  279. for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)); do \
  280. if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
  281. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
  282. fi; \
  283. done
  284. $(3)
  285. endef
  286. $$(eval $$(call BuildPackage,$(1)))
  287. endef
  288. L7_INSTALL:=\
  289. $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
  290. $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
  291. $(eval $(call BuildPackage,iptables))
  292. $(eval $(call BuildPackage,iptables-utils))
  293. $(eval $(call BuildPlugin,iptables-mod-conntrack,$(IPT_CONNTRACK-m)))
  294. $(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
  295. $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
  296. $(eval $(call BuildPlugin,iptables-mod-ipset,$(IPT_IPSET-m)))
  297. $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
  298. $(eval $(call BuildPlugin,iptables-mod-imq,$(IPT_IMQ-m)))
  299. $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
  300. $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
  301. $(eval $(call BuildPlugin,iptables-mod-nat,$(IPT_NAT-m)))
  302. $(eval $(call BuildPlugin,iptables-mod-nat-extra,$(IPT_NAT_EXTRA-m)))
  303. $(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
  304. $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
  305. $(eval $(call BuildPackage,ip6tables))
  306. $(eval $(call BuildPackage,ip6tables-utils))
  307. $(eval $(call BuildPackage,libiptc))
  308. $(eval $(call BuildPackage,libxtables))