include/download.mk: generate reproducable SCM tarballs
[openwrt/staging/yousong.git] / include / scan.mk
index c3015793d2e7d0c5acee48c5ce8781ee62d4b4dd..5bb263d713c03487e6e5c45ea50f222ca6b3f985 100644 (file)
@@ -40,16 +40,23 @@ define PackageDir
                        rm -f $$@; \
                }; \
                echo; \
-       } > $$@ || true
+       } > $$@.tmp
+       mv $$@.tmp $$@
 endef
 
 $(OVERRIDELIST):
        rm -f $(TMP_DIR)/info/.overrides-$(SCAN_TARGET)-*
        touch $@
 
+ifeq ($(SCAN_NAME),target)
+  GREP_STRING=BuildTarget
+else
+  GREP_STRING=(Build/DefaultTargets|BuildPackage|.+Package)
+endif
+
 $(FILELIST): $(OVERRIDELIST)
        rm -f $(TMP_DIR)/info/.files-$(SCAN_TARGET)-*
-       $(call FIND_L, $(SCAN_DIR)) $(SCAN_EXTRA) -mindepth 1 $(if $(SCAN_DEPTH),-maxdepth $(SCAN_DEPTH)) -name Makefile | xargs grep -HE 'call (Build/DefaultTargets|Build(Package|Target)|.+Package)' | sed -e 's#^$(SCAN_DIR)/##' -e 's#/Makefile:.*##' | uniq | awk -v of=$(OVERRIDELIST) -f include/scan.awk > $@
+       $(call FIND_L, $(SCAN_DIR)) $(SCAN_EXTRA) -mindepth 1 $(if $(SCAN_DEPTH),-maxdepth $(SCAN_DEPTH)) -name Makefile | xargs grep -aHE 'call $(GREP_STRING)' | sed -e 's#^$(SCAN_DIR)/##' -e 's#/Makefile:.*##' | uniq | awk -v of=$(OVERRIDELIST) -f include/scan.awk > $@
 
 $(TMP_DIR)/info/.files-$(SCAN_TARGET).mk: $(FILELIST)
        ( \
@@ -70,7 +77,8 @@ $(TMP_DIR)/info/.files-$(SCAN_TARGET).mk: $(FILELIST)
                        print "$$(eval $$(call PackageDir," info "," dir "," pkg "))"; \
                } ' < $<; \
                true; \
-       ) > $@
+       ) > $@.tmp
+       mv $@.tmp $@
 
 -include $(TMP_DIR)/info/.files-$(SCAN_TARGET).mk