Commonalise config.gen/{arch,kernel}.in generation.
/trunk/kconfig/kconfig.mk | 76 34 42 0 ++++++++++++++++++++++++-----------------------------
1 file changed, 34 insertions(+), 42 deletions(-)
1 # ===========================================================================
2 # crosstool-NG configuration targets
3 # These targets are used from top-level makefile
5 # Derive the project version from, well, the project version:
6 export PROJECTVERSION=$(CT_VERSION)
8 KCONFIG_TOP = config/config.in
9 obj = $(CT_TOP_DIR)/kconfig
10 PHONY += clean help oldconfig menuconfig config defoldconfig
12 # Darwin (MacOS-X) does not have proper libintl support
13 ifeq ($(shell uname -s),Darwin)
17 ifneq ($(KBUILD_NO_NLS),)
18 CFLAGS += -DKBUILD_NO_NLS
21 # Build a list of all config files
22 ARCH_CONFIG_FILES = $(wildcard $(CT_LIB_DIR)/config/arch/*.in)
23 KERNEL_CONFIG_FILES = $(wildcard $(CT_LIB_DIR)/config/kernel/*.in)
24 DEBUG_CONFIG_FILES = $(wildcard $(CT_LIB_DIR)/config/debug/*.in)
25 TOOLS_CONFIG_FILES = $(wildcard $(CT_LIB_DIR)/config/tools/*.in)
27 STATIC_CONFIG_FILES = $(shell find $(CT_LIB_DIR)/config -type f -name '*.in')
28 GEN_CONFIG_FILES=$(CT_TOP_DIR)/config.gen/arch.in \
29 $(CT_TOP_DIR)/config.gen/kernel.in \
30 $(CT_TOP_DIR)/config.gen/debug.in \
31 $(CT_TOP_DIR)/config.gen/tools.in
33 CONFIG_FILES=$(STATIC_CONFIG_FILES) $(GEN_CONFIG_FILES)
36 ARCHS = $(patsubst $(CT_LIB_DIR)/config/arch/%.in,%,$(ARCH_CONFIG_FILES))
37 KERNELS = $(patsubst $(CT_LIB_DIR)/config/kernel/%.in,%,$(KERNEL_CONFIG_FILES))
39 $(GEN_CONFIG_FILES): $(CT_TOP_DIR)/config.gen \
40 $(CT_LIB_DIR)/kconfig/kconfig.mk
42 $(CT_TOP_DIR)/config.gen: $(KCONFIG_TOP)
43 @mkdir -p $(CT_TOP_DIR)/config.gen
45 # Function build_gen_choice_in:
46 # $1 : destination file
47 # $2 : name for the entries family (eg. Architecture, kernel...)
48 # $3 : prefix for the choice entries (eg. ARCH, KERNEL...)
49 # $4 : base directory containing config files
50 # $5 : list of config entries (eg. for architectures: "alpha arm ia64"...,
51 # and for kernels: "bare-metal linux"...)
52 # Example to build the kernels generated config file:
53 # $(call build_gen_choice_in,config.gen/kernel.in,Kernel,KERNEL,config/kernel,$(KERNELS))
54 define build_gen_choice_in
56 @(echo "# $(2) menu"; \
57 echo "# Generated file, do not edit!!!"; \
59 for entry in $(5); do \
60 file="$(4)/$${entry}.in"; \
61 _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;'); \
62 echo "config $(3)_$${_entry}"; \
64 printf " prompt \"$${entry}"; \
65 if grep -E '^# +EXPERIMENTAL$$' $${file} >/dev/null 2>&1; then \
66 echo " (EXPERIMENTAL)\""; \
67 echo " depends on EXPERIMENTAL"; \
71 echo "if $(3)_$${_entry}"; \
73 echo " default \"$${entry}\" if $(3)_$${_entry}"; \
74 echo "source $${file}"; \
81 $(CT_TOP_DIR)/config.gen/arch.in: $(ARCH_CONFIG_FILES)
82 $(call build_gen_choice_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Architecture,ARCH,config/arch,$(ARCHS))
84 $(CT_TOP_DIR)/config.gen/kernel.in: $(KERNEL_CONFIG_FILES)
85 $(call build_gen_choice_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Kernel,KERNEL,config/kernel,$(KERNELS))
87 $(CT_TOP_DIR)/config.gen/debug.in: $(DEBUG_CONFIG_FILES)
88 @echo ' IN config.gen/debug.in'
89 @(echo "# Debug facilities menu"; \
90 echo "# Generated file, do not edit!!!"; \
91 echo "menu \"Debug facilities\""; \
92 for f in $(patsubst $(CT_LIB_DIR)/%,%,$(DEBUG_CONFIG_FILES)); do \
93 echo "source $${f}"; \
98 $(CT_TOP_DIR)/config.gen/tools.in: $(TOOLS_CONFIG_FILES)
99 @echo ' IN config.gen/tools.in'
100 @(echo "# Tools facilities menu"; \
101 echo "# Generated file, do not edit!!!"; \
102 echo "menu \"Tools facilities\""; \
103 for f in $(patsubst $(CT_LIB_DIR)/%,%,$(TOOLS_CONFIG_FILES)); do \
104 echo "source $${f}"; \
109 config menuconfig oldconfig defoldconfig: $(KCONFIG_TOP)
112 @ln -sf $(CT_LIB_DIR)/config config
114 menuconfig: $(CONFIG_FILES) $(obj)/mconf
115 @$(obj)/mconf $(KCONFIG_TOP)
117 config: $(CONFIG_FILES) $(obj)/conf
118 @$(obj)/conf $(KCONFIG_TOP)
120 oldconfig: $(CONFIG_FILES) $(obj)/conf
121 @$(obj)/conf -s $(KCONFIG_TOP)
123 defoldconfig: $(CONFIG_FILES) $(obj)/conf
124 @yes "" |$(obj)/conf -s $(KCONFIG_TOP)
126 # Help text used by make help
128 @echo ' config - Update current config using a line-oriented program'
129 @echo ' menuconfig - Update current config using a menu based program'
130 @echo ' oldconfig - Update current config using a provided .config as base'
131 @echo ' build log piped into stdin'
135 SHIPPED := $(CT_LIB_DIR)/kconfig/zconf.tab.c $(CT_LIB_DIR)/kconfig/lex.zconf.c $(CT_LIB_DIR)/kconfig/zconf.hash.c
137 $(obj)/conf $(obj)/mconf: $(obj)
142 HEADERS = $(CT_LIB_DIR)/kconfig/expr.h \
143 $(CT_LIB_DIR)/kconfig/lkc.h \
144 $(CT_LIB_DIR)/kconfig/lkc_proto.h
146 FILES = $(CT_LIB_DIR)/kconfig/confdata.c \
147 $(CT_LIB_DIR)/kconfig/expr.c \
148 $(CT_LIB_DIR)/kconfig/menu.c \
149 $(CT_LIB_DIR)/kconfig/symbol.c \
150 $(CT_LIB_DIR)/kconfig/util.c
152 $(obj)/mconf: $(SHIPPED) $(CT_LIB_DIR)/kconfig/mconf.c \
153 $(HEADERS) $(FILES) \
154 $(CT_LIB_DIR)/kconfig/kconfig.mk
155 @echo ' LD kconfig/mconf'
156 @$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{mconf.c,zconf.tab.c,lxdialog/*.c} \
157 $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ccflags) \
158 $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ldflags $(HOST_CC))
160 $(obj)/conf: $(SHIPPED) $(CT_LIB_DIR)/kconfig/conf.c \
161 $(HEADERS) $(FILES) \
162 $(CT_LIB_DIR)/kconfig/kconfig.mk
163 @echo ' LD kconfig/conf'
164 @$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{conf.c,zconf.tab.c}
167 @rm -f $(CT_TOP_DIR)/kconfig/{,m}conf
168 @rmdir --ignore-fail-on-non-empty $(CT_TOP_DIR)/kconfig 2>/dev/null || true
169 @rm -f $(CT_TOP_DIR)/config 2>/dev/null || true
170 @rm -rf $(CT_TOP_DIR)/config.gen