1.1 --- a/kconfig/kconfig.mk Fri Oct 17 12:47:53 2008 +0000
1.2 +++ b/kconfig/kconfig.mk Sat Oct 18 18:37:28 2008 +0000
1.3 @@ -8,180 +8,24 @@
1.4 #-----------------------------------------------------------
1.5 # Some static /configuration/
1.6
1.7 -KCONFIG_TOP = config/config.in
1.8 +# The place where the kconfig stuff lies
1.9 obj = kconfig
1.10 -PHONY += clean help oldconfig menuconfig defoldconfig
1.11 -
1.12 -#-----------------------------------------------------------
1.13 -# List all config files, source and generated
1.14 -
1.15 -# Build the list of all source config files
1.16 -STATIC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(shell find $(CT_LIB_DIR)/config -type f -name '*.in' 2>/dev/null))
1.17 -# ... and how to access them:
1.18 -$(STATIC_CONFIG_FILES): config
1.19 -
1.20 -# Build a list of per-component-type source config files
1.21 -ARCH_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/arch/*.in))
1.22 -KERNEL_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/kernel/*.in))
1.23 -CC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/cc/*.in))
1.24 -LIBC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/libc/*.in))
1.25 -DEBUG_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/debug/*.in))
1.26 -TOOL_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/tools/*.in))
1.27 -
1.28 -# Build the list of generated config files
1.29 -GEN_CONFIG_FILES = config.gen/arch.in \
1.30 - config.gen/kernel.in \
1.31 - config.gen/cc.in \
1.32 - config.gen/libc.in \
1.33 - config.gen/tools.in \
1.34 - config.gen/debug.in
1.35 -# ... and how to access them:
1.36 -# Generated files depends on kconfig.mk (this file) because it has the
1.37 -# functions needed to build the genrated files, and thus they might
1.38 -# need re-generation if kconfig.mk changes
1.39 -$(GEN_CONFIG_FILES): config.gen \
1.40 - $(CT_LIB_DIR)/kconfig/kconfig.mk
1.41 -
1.42 -# KCONFIG_TOP should already be in STATIC_CONFIG_FILES, anyway...
1.43 -CONFIG_FILES = $(sort $(KCONFIG_TOP) $(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 # The configurators rules
1.174
1.175 -menuconfig: $(obj)/mconf $(CONFIG_FILES)
1.176 +PHONY += oldconfig menuconfig defoldconfig
1.177 +
1.178 +menuconfig: $(obj)/mconf config_files
1.179 + @$(ECHO) " MCONF $(KCONFIG_TOP)"
1.180 $(SILENT)$< $(KCONFIG_TOP)
1.181
1.182 -oldconfig: $(obj)/conf .config $(CONFIG_FILES)
1.183 +oldconfig: $(obj)/conf .config config_files
1.184 + @$(ECHO) " CONF $(KCONFIG_TOP)"
1.185 $(SILENT)$< -s $(KCONFIG_TOP)
1.186
1.187 -defoldconfig: $(obj)/conf .config $(CONFIG_FILES)
1.188 +defoldconfig: $(obj)/conf .config config_files
1.189 + @$(ECHO) " CONF $(KCONFIG_TOP)"
1.190 $(SILENT)yes "" |$< -s $(KCONFIG_TOP)
1.191
1.192 #-----------------------------------------------------------
1.193 @@ -223,20 +67,20 @@
1.194 mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC))
1.195
1.196 # Cheesy auto-dependencies
1.197 -DEPS = $(patsubst %.c,%.d,$(sort $(conf_SRC) $(mconf_SRC)))
1.198 +DEPS = $(patsubst %.c,%.dep,$(sort $(conf_SRC) $(mconf_SRC)))
1.199 +-include $(DEPS)
1.200
1.201 # This is not very nice, as they will get rebuild even if (dist)cleaning... :-(
1.202 # Should look into the Linux kernel Kbuild to see how they do that...
1.203 # To really make me look into this, keep the annoying "DEP xxx" messages.
1.204 # Also see the comment for the "%.o: %c" rule below
1.205 -%.d: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk
1.206 +%.dep: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk $(CT_NG)
1.207 $(SILENT)if [ ! -d $(obj)/lxdialog ]; then \
1.208 $(ECHO) " MKDIR $(obj)"; \
1.209 mkdir -p $(obj)/lxdialog; \
1.210 fi
1.211 @$(ECHO) " DEP $@"
1.212 $(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) -MM $< |sed -r -e 's|([^:]+.o)( *:+)|$(<:.c=.o) $@\2|;' >$@
1.213 --include $(DEPS)
1.214
1.215 # Each .o must depend on the corresponding .c (obvious, isn't it?),
1.216 # but *can not* depend on kconfig/, because kconfig can be touched
1.217 @@ -270,7 +114,3 @@
1.218 @$(ECHO) " CLEAN kconfig"
1.219 $(SILENT)rm -f kconfig/{,m}conf $(conf_OBJ) $(mconf_OBJ) $(DEPS)
1.220 $(SILENT)rmdir --ignore-fail-on-non-empty kconfig{/lxdialog,} 2>/dev/null || true
1.221 - @$(ECHO) " CLEAN config"
1.222 - $(SILENT)rm -f config 2>/dev/null || true
1.223 - @$(ECHO) " CLEAN config.gen"
1.224 - $(SILENT)rm -rf config.gen