build: implement make check and make package/X/check
[openwrt/staging/wigyori.git] / package / Makefile
index 87dfe68e06330e5a37daf32315468632b7244cac..c4fb8ca97450e499304910badafe73243af78a56 100644 (file)
@@ -44,16 +44,20 @@ PACKAGE_INSTALL_FILES:= \
 $(curdir)/cleanup: $(TMP_DIR)/.build
        rm -rf $(STAGING_DIR_ROOT)
 
-$(curdir)/install: $(TMP_DIR)/.build $(curdir)/system/opkg/host/install
+$(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)
+       rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
        [ -d $(TARGET_DIR)/tmp ] || mkdir -p $(TARGET_DIR)/tmp
        $(call opkg,$(TARGET_DIR)) install \
-               $(wildcard \
-                 $(foreach dir,$(PACKAGE_SUBDIRS), \
-                   $(foreach pkg, \
-                     $(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null), \
-                     $(dir)/$(pkg)_*.ipk)))
+               $(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 \
@@ -61,6 +65,9 @@ $(curdir)/install: $(TMP_DIR)/.build $(curdir)/system/opkg/host/install
                done; \
        done || true
        @-$(MAKE) package/preconfig
+
+       $(CP) $(TARGET_DIR) $(TARGET_DIR_ORIG)
+
        $(call prepare_rootfs,$(TARGET_DIR))
 
 PASSOPT=""
@@ -116,5 +123,6 @@ $(eval $(call stampfile,$(curdir),package,prereq,.config))
 $(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
 $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
 $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
+$(eval $(call stampfile,$(curdir),package,check,$(TMP_DIR)/.build))
 
 $(eval $(call subdir,$(curdir)))