kconfig/kconfig.mk
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Fri Oct 17 12:47:53 2008 +0000 (2008-10-17)
changeset 943 1cca90ce0481
parent 942 86f3e28fa3cc
child 945 d0e5f04d2e06
permissions -rw-r--r--
Update the kconfig stuff to match the one in the linux-2.6.27 version.

/trunk/kconfig/zconf.hash.c | 225 110 115 0 +++----
/trunk/kconfig/lkc_proto.h | 4 3 1 0 +
/trunk/kconfig/mconf.c | 217 110 107 0 +++---
/trunk/kconfig/menu.c | 86 60 26 0 ++-
/trunk/kconfig/symbol.c | 212 156 56 0 ++++--
/trunk/kconfig/kconfig.mk | 24 9 15 0 -
/trunk/kconfig/lex.zconf.c | 97 80 17 0 ++-
/trunk/kconfig/util.c | 38 30 8 0 +
/trunk/kconfig/lkc.h | 22 18 4 0 +
/trunk/kconfig/expr.c | 32 19 13 0 +
/trunk/kconfig/confdata.c | 254 172 82 0 +++++---
/trunk/kconfig/lxdialog/dialog.h | 12 9 3 0 +
/trunk/kconfig/lxdialog/inputbox.c | 6 3 3 0
/trunk/kconfig/lxdialog/checklist.c | 4 2 2 0
/trunk/kconfig/lxdialog/menubox.c | 6 3 3 0
/trunk/kconfig/lxdialog/textbox.c | 2 1 1 0
/trunk/kconfig/lxdialog/util.c | 47 30 17 0 +
/trunk/kconfig/lxdialog/yesno.c | 4 2 2 0
/trunk/kconfig/expr.h | 20 10 10 0
/trunk/kconfig/zconf.tab.c | 1441 793 648 0 ++++++++++++++++++++++++-------------------
/trunk/kconfig/conf.c | 276 124 152 0 ++++----
/trunk/kconfig/check-gettext.sh | 14 14 0 0 +
/trunk/ct-ng.in | 2 1 1 0
23 files changed, 1759 insertions(+), 1286 deletions(-)
     1 # ===========================================================================
     2 # crosstool-NG configuration targets
     3 # These targets are used from top-level makefile
     4 
     5 # Derive the project version from, well, the project version:
     6 export PROJECTVERSION=$(CT_VERSION)
     7 
     8 #-----------------------------------------------------------
     9 # Some static /configuration/
    10 
    11 KCONFIG_TOP = config/config.in
    12 obj = kconfig
    13 PHONY += clean help oldconfig menuconfig defoldconfig
    14 
    15 #-----------------------------------------------------------
    16 # List all config files, source and generated
    17 
    18 # Build the list of all source config files
    19 STATIC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(shell find $(CT_LIB_DIR)/config -type f -name '*.in' 2>/dev/null))
    20 # ... and how to access them:
    21 $(STATIC_CONFIG_FILES): config
    22 
    23 # Build a list of per-component-type source config files
    24 ARCH_CONFIG_FILES   = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/arch/*.in))
    25 KERNEL_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/kernel/*.in))
    26 CC_CONFIG_FILES     = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/cc/*.in))
    27 LIBC_CONFIG_FILES   = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/libc/*.in))
    28 DEBUG_CONFIG_FILES  = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/debug/*.in))
    29 TOOL_CONFIG_FILES   = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/tools/*.in))
    30 
    31 # Build the list of generated config files
    32 GEN_CONFIG_FILES = config.gen/arch.in     \
    33                    config.gen/kernel.in   \
    34                    config.gen/cc.in       \
    35                    config.gen/libc.in     \
    36                    config.gen/tools.in    \
    37                    config.gen/debug.in
    38 # ... and how to access them:
    39 # Generated files depends on kconfig.mk (this file) because it has the
    40 # functions needed to build the genrated files, and thus they might
    41 # need re-generation if kconfig.mk changes
    42 $(GEN_CONFIG_FILES): config.gen                         \
    43                      $(CT_LIB_DIR)/kconfig/kconfig.mk
    44 
    45 # KCONFIG_TOP should already be in STATIC_CONFIG_FILES, anyway...
    46 CONFIG_FILES = $(sort $(KCONFIG_TOP) $(STATIC_CONFIG_FILES) $(GEN_CONFIG_FILES))
    47 
    48 # Where to access to the source config files from
    49 config:
    50 	@$(ECHO) "  LN    config"
    51 	$(SILENT)ln -s $(CT_LIB_DIR)/config config
    52 
    53 # Where to store the generated config files into
    54 config.gen:
    55 	@$(ECHO) "  MKDIR config.gen"
    56 	$(SILENT)mkdir -p config.gen
    57 
    58 #-----------------------------------------------------------
    59 # Build list of per-component-type items to easily build generated files
    60 
    61 ARCHS   = $(patsubst config/arch/%.in,%,$(ARCH_CONFIG_FILES))
    62 KERNELS = $(patsubst config/kernel/%.in,%,$(KERNEL_CONFIG_FILES))
    63 CCS     = $(patsubst config/cc/%.in,%,$(CC_CONFIG_FILES))
    64 LIBCS   = $(patsubst config/libc/%.in,%,$(LIBC_CONFIG_FILES))
    65 DEBUGS  = $(patsubst config/debug/%.in,%,$(DEBUG_CONFIG_FILES))
    66 TOOLS   = $(patsubst config/tools/%.in,%,$(TOOL_CONFIG_FILES))
    67 
    68 #-----------------------------------------------------------
    69 # Helper functions to ease building generated config files
    70 
    71 # The function 'build_gen_choice_in' builds a choice-menu of a list of
    72 # components in the given list, also adding source-ing of associazted
    73 # config files:
    74 # $1 : destination file
    75 # $2 : name for the entries family (eg. Architecture, kernel...)
    76 # $3 : prefix for the choice entries (eg. ARCH, KERNEL...)
    77 # $4 : base directory containing config files
    78 # $5 : list of config entries (eg. for architectures: "alpha arm ia64"...,
    79 #      and for kernels: "bare-metal linux"...)
    80 # Example to build the kernels generated config file:
    81 # $(call build_gen_choice_in,config.gen/kernel.in,Target OS,KERNEL,config/kernel,$(KERNELS))
    82 define build_gen_choice_in
    83 	@$(ECHO) '  IN    $(1)'
    84 	$(SILENT)(echo "# $(2) menu";                                       \
    85 	  echo "# Generated file, do not edit!!!";                          \
    86 	  echo "";                                                          \
    87 	  echo "choice";                                                    \
    88 	  echo "    bool";                                                  \
    89 	  echo "    prompt \"$(2)\"";                                       \
    90 	  echo "";                                                          \
    91 	  for entry in $(5); do                                             \
    92 	    file="$(4)/$${entry}.in";                                       \
    93 	    _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;');       \
    94 	    echo "config $(3)_$${_entry}";                                  \
    95 	    echo "    bool";                                                \
    96 	    printf "    prompt \"$${entry}";                                \
    97 	    if grep -E '^# +EXPERIMENTAL$$' $${file} >/dev/null 2>&1; then  \
    98 	      echo " (EXPERIMENTAL)\"";                                     \
    99 	      echo "    depends on EXPERIMENTAL";                           \
   100 	    else                                                            \
   101 	      echo "\"";                                                    \
   102 	    fi;                                                             \
   103 	  done;                                                             \
   104 	  echo "";                                                          \
   105 	  echo "endchoice";                                                 \
   106 	  for entry in $(5); do                                             \
   107 	    file="$(4)/$${entry}.in";                                       \
   108 	    _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;');       \
   109 	    echo "";                                                        \
   110 	    echo "if $(3)_$${_entry}";                                      \
   111 	    echo "config $(3)";                                             \
   112 	    echo "    default \"$${entry}\" if $(3)_$${_entry}";            \
   113 	    echo "source $${file}";                                         \
   114 	    echo "endif";                                                   \
   115 	  done;                                                             \
   116 	 ) >$(1)
   117 endef
   118 
   119 # The function 'build_gen_menu_in' builds a menuconfig for each component in
   120 # the given list, source-ing the associated files conditionnaly:
   121 # $1 : destination file
   122 # $2 : name of entries family (eg. Tools, Debug...)
   123 # $3 : prefix for the menu entries (eg. TOOL, DEBUG)
   124 # $4 : base directory containing config files
   125 # $5 : list of config entries (eg. for tools: "libelf sstrip"..., and for
   126 #      debug: "dmalloc duma gdb"...)
   127 # Example to build the tools generated config file:
   128 # $(call build_gen_menu_in,config.gen/tools.in,Tools,TOOL,config/tools,$(TOOLS))
   129 define build_gen_menu_in
   130 	@$(ECHO) '  IN    $(1)'
   131 	$(SILENT)(echo "# $(2) facilities menu";                            \
   132 	  echo "# Generated file, do not edit!!!";                          \
   133 	  echo "";                                                          \
   134 	  for entry in $(5); do                                             \
   135 	    file="$(4)/$${entry}.in";                                       \
   136 	    _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;');       \
   137 	    echo "menuconfig $(3)_$${_entry}";                              \
   138 	    echo "    bool";                                                \
   139 	    printf "    prompt \"$${entry}";                                \
   140 	    if grep -E '^# +EXPERIMENTAL$$' $${file} >/dev/null 2>&1; then  \
   141 	      echo " (EXPERIMENTAL)\"";                                     \
   142 	      echo "    depends on EXPERIMENTAL";                           \
   143 	    else                                                            \
   144 	      echo "\"";                                                    \
   145 	    fi;                                                             \
   146 	    echo "if $(3)_$${_entry}";                                      \
   147 	    echo "source $${file}";                                         \
   148 	    echo "endif";                                                   \
   149 	    echo "";                                                        \
   150 	  done;                                                             \
   151 	 ) >$(1)
   152 endef
   153 
   154 #-----------------------------------------------------------
   155 # The rules for the generated config files
   156 
   157 config.gen/arch.in: $(ARCH_CONFIG_FILES)
   158 	$(call build_gen_choice_in,$@,Target Architecture,ARCH,config/arch,$(ARCHS))
   159 
   160 config.gen/kernel.in: $(KERNEL_CONFIG_FILES)
   161 	$(call build_gen_choice_in,$@,Target OS,KERNEL,config/kernel,$(KERNELS))
   162 
   163 config.gen/cc.in: $(CC_CONFIG_FILES)
   164 	$(call build_gen_choice_in,$@,C compiler,CC,config/cc,$(CCS))
   165 
   166 config.gen/libc.in: $(LIBC_CONFIG_FILES)
   167 	$(call build_gen_choice_in,$@,C library,LIBC,config/libc,$(LIBCS))
   168 
   169 config.gen/tools.in: $(TOOL_CONFIG_FILES)
   170 	$(call build_gen_menu_in,$@,Tools,TOOL,config/tools,$(TOOLS))
   171 
   172 config.gen/debug.in: $(DEBUG_CONFIG_FILES)
   173 	$(call build_gen_menu_in,$@,Debug,DEBUG,config/debug,$(DEBUGS))
   174 
   175 #-----------------------------------------------------------
   176 # The configurators rules
   177 
   178 menuconfig: $(obj)/mconf $(CONFIG_FILES)
   179 	$(SILENT)$< $(KCONFIG_TOP)
   180 
   181 oldconfig: $(obj)/conf .config $(CONFIG_FILES)
   182 	$(SILENT)$< -s $(KCONFIG_TOP)
   183 
   184 defoldconfig: $(obj)/conf .config $(CONFIG_FILES)
   185 	$(SILENT)yes "" |$< -s $(KCONFIG_TOP)
   186 
   187 #-----------------------------------------------------------
   188 # Help text used by make help
   189 
   190 help-config::
   191 	@echo  '  menuconfig         - Update current config using a menu based program'
   192 	@echo  '  oldconfig          - Update current config using a provided .config as base'
   193 	@echo  '  defoldconfig       - As oldconfig, above, but using defaults for new options'
   194 
   195 #-----------------------------------------------------------
   196 # Hmmm! Cheesy build!
   197 # Or: where I can unveil my make-fu... :-]
   198 
   199 # Oh! Files not here are there, in fact! :-)
   200 vpath %.c $(CT_LIB_DIR)
   201 vpath %.h $(CT_LIB_DIR)
   202 
   203 # What is the compiler?
   204 HOST_CC ?= gcc -funsigned-char
   205 
   206 # Compiler flags to use gettext
   207 EXTRA_CFLAGS += $(shell $(SHELL) $(CT_LIB_DIR)/kconfig/check-gettext.sh $(HOST_CC) $(CFLAGS))
   208 
   209 # Compiler and linker flags to use ncurses
   210 EXTRA_CFLAGS += $(shell $(SHELL) $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ccflags)
   211 EXTRA_LDFLAGS += $(shell $(SHELL) $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ldflags $(HOST_CC))
   212 
   213 # Common source files, and lxdialog source files
   214 SRC = kconfig/zconf.tab.c
   215 LXSRC = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/kconfig/lxdialog/*.c))
   216 
   217 # What's needed to build 'conf'
   218 conf_SRC  = $(SRC) kconfig/conf.c
   219 conf_OBJ  = $(patsubst %.c,%.o,$(conf_SRC))
   220 
   221 # What's needed to build 'mconf'
   222 mconf_SRC = $(SRC) $(LXSRC) kconfig/mconf.c
   223 mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC))
   224 
   225 # Cheesy auto-dependencies
   226 DEPS = $(patsubst %.c,%.d,$(sort $(conf_SRC) $(mconf_SRC)))
   227 
   228 # This is not very nice, as they will get rebuild even if (dist)cleaning... :-(
   229 # Should look into the Linux kernel Kbuild to see how they do that...
   230 # To really make me look into this, keep the annoying "DEP xxx" messages.
   231 # Also see the comment for the "%.o: %c" rule below
   232 %.d: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk
   233 	$(SILENT)if [ ! -d $(obj)/lxdialog ]; then  \
   234 	   $(ECHO) "  MKDIR $(obj)";           \
   235 	   mkdir -p $(obj)/lxdialog;        \
   236 	 fi
   237 	@$(ECHO) "  DEP   $@"
   238 	$(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) -MM $< |sed -r -e 's|([^:]+.o)( *:+)|$(<:.c=.o) $@\2|;' >$@
   239 -include $(DEPS)
   240 
   241 # Each .o must depend on the corresponding .c (obvious, isn't it?),
   242 # but *can not* depend on kconfig/, because kconfig can be touched
   243 # during the build (who's touching it, btw?) so each .o would be
   244 # re-built when they sould not be.
   245 # So manually check for presence of $(obj) (ie. kconfig), and only mkdir
   246 # if needed. After all, that's not so bad...
   247 # mkdir $(obj)/lxdialog, because we need it, and incidentally, that
   248 # also creates $(obj).
   249 # Also rebuild the object files is the makefile is changed
   250 %.o: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk
   251 	$(SILENT)if [ ! -d $(obj)/lxdialog ]; then  \
   252 	   $(ECHO) "  MKDIR $(obj)";           \
   253 	   mkdir -p $(obj)/lxdialog;        \
   254 	 fi
   255 	@$(ECHO) "  CC    $@"
   256 	$(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $<
   257 
   258 $(obj)/mconf: $(mconf_OBJ)
   259 	@$(ECHO) '  LD    $@'
   260 	$(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $^
   261 
   262 $(obj)/conf: $(conf_OBJ)
   263 	@$(ECHO) '  LD    $@'
   264 	$(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $^
   265 
   266 #-----------------------------------------------------------
   267 # Cleaning up the mess...
   268 
   269 clean::
   270 	@$(ECHO) "  CLEAN kconfig"
   271 	$(SILENT)rm -f kconfig/{,m}conf $(conf_OBJ) $(mconf_OBJ) $(DEPS)
   272 	$(SILENT)rmdir --ignore-fail-on-non-empty kconfig{/lxdialog,} 2>/dev/null || true
   273 	@$(ECHO) "  CLEAN config"
   274 	$(SILENT)rm -f config 2>/dev/null || true
   275 	@$(ECHO) "  CLEAN config.gen"
   276 	$(SILENT)rm -rf config.gen