build: fix bin/ package empty check
authorFelix Fietkau <nbd@nbd.name>
Mon, 23 Jan 2017 11:32:04 +0000 (12:32 +0100)
committerFelix Fietkau <nbd@nbd.name>
Mon, 23 Jan 2017 11:41:49 +0000 (12:41 +0100)
$(wildcard) is evaluated too early in the build process

Signed-off-by: Felix Fietkau <nbd@nbd.name>
include/package-bin.mk

index 3d0baad2287bf603d39feeb82e4b53187ec6c934..68f5831340949105280c3dc66718e143ab3dd556 100644 (file)
@@ -27,10 +27,12 @@ ifeq ($(DUMP),)
                touch $$@
 
     install-bin-$(1): $(PKG_BUILD_DIR)/.pkgdir/$(1).installed
-         rm -rf $(BIN_DIR)/$(1)
-         $(if $(wildcard $(PKG_BUILD_DIR)/.pkgdir/$(1)/*), \
-               $(INSTALL_DIR) $(BIN_DIR)/$(1) && $(CP) $(PKG_BUILD_DIR)/.pkgdir/$(1)/. $(BIN_DIR)/$(1)/ \
-         )
+       rm -rf $(BIN_DIR)/$(1)
+       -rmdir $(PKG_BUILD_DIR)/.pkgdir/$(1) >/dev/null 2>/dev/null
+       [ -d $(PKG_BUILD_DIR)/.pkgdir/$(1) ] && { \
+               $(INSTALL_DIR) $(BIN_DIR)/$(1) && \
+               $(CP) $(PKG_BUILD_DIR)/.pkgdir/$(1)/. $(BIN_DIR)/$(1)/; \
+       }
 
     clean-$(1):
          rm -rf $(BIN_DIR)/$(1)