toolchain/binutils: Switch to 2.27 as default version
[openwrt/openwrt.git] / include / package.mk
index 6e24788a58e1b72c23e261903abb0f20dc95336e..ce1aa256bdf0eaf78c298fcba0f207e6ca9047fc 100644 (file)
@@ -96,6 +96,8 @@ include $(INCLUDE_DIR)/package-ipkg.mk
 include $(INCLUDE_DIR)/package-bin.mk
 include $(INCLUDE_DIR)/autotools.mk
 
+_pkg_target:=$(if $(QUILT),,.)
+
 override MAKEFLAGS=
 CONFIG_SITE:=$(INCLUDE_DIR)/site/$(ARCH)
 CUR_MAKEFILE:=$(filter-out Makefile,$(firstword $(MAKEFILE_LIST)))
@@ -154,6 +156,7 @@ define Build/CoreTargets
   $(STAMP_PREPARED): $(STAMP_PREPARED_DEPENDS)
        @-rm -rf $(PKG_BUILD_DIR)
        @mkdir -p $(PKG_BUILD_DIR)
+       touch $$@_check
        $(foreach hook,$(Hooks/Prepare/Pre),$(call $(hook))$(sep))
        $(Build/Prepare)
        $(foreach hook,$(Hooks/Prepare/Post),$(call $(hook))$(sep))
@@ -170,6 +173,8 @@ define Build/CoreTargets
 
   $(call Build/Exports,$(STAMP_BUILT))
   $(STAMP_BUILT): $(STAMP_CONFIGURED) $(STAMP_BUILT_DEPENDS)
+       rm -f $$@
+       touch $$@_check
        $(foreach hook,$(Hooks/Compile/Pre),$(call $(hook))$(sep))
        $(Build/Compile)
        $(foreach hook,$(Hooks/Compile/Post),$(call $(hook))$(sep))
@@ -204,16 +209,17 @@ define Build/CoreTargets
        touch $$@
 
   ifdef Build/InstallDev
-    .compile: $(STAMP_INSTALLED)
+    $(_pkg_target)compile: $(STAMP_INSTALLED)
   endif
 
-  .prepare: $(STAMP_PREPARED)
-  .configure: $(STAMP_CONFIGURED)
-  .dist: $(STAMP_CONFIGURED)
-  .distcheck: $(STAMP_CONFIGURED)
+  $(_pkg_target)prepare: $(STAMP_PREPARED)
+  $(_pkg_target)configure: $(STAMP_CONFIGURED)
+  $(_pkg_target)dist: $(STAMP_CONFIGURED)
+  $(_pkg_target)distcheck: $(STAMP_CONFIGURED)
 
   ifneq ($(CONFIG_AUTOREMOVE),)
     compile:
+               -touch $(PKG_BUILD_DIR)/.autoremove 2>/dev/null >/dev/null
                $(FIND) $(PKG_BUILD_DIR) -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' -and -not -name '.pkgdir' | \
                        $(XARGS) rm -rf
   endif
@@ -298,12 +304,16 @@ compile: prepare-package-install
 .install: .compile
 install: compile
 
-clean: FORCE
+force-clean-build: FORCE
+       rm -rf $(PKG_BUILD_DIR)
+
+clean-build: $(if $(wildcard $(PKG_BUILD_DIR)/.autoremove),force-clean-build)
+
+clean: force-clean-build
        $(CleanStaging)
        $(call Build/UninstallDev,$(STAGING_DIR),$(STAGING_DIR_HOST))
        $(Build/Clean)
        rm -f $(STAGING_DIR)/packages/$(STAGING_FILES_LIST) $(STAGING_DIR_HOST)/packages/$(STAGING_FILES_LIST)
-       rm -rf $(PKG_BUILD_DIR)
 
 dist:
        $(Build/Dist)