build: add support for automatically removing build dir contents during build
[openwrt/staging/dedeckeh.git] / include / package.mk
index 37cea1448df8339f9eb2d325bbac70b04dc537ad..b88f2c52b0e54ab0d686ea679c665d34401788f7 100644 (file)
@@ -211,6 +211,12 @@ define Build/CoreTargets
   .configure: $(STAMP_CONFIGURED)
   .dist: $(STAMP_CONFIGURED)
   .distcheck: $(STAMP_CONFIGURED)
   .configure: $(STAMP_CONFIGURED)
   .dist: $(STAMP_CONFIGURED)
   .distcheck: $(STAMP_CONFIGURED)
+
+  ifneq ($(CONFIG_AUTOREMOVE),)
+    compile:
+               $(FIND) $(PKG_BUILD_DIR) -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' -and -not -name '.pkgdir' | \
+                       $(XARGS) rm -rf
+  endif
 endef
 
 define Build/DefaultTargets
 endef
 
 define Build/DefaultTargets