2007-02-27 22:14:00 +01:00
|
|
|
include $(TOPDIR)/include/verbose.mk
|
2007-07-16 09:19:45 +02:00
|
|
|
TMP_DIR:=$(TOPDIR)/tmp
|
2007-02-27 22:14:00 +01:00
|
|
|
|
2007-09-23 04:39:01 +02:00
|
|
|
all: $(TMP_DIR)/.$(SCAN_TARGET)
|
2007-07-16 00:51:12 +02:00
|
|
|
|
2007-07-16 09:19:45 +02:00
|
|
|
include $(TOPDIR)/include/host.mk
|
|
|
|
|
2007-04-04 01:03:56 +02:00
|
|
|
SCAN_TARGET ?= packageinfo
|
2007-02-27 22:14:00 +01:00
|
|
|
SCAN_NAME ?= package
|
|
|
|
SCAN_DIR ?= package
|
2007-09-23 04:39:01 +02:00
|
|
|
TARGET_STAMP:=$(TMP_DIR)/info/.files-$(SCAN_TARGET).stamp
|
|
|
|
FILELIST:=$(TMP_DIR)/info/.files-$(SCAN_TARGET)-$(SCAN_COOKIE)
|
2007-02-27 22:14:00 +01:00
|
|
|
|
|
|
|
ifeq ($(IS_TTY),1)
|
|
|
|
define progress
|
|
|
|
printf "\033[M\r$(1)" >&2;
|
|
|
|
endef
|
|
|
|
else
|
|
|
|
define progress
|
2008-01-26 13:19:45 +01:00
|
|
|
:;
|
2007-02-27 22:14:00 +01:00
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2007-07-16 00:51:12 +02:00
|
|
|
define PackageDir
|
2007-09-23 04:39:01 +02: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 00:51:12 +02:00
|
|
|
{ \
|
2007-07-16 01:16:47 +02:00
|
|
|
$$(call progress,Collecting $(SCAN_NAME) info: $(SCAN_DIR)/$(2)) \
|
|
|
|
echo Source-Makefile: $(SCAN_DIR)/$(2)/Makefile; \
|
2009-03-03 15:07:39 +01:00
|
|
|
$(NO_TRACE_MAKE) --no-print-dir -r DUMP=1 -C $(SCAN_DIR)/$(2) $(SCAN_MAKEOPTS) 2>/dev/null || echo "ERROR: please fix $(SCAN_DIR)/$(2)/Makefile" >&2; \
|
2007-02-27 22:14:00 +01:00
|
|
|
echo; \
|
2007-04-01 16:12:42 +02:00
|
|
|
} > $$@ || true
|
2007-02-27 22:14:00 +01:00
|
|
|
endef
|
2007-07-16 00:51:12 +02:00
|
|
|
|
|
|
|
$(FILELIST):
|
2007-09-23 04:39:01 +02:00
|
|
|
rm -f $(TMP_DIR)/info/.files-$(SCAN_TARGET)-*
|
2007-09-08 21:55:42 +02: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 00:51:12 +02:00
|
|
|
|
2007-09-23 04:39:01 +02:00
|
|
|
$(TMP_DIR)/info/.files-$(SCAN_TARGET).mk: $(FILELIST)
|
2007-07-16 00:51:12 +02: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 01:16:47 +02:00
|
|
|
info=$$0; \
|
|
|
|
gsub(/\//, "_", info); \
|
|
|
|
print "$$(eval $$(call PackageDir," info "," $$0 "))"; \
|
2007-07-16 00:51:12 +02:00
|
|
|
} ' < $<; \
|
|
|
|
true; \
|
|
|
|
) > $@
|
|
|
|
|
2007-09-23 04:39:01 +02:00
|
|
|
-include $(TMP_DIR)/info/.files-$(SCAN_TARGET).mk
|
2007-07-16 00:51:12 +02:00
|
|
|
|
2007-12-14 01:33:25 +01:00
|
|
|
$(TARGET_STAMP)::
|
2008-06-09 17:38:45 +02:00
|
|
|
+( \
|
2007-07-16 00:51:12 +02:00
|
|
|
$(NO_TRACE_MAKE) $(FILELIST); \
|
2008-09-02 12:57:56 +02:00
|
|
|
MD5SUM=$$(cat $(FILELIST) | (md5sum || md5) 2>/dev/null | awk '{print $$1}'); \
|
2007-07-16 00:51:12 +02:00
|
|
|
[ -f "$@.$$MD5SUM" ] || { \
|
|
|
|
rm -f $@.*; \
|
|
|
|
touch $@.$$MD5SUM; \
|
|
|
|
touch $@; \
|
|
|
|
} \
|
|
|
|
)
|
|
|
|
|
2007-09-23 04:39:01 +02:00
|
|
|
$(TMP_DIR)/.$(SCAN_TARGET): $(TARGET_STAMP) $(SCAN_STAMP)
|
2007-07-16 00:51:12 +02:00
|
|
|
$(call progress,Collecting $(SCAN_NAME) info: merging...)
|
2007-09-23 04:39:01 +02:00
|
|
|
cat $(FILELIST) | awk '{gsub(/\//, "_", $$0);print "$(TMP_DIR)/info/.$(SCAN_TARGET)-" $$0}' | xargs cat > $@
|
2007-07-16 00:51:12 +02:00
|
|
|
$(call progress,Collecting $(SCAN_NAME) info: done)
|
|
|
|
echo
|
2007-02-27 22:14:00 +01:00
|
|
|
|
|
|
|
FORCE:
|
|
|
|
.PHONY: FORCE
|
2007-07-28 15:00:43 +02:00
|
|
|
.NOTPARALLEL:
|