+define extract_var
+ $(1)=$$((cat $(2); echo printit:; \
+ echo ' @echo $$($(3))') | \
+ $(MAKE) --no-print-directory -f - printit)
+endef
+
+define create_kconfig
+ $(VERBOSE)echo "# vi:set ft=kconfig:" > $(1)
+ $(VERBOSE)echo "# This Kconfig is auto-generated." >> $(1)
+ $(VERBOSE)pt=""; \
+ while IFS="" read l; do \
+ if [ "$$l" = "INSERT_PLATFORMS" ]; then \
+ for p in $(wildcard $(L4DIR)/conf/platforms/*.conf \
+ $(L4DIR)/mk/platforms/*.conf); do \
+ $(call extract_var,n,$$p,PLATFORM_NAME); \
+ pn=$${p##*/}; \
+ pn=$${pn%.conf}; \
+ echo "config PLATFORM_TYPE_$${pn}" >> $(1); \
+ echo " bool \"$$n\"" >> $(1); \
+ pt="$$pt default \"$$pn\" if PLATFORM_TYPE_$${pn}\n"; \
+ $(call extract_var,n,$$p,PLATFORM_ARCH); \
+ dep=""; \
+ for a in $$n; do \
+ if [ -z "$$dep" ]; then \
+ dep=" depends on BUILD_ARCH_$$a"; \
+ else \
+ dep="$$dep || BUILD_ARCH_$$a"; \
+ fi; \
+ done; \
+ echo "$$dep" >> $(1); \
+ echo "" >> $(1); \
+ done; \
+ elif [ "$$l" = "INSERT_PLATFORM_TYPES" ]; then \
+ echo "config PLATFORM_TYPE" >> $(1); \
+ echo " string" >> $(1); \
+ echo -e "$$pt" >> $(1); \
+ else \
+ echo "$$l" >> $(1); \
+ fi; \
+ done < $(2)
+endef
+
+KCONFIGS_ARCH := $(wildcard $(L4DIR)/mk/arch/Kconfig.*.inc)
+
+$(KCONFIG_FILE): $(KCONFIG_FILE_SRC) Makefile $(wildcard $(L4DIR)/conf/platforms/*.conf $(L4DIR)/conf/platforms/*.conf) \
+ $(KCONFIGS_ARCH)
+ $(VERBOSE)$(L4DIR)/tool/bin/gen_kconfig $(KCONFIG_FILE_SRC) $(KCONFIG_FILE).im $(KCONFIGS_ARCH)
+ +$(call create_kconfig,$@,$(KCONFIG_FILE).im)
+