1 # ===========================================================================
2 # crosstool-NG genererated config files
3 # These targets are used from top-level makefile
5 #-----------------------------------------------------------
6 # List all config files, wether sourced or generated
8 # The top-level config file to be used be configurators
9 KCONFIG_TOP = config/config.in
11 # Build the list of all source config files
12 STATIC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(shell find $(CT_LIB_DIR)/config -type f -name '*.in' 2>/dev/null))
13 # ... and how to access them:
14 $(STATIC_CONFIG_FILES): config
16 # Build a list of per-component-type source config files
17 ARCH_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/arch/*.in))
18 KERNEL_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/kernel/*.in))
19 CC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/cc/*.in))
20 LIBC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/libc/*.in))
21 DEBUG_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/debug/*.in))
23 # Build the list of generated config files
24 GEN_CONFIG_FILES = config.gen/arch.in \
25 config.gen/kernel.in \
29 # ... and how to access them:
30 # Generated files depends on config.mk (this file) because it has the
31 # functions needed to build the genrated files, and thus they might
32 # need re-generation if config.mk changes
33 $(GEN_CONFIG_FILES): config.gen \
34 $(CT_LIB_DIR)/config/config.mk
36 # Helper entry for the configurators
38 config_files: $(STATIC_CONFIG_FILES) $(GEN_CONFIG_FILES)
40 # Where to access to the source config files from
43 $(SILENT)ln -s $(CT_LIB_DIR)/config config
45 # Where to store the generated config files into
47 @$(ECHO) " MKDIR config.gen"
48 $(SILENT)mkdir -p config.gen
50 #-----------------------------------------------------------
51 # Build list of per-component-type items to easily build generated files
53 ARCHS = $(patsubst config/arch/%.in,%,$(ARCH_CONFIG_FILES))
54 KERNELS = $(patsubst config/kernel/%.in,%,$(KERNEL_CONFIG_FILES))
55 CCS = $(patsubst config/cc/%.in,%,$(CC_CONFIG_FILES))
56 LIBCS = $(patsubst config/libc/%.in,%,$(LIBC_CONFIG_FILES))
57 DEBUGS = $(patsubst config/debug/%.in,%,$(DEBUG_CONFIG_FILES))
59 #-----------------------------------------------------------
60 # Helper functions to ease building generated config files
62 # The function 'build_gen_choice_in' builds a choice-menu of a list of
63 # components in the given list, also adding source-ing of associazted
65 # $1 : destination file
66 # $2 : name for the entries family (eg. Architecture, kernel...)
67 # $3 : prefix for the choice entries (eg. ARCH, KERNEL...)
68 # $4 : base directory containing config files
69 # $5 : generate backend conditionals if Y, don't if anything else
70 # $6 : list of config entries (eg. for architectures: "alpha arm ia64"...,
71 # and for kernels: "bare-metal linux"...)
72 # Example to build the kernels generated config file:
73 # $(call build_gen_choice_in,config.gen/kernel.in,Target OS,KERNEL,config/kernel,$(KERNELS))
74 define build_gen_choice_in
76 $(SILENT)(echo "# $(2) menu"; \
77 echo "# Generated file, do not edit!!!"; \
81 echo " prompt \"$(2)\""; \
83 for entry in $(6); do \
84 file="$(4)/$${entry}.in"; \
85 _entry=$$(echo "$${entry}" |$(sed) -r -s -e 's/[-.+]/_/g;'); \
86 echo "config $(3)_$${_entry}"; \
88 echo " prompt \"$${entry}\""; \
89 dep_val=$$($(grep) -E '^# depends on ' $${file} 2>/dev/null); \
90 if [ -n "$${dep_val}" ]; then \
91 echo " $${dep_val#\# }"; \
93 if [ "$(5)" = "Y" ]; then \
94 echo " depends on $(3)_$${_entry}_AVAILABLE"; \
99 for entry in $(6); do \
100 file="$(4)/$${entry}.in"; \
101 _entry=$$(echo "$${entry}" |$(sed) -r -s -e 's/[-.+]/_/g;'); \
103 if [ "$(5)" = "Y" ]; then \
104 echo "config $(3)_$${_entry}_AVAILABLE"; \
106 echo " default n if ! ( BACKEND_$(3) = \"$${entry}\" || BACKEND_$(3) = \"\" || ! BACKEND )"; \
107 echo " default y if BACKEND_$(3) = \"$${entry}\" || BACKEND_$(3) = \"\" || ! BACKEND"; \
109 echo "if $(3)_$${_entry}"; \
110 echo "config $(3)"; \
111 echo " default \"$${entry}\" if $(3)_$${_entry}"; \
112 echo "source \"$${file}\""; \
116 for file in $(wildcard $(4)/*.in-common); do \
117 echo "source \"$${file}\""; \
122 # The function 'build_gen_menu_in' builds a menuconfig for each component in
123 # the given list, source-ing the associated files conditionnaly:
124 # $1 : destination file
125 # $2 : name of entries family (eg. Tools, Debug...)
126 # $3 : prefix for the menu entries (eg. DEBUG)
127 # $4 : base directory containing config files
128 # $5 : list of config entries (eg. for debug: "dmalloc duma gdb"...)
129 # Example to build the generated debug config file:
130 # $(call build_gen_menu_in,config.gen/debug.in,Debug,DEBUG,config/debug,$(DEBUGS))
131 define build_gen_menu_in
133 $(SILENT)(echo "# $(2) facilities menu"; \
134 echo "# Generated file, do not edit!!!"; \
136 for entry in $(5); do \
137 file="$(4)/$${entry}.in"; \
138 _entry=$$(echo "$${entry}" |$(sed) -r -s -e 's/[-.+]/_/g;'); \
139 echo "menuconfig $(3)_$${_entry}"; \
141 echo " prompt \"$${entry}\""; \
142 dep_val=$$($(grep) -E '^# depends on ' $${file} 2>/dev/null); \
143 if [ -n "$${dep_val}" ]; then \
144 echo " $${dep_val#\# }"; \
146 echo "if $(3)_$${_entry}"; \
147 echo "source \"$${file}\""; \
154 #-----------------------------------------------------------
155 # The rules for the generated config files
157 config.gen/arch.in: $(ARCH_CONFIG_FILES)
158 $(call build_gen_choice_in,$@,Target Architecture,ARCH,config/arch,Y,$(ARCHS))
160 config.gen/kernel.in: $(KERNEL_CONFIG_FILES)
161 $(call build_gen_choice_in,$@,Target OS,KERNEL,config/kernel,Y,$(KERNELS))
163 config.gen/cc.in: $(CC_CONFIG_FILES)
164 $(call build_gen_choice_in,$@,C compiler,CC,config/cc,,$(CCS))
166 config.gen/libc.in: $(LIBC_CONFIG_FILES)
167 $(call build_gen_choice_in,$@,C library,LIBC,config/libc,Y,$(LIBCS))
169 config.gen/debug.in: $(DEBUG_CONFIG_FILES)
170 $(call build_gen_menu_in,$@,Debug,DEBUG,config/debug,$(DEBUGS))
172 #-----------------------------------------------------------
173 # Cleaning up the mess...
176 @$(ECHO) " CLEAN config"
177 $(SILENT)rm -f config 2>/dev/null || true
178 @$(ECHO) " CLEAN config.gen"
179 $(SILENT)rm -rf config.gen