kconfig/kconfig.mk
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Oct 12 11:22:46 2008 +0000 (2008-10-12)
changeset 920 44dd635202a4
parent 916 68af6b83ff7e
child 922 3f0456891349
permissions -rw-r--r--
In generated choice menus, move the selection options outside the choice menu.

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