-preconfig:
-clean: $(patsubst %,%-clean,$(package-) $(package-y) $(package-m))
-prereq: $(PREREQ_PACKAGES)
-download: $(DOWNLOAD_PACKAGES)
-compile: $(COMPILE_PACKAGES)
+$(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/install $(curdir)/merge $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),$(curdir)/merge-index)
+ - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
+ rm -rf $(TARGET_DIR)
+ [ -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
+ $(call prepare_rootfs,$(TARGET_DIR))
+
+PASSOPT=""
+PASSARG=""
+ifndef CONFIG_OPKGSMIME_PASSPHRASE
+ ifneq ($(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE)),)
+ PASSOPT="-passin"
+ PASSARG="file:$(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE))"
+ endif
+endif