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 : list of config entries (eg. for architectures: "alpha arm ia64"...,
70 # and for kernels: "bare-metal linux"...)
71 # Example to build the kernels generated config file:
72 # $(call build_gen_choice_in,config.gen/kernel.in,Target OS,KERNEL,config/kernel,$(KERNELS))
73 define build_gen_choice_in
75 $(SILENT)(echo "# $(2) menu"; \
76 echo "# Generated file, do not edit!!!"; \
80 echo " prompt \"$(2)\""; \
82 for entry in $(5); do \
83 file="$(4)/$${entry}.in"; \
84 _entry=$$(echo "$${entry}" |$(sed) -r -s -e 's/[-.+]/_/g;'); \
85 echo "config $(3)_$${_entry}"; \
87 echo " prompt \"$${entry}\""; \
88 dep_val=$$($(grep) -E '^# depends on ' $${file} 2>/dev/null); \
89 if [ -n "$${dep_val}" ]; then \
90 echo " $${dep_val#\# }"; \
95 for entry in $(5); do \
96 file="$(4)/$${entry}.in"; \
97 _entry=$$(echo "$${entry}" |$(sed) -r -s -e 's/[-.+]/_/g;'); \
99 echo "if $(3)_$${_entry}"; \
100 echo "config $(3)"; \
101 echo " default \"$${entry}\" if $(3)_$${_entry}"; \
102 echo "source $${file}"; \
106 for file in $(wildcard $(4)/*.in-common); do \
107 echo "source $${file}"; \
112 # The function 'build_gen_menu_in' builds a menuconfig for each component in
113 # the given list, source-ing the associated files conditionnaly:
114 # $1 : destination file
115 # $2 : name of entries family (eg. Tools, Debug...)
116 # $3 : prefix for the menu entries (eg. DEBUG)
117 # $4 : base directory containing config files
118 # $5 : list of config entries (eg. for debug: "dmalloc duma gdb"...)
119 # Example to build the generated debug config file:
120 # $(call build_gen_menu_in,config.gen/debug.in,Debug,DEBUG,config/debug,$(DEBUGS))
121 define build_gen_menu_in
123 $(SILENT)(echo "# $(2) facilities menu"; \
124 echo "# Generated file, do not edit!!!"; \
126 for entry in $(5); do \
127 file="$(4)/$${entry}.in"; \
128 _entry=$$(echo "$${entry}" |$(sed) -r -s -e 's/[-.+]/_/g;'); \
129 echo "menuconfig $(3)_$${_entry}"; \
131 echo " prompt \"$${entry}\""; \
132 dep_val=$$($(grep) -E '^# depends on ' $${file} 2>/dev/null); \
133 if [ -n "$${dep_val}" ]; then \
134 echo " $${dep_val#\# }"; \
136 echo "if $(3)_$${_entry}"; \
137 echo "source $${file}"; \
144 #-----------------------------------------------------------
145 # The rules for the generated config files
147 config.gen/arch.in: $(ARCH_CONFIG_FILES)
148 $(call build_gen_choice_in,$@,Target Architecture,ARCH,config/arch,$(ARCHS))
150 config.gen/kernel.in: $(KERNEL_CONFIG_FILES)
151 $(call build_gen_choice_in,$@,Target OS,KERNEL,config/kernel,$(KERNELS))
153 config.gen/cc.in: $(CC_CONFIG_FILES)
154 $(call build_gen_choice_in,$@,C compiler,CC,config/cc,$(CCS))
156 config.gen/libc.in: $(LIBC_CONFIG_FILES)
157 $(call build_gen_choice_in,$@,C library,LIBC,config/libc,$(LIBCS))
159 config.gen/debug.in: $(DEBUG_CONFIG_FILES)
160 $(call build_gen_menu_in,$@,Debug,DEBUG,config/debug,$(DEBUGS))
162 #-----------------------------------------------------------
163 # Cleaning up the mess...
166 @$(ECHO) " CLEAN config"
167 $(SILENT)rm -f config 2>/dev/null || true
168 @$(ECHO) " CLEAN config.gen"
169 $(SILENT)rm -rf config.gen