kconfig/kconfig.mk
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Oct 13 11:23:51 2008 +0000 (2008-10-13)
changeset 922 3f0456891349
parent 920 44dd635202a4
child 923 54fc137f9dc8
permissions -rw-r--r--
Generate the choice menu for C libraries, the same way arch and kernels are generated.

/trunk/kconfig/kconfig.mk | 10 8 2 0 ++++++--
/trunk/scripts/build/libc/glibc.sh | 2 1 1 0 +-
/trunk/config/libc/glibc.in | 22 6 16 0 +++++-------------
/trunk/config/libc/uClibc.in | 7 6 1 0 +++++-
/trunk/config/libc/eglibc.in | 12 11 1 0 +++++++++-
/trunk/config/libc.in | 53 4 49 0 +++-----------------------------------------
6 files changed, 36 insertions(+), 70 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 KCONFIG_TOP = config/config.in
     9 obj = $(CT_TOP_DIR)/kconfig
    10 PHONY += clean help oldconfig menuconfig config defoldconfig
    11 
    12 # Darwin (MacOS-X) does not have proper libintl support
    13 ifeq ($(shell uname -s),Darwin)
    14 KBUILD_NO_NLS:=1
    15 endif
    16 
    17 ifneq ($(KBUILD_NO_NLS),)
    18 CFLAGS += -DKBUILD_NO_NLS
    19 endif
    20 
    21 # Build a list of all config files
    22 ARCH_CONFIG_FILES   = $(wildcard $(CT_LIB_DIR)/config/arch/*.in)
    23 KERNEL_CONFIG_FILES = $(wildcard $(CT_LIB_DIR)/config/kernel/*.in)
    24 LIBC_CONFIG_FILES   = $(wildcard $(CT_LIB_DIR)/config/libc/*.in)
    25 DEBUG_CONFIG_FILES  = $(wildcard $(CT_LIB_DIR)/config/debug/*.in)
    26 TOOL_CONFIG_FILES   = $(wildcard $(CT_LIB_DIR)/config/tools/*.in)
    27 
    28 STATIC_CONFIG_FILES = $(shell find $(CT_LIB_DIR)/config -type f -name '*.in')
    29 GEN_CONFIG_FILES=$(CT_TOP_DIR)/config.gen/arch.in   \
    30                  $(CT_TOP_DIR)/config.gen/kernel.in \
    31                  $(CT_TOP_DIR)/config.gen/libc.in   \
    32                  $(CT_TOP_DIR)/config.gen/tools.in  \
    33                  $(CT_TOP_DIR)/config.gen/debug.in
    34 
    35 CONFIG_FILES=$(STATIC_CONFIG_FILES) $(GEN_CONFIG_FILES)
    36 
    37 # Build list of items
    38 ARCHS   = $(patsubst $(CT_LIB_DIR)/config/arch/%.in,%,$(ARCH_CONFIG_FILES))
    39 KERNELS = $(patsubst $(CT_LIB_DIR)/config/kernel/%.in,%,$(KERNEL_CONFIG_FILES))
    40 LIBCS   = $(patsubst $(CT_LIB_DIR)/config/libc/%.in,%,$(LIBC_CONFIG_FILES))
    41 DEBUGS  = $(patsubst $(CT_LIB_DIR)/config/debug/%.in,%,$(DEBUG_CONFIG_FILES))
    42 TOOLS   = $(patsubst $(CT_LIB_DIR)/config/tools/%.in,%,$(TOOL_CONFIG_FILES))
    43 
    44 $(GEN_CONFIG_FILES): $(CT_TOP_DIR)/config.gen           \
    45                      $(CT_LIB_DIR)/kconfig/kconfig.mk
    46 
    47 $(CT_TOP_DIR)/config.gen: $(KCONFIG_TOP)
    48 	@mkdir -p $(CT_TOP_DIR)/config.gen
    49 
    50 # Function build_gen_choice_in:
    51 # $1 : destination file
    52 # $2 : name for the entries family (eg. Architecture, kernel...)
    53 # $3 : prefix for the choice entries (eg. ARCH, KERNEL...)
    54 # $4 : base directory containing config files
    55 # $5 : list of config entries (eg. for architectures: "alpha arm ia64"...,
    56 #      and for kernels: "bare-metal linux"...)
    57 # Example to build the kernels generated config file:
    58 # $(call build_gen_choice_in,config.gen/kernel.in,Target OS,KERNEL,config/kernel,$(KERNELS))
    59 define build_gen_choice_in
    60 	@echo '  IN   $(1)'
    61 	@(echo "# $(2) menu";                                               \
    62 	  echo "# Generated file, do not edit!!!";                          \
    63 	  echo "";                                                          \
    64 	  echo "choice";                                                    \
    65 	  echo "    bool";                                                  \
    66 	  echo "    prompt \"$(2)\"";                                       \
    67 	  echo "";                                                          \
    68 	  for entry in $(5); do                                             \
    69 	    file="$(4)/$${entry}.in";                                       \
    70 	    _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;');       \
    71 	    echo "config $(3)_$${_entry}";                                  \
    72 	    echo "    bool";                                                \
    73 	    printf "    prompt \"$${entry}";                                \
    74 	    if grep -E '^# +EXPERIMENTAL$$' $${file} >/dev/null 2>&1; then  \
    75 	      echo " (EXPERIMENTAL)\"";                                     \
    76 	      echo "    depends on EXPERIMENTAL";                           \
    77 	    else                                                            \
    78 	      echo "\"";                                                    \
    79 	    fi;                                                             \
    80 	  done;                                                             \
    81 	  echo "";                                                          \
    82 	  echo "endchoice";                                                 \
    83 	  for entry in $(5); do                                             \
    84 	    file="$(4)/$${entry}.in";                                       \
    85 	    _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;');       \
    86 	    echo "";                                                        \
    87 	    echo "if $(3)_$${_entry}";                                      \
    88 	    echo "config $(3)";                                             \
    89 	    echo "    default \"$${entry}\" if $(3)_$${_entry}";            \
    90 	    echo "source $${file}";                                         \
    91 	    echo "endif";                                                   \
    92 	  done;                                                             \
    93 	 ) >$(1)
    94 endef
    95 
    96 $(CT_TOP_DIR)/config.gen/arch.in: $(ARCH_CONFIG_FILES)
    97 	$(call build_gen_choice_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Target Architecture,ARCH,config/arch,$(ARCHS))
    98 
    99 $(CT_TOP_DIR)/config.gen/kernel.in: $(KERNEL_CONFIG_FILES)
   100 	$(call build_gen_choice_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Target OS,KERNEL,config/kernel,$(KERNELS))
   101 
   102 $(CT_TOP_DIR)/config.gen/libc.in: $(LIBC_CONFIG_FILES)
   103 	$(call build_gen_choice_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),C library,LIBC,config/libc,$(LIBCS))
   104 
   105 # Function build_gen_menu_in:
   106 # $1 : destination file
   107 # $2 : name of entries family (eg. Tools, Debug...)
   108 # $3 : prefix for the menu entries (eg. TOOL, DEBUG)
   109 # $4 : base directory containing config files
   110 # $5 : list of config entries (eg. for tools: "libelf sstrip"..., and for
   111 #      debug: "dmalloc duma gdb"...)
   112 # Example to build the tools generated config file:
   113 # $(call build_gen_menu_in,config.gen/tools.in,Tools,TOOL,config/tools,$(TOOLS))
   114 define build_gen_menu_in
   115 	@echo '  IN   $(1)'
   116 	@(echo "# $(2) facilities menu";                                    \
   117 	  echo "# Generated file, do not edit!!!";                          \
   118 	  echo "";                                                          \
   119 	  for entry in $(5); do                                             \
   120 	    file="$(4)/$${entry}.in";                                       \
   121 	    _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;');       \
   122 	    echo "menuconfig $(3)_$${_entry}";                              \
   123 	    echo "    bool";                                                \
   124 	    printf "    prompt \"$${entry}";                                \
   125 	    if grep -E '^# +EXPERIMENTAL$$' $${file} >/dev/null 2>&1; then  \
   126 	      echo " (EXPERIMENTAL)\"";                                     \
   127 	      echo "    depends on EXPERIMENTAL";                           \
   128 	    else                                                            \
   129 	      echo "\"";                                                    \
   130 	    fi;                                                             \
   131 	    echo "if $(3)_$${_entry}";                                      \
   132 	    echo "source $${file}";                                         \
   133 	    echo "endif";                                                   \
   134 	    echo "";                                                        \
   135 	  done;                                                             \
   136 	 ) >$(1)
   137 endef
   138 
   139 $(CT_TOP_DIR)/config.gen/tools.in: $(TOOL_CONFIG_FILES)
   140 	$(call build_gen_menu_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Tools,TOOL,config/tools,$(TOOLS))
   141 
   142 $(CT_TOP_DIR)/config.gen/debug.in: $(DEBUG_CONFIG_FILES)
   143 	$(call build_gen_menu_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Debug,DEBUG,config/debug,$(DEBUGS))
   144 
   145 config menuconfig oldconfig defoldconfig: $(KCONFIG_TOP)
   146 
   147 $(KCONFIG_TOP):
   148 	@ln -sf $(CT_LIB_DIR)/config config
   149 
   150 menuconfig: $(CONFIG_FILES) $(obj)/mconf
   151 	@$(obj)/mconf $(KCONFIG_TOP)
   152 
   153 config: $(CONFIG_FILES) $(obj)/conf
   154 	@$(obj)/conf $(KCONFIG_TOP)
   155 
   156 oldconfig: $(CONFIG_FILES) $(obj)/conf
   157 	@$(obj)/conf -s $(KCONFIG_TOP)
   158 
   159 defoldconfig: $(CONFIG_FILES) $(obj)/conf
   160 	@yes "" |$(obj)/conf -s $(KCONFIG_TOP)
   161 
   162 # Help text used by make help
   163 help-config::
   164 	@echo  '  config             - Update current config using a line-oriented program'
   165 	@echo  '  menuconfig         - Update current config using a menu based program'
   166 	@echo  '  oldconfig          - Update current config using a provided .config as base'
   167 	@echo  '                       build log piped into stdin'
   168 
   169 # Cheesy build
   170 
   171 SHIPPED := $(CT_LIB_DIR)/kconfig/zconf.tab.c $(CT_LIB_DIR)/kconfig/lex.zconf.c $(CT_LIB_DIR)/kconfig/zconf.hash.c
   172 
   173 $(obj)/conf $(obj)/mconf: $(obj)
   174 
   175 $(obj):
   176 	@mkdir -p $(obj)
   177 
   178 HEADERS = $(CT_LIB_DIR)/kconfig/expr.h      \
   179           $(CT_LIB_DIR)/kconfig/lkc.h       \
   180           $(CT_LIB_DIR)/kconfig/lkc_proto.h
   181 
   182 FILES = $(CT_LIB_DIR)/kconfig/confdata.c    \
   183         $(CT_LIB_DIR)/kconfig/expr.c        \
   184         $(CT_LIB_DIR)/kconfig/menu.c        \
   185         $(CT_LIB_DIR)/kconfig/symbol.c      \
   186         $(CT_LIB_DIR)/kconfig/util.c
   187 
   188 $(obj)/mconf: $(SHIPPED) $(CT_LIB_DIR)/kconfig/mconf.c  \
   189               $(HEADERS) $(FILES)                       \
   190               $(CT_LIB_DIR)/kconfig/kconfig.mk
   191 	@echo '  LD   kconfig/mconf'
   192 	@$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{mconf.c,zconf.tab.c,lxdialog/*.c} \
   193 	     $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ccflags)              \
   194 	     $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ldflags $(HOST_CC))
   195 
   196 $(obj)/conf: $(SHIPPED) $(CT_LIB_DIR)/kconfig/conf.c    \
   197              $(HEADERS) $(FILES)                        \
   198              $(CT_LIB_DIR)/kconfig/kconfig.mk
   199 	@echo '  LD   kconfig/conf'
   200 	@$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{conf.c,zconf.tab.c}
   201 
   202 clean::
   203 	@rm -f $(CT_TOP_DIR)/kconfig/{,m}conf
   204 	@rmdir --ignore-fail-on-non-empty $(CT_TOP_DIR)/kconfig 2>/dev/null || true
   205 	@rm -f $(CT_TOP_DIR)/config 2>/dev/null || true
   206 	@rm -rf $(CT_TOP_DIR)/config.gen