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)
|
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
|
|
|
|
|
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)
|
|
|
|
$(TMP_DIR)/info/.$(SCAN_TARGET)-$(1): $(SCAN_DIR)/$(2)/Makefile $(SCAN_STAMP) $(foreach DEP,$(DEPS_$(SCAN_DIR)/$(1)/Makefile) $(SCAN_DEPS),$(wildcard $(if $(filter /%,$(DEP)),$(DEP),$(SCAN_DIR)/$(1)/$(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; \
|
2011-04-06 22:48:59 +08:00
|
|
|
$(NO_TRACE_MAKE) --no-print-dir -r DUMP=1 -C $(SCAN_DIR)/$(2) $(SCAN_MAKEOPTS) 2>/dev/null || { \
|
|
|
|
mkdir -p "$(TOPDIR)/logs/$(SCAN_DIR)/$(2)"; \
|
|
|
|
$(NO_TRACE_MAKE) --no-print-dir -r DUMP=1 -C $(SCAN_DIR)/$(2) $(SCAN_MAKEOPTS) > $(TOPDIR)/logs/$(SCAN_DIR)/$(2)/dump.txt 2>&1; \
|
|
|
|
$$(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
|
|
|
|
|
|
|
$(FILELIST):
|
2007-09-23 10:39:01 +08:00
|
|
|
rm -f $(TMP_DIR)/info/.files-$(SCAN_TARGET)-*
|
2007-09-09 03:55:42 +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 > $@
|
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 }'; \
|
|
|
|
awk -v deps="$$DEPS" '{ \
|
2007-07-16 07:16:47 +08:00
|
|
|
info=$$0; \
|
|
|
|
gsub(/\//, "_", info); \
|
|
|
|
print "$$(eval $$(call PackageDir," info "," $$0 "))"; \
|
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); \
|
2008-09-02 18:57:56 +08:00
|
|
|
MD5SUM=$$(cat $(FILELIST) | (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:
|