1.1 --- a/kconfig/kconfig.mk Mon Oct 13 20:36:37 2008 +0000
1.2 +++ b/kconfig/kconfig.mk Tue Oct 14 21:30:27 2008 +0000
1.3 @@ -5,8 +5,11 @@
1.4 # Derive the project version from, well, the project version:
1.5 export PROJECTVERSION=$(CT_VERSION)
1.6
1.7 +#-----------------------------------------------------------
1.8 +# Some static /configuration/
1.9 +
1.10 KCONFIG_TOP = config/config.in
1.11 -obj = $(CT_TOP_DIR)/kconfig
1.12 +obj = kconfig
1.13 PHONY += clean help oldconfig menuconfig defoldconfig
1.14
1.15 # Darwin (MacOS-X) does not have proper libintl support
1.16 @@ -18,39 +21,65 @@
1.17 CFLAGS += -DKBUILD_NO_NLS
1.18 endif
1.19
1.20 -# Build a list of all config files
1.21 -ARCH_CONFIG_FILES = $(wildcard $(CT_LIB_DIR)/config/arch/*.in)
1.22 -KERNEL_CONFIG_FILES = $(wildcard $(CT_LIB_DIR)/config/kernel/*.in)
1.23 -CC_CONFIG_FILES = $(wildcard $(CT_LIB_DIR)/config/cc/*.in)
1.24 -LIBC_CONFIG_FILES = $(wildcard $(CT_LIB_DIR)/config/libc/*.in)
1.25 -DEBUG_CONFIG_FILES = $(wildcard $(CT_LIB_DIR)/config/debug/*.in)
1.26 -TOOL_CONFIG_FILES = $(wildcard $(CT_LIB_DIR)/config/tools/*.in)
1.27 +#-----------------------------------------------------------
1.28 +# List all config files, source and generated
1.29
1.30 -STATIC_CONFIG_FILES = $(shell find $(CT_LIB_DIR)/config -type f -name '*.in')
1.31 -GEN_CONFIG_FILES=$(CT_TOP_DIR)/config.gen/arch.in \
1.32 - $(CT_TOP_DIR)/config.gen/kernel.in \
1.33 - $(CT_TOP_DIR)/config.gen/cc.in \
1.34 - $(CT_TOP_DIR)/config.gen/libc.in \
1.35 - $(CT_TOP_DIR)/config.gen/tools.in \
1.36 - $(CT_TOP_DIR)/config.gen/debug.in
1.37 +# Build the list of all source config files
1.38 +STATIC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(shell find $(CT_LIB_DIR)/config -type f -name '*.in' 2>/dev/null))
1.39 +# ... and how to access them:
1.40 +$(STATIC_CONFIG_FILES): config
1.41
1.42 -CONFIG_FILES=$(STATIC_CONFIG_FILES) $(GEN_CONFIG_FILES)
1.43 +# Build a list of per-component-type source config files
1.44 +ARCH_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/arch/*.in))
1.45 +KERNEL_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/kernel/*.in))
1.46 +CC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/cc/*.in))
1.47 +LIBC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/libc/*.in))
1.48 +DEBUG_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/debug/*.in))
1.49 +TOOL_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/tools/*.in))
1.50
1.51 -# Build list of items
1.52 -ARCHS = $(patsubst $(CT_LIB_DIR)/config/arch/%.in,%,$(ARCH_CONFIG_FILES))
1.53 -KERNELS = $(patsubst $(CT_LIB_DIR)/config/kernel/%.in,%,$(KERNEL_CONFIG_FILES))
1.54 -CCS = $(patsubst $(CT_LIB_DIR)/config/cc/%.in,%,$(CC_CONFIG_FILES))
1.55 -LIBCS = $(patsubst $(CT_LIB_DIR)/config/libc/%.in,%,$(LIBC_CONFIG_FILES))
1.56 -DEBUGS = $(patsubst $(CT_LIB_DIR)/config/debug/%.in,%,$(DEBUG_CONFIG_FILES))
1.57 -TOOLS = $(patsubst $(CT_LIB_DIR)/config/tools/%.in,%,$(TOOL_CONFIG_FILES))
1.58 -
1.59 -$(GEN_CONFIG_FILES): $(CT_TOP_DIR)/config.gen \
1.60 +# Build the list of generated config files
1.61 +GEN_CONFIG_FILES = config.gen/arch.in \
1.62 + config.gen/kernel.in \
1.63 + config.gen/cc.in \
1.64 + config.gen/libc.in \
1.65 + config.gen/tools.in \
1.66 + config.gen/debug.in
1.67 +# ... and how to access them:
1.68 +# Generated files depends on kconfig.mk (this file) because it has the
1.69 +# functions needed to build the genrated files, and thus they might
1.70 +# need re-generation if kconfig.mk changes
1.71 +$(GEN_CONFIG_FILES): config.gen \
1.72 $(CT_LIB_DIR)/kconfig/kconfig.mk
1.73
1.74 -$(CT_TOP_DIR)/config.gen: $(KCONFIG_TOP)
1.75 - @mkdir -p $(CT_TOP_DIR)/config.gen
1.76 +# KCONFIG_TOP should already be in STATIC_CONFIG_FILES, anyway...
1.77 +CONFIG_FILES = $(sort $(KCONFIG_TOP) $(STATIC_CONFIG_FILES) $(GEN_CONFIG_FILES))
1.78
1.79 -# Function build_gen_choice_in:
1.80 +# Where to access to the source config files from
1.81 +config:
1.82 + @echo " LN config"
1.83 + @ln -s $(CT_LIB_DIR)/config config
1.84 +
1.85 +# Where to store the generated config files into
1.86 +config.gen:
1.87 + @echo " MKDIR config.gen"
1.88 + @mkdir -p config.gen
1.89 +
1.90 +#-----------------------------------------------------------
1.91 +# Build list of per-component-type items to easily build generated files
1.92 +
1.93 +ARCHS = $(patsubst config/arch/%.in,%,$(ARCH_CONFIG_FILES))
1.94 +KERNELS = $(patsubst config/kernel/%.in,%,$(KERNEL_CONFIG_FILES))
1.95 +CCS = $(patsubst config/cc/%.in,%,$(CC_CONFIG_FILES))
1.96 +LIBCS = $(patsubst config/libc/%.in,%,$(LIBC_CONFIG_FILES))
1.97 +DEBUGS = $(patsubst config/debug/%.in,%,$(DEBUG_CONFIG_FILES))
1.98 +TOOLS = $(patsubst config/tools/%.in,%,$(TOOL_CONFIG_FILES))
1.99 +
1.100 +#-----------------------------------------------------------
1.101 +# Helper functions to ease building generated config files
1.102 +
1.103 +# The function 'build_gen_choice_in' builds a choice-menu of a list of
1.104 +# components in the given list, also adding source-ing of associazted
1.105 +# config files:
1.106 # $1 : destination file
1.107 # $2 : name for the entries family (eg. Architecture, kernel...)
1.108 # $3 : prefix for the choice entries (eg. ARCH, KERNEL...)
1.109 @@ -60,7 +89,7 @@
1.110 # Example to build the kernels generated config file:
1.111 # $(call build_gen_choice_in,config.gen/kernel.in,Target OS,KERNEL,config/kernel,$(KERNELS))
1.112 define build_gen_choice_in
1.113 - @echo ' IN $(1)'
1.114 + @echo ' IN $(1)'
1.115 @(echo "# $(2) menu"; \
1.116 echo "# Generated file, do not edit!!!"; \
1.117 echo ""; \
1.118 @@ -96,19 +125,8 @@
1.119 ) >$(1)
1.120 endef
1.121
1.122 -$(CT_TOP_DIR)/config.gen/arch.in: $(ARCH_CONFIG_FILES)
1.123 - $(call build_gen_choice_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Target Architecture,ARCH,config/arch,$(ARCHS))
1.124 -
1.125 -$(CT_TOP_DIR)/config.gen/kernel.in: $(KERNEL_CONFIG_FILES)
1.126 - $(call build_gen_choice_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Target OS,KERNEL,config/kernel,$(KERNELS))
1.127 -
1.128 -$(CT_TOP_DIR)/config.gen/cc.in: $(CC_CONFIG_FILES)
1.129 - $(call build_gen_choice_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),C compiler,CC,config/cc,$(CCS))
1.130 -
1.131 -$(CT_TOP_DIR)/config.gen/libc.in: $(LIBC_CONFIG_FILES)
1.132 - $(call build_gen_choice_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),C library,LIBC,config/libc,$(LIBCS))
1.133 -
1.134 -# Function build_gen_menu_in:
1.135 +# The function 'build_gen_menu_in' builds a menuconfig for each component in
1.136 +# the given list, source-ing the associated files conditionnaly:
1.137 # $1 : destination file
1.138 # $2 : name of entries family (eg. Tools, Debug...)
1.139 # $3 : prefix for the menu entries (eg. TOOL, DEBUG)
1.140 @@ -118,7 +136,7 @@
1.141 # Example to build the tools generated config file:
1.142 # $(call build_gen_menu_in,config.gen/tools.in,Tools,TOOL,config/tools,$(TOOLS))
1.143 define build_gen_menu_in
1.144 - @echo ' IN $(1)'
1.145 + @echo ' IN $(1)'
1.146 @(echo "# $(2) facilities menu"; \
1.147 echo "# Generated file, do not edit!!!"; \
1.148 echo ""; \
1.149 @@ -142,16 +160,29 @@
1.150 ) >$(1)
1.151 endef
1.152
1.153 -$(CT_TOP_DIR)/config.gen/tools.in: $(TOOL_CONFIG_FILES)
1.154 - $(call build_gen_menu_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Tools,TOOL,config/tools,$(TOOLS))
1.155 +#-----------------------------------------------------------
1.156 +# The rules for the generated config files
1.157
1.158 -$(CT_TOP_DIR)/config.gen/debug.in: $(DEBUG_CONFIG_FILES)
1.159 - $(call build_gen_menu_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Debug,DEBUG,config/debug,$(DEBUGS))
1.160 +config.gen/arch.in: $(ARCH_CONFIG_FILES)
1.161 + $(call build_gen_choice_in,$@,Target Architecture,ARCH,config/arch,$(ARCHS))
1.162
1.163 -menuconfig oldconfig defoldconfig: $(KCONFIG_TOP)
1.164 +config.gen/kernel.in: $(KERNEL_CONFIG_FILES)
1.165 + $(call build_gen_choice_in,$@,Target OS,KERNEL,config/kernel,$(KERNELS))
1.166
1.167 -$(KCONFIG_TOP):
1.168 - @ln -sf $(CT_LIB_DIR)/config config
1.169 +config.gen/cc.in: $(CC_CONFIG_FILES)
1.170 + $(call build_gen_choice_in,$@,C compiler,CC,config/cc,$(CCS))
1.171 +
1.172 +config.gen/libc.in: $(LIBC_CONFIG_FILES)
1.173 + $(call build_gen_choice_in,$@,C library,LIBC,config/libc,$(LIBCS))
1.174 +
1.175 +config.gen/tools.in: $(TOOL_CONFIG_FILES)
1.176 + $(call build_gen_menu_in,$@,Tools,TOOL,config/tools,$(TOOLS))
1.177 +
1.178 +config.gen/debug.in: $(DEBUG_CONFIG_FILES)
1.179 + $(call build_gen_menu_in,$@,Debug,DEBUG,config/debug,$(DEBUGS))
1.180 +
1.181 +#-----------------------------------------------------------
1.182 +# The configurators rules
1.183
1.184 menuconfig: $(CONFIG_FILES) $(obj)/mconf
1.185 @$(obj)/mconf $(KCONFIG_TOP)
1.186 @@ -162,13 +193,16 @@
1.187 defoldconfig: $(CONFIG_FILES) $(obj)/conf
1.188 @yes "" |$(obj)/conf -s $(KCONFIG_TOP)
1.189
1.190 +#-----------------------------------------------------------
1.191 # Help text used by make help
1.192 +
1.193 help-config::
1.194 @echo ' menuconfig - Update current config using a menu based program'
1.195 @echo ' oldconfig - Update current config using a provided .config as base'
1.196 @echo ' build log piped into stdin'
1.197
1.198 -# Cheesy build
1.199 +#-----------------------------------------------------------
1.200 +# Not-so-cheesy build, needs rework...
1.201
1.202 SHIPPED := $(CT_LIB_DIR)/kconfig/zconf.tab.c $(CT_LIB_DIR)/kconfig/lex.zconf.c $(CT_LIB_DIR)/kconfig/zconf.hash.c
1.203
1.204 @@ -190,7 +224,7 @@
1.205 $(obj)/mconf: $(SHIPPED) $(CT_LIB_DIR)/kconfig/mconf.c \
1.206 $(HEADERS) $(FILES) \
1.207 $(CT_LIB_DIR)/kconfig/kconfig.mk
1.208 - @echo ' LD kconfig/mconf'
1.209 + @echo ' LD $@'
1.210 @$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{mconf.c,zconf.tab.c,lxdialog/*.c} \
1.211 $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ccflags) \
1.212 $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ldflags $(HOST_CC))
1.213 @@ -198,11 +232,17 @@
1.214 $(obj)/conf: $(SHIPPED) $(CT_LIB_DIR)/kconfig/conf.c \
1.215 $(HEADERS) $(FILES) \
1.216 $(CT_LIB_DIR)/kconfig/kconfig.mk
1.217 - @echo ' LD kconfig/conf'
1.218 + @echo ' LD $@'
1.219 @$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{conf.c,zconf.tab.c}
1.220
1.221 +#-----------------------------------------------------------
1.222 +# Cleaning up the mess...
1.223 +
1.224 clean::
1.225 - @rm -f $(CT_TOP_DIR)/kconfig/{,m}conf
1.226 - @rmdir --ignore-fail-on-non-empty $(CT_TOP_DIR)/kconfig 2>/dev/null || true
1.227 - @rm -f $(CT_TOP_DIR)/config 2>/dev/null || true
1.228 - @rm -rf $(CT_TOP_DIR)/config.gen
1.229 + @echo " CLEAN kconfig"
1.230 + @rm -f kconfig/{,m}conf
1.231 + @rmdir --ignore-fail-on-non-empty kconfig 2>/dev/null || true
1.232 + @echo " CLEAN config"
1.233 + @rm -f config 2>/dev/null || true
1.234 + @echo " CLEAN config.gen"
1.235 + @rm -rf config.gen