- KERNEL_DIR=$(LINUX_DIR) PREFIX=/usr \
- CC=$(TARGET_CC) COPT_FLAGS="$(TARGET_CFLAGS)" \
- libipq/libipq.a
- cp -a $(PKG_BUILD_DIR)/include/* $(STAGING_DIR)/include/
- cp $(PKG_BUILD_DIR)/libipq/libipq.a $(STAGING_DIR)/lib/
- cp $(PKG_BUILD_DIR)/libiptc/libiptc.a $(STAGING_DIR)/lib/
-
-$(PKG_IPT): $(PKG_BUILD_DIR)/iptables
- $(SCRIPT_DIR)/make-ipkg-dir.sh $(I_IPT) control/iptables.control $(PKG_VERSION)-$(PKG_RELEASE) $(ARCH)
- mkdir -p $(I_IPT)/usr/sbin
- cp -af $(PKG_BUILD_DIR)/iptables $(I_IPT)/usr/sbin/
- $(STRIP) $(I_IPT)/usr/sbin/iptables
- mkdir -p $(I_IPT)/usr/lib/iptables
- (cd $(PKG_BUILD_DIR)/extensions; \
- cp $(patsubst %,libipt_%.so,$(ext-y)) $(I_IPT)/usr/lib/iptables)
- -$(STRIP) $(I_IPT)/usr/lib/iptables/*.so
- mkdir -p $(PACKAGE_DIR)
- $(IPKG_BUILD) $(I_IPT) $(PACKAGE_DIR)
-
-$(IPKG_STATE_DIR)/info/iptables.list: $(PKG_IPT)
- $(IPKG) install $(PKG_IPT)
-
-$(PKG_IPT_EXTRA): $(PKG_BUILD_DIR)/iptables
- $(SCRIPT_DIR)/make-ipkg-dir.sh $(I_IPT_EXTRA) control/iptables-extra.control $(PKG_VERSION)-$(PKG_RELEASE) $(ARCH)
- mkdir -p $(I_IPT_EXTRA)/usr/lib/iptables
- (cd $(PKG_BUILD_DIR)/extensions; \
- cp $(patsubst %,libipt_%.so,$(ext-m)) $(I_IPT_EXTRA)/usr/lib/iptables)
- -$(STRIP) $(I_IPT_EXTRA)/usr/lib/iptables/*.so
- mkdir -p $(PACKAGE_DIR)
- $(IPKG_BUILD) $(I_IPT_EXTRA) $(PACKAGE_DIR)
-
-$(IPKG_STATE_DIR)/info/iptables-extra.list: $(PKG_IPT)
- $(IPKG) install $(PKG_IPT_EXTRA)
-
-$(PKG_IPT_UTILS): $(PKG_BUILD_DIR)/iptables
- $(SCRIPT_DIR)/make-ipkg-dir.sh $(I_IPT_UTILS) control/iptables-utils.control $(PKG_VERSION)-$(PKG_RELEASE) $(ARCH)
- mkdir -p $(I_IPT_UTILS)/usr/sbin
- cp $(PKG_BUILD_DIR)/iptables-save $(I_IPT_UTILS)/usr/sbin
- cp $(PKG_BUILD_DIR)/iptables-restore $(I_IPT_UTILS)/usr/sbin
- -$(STRIP) $(I_IPT_UTILS)/usr/sbin/*
- mkdir -p $(PACKAGE_DIR)
- $(IPKG_BUILD) $(I_IPT_UTILS) $(PACKAGE_DIR)
-
-$(IPKG_STATE_DIR)/info/iptables-utils.list: $(PKG_IPT)
- $(IPKG) install $(PKG_IPT_UTILS)
-
-$(PKG_IP6T): $(PKG_BUILD_DIR)/iptables
- $(SCRIPT_DIR)/make-ipkg-dir.sh $(I_IP6T) control/ip6tables.control $(PKG_VERSION)-$(PKG_RELEASE) $(ARCH)
- mkdir -p $(I_IP6T)/usr/sbin
- cp -af $(PKG_BUILD_DIR)/ip6tables $(I_IP6T)/usr/sbin/
- $(STRIP) $(I_IP6T)/usr/sbin/ip6tables
- mkdir -p $(I_IP6T)/usr/lib/iptables
- (cd $(PKG_BUILD_DIR)/extensions; \
- cp libip6t_*.so $(I_IP6T)/usr/lib/iptables)
- -$(STRIP) $(I_IP6T)/usr/lib/iptables/*.so
- mkdir -p $(PACKAGE_DIR)
- $(IPKG_BUILD) $(I_IP6T) $(PACKAGE_DIR)
-
-$(IPKG_STATE_DIR)/info/ip6tables.list: $(PKG_IP6T)
- $(IPKG) install $(PKG_IP6T)
-
-
-source: $(DL_DIR)/$(PKG_SOURCE_FILE)
-prepare: $(PKG_BUILD_DIR)/.patched
-compile: $(TARGETS)
-install: $(INSTALL_TARGETS)
-
-clean:
- rm -rf $(PKG_BUILD_DIR)
- rm -f $(PKG_IPT) $(PKG_IPT_EXTRA) $(PKG_IP6T)
+ $(TARGET_CONFIGURE_OPTS) \
+ COPT_FLAGS="$(TARGET_CFLAGS)" \
+ KERNEL_DIR="$(LINUX_DIR)" PREFIX=/usr \
+ DESTDIR="$(STAGING_DIR)" \
+ install install-devel
+ $(CP) $(PKG_BUILD_DIR)/include $(STAGING_DIR)/usr
+endef
+
+define Build/UninstallDev
+ rm -rf $(STAGING_DIR)/usr/include/libipq.h
+ rm -rf $(STAGING_DIR)/usr/lib/libipq.a
+endef
+
+define Package/iptables/install
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/firewall.config $(1)/etc/config/firewall
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/firewall.init $(1)/etc/init.d/firewall
+ $(INSTALL_BIN) ./files/firewall.user $(1)/etc/
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(INSTALL_DATA) ./files/firewall.awk $(1)/usr/lib
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/usr/lib/iptables
+ (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
+ $(CP) $(patsubst %,lib%.so,$(IPT_BUILTIN:xt_%=ipt_%)) $(1)/usr/lib/iptables/ \
+ )
+endef
+
+define Package/iptables-utils/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables-{save,restore} $(1)/usr/sbin/
+endef
+
+define Package/ip6tables/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/usr/lib/iptables
+ (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
+ $(CP) libip6t_*.so $(1)/usr/lib/iptables/ \
+ )
+endef
+
+define BuildPlugin
+ define Package/$(1)/install
+ $(INSTALL_DIR) $$(1)/usr/lib/iptables
+ for m in $$(patsubst xt_%,ipt_%,$(2)); do \
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
+ done
+ $(3)
+ endef
+
+ $$(eval $$(call BuildPackage,$(1)))
+endef
+
+L7_INSTALL:=mkdir -p $$(1)/etc/l7-protocols; \
+ $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/
+
+$(eval $(call BuildPackage,iptables))
+$(eval $(call BuildPackage,iptables-utils))
+$(eval $(call BuildPlugin,iptables-mod-conntrack,$(IPT_CONNTRACK-m)))
+$(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
+$(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m),$(L7_INSTALL)))
+$(eval $(call BuildPlugin,iptables-mod-imq,$(IPT_IMQ-m)))
+$(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
+$(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
+$(eval $(call BuildPlugin,iptables-mod-nat,$(IPT_NAT-m)))
+$(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m)))
+$(eval $(call BuildPackage,ip6tables))