2007-02-28 05:14:00 +08:00
|
|
|
include $(TOPDIR)/include/verbose.mk
|
2007-07-16 15:19:45 +08:00
|
|
|
TMP_DIR:=$(TOPDIR)/tmp
|
2007-02-28 05:14:00 +08:00
|
|
|
|
2007-09-23 10:39:01 +08:00
|
|
|
all: $(TMP_DIR)/.$(SCAN_TARGET)
|
2007-07-16 06:51:12 +08:00
|
|
|
|
2007-07-16 15:19:45 +08:00
|
|
|
include $(TOPDIR)/include/host.mk
|
|
|
|
|
2007-04-04 07:03:56 +08:00
|
|
|
SCAN_TARGET ?= packageinfo
|
2007-02-28 05:14:00 +08:00
|
|
|
SCAN_NAME ?= package
|
|
|
|
SCAN_DIR ?= package
|
2007-09-23 10:39:01 +08:00
|
|
|
TARGET_STAMP:=$(TMP_DIR)/info/.files-$(SCAN_TARGET).stamp
|
|
|
|
FILELIST:=$(TMP_DIR)/info/.files-$(SCAN_TARGET)-$(SCAN_COOKIE)
|
2015-02-09 20:09:31 +08:00
|
|
|
OVERRIDELIST:=$(TMP_DIR)/info/.overrides-$(SCAN_TARGET)-$(SCAN_COOKIE)
|
2007-02-28 05:14:00 +08:00
|
|
|
|
|
|
|
ifeq ($(IS_TTY),1)
|
|
|
|
define progress
|
|
|
|
printf "\033[M\r$(1)" >&2;
|
|
|
|
endef
|
|
|
|
else
|
|
|
|
define progress
|
2008-01-26 20:19:45 +08:00
|
|
|
:;
|
2007-02-28 05:14:00 +08:00
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2014-08-05 19:24:24 +08:00
|
|
|
define feedname
|
|
|
|
$(if $(patsubst feeds/%,,$(1)),,$(word 2,$(subst /, ,$(1))))
|
|
|
|
endef
|
|
|
|
|
2007-07-16 06:51:12 +08:00
|
|
|
define PackageDir
|
2007-09-23 10:39:01 +08:00
|
|
|
$(TMP_DIR)/.$(SCAN_TARGET): $(TMP_DIR)/info/.$(SCAN_TARGET)-$(1)
|
2013-07-19 18:52:56 +08:00
|
|
|
$(TMP_DIR)/info/.$(SCAN_TARGET)-$(1): $(SCAN_DIR)/$(2)/Makefile $(SCAN_STAMP) $(foreach DEP,$(DEPS_$(SCAN_DIR)/$(2)/Makefile) $(SCAN_DEPS),$(wildcard $(if $(filter /%,$(DEP)),$(DEP),$(SCAN_DIR)/$(2)/$(DEP))))
|
2007-07-16 06:51:12 +08:00
|
|
|
{ \
|
2007-07-16 07:16:47 +08:00
|
|
|
$$(call progress,Collecting $(SCAN_NAME) info: $(SCAN_DIR)/$(2)) \
|
|
|
|
echo Source-Makefile: $(SCAN_DIR)/$(2)/Makefile; \
|
2015-02-09 20:09:31 +08:00
|
|
|
$(if $(3),echo Override: $(3),true); \
|
2014-08-05 19:24:24 +08: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 22:48:59 +08:00
|
|
|
mkdir -p "$(TOPDIR)/logs/$(SCAN_DIR)/$(2)"; \
|
2014-08-05 19:24:24 +08: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 22:48:59 +08:00
|
|
|
$$(call progress,ERROR: please fix $(SCAN_DIR)/$(2)/Makefile - see logs/$(SCAN_DIR)/$(2)/dump.txt for details\n) \
|
|
|
|
rm -f $$@; \
|
|
|
|
}; \
|
2007-02-28 05:14:00 +08:00
|
|
|
echo; \
|
2007-04-01 22:12:42 +08:00
|
|
|
} > $$@ || true
|
2007-02-28 05:14:00 +08:00
|
|
|
endef
|
2007-07-16 06:51:12 +08:00
|
|
|
|
2015-02-09 20:09:31 +08:00
|
|
|
$(OVERRIDELIST):
|
|
|
|
rm -f $(TMP_DIR)/info/.overrides-$(SCAN_TARGET)-*
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
$(FILELIST): $(OVERRIDELIST)
|
2007-09-23 10:39:01 +08:00
|
|
|
rm -f $(TMP_DIR)/info/.files-$(SCAN_TARGET)-*
|
2015-02-09 20:09:31 +08:00
|
|
|
$(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 > $@
|
2007-07-16 06:51:12 +08:00
|
|
|
|
2007-09-23 10:39:01 +08:00
|
|
|
$(TMP_DIR)/info/.files-$(SCAN_TARGET).mk: $(FILELIST)
|
2007-07-16 06:51:12 +08: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 20:09:31 +08:00
|
|
|
awk -F/ -v deps="$$DEPS" -v of="$(OVERRIDELIST)" ' \
|
|
|
|
BEGIN { \
|
|
|
|
while (getline < (of)) \
|
|
|
|
override[$$NF]=$$0; \
|
|
|
|
close(of) \
|
|
|
|
} \
|
|
|
|
{ \
|
2007-07-16 07:16:47 +08:00
|
|
|
info=$$0; \
|
|
|
|
gsub(/\//, "_", info); \
|
2015-02-09 20:09:31 +08:00
|
|
|
dir=$$0; \
|
|
|
|
pkg=""; \
|
|
|
|
if($$NF in override) \
|
|
|
|
pkg=override[$$NF]; \
|
|
|
|
print "$$(eval $$(call PackageDir," info "," dir "," pkg "))"; \
|
2007-07-16 06:51:12 +08:00
|
|
|
} ' < $<; \
|
|
|
|
true; \
|
|
|
|
) > $@
|
|
|
|
|
2007-09-23 10:39:01 +08:00
|
|
|
-include $(TMP_DIR)/info/.files-$(SCAN_TARGET).mk
|
2007-07-16 06:51:12 +08:00
|
|
|
|
2007-12-14 08:33:25 +08:00
|
|
|
$(TARGET_STAMP)::
|
2008-06-09 23:38:45 +08:00
|
|
|
+( \
|
2007-07-16 06:51:12 +08:00
|
|
|
$(NO_TRACE_MAKE) $(FILELIST); \
|
2015-02-09 20:09:31 +08:00
|
|
|
MD5SUM=$$(cat $(FILELIST) $(OVERRIDELIST) | (md5sum || md5) 2>/dev/null | awk '{print $$1}'); \
|
2007-07-16 06:51:12 +08:00
|
|
|
[ -f "$@.$$MD5SUM" ] || { \
|
|
|
|
rm -f $@.*; \
|
|
|
|
touch $@.$$MD5SUM; \
|
|
|
|
touch $@; \
|
|
|
|
} \
|
|
|
|
)
|
|
|
|
|
2007-09-23 10:39:01 +08:00
|
|
|
$(TMP_DIR)/.$(SCAN_TARGET): $(TARGET_STAMP) $(SCAN_STAMP)
|
2007-07-16 06:51:12 +08:00
|
|
|
$(call progress,Collecting $(SCAN_NAME) info: merging...)
|
2009-05-27 10:50:53 +08:00
|
|
|
-cat $(FILELIST) | awk '{gsub(/\//, "_", $$0);print "$(TMP_DIR)/info/.$(SCAN_TARGET)-" $$0}' | xargs cat > $@ 2>/dev/null
|
2007-07-16 06:51:12 +08:00
|
|
|
$(call progress,Collecting $(SCAN_NAME) info: done)
|
|
|
|
echo
|
2007-02-28 05:14:00 +08:00
|
|
|
|
|
|
|
FORCE:
|
|
|
|
.PHONY: FORCE
|
2007-07-28 21:00:43 +08:00
|
|
|
.NOTPARALLEL:
|