1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/config/config.mk Mon Oct 20 09:50:45 2008 +0000
1.3 @@ -0,0 +1,176 @@
1.4 +# ===========================================================================
1.5 +# crosstool-NG genererated config files
1.6 +# These targets are used from top-level makefile
1.7 +
1.8 +#-----------------------------------------------------------
1.9 +# List all config files, source and generated
1.10 +
1.11 +# The top-level config file to be used be configurators
1.12 +KCONFIG_TOP = config/config.in
1.13 +
1.14 +# Build the list of all source config files
1.15 +STATIC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(shell find $(CT_LIB_DIR)/config -type f -name '*.in' 2>/dev/null))
1.16 +# ... and how to access them:
1.17 +$(STATIC_CONFIG_FILES): config
1.18 +
1.19 +# Build a list of per-component-type source config files
1.20 +ARCH_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/arch/*.in))
1.21 +KERNEL_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/kernel/*.in))
1.22 +CC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/cc/*.in))
1.23 +LIBC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/libc/*.in))
1.24 +DEBUG_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/debug/*.in))
1.25 +TOOL_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/tools/*.in))
1.26 +
1.27 +# Build the list of generated config files
1.28 +GEN_CONFIG_FILES = config.gen/arch.in \
1.29 + config.gen/kernel.in \
1.30 + config.gen/cc.in \
1.31 + config.gen/libc.in \
1.32 + config.gen/tools.in \
1.33 + config.gen/debug.in
1.34 +# ... and how to access them:
1.35 +# Generated files depends on config.mk (this file) because it has the
1.36 +# functions needed to build the genrated files, and thus they might
1.37 +# need re-generation if config.mk changes
1.38 +$(GEN_CONFIG_FILES): config.gen \
1.39 + $(CT_LIB_DIR)/config/config.mk
1.40 +
1.41 +# Helper entry for the configurators
1.42 +PHONY += config_files
1.43 +config_files: $(STATIC_CONFIG_FILES) $(GEN_CONFIG_FILES)
1.44 +
1.45 +# Where to access to the source config files from
1.46 +config:
1.47 + @$(ECHO) " LN config"
1.48 + $(SILENT)ln -s $(CT_LIB_DIR)/config config
1.49 +
1.50 +# Where to store the generated config files into
1.51 +config.gen:
1.52 + @$(ECHO) " MKDIR config.gen"
1.53 + $(SILENT)mkdir -p config.gen
1.54 +
1.55 +#-----------------------------------------------------------
1.56 +# Build list of per-component-type items to easily build generated files
1.57 +
1.58 +ARCHS = $(patsubst config/arch/%.in,%,$(ARCH_CONFIG_FILES))
1.59 +KERNELS = $(patsubst config/kernel/%.in,%,$(KERNEL_CONFIG_FILES))
1.60 +CCS = $(patsubst config/cc/%.in,%,$(CC_CONFIG_FILES))
1.61 +LIBCS = $(patsubst config/libc/%.in,%,$(LIBC_CONFIG_FILES))
1.62 +DEBUGS = $(patsubst config/debug/%.in,%,$(DEBUG_CONFIG_FILES))
1.63 +TOOLS = $(patsubst config/tools/%.in,%,$(TOOL_CONFIG_FILES))
1.64 +
1.65 +#-----------------------------------------------------------
1.66 +# Helper functions to ease building generated config files
1.67 +
1.68 +# The function 'build_gen_choice_in' builds a choice-menu of a list of
1.69 +# components in the given list, also adding source-ing of associazted
1.70 +# config files:
1.71 +# $1 : destination file
1.72 +# $2 : name for the entries family (eg. Architecture, kernel...)
1.73 +# $3 : prefix for the choice entries (eg. ARCH, KERNEL...)
1.74 +# $4 : base directory containing config files
1.75 +# $5 : list of config entries (eg. for architectures: "alpha arm ia64"...,
1.76 +# and for kernels: "bare-metal linux"...)
1.77 +# Example to build the kernels generated config file:
1.78 +# $(call build_gen_choice_in,config.gen/kernel.in,Target OS,KERNEL,config/kernel,$(KERNELS))
1.79 +define build_gen_choice_in
1.80 + @$(ECHO) ' IN $(1)'
1.81 + $(SILENT)(echo "# $(2) menu"; \
1.82 + echo "# Generated file, do not edit!!!"; \
1.83 + echo ""; \
1.84 + echo "choice"; \
1.85 + echo " bool"; \
1.86 + echo " prompt \"$(2)\""; \
1.87 + echo ""; \
1.88 + for entry in $(5); do \
1.89 + file="$(4)/$${entry}.in"; \
1.90 + _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;'); \
1.91 + echo "config $(3)_$${_entry}"; \
1.92 + echo " bool"; \
1.93 + printf " prompt \"$${entry}"; \
1.94 + if grep -E '^# +EXPERIMENTAL$$' $${file} >/dev/null 2>&1; then \
1.95 + echo " (EXPERIMENTAL)\""; \
1.96 + echo " depends on EXPERIMENTAL"; \
1.97 + else \
1.98 + echo "\""; \
1.99 + fi; \
1.100 + done; \
1.101 + echo ""; \
1.102 + echo "endchoice"; \
1.103 + for entry in $(5); do \
1.104 + file="$(4)/$${entry}.in"; \
1.105 + _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;'); \
1.106 + echo ""; \
1.107 + echo "if $(3)_$${_entry}"; \
1.108 + echo "config $(3)"; \
1.109 + echo " default \"$${entry}\" if $(3)_$${_entry}"; \
1.110 + echo "source $${file}"; \
1.111 + echo "endif"; \
1.112 + done; \
1.113 + ) >$(1)
1.114 +endef
1.115 +
1.116 +# The function 'build_gen_menu_in' builds a menuconfig for each component in
1.117 +# the given list, source-ing the associated files conditionnaly:
1.118 +# $1 : destination file
1.119 +# $2 : name of entries family (eg. Tools, Debug...)
1.120 +# $3 : prefix for the menu entries (eg. TOOL, DEBUG)
1.121 +# $4 : base directory containing config files
1.122 +# $5 : list of config entries (eg. for tools: "libelf sstrip"..., and for
1.123 +# debug: "dmalloc duma gdb"...)
1.124 +# Example to build the tools generated config file:
1.125 +# $(call build_gen_menu_in,config.gen/tools.in,Tools,TOOL,config/tools,$(TOOLS))
1.126 +define build_gen_menu_in
1.127 + @$(ECHO) ' IN $(1)'
1.128 + $(SILENT)(echo "# $(2) facilities menu"; \
1.129 + echo "# Generated file, do not edit!!!"; \
1.130 + echo ""; \
1.131 + for entry in $(5); do \
1.132 + file="$(4)/$${entry}.in"; \
1.133 + _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;'); \
1.134 + echo "menuconfig $(3)_$${_entry}"; \
1.135 + echo " bool"; \
1.136 + printf " prompt \"$${entry}"; \
1.137 + if grep -E '^# +EXPERIMENTAL$$' $${file} >/dev/null 2>&1; then \
1.138 + echo " (EXPERIMENTAL)\""; \
1.139 + echo " depends on EXPERIMENTAL"; \
1.140 + else \
1.141 + echo "\""; \
1.142 + fi; \
1.143 + echo "if $(3)_$${_entry}"; \
1.144 + echo "source $${file}"; \
1.145 + echo "endif"; \
1.146 + echo ""; \
1.147 + done; \
1.148 + ) >$(1)
1.149 +endef
1.150 +
1.151 +#-----------------------------------------------------------
1.152 +# The rules for the generated config files
1.153 +
1.154 +config.gen/arch.in: $(ARCH_CONFIG_FILES)
1.155 + $(call build_gen_choice_in,$@,Target Architecture,ARCH,config/arch,$(ARCHS))
1.156 +
1.157 +config.gen/kernel.in: $(KERNEL_CONFIG_FILES)
1.158 + $(call build_gen_choice_in,$@,Target OS,KERNEL,config/kernel,$(KERNELS))
1.159 +
1.160 +config.gen/cc.in: $(CC_CONFIG_FILES)
1.161 + $(call build_gen_choice_in,$@,C compiler,CC,config/cc,$(CCS))
1.162 +
1.163 +config.gen/libc.in: $(LIBC_CONFIG_FILES)
1.164 + $(call build_gen_choice_in,$@,C library,LIBC,config/libc,$(LIBCS))
1.165 +
1.166 +config.gen/tools.in: $(TOOL_CONFIG_FILES)
1.167 + $(call build_gen_menu_in,$@,Tools,TOOL,config/tools,$(TOOLS))
1.168 +
1.169 +config.gen/debug.in: $(DEBUG_CONFIG_FILES)
1.170 + $(call build_gen_menu_in,$@,Debug,DEBUG,config/debug,$(DEBUGS))
1.171 +
1.172 +#-----------------------------------------------------------
1.173 +# Cleaning up the mess...
1.174 +
1.175 +clean::
1.176 + @$(ECHO) " CLEAN config"
1.177 + $(SILENT)rm -f config 2>/dev/null || true
1.178 + @$(ECHO) " CLEAN config.gen"
1.179 + $(SILENT)rm -rf config.gen