# HG changeset patch # User "Yann E. MORIN" # Date 1224355048 0 # Node ID d0e5f04d2e0690d0461542565b4b35de12ed6fad # Parent a6e9767c8ef9fee075c016740259b09179456c10 Extract the config files related stuff from the kconfig stuff - create config/config.mk, with all the config.gen/ rules - the only common points between config files and configurators: - the top-level config file to include, stored in KCONFIG_TOP - the config_file rules, which makes config files available to configurators - dependency-files are renamed from %.d to %.dep (.d is reserved for directories) - a few eye-candy here and there /trunk/kconfig/kconfig.mk | 184 12 172 0 +++-------------------------------------------------- /trunk/config/config.mk | 118 9 109 0 +++------------------------------- /trunk/ct-ng.in | 1 1 0 0 + 3 files changed, 22 insertions(+), 281 deletions(-) diff -r a6e9767c8ef9 -r d0e5f04d2e06 config/config.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/config.mk Sat Oct 18 18:37:28 2008 +0000 @@ -0,0 +1,176 @@ +# =========================================================================== +# crosstool-NG genererated config files +# These targets are used from top-level makefile + +#----------------------------------------------------------- +# List all config files, source and generated + +# The top-level config file to be used be configurators +KCONFIG_TOP = config/config.in + +# Build the list of all source config files +STATIC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(shell find $(CT_LIB_DIR)/config -type f -name '*.in' 2>/dev/null)) +# ... and how to access them: +$(STATIC_CONFIG_FILES): config + +# Build a list of per-component-type source config files +ARCH_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/arch/*.in)) +KERNEL_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/kernel/*.in)) +CC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/cc/*.in)) +LIBC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/libc/*.in)) +DEBUG_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/debug/*.in)) +TOOL_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/tools/*.in)) + +# Build the list of generated config files +GEN_CONFIG_FILES = config.gen/arch.in \ + config.gen/kernel.in \ + config.gen/cc.in \ + config.gen/libc.in \ + config.gen/tools.in \ + config.gen/debug.in +# ... and how to access them: +# Generated files depends on config.mk (this file) because it has the +# functions needed to build the genrated files, and thus they might +# need re-generation if config.mk changes +$(GEN_CONFIG_FILES): config.gen \ + $(CT_LIB_DIR)/config/config.mk + +# Helper entry for the configurators +PHONY += config_files +config_files: $(STATIC_CONFIG_FILES) $(GEN_CONFIG_FILES) + +# Where to access to the source config files from +config: + @$(ECHO) " LN config" + $(SILENT)ln -s $(CT_LIB_DIR)/config config + +# Where to store the generated config files into +config.gen: + @$(ECHO) " MKDIR config.gen" + $(SILENT)mkdir -p config.gen + +#----------------------------------------------------------- +# Build list of per-component-type items to easily build generated files + +ARCHS = $(patsubst config/arch/%.in,%,$(ARCH_CONFIG_FILES)) +KERNELS = $(patsubst config/kernel/%.in,%,$(KERNEL_CONFIG_FILES)) +CCS = $(patsubst config/cc/%.in,%,$(CC_CONFIG_FILES)) +LIBCS = $(patsubst config/libc/%.in,%,$(LIBC_CONFIG_FILES)) +DEBUGS = $(patsubst config/debug/%.in,%,$(DEBUG_CONFIG_FILES)) +TOOLS = $(patsubst config/tools/%.in,%,$(TOOL_CONFIG_FILES)) + +#----------------------------------------------------------- +# Helper functions to ease building generated config files + +# The function 'build_gen_choice_in' builds a choice-menu of a list of +# components in the given list, also adding source-ing of associazted +# config files: +# $1 : destination file +# $2 : name for the entries family (eg. Architecture, kernel...) +# $3 : prefix for the choice entries (eg. ARCH, KERNEL...) +# $4 : base directory containing config files +# $5 : list of config entries (eg. for architectures: "alpha arm ia64"..., +# and for kernels: "bare-metal linux"...) +# Example to build the kernels generated config file: +# $(call build_gen_choice_in,config.gen/kernel.in,Target OS,KERNEL,config/kernel,$(KERNELS)) +define build_gen_choice_in + @$(ECHO) ' IN $(1)' + $(SILENT)(echo "# $(2) menu"; \ + echo "# Generated file, do not edit!!!"; \ + echo ""; \ + echo "choice"; \ + echo " bool"; \ + echo " prompt \"$(2)\""; \ + echo ""; \ + for entry in $(5); do \ + file="$(4)/$${entry}.in"; \ + _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;'); \ + echo "config $(3)_$${_entry}"; \ + echo " bool"; \ + printf " prompt \"$${entry}"; \ + if grep -E '^# +EXPERIMENTAL$$' $${file} >/dev/null 2>&1; then \ + echo " (EXPERIMENTAL)\""; \ + echo " depends on EXPERIMENTAL"; \ + else \ + echo "\""; \ + fi; \ + done; \ + echo ""; \ + echo "endchoice"; \ + for entry in $(5); do \ + file="$(4)/$${entry}.in"; \ + _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;'); \ + echo ""; \ + echo "if $(3)_$${_entry}"; \ + echo "config $(3)"; \ + echo " default \"$${entry}\" if $(3)_$${_entry}"; \ + echo "source $${file}"; \ + echo "endif"; \ + done; \ + ) >$(1) +endef + +# The function 'build_gen_menu_in' builds a menuconfig for each component in +# the given list, source-ing the associated files conditionnaly: +# $1 : destination file +# $2 : name of entries family (eg. Tools, Debug...) +# $3 : prefix for the menu entries (eg. TOOL, DEBUG) +# $4 : base directory containing config files +# $5 : list of config entries (eg. for tools: "libelf sstrip"..., and for +# debug: "dmalloc duma gdb"...) +# Example to build the tools generated config file: +# $(call build_gen_menu_in,config.gen/tools.in,Tools,TOOL,config/tools,$(TOOLS)) +define build_gen_menu_in + @$(ECHO) ' IN $(1)' + $(SILENT)(echo "# $(2) facilities menu"; \ + echo "# Generated file, do not edit!!!"; \ + echo ""; \ + for entry in $(5); do \ + file="$(4)/$${entry}.in"; \ + _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;'); \ + echo "menuconfig $(3)_$${_entry}"; \ + echo " bool"; \ + printf " prompt \"$${entry}"; \ + if grep -E '^# +EXPERIMENTAL$$' $${file} >/dev/null 2>&1; then \ + echo " (EXPERIMENTAL)\""; \ + echo " depends on EXPERIMENTAL"; \ + else \ + echo "\""; \ + fi; \ + echo "if $(3)_$${_entry}"; \ + echo "source $${file}"; \ + echo "endif"; \ + echo ""; \ + done; \ + ) >$(1) +endef + +#----------------------------------------------------------- +# The rules for the generated config files + +config.gen/arch.in: $(ARCH_CONFIG_FILES) + $(call build_gen_choice_in,$@,Target Architecture,ARCH,config/arch,$(ARCHS)) + +config.gen/kernel.in: $(KERNEL_CONFIG_FILES) + $(call build_gen_choice_in,$@,Target OS,KERNEL,config/kernel,$(KERNELS)) + +config.gen/cc.in: $(CC_CONFIG_FILES) + $(call build_gen_choice_in,$@,C compiler,CC,config/cc,$(CCS)) + +config.gen/libc.in: $(LIBC_CONFIG_FILES) + $(call build_gen_choice_in,$@,C library,LIBC,config/libc,$(LIBCS)) + +config.gen/tools.in: $(TOOL_CONFIG_FILES) + $(call build_gen_menu_in,$@,Tools,TOOL,config/tools,$(TOOLS)) + +config.gen/debug.in: $(DEBUG_CONFIG_FILES) + $(call build_gen_menu_in,$@,Debug,DEBUG,config/debug,$(DEBUGS)) + +#----------------------------------------------------------- +# Cleaning up the mess... + +clean:: + @$(ECHO) " CLEAN config" + $(SILENT)rm -f config 2>/dev/null || true + @$(ECHO) " CLEAN config.gen" + $(SILENT)rm -rf config.gen diff -r a6e9767c8ef9 -r d0e5f04d2e06 ct-ng.in --- a/ct-ng.in Fri Oct 17 14:26:53 2008 +0000 +++ b/ct-ng.in Sat Oct 18 18:37:28 2008 +0000 @@ -92,6 +92,7 @@ @echo ' clean - Remove generated files' @echo ' distclean - Remove generated files, configuration and build directories' +include $(CT_LIB_DIR)/config/config.mk include $(CT_LIB_DIR)/kconfig/kconfig.mk include $(CT_LIB_DIR)/steps.mk include $(CT_LIB_DIR)/samples/samples.mk diff -r a6e9767c8ef9 -r d0e5f04d2e06 kconfig/kconfig.mk --- a/kconfig/kconfig.mk Fri Oct 17 14:26:53 2008 +0000 +++ b/kconfig/kconfig.mk Sat Oct 18 18:37:28 2008 +0000 @@ -8,180 +8,24 @@ #----------------------------------------------------------- # Some static /configuration/ -KCONFIG_TOP = config/config.in +# The place where the kconfig stuff lies obj = kconfig -PHONY += clean help oldconfig menuconfig defoldconfig - -#----------------------------------------------------------- -# List all config files, source and generated - -# Build the list of all source config files -STATIC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(shell find $(CT_LIB_DIR)/config -type f -name '*.in' 2>/dev/null)) -# ... and how to access them: -$(STATIC_CONFIG_FILES): config - -# Build a list of per-component-type source config files -ARCH_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/arch/*.in)) -KERNEL_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/kernel/*.in)) -CC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/cc/*.in)) -LIBC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/libc/*.in)) -DEBUG_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/debug/*.in)) -TOOL_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/tools/*.in)) - -# Build the list of generated config files -GEN_CONFIG_FILES = config.gen/arch.in \ - config.gen/kernel.in \ - config.gen/cc.in \ - config.gen/libc.in \ - config.gen/tools.in \ - config.gen/debug.in -# ... and how to access them: -# Generated files depends on kconfig.mk (this file) because it has the -# functions needed to build the genrated files, and thus they might -# need re-generation if kconfig.mk changes -$(GEN_CONFIG_FILES): config.gen \ - $(CT_LIB_DIR)/kconfig/kconfig.mk - -# KCONFIG_TOP should already be in STATIC_CONFIG_FILES, anyway... -CONFIG_FILES = $(sort $(KCONFIG_TOP) $(STATIC_CONFIG_FILES) $(GEN_CONFIG_FILES)) - -# Where to access to the source config files from -config: - @$(ECHO) " LN config" - $(SILENT)ln -s $(CT_LIB_DIR)/config config - -# Where to store the generated config files into -config.gen: - @$(ECHO) " MKDIR config.gen" - $(SILENT)mkdir -p config.gen - -#----------------------------------------------------------- -# Build list of per-component-type items to easily build generated files - -ARCHS = $(patsubst config/arch/%.in,%,$(ARCH_CONFIG_FILES)) -KERNELS = $(patsubst config/kernel/%.in,%,$(KERNEL_CONFIG_FILES)) -CCS = $(patsubst config/cc/%.in,%,$(CC_CONFIG_FILES)) -LIBCS = $(patsubst config/libc/%.in,%,$(LIBC_CONFIG_FILES)) -DEBUGS = $(patsubst config/debug/%.in,%,$(DEBUG_CONFIG_FILES)) -TOOLS = $(patsubst config/tools/%.in,%,$(TOOL_CONFIG_FILES)) - -#----------------------------------------------------------- -# Helper functions to ease building generated config files - -# The function 'build_gen_choice_in' builds a choice-menu of a list of -# components in the given list, also adding source-ing of associazted -# config files: -# $1 : destination file -# $2 : name for the entries family (eg. Architecture, kernel...) -# $3 : prefix for the choice entries (eg. ARCH, KERNEL...) -# $4 : base directory containing config files -# $5 : list of config entries (eg. for architectures: "alpha arm ia64"..., -# and for kernels: "bare-metal linux"...) -# Example to build the kernels generated config file: -# $(call build_gen_choice_in,config.gen/kernel.in,Target OS,KERNEL,config/kernel,$(KERNELS)) -define build_gen_choice_in - @$(ECHO) ' IN $(1)' - $(SILENT)(echo "# $(2) menu"; \ - echo "# Generated file, do not edit!!!"; \ - echo ""; \ - echo "choice"; \ - echo " bool"; \ - echo " prompt \"$(2)\""; \ - echo ""; \ - for entry in $(5); do \ - file="$(4)/$${entry}.in"; \ - _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;'); \ - echo "config $(3)_$${_entry}"; \ - echo " bool"; \ - printf " prompt \"$${entry}"; \ - if grep -E '^# +EXPERIMENTAL$$' $${file} >/dev/null 2>&1; then \ - echo " (EXPERIMENTAL)\""; \ - echo " depends on EXPERIMENTAL"; \ - else \ - echo "\""; \ - fi; \ - done; \ - echo ""; \ - echo "endchoice"; \ - for entry in $(5); do \ - file="$(4)/$${entry}.in"; \ - _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;'); \ - echo ""; \ - echo "if $(3)_$${_entry}"; \ - echo "config $(3)"; \ - echo " default \"$${entry}\" if $(3)_$${_entry}"; \ - echo "source $${file}"; \ - echo "endif"; \ - done; \ - ) >$(1) -endef - -# The function 'build_gen_menu_in' builds a menuconfig for each component in -# the given list, source-ing the associated files conditionnaly: -# $1 : destination file -# $2 : name of entries family (eg. Tools, Debug...) -# $3 : prefix for the menu entries (eg. TOOL, DEBUG) -# $4 : base directory containing config files -# $5 : list of config entries (eg. for tools: "libelf sstrip"..., and for -# debug: "dmalloc duma gdb"...) -# Example to build the tools generated config file: -# $(call build_gen_menu_in,config.gen/tools.in,Tools,TOOL,config/tools,$(TOOLS)) -define build_gen_menu_in - @$(ECHO) ' IN $(1)' - $(SILENT)(echo "# $(2) facilities menu"; \ - echo "# Generated file, do not edit!!!"; \ - echo ""; \ - for entry in $(5); do \ - file="$(4)/$${entry}.in"; \ - _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;'); \ - echo "menuconfig $(3)_$${_entry}"; \ - echo " bool"; \ - printf " prompt \"$${entry}"; \ - if grep -E '^# +EXPERIMENTAL$$' $${file} >/dev/null 2>&1; then \ - echo " (EXPERIMENTAL)\""; \ - echo " depends on EXPERIMENTAL"; \ - else \ - echo "\""; \ - fi; \ - echo "if $(3)_$${_entry}"; \ - echo "source $${file}"; \ - echo "endif"; \ - echo ""; \ - done; \ - ) >$(1) -endef - -#----------------------------------------------------------- -# The rules for the generated config files - -config.gen/arch.in: $(ARCH_CONFIG_FILES) - $(call build_gen_choice_in,$@,Target Architecture,ARCH,config/arch,$(ARCHS)) - -config.gen/kernel.in: $(KERNEL_CONFIG_FILES) - $(call build_gen_choice_in,$@,Target OS,KERNEL,config/kernel,$(KERNELS)) - -config.gen/cc.in: $(CC_CONFIG_FILES) - $(call build_gen_choice_in,$@,C compiler,CC,config/cc,$(CCS)) - -config.gen/libc.in: $(LIBC_CONFIG_FILES) - $(call build_gen_choice_in,$@,C library,LIBC,config/libc,$(LIBCS)) - -config.gen/tools.in: $(TOOL_CONFIG_FILES) - $(call build_gen_menu_in,$@,Tools,TOOL,config/tools,$(TOOLS)) - -config.gen/debug.in: $(DEBUG_CONFIG_FILES) - $(call build_gen_menu_in,$@,Debug,DEBUG,config/debug,$(DEBUGS)) #----------------------------------------------------------- # The configurators rules -menuconfig: $(obj)/mconf $(CONFIG_FILES) +PHONY += oldconfig menuconfig defoldconfig + +menuconfig: $(obj)/mconf config_files + @$(ECHO) " MCONF $(KCONFIG_TOP)" $(SILENT)$< $(KCONFIG_TOP) -oldconfig: $(obj)/conf .config $(CONFIG_FILES) +oldconfig: $(obj)/conf .config config_files + @$(ECHO) " CONF $(KCONFIG_TOP)" $(SILENT)$< -s $(KCONFIG_TOP) -defoldconfig: $(obj)/conf .config $(CONFIG_FILES) +defoldconfig: $(obj)/conf .config config_files + @$(ECHO) " CONF $(KCONFIG_TOP)" $(SILENT)yes "" |$< -s $(KCONFIG_TOP) #----------------------------------------------------------- @@ -223,20 +67,20 @@ mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC)) # Cheesy auto-dependencies -DEPS = $(patsubst %.c,%.d,$(sort $(conf_SRC) $(mconf_SRC))) +DEPS = $(patsubst %.c,%.dep,$(sort $(conf_SRC) $(mconf_SRC))) +-include $(DEPS) # This is not very nice, as they will get rebuild even if (dist)cleaning... :-( # Should look into the Linux kernel Kbuild to see how they do that... # To really make me look into this, keep the annoying "DEP xxx" messages. # Also see the comment for the "%.o: %c" rule below -%.d: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk +%.dep: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk $(CT_NG) $(SILENT)if [ ! -d $(obj)/lxdialog ]; then \ $(ECHO) " MKDIR $(obj)"; \ mkdir -p $(obj)/lxdialog; \ fi @$(ECHO) " DEP $@" $(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) -MM $< |sed -r -e 's|([^:]+.o)( *:+)|$(<:.c=.o) $@\2|;' >$@ --include $(DEPS) # Each .o must depend on the corresponding .c (obvious, isn't it?), # but *can not* depend on kconfig/, because kconfig can be touched @@ -270,7 +114,3 @@ @$(ECHO) " CLEAN kconfig" $(SILENT)rm -f kconfig/{,m}conf $(conf_OBJ) $(mconf_OBJ) $(DEPS) $(SILENT)rmdir --ignore-fail-on-non-empty kconfig{/lxdialog,} 2>/dev/null || true - @$(ECHO) " CLEAN config" - $(SILENT)rm -f config 2>/dev/null || true - @$(ECHO) " CLEAN config.gen" - $(SILENT)rm -rf config.gen