Makefile 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. #
  2. # Copyright (C) 2006 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. # $Id$
  8. include $(TOPDIR)/rules.mk
  9. include $(INCLUDE_DIR)/kernel.mk
  10. PKG_NAME:=iptables
  11. PKG_VERSION:=1.3.5
  12. PKG_RELEASE:=1
  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_MD5SUM:=00fb916fa8040ca992a5ace56d905ea5
  19. include $(INCLUDE_DIR)/package.mk
  20. ifeq ($(DUMP),)
  21. -include $(LINUX_DIR)/.config
  22. include $(INCLUDE_DIR)/netfilter.mk
  23. STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep 'NETFILTER' $(LINUX_DIR)/.config | md5s)
  24. endif
  25. define Package/iptables/Default
  26. SECTION:=net
  27. CATEGORY:=Base system
  28. URL:=http://netfilter.org/
  29. endef
  30. define Package/iptables
  31. $(call Package/iptables/Default)
  32. TITLE:=IPv4 firewall administration tool
  33. MENU:=1
  34. endef
  35. define Package/iptables/conffiles
  36. /etc/config/firewall
  37. /etc/firewall.user
  38. endef
  39. define Package/iptables-mod-conntrack
  40. $(call Package/iptables/Default)
  41. DEPENDS:=iptables +kmod-ipt-conntrack
  42. TITLE:=connection tracking modules
  43. DESCRIPTION:=\
  44. iptables extensions for connection tracking.\\\
  45. \\\
  46. Includes: \\\
  47. - libipt_conntrack \\\
  48. - libipt_helper \\\
  49. - libipt_connmark/CONNMARK
  50. endef
  51. define Package/iptables-mod-filter
  52. $(call Package/iptables/Default)
  53. DEPENDS:=iptables +kmod-ipt-filter
  54. TITLE:=filter modules
  55. DESCRIPTION:=\
  56. iptables extensions for packet content inspection.\\\
  57. \\\
  58. Includes: \\\
  59. - libipt_ipp2p \\\
  60. - libipt_layer7
  61. endef
  62. define Package/iptables-mod-imq
  63. $(call Package/iptables/Default)
  64. DEPENDS:=iptables +kmod-ipt-imq
  65. TITLE:=IMQ support
  66. DESCRIPTION:=\
  67. iptables extension for IMQ support.\\\
  68. \\\
  69. Includes: \\\
  70. - libipt_IMQ
  71. endef
  72. define Package/iptables-mod-ipopt
  73. $(call Package/iptables/Default)
  74. DEPENDS:=iptables +kmod-ipt-ipopt
  75. TITLE:=IP/Packet option modules
  76. DESCRIPTION:=\
  77. iptables extensions for matching/changing IP packet options.\\\
  78. \\\
  79. Includes: \\\
  80. - libipt_CLASSIFY \\\
  81. - libipt_dscp/DSCP \\\
  82. - libipt_ecn/ECN \\\
  83. - libipt_length \\\
  84. - libipt_mac \\\
  85. - libipt_tos/TOS \\\
  86. - libipt_tcpmms \\\
  87. - libipt_ttl/TTL \\\
  88. - libipt_unclean
  89. endef
  90. define Package/iptables-mod-ipsec
  91. $(call Package/iptables/Default)
  92. DEPENDS:=iptables +kmod-ipt-ipsec
  93. TITLE:=IPSec extensions
  94. DESCRIPTION:=\
  95. iptables extensions for matching ipsec traffic.\\\
  96. \\\
  97. Includes: \\\
  98. - libipt_ah \\\
  99. - libipt_esp
  100. endef
  101. define Package/iptables-mod-nat
  102. $(call Package/iptables/Default)
  103. DEPENDS:=iptables +kmod-ipt-nat
  104. TITLE:=extra NAT targets
  105. DESCRIPTION:=\
  106. iptables extensions for different NAT targets.\\\
  107. \\\
  108. Includes: \\\
  109. - libipt_REDIRECT
  110. endef
  111. define Package/iptables-mod-ulog
  112. $(call Package/iptables/Default)
  113. DEPENDS:=iptables +kmod-ipt-ulog
  114. TITLE:=user-space packet logging
  115. DESCRIPTION:=\
  116. iptables extensions for user-space packet logging.\\\
  117. \\\
  118. Includes: \\\
  119. - libipt_ULOG
  120. endef
  121. define Package/iptables-mod-extra
  122. $(call Package/iptables/Default)
  123. DEPENDS:=iptables +kmod-ipt-extra
  124. TITLE:=other extra iptables extensions
  125. DESCRIPTION:=\
  126. other extra iptables extensions.\\\
  127. \\\
  128. Includes: \\\
  129. - libipt_limit \\\
  130. - libipt_owner \\\
  131. - libipt_physdev \\\
  132. - libipt_pkttype \\\
  133. - libipt_recent
  134. endef
  135. define Package/iptables-utils
  136. $(call Package/iptables/Default)
  137. DEPENDS:=iptables
  138. TITLE:=iptables save and restore utilities
  139. endef
  140. define Package/ip6tables
  141. $(call Package/iptables/Default)
  142. CATEGORY:=Network
  143. TITLE:=IPv6 firewall administration tool
  144. endef
  145. define Build/Configure
  146. rm -f $(PKG_BUILD_DIR)/.configured*
  147. $(MAKE) -C $(PKG_BUILD_DIR) \
  148. clean
  149. endef
  150. define Build/Compile
  151. chmod a+x $(PKG_BUILD_DIR)/extensions/.*-test*
  152. mkdir -p $(PKG_INSTALL_DIR)
  153. $(MAKE) -C $(PKG_BUILD_DIR) \
  154. $(TARGET_CONFIGURE_OPTS) \
  155. COPT_FLAGS="$(TARGET_CFLAGS)" \
  156. LDFLAGS="-rdynamic -static-libgcc" \
  157. KERNEL_DIR="$(LINUX_DIR)" PREFIX=/usr \
  158. DESTDIR="$(PKG_INSTALL_DIR)" \
  159. all install
  160. endef
  161. define Build/InstallDev
  162. $(MAKE) -C $(PKG_BUILD_DIR) \
  163. $(TARGET_CONFIGURE_OPTS) \
  164. COPT_FLAGS="$(TARGET_CFLAGS)" \
  165. KERNEL_DIR="$(LINUX_DIR)" PREFIX=/usr \
  166. DESTDIR="$(STAGING_DIR)" \
  167. install-devel
  168. $(CP) $(PKG_BUILD_DIR)/include $(STAGING_DIR)/usr
  169. $(CP) $(PKG_BUILD_DIR)/libiptc/libiptc.a $(STAGING_DIR)/usr/lib
  170. endef
  171. define Build/UninstallDev
  172. rm -rf $(STAGING_DIR)/usr/include/libipq.h
  173. rm -rf $(STAGING_DIR)/usr/include/libipulog
  174. rm -rf $(STAGING_DIR)/usr/include/libipq
  175. rm -rf $(STAGING_DIR)/usr/include/libiptc
  176. rm -rf $(STAGING_DIR)/usr/include/linux/netfilter*
  177. rm -rf $(STAGING_DIR)/usr/include/iptables*
  178. rm -rf $(STAGING_DIR)/usr/include/ip6tables*
  179. rm -rf $(STAGING_DIR)/usr/lib/libipq.a
  180. rm -rf $(STAGING_DIR)/usr/lib/libiptc.a
  181. endef
  182. define Package/iptables/install
  183. $(INSTALL_DIR) $(1)/etc/config
  184. $(INSTALL_DATA) ./files/firewall.config $(1)/etc/config/firewall
  185. $(INSTALL_DIR) $(1)/etc/init.d
  186. $(INSTALL_BIN) ./files/firewall.init $(1)/etc/init.d/firewall
  187. $(INSTALL_BIN) ./files/firewall.user $(1)/etc/
  188. $(INSTALL_DIR) $(1)/usr/lib
  189. $(INSTALL_DATA) ./files/firewall.awk $(1)/usr/lib
  190. $(INSTALL_DIR) $(1)/usr/sbin
  191. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables $(1)/usr/sbin/
  192. $(INSTALL_DIR) $(1)/usr/lib/iptables
  193. (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
  194. $(CP) $(patsubst %,lib%.so,$(IPT_BUILTIN:xt_%=ipt_%)) $(1)/usr/lib/iptables/ \
  195. )
  196. endef
  197. define Package/iptables-utils/install
  198. $(INSTALL_DIR) $(1)/usr/sbin
  199. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables-{save,restore} $(1)/usr/sbin/
  200. endef
  201. define Package/ip6tables/install
  202. $(INSTALL_DIR) $(1)/usr/sbin
  203. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables $(1)/usr/sbin/
  204. $(INSTALL_DIR) $(1)/usr/lib/iptables
  205. (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
  206. $(CP) libip6t_*.so $(1)/usr/lib/iptables/ \
  207. )
  208. endef
  209. define BuildPlugin
  210. define Package/$(1)/install
  211. $(INSTALL_DIR) $$(1)/usr/lib/iptables
  212. for m in $$(patsubst xt_%,ipt_%,$(2)); do \
  213. $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
  214. done
  215. $(3)
  216. endef
  217. $$(eval $$(call BuildPackage,$(1)))
  218. endef
  219. L7_INSTALL:=\
  220. $(INSTALL_DIR) $$(1)/etc/l7-protocols; \
  221. $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
  222. $(eval $(call BuildPackage,iptables))
  223. $(eval $(call BuildPackage,iptables-utils))
  224. $(eval $(call BuildPlugin,iptables-mod-conntrack,$(IPT_CONNTRACK-m)))
  225. $(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
  226. $(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
  227. $(eval $(call BuildPlugin,iptables-mod-imq,$(IPT_IMQ-m)))
  228. $(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
  229. $(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
  230. $(eval $(call BuildPlugin,iptables-mod-nat,$(IPT_NAT-m)))
  231. $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
  232. $(eval $(call BuildPackage,ip6tables))