- CC=$(TARGET_CC) COPT_FLAGS="$(TARGET_CFLAGS)"
-
-$(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 $(I_IPT_EXTRA)/$(MODULES_SUBDIR)
- cp $(MODULES_DIR)/kernel/net/ipv6/netfilter/*.o $(I_IPT_EXTRA)/$(MODULES_SUBDIR)
- mkdir -p $(PACKAGE_DIR)
- $(IPKG_BUILD) $(I_IPT) $(PACKAGE_DIR)
-
-$(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)
-
-$(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)
-
-
-source: $(DL_DIR)/$(PKG_SOURCE_FILE)
-prepare: $(PKG_BUILD_DIR)/.patched
-compile: $(TARGETS)
-install: compile
- $(IPKG) install $(PKG_IPT)
-ifeq ($(BR2_PACKAGE_IPTABLES_EXTRA),y)
- $(IPKG) install $(PKG_IPT_EXTRA)
-endif
-ifeq ($(BR2_PACKAGE_IP6TABLES),y)
- $(IPKG) install $(PKG_IP6T)
-endif
+ DESTDIR="$(PKG_INSTALL_DIR)" \
+ all install install-devel
+endef
+
+
+define Build/InstallDev
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ CC=$(TARGET_CC) COPT_FLAGS="$(TARGET_CFLAGS)" \
+ KERNEL_DIR=$(LINUX_DIR) PREFIX=/usr \
+ DESTDIR="$(STAGING_DIR)" \
+ install install-devel
+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 -d -m0755 $(1)/etc/config
+ install -m0644 ./files/firewall.config $(1)/etc/config/firewall
+ install -d -m0755 $(1)/etc/init.d
+ install -m0755 ./files/firewall.init $(1)/etc/init.d/S45firewall
+ install -m0755 ./files/firewall.user $(1)/etc/
+ install -d -m0755 $(1)/usr/lib
+ install -m0644 ./files/firewall.awk $(1)/usr/lib
+ install -d -m0755 $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables $(1)/usr/sbin/
+ install -d -m0755 $(1)/usr/lib/iptables
+ (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
+ $(CP) $(patsubst %,lib%.so,$(IPT_BUILTIN:xt_%=ipt_%)) $(1)/usr/lib/iptables/ \
+ )
+ $(RSTRIP) $(1)
+endef
+
+define Package/iptables-utils/install
+ install -d -m0755 $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables-{save,restore} $(1)/usr/sbin/
+ $(RSTRIP) $(1)
+endef
+
+define Package/ip6tables/install
+ install -d -m0755 $(1)/usr/sbin
+ $(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables $(1)/usr/sbin/
+ install -d -m0755 $(1)/usr/lib/iptables
+ (cd $(PKG_INSTALL_DIR)/usr/lib/iptables ; \
+ $(CP) libip6t_*.so $(1)/usr/lib/iptables/ \
+ )
+ $(RSTRIP) $(1)
+endef
+
+define BuildPlugin
+define Package/$(1)/install
+ install -m0755 -d $$(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)
+ $(RSTRIP) $$(1)
+endef
+
+$$(eval $$(call BuildPackage,$(1)))
+endef
+
+L7_INSTALL:=mkdir -p $$(1)/etc/l7-protocols; \
+ $(CP) files/l7/*.pat $$(1)/etc/l7-protocols/