mac80211: rt2x00: clear IV's on start to fix AP mode regression
[openwrt/openwrt.git] / include / scan.mk
1 include $(TOPDIR)/include/verbose.mk
2 TMP_DIR:=$(TOPDIR)/tmp
3
4 all: $(TMP_DIR)/.$(SCAN_TARGET)
5
6 SCAN_TARGET ?= packageinfo
7 SCAN_NAME ?= package
8 SCAN_DIR ?= package
9 TARGET_STAMP:=$(TMP_DIR)/info/.files-$(SCAN_TARGET).stamp
10 FILELIST:=$(TMP_DIR)/info/.files-$(SCAN_TARGET)-$(SCAN_COOKIE)
11 OVERRIDELIST:=$(TMP_DIR)/info/.overrides-$(SCAN_TARGET)-$(SCAN_COOKIE)
12
13 export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH)
14
15 ifeq ($(SCAN_NAME),target)
16 SCAN_DEPS=image/Makefile profiles/*.mk $(TOPDIR)/include/kernel*.mk $(TOPDIR)/include/target.mk image/*.mk
17 else
18 SCAN_DEPS=$(TOPDIR)/include/package*.mk
19 endif
20
21 ifeq ($(IS_TTY),1)
22 ifneq ($(strip $(NO_COLOR)),1)
23 define progress
24 printf "\033[M\r$(1)" >&2;
25 endef
26 else
27 define progress
28 printf "\r$(1)" >&2;
29 endef
30 endif
31 else
32 define progress
33 :;
34 endef
35 endif
36
37 define feedname
38 $(if $(patsubst feeds/%,,$(1)),,$(word 2,$(subst /, ,$(1))))
39 endef
40
41 define PackageDir
42 $(TMP_DIR)/.$(SCAN_TARGET): $(TMP_DIR)/info/.$(SCAN_TARGET)-$(1)
43 $(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))))
44 { \
45 $$(call progress,Collecting $(SCAN_NAME) info: $(SCAN_DIR)/$(2)) \
46 echo Source-Makefile: $(SCAN_DIR)/$(2)/Makefile; \
47 $(if $(3),echo Override: $(3),true); \
48 $(NO_TRACE_MAKE) --no-print-dir -r DUMP=1 FEED="$(call feedname,$(2))" -C $(SCAN_DIR)/$(2) $(SCAN_MAKEOPTS) 2>/dev/null || { \
49 mkdir -p "$(TOPDIR)/logs/$(SCAN_DIR)/$(2)"; \
50 $(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; \
51 $$(call progress,ERROR: please fix $(SCAN_DIR)/$(2)/Makefile - see logs/$(SCAN_DIR)/$(2)/dump.txt for details\n) \
52 rm -f $$@; \
53 }; \
54 echo; \
55 } > $$@.tmp
56 mv $$@.tmp $$@
57 endef
58
59 $(OVERRIDELIST):
60 rm -f $(TMP_DIR)/info/.overrides-$(SCAN_TARGET)-*
61 touch $@
62
63 ifeq ($(SCAN_NAME),target)
64 GREP_STRING=BuildTarget
65 else
66 GREP_STRING=(Build/DefaultTargets|BuildPackage|KernelPackage)
67 endif
68
69 $(FILELIST): $(OVERRIDELIST)
70 rm -f $(TMP_DIR)/info/.files-$(SCAN_TARGET)-*
71 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 > $@
72
73 $(TMP_DIR)/info/.files-$(SCAN_TARGET).mk: $(FILELIST)
74 ( \
75 cat $< | awk '{print "$(SCAN_DIR)/" $$0 "/Makefile" }' | xargs grep -HE '^ *SCAN_DEPS *= *' | awk -F: '{ gsub(/^.*DEPS *= */, "", $$2); print "DEPS_" $$1 "=" $$2 }'; \
76 awk -F/ -v deps="$$DEPS" -v of="$(OVERRIDELIST)" ' \
77 BEGIN { \
78 while (getline < (of)) \
79 override[$$NF]=$$0; \
80 close(of) \
81 } \
82 { \
83 info=$$0; \
84 gsub(/\//, "_", info); \
85 dir=$$0; \
86 pkg=""; \
87 if($$NF in override) \
88 pkg=override[$$NF]; \
89 print "$$(eval $$(call PackageDir," info "," dir "," pkg "))"; \
90 } ' < $<; \
91 true; \
92 ) > $@.tmp
93 mv $@.tmp $@
94
95 -include $(TMP_DIR)/info/.files-$(SCAN_TARGET).mk
96
97 $(TARGET_STAMP)::
98 +( \
99 $(NO_TRACE_MAKE) $(FILELIST); \
100 MD5SUM=$$(cat $(FILELIST) $(OVERRIDELIST) | mkhash md5 | awk '{print $$1}'); \
101 [ -f "$@.$$MD5SUM" ] || { \
102 rm -f $@.*; \
103 touch $@.$$MD5SUM; \
104 touch $@; \
105 } \
106 )
107
108 $(TMP_DIR)/.$(SCAN_TARGET): $(TARGET_STAMP)
109 $(call progress,Collecting $(SCAN_NAME) info: merging...)
110 -cat $(FILELIST) | awk '{gsub(/\//, "_", $$0);print "$(TMP_DIR)/info/.$(SCAN_TARGET)-" $$0}' | xargs cat > $@ 2>/dev/null
111 $(call progress,Collecting $(SCAN_NAME) info: done)
112 echo
113
114 FORCE:
115 .PHONY: FORCE
116 .NOTPARALLEL: