2007-02-27 21:14:00 +00:00
|
|
|
include $(TOPDIR)/include/verbose.mk
|
2007-07-16 07:19:45 +00:00
|
|
|
TMP_DIR:=$(TOPDIR)/tmp
|
2007-02-27 21:14:00 +00:00
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
all: $(TMP_DIR)/.$(SCAN_TARGET)
|
2007-07-15 22:51:12 +00:00
|
|
|
|
2007-04-03 23:03:56 +00:00
|
|
|
SCAN_TARGET ?= packageinfo
|
2007-02-27 21:14:00 +00:00
|
|
|
SCAN_NAME ?= package
|
|
|
|
SCAN_DIR ?= package
|
2007-09-23 02:39:01 +00:00
|
|
|
TARGET_STAMP:=$(TMP_DIR)/info/.files-$(SCAN_TARGET).stamp
|
|
|
|
FILELIST:=$(TMP_DIR)/info/.files-$(SCAN_TARGET)-$(SCAN_COOKIE)
|
2015-02-09 12:09:31 +00:00
|
|
|
OVERRIDELIST:=$(TMP_DIR)/info/.overrides-$(SCAN_TARGET)-$(SCAN_COOKIE)
|
2007-02-27 21:14:00 +00:00
|
|
|
|
2017-02-20 13:24:54 +00:00
|
|
|
export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH)
|
|
|
|
|
2018-07-02 12:23:19 +00:00
|
|
|
ifeq ($(SCAN_NAME),target)
|
|
|
|
SCAN_DEPS=image/Makefile profiles/*.mk $(TOPDIR)/include/kernel*.mk $(TOPDIR)/include/target.mk image/*.mk
|
|
|
|
else
|
|
|
|
SCAN_DEPS=$(TOPDIR)/include/package*.mk
|
|
|
|
endif
|
|
|
|
|
2007-02-27 21:14:00 +00:00
|
|
|
ifeq ($(IS_TTY),1)
|
2019-01-21 18:32:06 +00:00
|
|
|
ifneq ($(strip $(NO_COLOR)),1)
|
|
|
|
define progress
|
2007-02-27 21:14:00 +00:00
|
|
|
printf "\033[M\r$(1)" >&2;
|
2019-01-21 18:32:06 +00:00
|
|
|
endef
|
|
|
|
else
|
|
|
|
define progress
|
2019-02-17 18:29:08 +00:00
|
|
|
printf "\r$(1)" >&2;
|
2019-01-21 18:32:06 +00:00
|
|
|
endef
|
|
|
|
endif
|
2007-02-27 21:14:00 +00:00
|
|
|
else
|
|
|
|
define progress
|
2008-01-26 12:19:45 +00:00
|
|
|
:;
|
2007-02-27 21:14:00 +00:00
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2014-08-05 11:24:24 +00:00
|
|
|
define feedname
|
|
|
|
$(if $(patsubst feeds/%,,$(1)),,$(word 2,$(subst /, ,$(1))))
|
|
|
|
endef
|
|
|
|
|
2007-07-15 22:51:12 +00:00
|
|
|
define PackageDir
|
2016-01-10 16:35:24 +00:00
|
|
|
$(TMP_DIR)/.$(SCAN_TARGET): $(TMP_DIR)/info/.$(SCAN_TARGET)-$(1)
|
2016-11-23 16:03:38 +00:00
|
|
|
$(TMP_DIR)/info/.$(SCAN_TARGET)-$(1): $(SCAN_DIR)/$(2)/Makefile $(foreach DEP,$(DEPS_$(SCAN_DIR)/$(2)/Makefile) $(SCAN_DEPS),$(wildcard $(if $(filter /%,$(DEP)),$(DEP),$(SCAN_DIR)/$(2)/$(DEP))))
|
2007-07-15 22:51:12 +00:00
|
|
|
{ \
|
2007-07-15 23:16:47 +00:00
|
|
|
$$(call progress,Collecting $(SCAN_NAME) info: $(SCAN_DIR)/$(2)) \
|
|
|
|
echo Source-Makefile: $(SCAN_DIR)/$(2)/Makefile; \
|
2015-02-09 12:09:31 +00:00
|
|
|
$(if $(3),echo Override: $(3),true); \
|
2014-08-05 11:24:24 +00:00
|
|
|
$(NO_TRACE_MAKE) --no-print-dir -r DUMP=1 FEED="$(call feedname,$(2))" -C $(SCAN_DIR)/$(2) $(SCAN_MAKEOPTS) 2>/dev/null || { \
|
2011-04-06 14:48:59 +00:00
|
|
|
mkdir -p "$(TOPDIR)/logs/$(SCAN_DIR)/$(2)"; \
|
2014-08-05 11:24:24 +00:00
|
|
|
$(NO_TRACE_MAKE) --no-print-dir -r DUMP=1 FEED="$(call feedname,$(2))" -C $(SCAN_DIR)/$(2) $(SCAN_MAKEOPTS) > $(TOPDIR)/logs/$(SCAN_DIR)/$(2)/dump.txt 2>&1; \
|
2011-04-06 14:48:59 +00:00
|
|
|
$$(call progress,ERROR: please fix $(SCAN_DIR)/$(2)/Makefile - see logs/$(SCAN_DIR)/$(2)/dump.txt for details\n) \
|
|
|
|
rm -f $$@; \
|
|
|
|
}; \
|
2007-02-27 21:14:00 +00:00
|
|
|
echo; \
|
2016-10-02 09:40:06 +00:00
|
|
|
} > $$@.tmp
|
|
|
|
mv $$@.tmp $$@
|
2007-02-27 21:14:00 +00:00
|
|
|
endef
|
2007-07-15 22:51:12 +00:00
|
|
|
|
2015-02-09 12:09:31 +00:00
|
|
|
$(OVERRIDELIST):
|
|
|
|
rm -f $(TMP_DIR)/info/.overrides-$(SCAN_TARGET)-*
|
|
|
|
touch $@
|
|
|
|
|
2015-03-15 11:07:29 +00:00
|
|
|
ifeq ($(SCAN_NAME),target)
|
|
|
|
GREP_STRING=BuildTarget
|
|
|
|
else
|
2017-01-10 15:25:10 +00:00
|
|
|
GREP_STRING=(Build/DefaultTargets|BuildPackage|KernelPackage)
|
2015-03-15 11:07:29 +00:00
|
|
|
endif
|
|
|
|
|
2015-02-09 12:09:31 +00:00
|
|
|
$(FILELIST): $(OVERRIDELIST)
|
2007-09-23 02:39:01 +00:00
|
|
|
rm -f $(TMP_DIR)/info/.files-$(SCAN_TARGET)-*
|
2017-02-20 12:03:49 +00:00
|
|
|
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 > $@
|
2007-07-15 22:51:12 +00:00
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
$(TMP_DIR)/info/.files-$(SCAN_TARGET).mk: $(FILELIST)
|
2007-07-15 22:51:12 +00:00
|
|
|
( \
|
|
|
|
cat $< | awk '{print "$(SCAN_DIR)/" $$0 "/Makefile" }' | xargs grep -HE '^ *SCAN_DEPS *= *' | awk -F: '{ gsub(/^.*DEPS *= */, "", $$2); print "DEPS_" $$1 "=" $$2 }'; \
|
2015-02-09 12:09:31 +00:00
|
|
|
awk -F/ -v deps="$$DEPS" -v of="$(OVERRIDELIST)" ' \
|
|
|
|
BEGIN { \
|
|
|
|
while (getline < (of)) \
|
|
|
|
override[$$NF]=$$0; \
|
|
|
|
close(of) \
|
|
|
|
} \
|
|
|
|
{ \
|
2007-07-15 23:16:47 +00:00
|
|
|
info=$$0; \
|
|
|
|
gsub(/\//, "_", info); \
|
2015-02-09 12:09:31 +00:00
|
|
|
dir=$$0; \
|
|
|
|
pkg=""; \
|
|
|
|
if($$NF in override) \
|
|
|
|
pkg=override[$$NF]; \
|
|
|
|
print "$$(eval $$(call PackageDir," info "," dir "," pkg "))"; \
|
2007-07-15 22:51:12 +00:00
|
|
|
} ' < $<; \
|
|
|
|
true; \
|
2016-10-02 09:40:06 +00:00
|
|
|
) > $@.tmp
|
|
|
|
mv $@.tmp $@
|
2007-07-15 22:51:12 +00:00
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
-include $(TMP_DIR)/info/.files-$(SCAN_TARGET).mk
|
2007-07-15 22:51:12 +00:00
|
|
|
|
2007-12-14 00:33:25 +00:00
|
|
|
$(TARGET_STAMP)::
|
2008-06-09 15:38:45 +00:00
|
|
|
+( \
|
2007-07-15 22:51:12 +00:00
|
|
|
$(NO_TRACE_MAKE) $(FILELIST); \
|
2016-12-25 15:40:05 +00:00
|
|
|
MD5SUM=$$(cat $(FILELIST) $(OVERRIDELIST) | mkhash md5 | awk '{print $$1}'); \
|
2007-07-15 22:51:12 +00:00
|
|
|
[ -f "$@.$$MD5SUM" ] || { \
|
|
|
|
rm -f $@.*; \
|
|
|
|
touch $@.$$MD5SUM; \
|
|
|
|
touch $@; \
|
|
|
|
} \
|
|
|
|
)
|
|
|
|
|
2016-11-23 16:03:38 +00:00
|
|
|
$(TMP_DIR)/.$(SCAN_TARGET): $(TARGET_STAMP)
|
2007-07-15 22:51:12 +00:00
|
|
|
$(call progress,Collecting $(SCAN_NAME) info: merging...)
|
2009-05-27 02:50:53 +00:00
|
|
|
-cat $(FILELIST) | awk '{gsub(/\//, "_", $$0);print "$(TMP_DIR)/info/.$(SCAN_TARGET)-" $$0}' | xargs cat > $@ 2>/dev/null
|
2007-07-15 22:51:12 +00:00
|
|
|
$(call progress,Collecting $(SCAN_NAME) info: done)
|
|
|
|
echo
|
2007-02-27 21:14:00 +00:00
|
|
|
|
|
|
|
FORCE:
|
|
|
|
.PHONY: FORCE
|
2007-07-28 13:00:43 +00:00
|
|
|
.NOTPARALLEL:
|