-.pkginfo:
- @echo Collecting package info...
- @-for dir in package/*/; do \
- echo Source-Makefile: $${dir}Makefile; \
- $(NO_TRACE_MAKE) --no-print-dir DUMP=1 -C $$dir 2>&- || true; \
- done > $@
+package/%/Makefile: ;
+target/%/Makefile: ;
+
+SCAN_COOKIE?=$(shell echo $$$$)
+export SCAN_COOKIE
+
+tmp/.packageinfo tmp/.targetinfo: FORCE
+ mkdir -p tmp/info
+ $(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPS="profiles/*.mk $(TOPDIR)/include/kernel*.mk" SCAN_DEPTH=2 SCAN_EXTRA=""
+ $(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPS="$(TOPDIR)/include/package*.mk" SCAN_DEPTH=4 SCAN_EXTRA=""
+
+tmpinfo-clean: FORCE
+ -rm -rf tmp/.*info
+
+tmp/.config-%.in: tmp/.%info scripts/metadata.pl
+ ./scripts/metadata.pl $*_config < $< > $@ || rm -f $@
+
+.config: ./scripts/config/conf tmp/.config-target.in tmp/.config-package.in
+ if [ \! -f .config ]; then \
+ [ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \
+ $(NO_TRACE_MAKE) menuconfig; \
+ fi
+ $< -D .config Config.in &> /dev/null