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-07-16 07:19:45 +00:00
|
|
|
include $(TOPDIR)/include/host.mk
|
|
|
|
|
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)
|
2007-02-27 21:14:00 +00:00
|
|
|
|
|
|
|
ifeq ($(IS_TTY),1)
|
|
|
|
define progress
|
|
|
|
printf "\033[M\r$(1)" >&2;
|
|
|
|
endef
|
|
|
|
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
|
2007-09-23 02:39:01 +00:00
|
|
|
$(TMP_DIR)/.$(SCAN_TARGET): $(TMP_DIR)/info/.$(SCAN_TARGET)-$(1)
|
2013-07-19 10:52:56 +00: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-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; \
|
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; \
|
2007-04-01 14:12:42 +00:00
|
|
|
} > $$@ || true
|
2007-02-27 21:14:00 +00:00
|
|
|
endef
|
2007-07-15 22:51:12 +00:00
|
|
|
|
|
|
|
$(FILELIST):
|
2007-09-23 02:39:01 +00:00
|
|
|
rm -f $(TMP_DIR)/info/.files-$(SCAN_TARGET)-*
|
2015-02-09 12:09:23 +00: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 -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 }'; \
|
|
|
|
awk -v deps="$$DEPS" '{ \
|
2007-07-15 23:16:47 +00:00
|
|
|
info=$$0; \
|
|
|
|
gsub(/\//, "_", info); \
|
|
|
|
print "$$(eval $$(call PackageDir," info "," $$0 "))"; \
|
2007-07-15 22:51:12 +00:00
|
|
|
} ' < $<; \
|
|
|
|
true; \
|
|
|
|
) > $@
|
|
|
|
|
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); \
|
2008-09-02 10:57:56 +00:00
|
|
|
MD5SUM=$$(cat $(FILELIST) | (md5sum || md5) 2>/dev/null | awk '{print $$1}'); \
|
2007-07-15 22:51:12 +00:00
|
|
|
[ -f "$@.$$MD5SUM" ] || { \
|
|
|
|
rm -f $@.*; \
|
|
|
|
touch $@.$$MD5SUM; \
|
|
|
|
touch $@; \
|
|
|
|
} \
|
|
|
|
)
|
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
$(TMP_DIR)/.$(SCAN_TARGET): $(TARGET_STAMP) $(SCAN_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:
|