+
+$(curdir)/cleanup: $(TMP_DIR)/.build
+ rm -rf $(STAGING_DIR_ROOT)
+
+$(curdir)/merge:
+ rm -rf $(PACKAGE_DIR_ALL)
+ mkdir -p $(PACKAGE_DIR_ALL)
+ -$(foreach pdir,$(PACKAGE_SUBDIRS),$(if $(wildcard $(pdir)/*.ipk),ln -s $(pdir)/*.ipk $(PACKAGE_DIR_ALL);))
+
+$(curdir)/merge-index: $(curdir)/merge
+ (cd $(PACKAGE_DIR_ALL) && $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages; )
+
+$(curdir)/install: $(TMP_DIR)/.build $(curdir)/system/opkg/host/compile $(curdir)/merge $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),$(curdir)/merge-index)
+ - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
+ rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
+ [ -d $(TARGET_DIR)/tmp ] || mkdir -p $(TARGET_DIR)/tmp
+ $(call opkg,$(TARGET_DIR)) install \
+ $(call opkg_package_files,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null))
+ @for file in $(PACKAGE_INSTALL_FILES); do \
+ [ -s $$file.flags ] || continue; \
+ for flag in `cat $$file.flags`; do \
+ $(call opkg,$(TARGET_DIR)) flag $$flag `cat $$file`; \
+ done; \
+ done || true
+ @-$(MAKE) package/preconfig
+
+ $(CP) $(TARGET_DIR) $(TARGET_DIR_ORIG)
+
+ $(call prepare_rootfs,$(TARGET_DIR))