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 TOOL_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/tools.in \
31 $(CT_TOP_DIR)/config.gen/debug.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))
38 DEBUGS = $(patsubst $(CT_LIB_DIR)/config/debug/%.in,%,$(DEBUG_CONFIG_FILES))
39 TOOLS = $(patsubst $(CT_LIB_DIR)/config/tools/%.in,%,$(TOOL_CONFIG_FILES))
41 $(GEN_CONFIG_FILES): $(CT_TOP_DIR)/config.gen \
42 $(CT_LIB_DIR)/kconfig/kconfig.mk
44 $(CT_TOP_DIR)/config.gen: $(KCONFIG_TOP)
45 @mkdir -p $(CT_TOP_DIR)/config.gen
47 # Function build_gen_choice_in:
48 # $1 : destination file
49 # $2 : name for the entries family (eg. Architecture, kernel...)
50 # $3 : prefix for the choice entries (eg. ARCH, KERNEL...)
51 # $4 : base directory containing config files
52 # $5 : list of config entries (eg. for architectures: "alpha arm ia64"...,
53 # and for kernels: "bare-metal linux"...)
54 # Example to build the kernels generated config file:
55 # $(call build_gen_choice_in,config.gen/kernel.in,Kernel,KERNEL,config/kernel,$(KERNELS))
56 define build_gen_choice_in
58 @(echo "# $(2) menu"; \
59 echo "# Generated file, do not edit!!!"; \
61 for entry in $(5); do \
62 file="$(4)/$${entry}.in"; \
63 _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;'); \
64 echo "config $(3)_$${_entry}"; \
66 printf " prompt \"$${entry}"; \
67 if grep -E '^# +EXPERIMENTAL$$' $${file} >/dev/null 2>&1; then \
68 echo " (EXPERIMENTAL)\""; \
69 echo " depends on EXPERIMENTAL"; \
73 echo "if $(3)_$${_entry}"; \
75 echo " default \"$${entry}\" if $(3)_$${_entry}"; \
76 echo "source $${file}"; \
83 $(CT_TOP_DIR)/config.gen/arch.in: $(ARCH_CONFIG_FILES)
84 $(call build_gen_choice_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Architecture,ARCH,config/arch,$(ARCHS))
86 $(CT_TOP_DIR)/config.gen/kernel.in: $(KERNEL_CONFIG_FILES)
87 $(call build_gen_choice_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Kernel,KERNEL,config/kernel,$(KERNELS))
89 # Function build_gen_menu_in:
90 # $1 : destination file
91 # $2 : name of entries family (eg. Tools, Debug...)
92 # $3 : prefix for the menu entries (eg. TOOL, DEBUG)
93 # $4 : base directory containing config files
94 # $5 : list of config entries (eg. for tools: "libelf sstrip"..., and for
95 # debug: "dmalloc duma gdb"...)
96 # Example to build the tools generated config file:
97 # $(call build_gen_menu_in,config.gen/tools.in,Tools,TOOL,config/tools,$(TOOLS))
98 define build_gen_menu_in
100 @(echo "# $(2) facilities menu"; \
101 echo "# Generated file, do not edit!!!"; \
103 for entry in $(5); do \
104 file="$(4)/$${entry}.in"; \
105 _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;'); \
106 echo "menuconfig $(3)_$${_entry}"; \
108 printf " prompt \"$${entry}"; \
109 if grep -E '^# +EXPERIMENTAL$$' $${file} >/dev/null 2>&1; then \
110 echo " (EXPERIMENTAL)\""; \
111 echo " depends on EXPERIMENTAL"; \
115 echo "if $(3)_$${_entry}"; \
116 echo "source $${file}"; \
123 $(CT_TOP_DIR)/config.gen/tools.in: $(TOOL_CONFIG_FILES)
124 $(call build_gen_menu_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Tools,TOOL,config/tools,$(TOOLS))
126 $(CT_TOP_DIR)/config.gen/debug.in: $(DEBUG_CONFIG_FILES)
127 $(call build_gen_menu_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Debug,DEBUG,config/debug,$(DEBUGS))
129 config menuconfig oldconfig defoldconfig: $(KCONFIG_TOP)
132 @ln -sf $(CT_LIB_DIR)/config config
134 menuconfig: $(CONFIG_FILES) $(obj)/mconf
135 @$(obj)/mconf $(KCONFIG_TOP)
137 config: $(CONFIG_FILES) $(obj)/conf
138 @$(obj)/conf $(KCONFIG_TOP)
140 oldconfig: $(CONFIG_FILES) $(obj)/conf
141 @$(obj)/conf -s $(KCONFIG_TOP)
143 defoldconfig: $(CONFIG_FILES) $(obj)/conf
144 @yes "" |$(obj)/conf -s $(KCONFIG_TOP)
146 # Help text used by make help
148 @echo ' config - Update current config using a line-oriented program'
149 @echo ' menuconfig - Update current config using a menu based program'
150 @echo ' oldconfig - Update current config using a provided .config as base'
151 @echo ' build log piped into stdin'
155 SHIPPED := $(CT_LIB_DIR)/kconfig/zconf.tab.c $(CT_LIB_DIR)/kconfig/lex.zconf.c $(CT_LIB_DIR)/kconfig/zconf.hash.c
157 $(obj)/conf $(obj)/mconf: $(obj)
162 HEADERS = $(CT_LIB_DIR)/kconfig/expr.h \
163 $(CT_LIB_DIR)/kconfig/lkc.h \
164 $(CT_LIB_DIR)/kconfig/lkc_proto.h
166 FILES = $(CT_LIB_DIR)/kconfig/confdata.c \
167 $(CT_LIB_DIR)/kconfig/expr.c \
168 $(CT_LIB_DIR)/kconfig/menu.c \
169 $(CT_LIB_DIR)/kconfig/symbol.c \
170 $(CT_LIB_DIR)/kconfig/util.c
172 $(obj)/mconf: $(SHIPPED) $(CT_LIB_DIR)/kconfig/mconf.c \
173 $(HEADERS) $(FILES) \
174 $(CT_LIB_DIR)/kconfig/kconfig.mk
175 @echo ' LD kconfig/mconf'
176 @$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{mconf.c,zconf.tab.c,lxdialog/*.c} \
177 $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ccflags) \
178 $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ldflags $(HOST_CC))
180 $(obj)/conf: $(SHIPPED) $(CT_LIB_DIR)/kconfig/conf.c \
181 $(HEADERS) $(FILES) \
182 $(CT_LIB_DIR)/kconfig/kconfig.mk
183 @echo ' LD kconfig/conf'
184 @$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{conf.c,zconf.tab.c}
187 @rm -f $(CT_TOP_DIR)/kconfig/{,m}conf
188 @rmdir --ignore-fail-on-non-empty $(CT_TOP_DIR)/kconfig 2>/dev/null || true
189 @rm -f $(CT_TOP_DIR)/config 2>/dev/null || true
190 @rm -rf $(CT_TOP_DIR)/config.gen