kconfig/kconfig.mk
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Fri Oct 10 14:30:44 2008 +0000 (2008-10-10)
changeset 916 68af6b83ff7e
parent 912 e611d558eb25
child 920 44dd635202a4
permissions -rw-r--r--
Simplify the Tools and Debug facilities menu entries:
- each config file no longer have to define their own 'menuconfig foo - if FOO - endif' gym
- each build script no longer has to say wether they are enabled
- generation of the 'menuconfig' entries for the Tools and Debug facilities now uses the same code
Some re-ordering of the code to be consistent with the steps ordering (tools, then debug).

/trunk/kconfig/kconfig.mk | 66 43 23 0 +++++++++++++++++++++++-------------
/trunk/scripts/build/debug.sh | 14 9 5 0 +++++---
/trunk/scripts/build/tools/000-template.sh | 7 0 7 0 ----
/trunk/scripts/build/tools/100-libelf.sh | 3 0 3 0 --
/trunk/scripts/build/tools/200-sstrip.sh | 2 0 2 0 -
/trunk/scripts/build/debug/000-template.sh | 7 0 7 0 ----
/trunk/scripts/build/debug/100-dmalloc.sh | 3 0 3 0 --
/trunk/scripts/build/debug/400-ltrace.sh | 3 0 3 0 --
/trunk/scripts/build/debug/300-gdb.sh | 3 0 3 0 --
/trunk/scripts/build/debug/500-strace.sh | 3 0 3 0 --
/trunk/scripts/build/debug/200-duma.sh | 3 0 3 0 --
/trunk/scripts/build/tools.sh | 14 9 5 0 +++++---
/trunk/scripts/crosstool.sh | 2 1 1 0
/trunk/config/debug/ltrace.in | 14 3 11 0 ++------
/trunk/config/debug/dmalloc.in | 9 1 8 0 +----
/trunk/config/debug/gdb.in | 9 1 8 0 +----
/trunk/config/debug/strace.in | 10 1 9 0 -----
/trunk/config/debug/duma.in | 10 1 9 0 -----
/trunk/config/tools/libelf.in | 12 2 10 0 +------
/trunk/config/tools/sstrip.in | 10 1 9 0 -----
/trunk/config/config.in | 4 2 2 0 +-
21 files changed, 74 insertions(+), 134 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,Kernel,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 	  for entry in $(5); do                                                             \
    62 	    file="$(4)/$${entry}.in";                                                       \
    63 	    _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;');                       \
    64 	    echo "config $(3)_$${_entry}";                                                  \
    65 	    echo "    bool";                                                                \
    66 	    printf "    prompt \"$${entry}";                                                \
    67 	    if grep -E '^# +EXPERIMENTAL$$' $${file} >/dev/null 2>&1; then                  \
    68 	      echo " (EXPERIMENTAL)\"";                                                     \
    69 	      echo "    depends on EXPERIMENTAL";                                           \
    70 	    else                                                                            \
    71 	      echo "\"";                                                                    \
    72 	    fi;                                                                             \
    73 	    echo "if $(3)_$${_entry}";                                                      \
    74 	    echo "config $(3)";                                                             \
    75 	    echo "    default \"$${entry}\" if $(3)_$${_entry}";                            \
    76 	    echo "source $${file}";                                                         \
    77 	    echo "endif";                                                                   \
    78 	    echo "";                                                                        \
    79 	  done;                                                                             \
    80 	 ) >$(1)
    81 endef
    82 
    83 $(CT_TOP_DIR)/config.gen/arch.in: $(ARCH_CONFIG_FILES)
    84 	$(call build_gen_choice_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Architecture,ARCH,config/arch,$(ARCHS))
    85 
    86 $(CT_TOP_DIR)/config.gen/kernel.in: $(KERNEL_CONFIG_FILES)
    87 	$(call build_gen_choice_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Kernel,KERNEL,config/kernel,$(KERNELS))
    88 
    89 # Function build_gen_menu_in:
    90 # $1 : destination file
    91 # $2 : name of entries family (eg. Tools, Debug...)
    92 # $3 : prefix for the menu entries (eg. TOOL, DEBUG)
    93 # $4 : base directory containing config files
    94 # $5 : list of config entries (eg. for tools: "libelf sstrip"..., and for
    95 #      debug: "dmalloc duma gdb"...)
    96 # Example to build the tools generated config file:
    97 # $(call build_gen_menu_in,config.gen/tools.in,Tools,TOOL,config/tools,$(TOOLS))
    98 define build_gen_menu_in
    99 	@echo '  IN   $(1)'
   100 	@(echo "# $(2) facilities menu";                                    \
   101 	  echo "# Generated file, do not edit!!!";                          \
   102 	  echo "";                                                          \
   103 	  for entry in $(5); do                                             \
   104 	    file="$(4)/$${entry}.in";                                       \
   105 	    _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;');       \
   106 	    echo "menuconfig $(3)_$${_entry}";                              \
   107 	    echo "    bool";                                                \
   108 	    printf "    prompt \"$${entry}";                                \
   109 	    if grep -E '^# +EXPERIMENTAL$$' $${file} >/dev/null 2>&1; then  \
   110 	      echo " (EXPERIMENTAL)\"";                                     \
   111 	      echo "    depends on EXPERIMENTAL";                           \
   112 	    else                                                            \
   113 	      echo "\"";                                                    \
   114 	    fi;                                                             \
   115 	    echo "if $(3)_$${_entry}";                                      \
   116 	    echo "source $${file}";                                         \
   117 	    echo "endif";                                                   \
   118 	    echo "";                                                        \
   119 	  done;                                                             \
   120 	 ) >$(1)
   121 endef
   122 
   123 $(CT_TOP_DIR)/config.gen/tools.in: $(TOOL_CONFIG_FILES)
   124 	$(call build_gen_menu_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Tools,TOOL,config/tools,$(TOOLS))
   125 
   126 $(CT_TOP_DIR)/config.gen/debug.in: $(DEBUG_CONFIG_FILES)
   127 	$(call build_gen_menu_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Debug,DEBUG,config/debug,$(DEBUGS))
   128 
   129 config menuconfig oldconfig defoldconfig: $(KCONFIG_TOP)
   130 
   131 $(KCONFIG_TOP):
   132 	@ln -sf $(CT_LIB_DIR)/config config
   133 
   134 menuconfig: $(CONFIG_FILES) $(obj)/mconf
   135 	@$(obj)/mconf $(KCONFIG_TOP)
   136 
   137 config: $(CONFIG_FILES) $(obj)/conf
   138 	@$(obj)/conf $(KCONFIG_TOP)
   139 
   140 oldconfig: $(CONFIG_FILES) $(obj)/conf
   141 	@$(obj)/conf -s $(KCONFIG_TOP)
   142 
   143 defoldconfig: $(CONFIG_FILES) $(obj)/conf
   144 	@yes "" |$(obj)/conf -s $(KCONFIG_TOP)
   145 
   146 # Help text used by make help
   147 help-config::
   148 	@echo  '  config             - Update current config using a line-oriented program'
   149 	@echo  '  menuconfig         - Update current config using a menu based program'
   150 	@echo  '  oldconfig          - Update current config using a provided .config as base'
   151 	@echo  '                       build log piped into stdin'
   152 
   153 # Cheesy build
   154 
   155 SHIPPED := $(CT_LIB_DIR)/kconfig/zconf.tab.c $(CT_LIB_DIR)/kconfig/lex.zconf.c $(CT_LIB_DIR)/kconfig/zconf.hash.c
   156 
   157 $(obj)/conf $(obj)/mconf: $(obj)
   158 
   159 $(obj):
   160 	@mkdir -p $(obj)
   161 
   162 HEADERS = $(CT_LIB_DIR)/kconfig/expr.h      \
   163           $(CT_LIB_DIR)/kconfig/lkc.h       \
   164           $(CT_LIB_DIR)/kconfig/lkc_proto.h
   165 
   166 FILES = $(CT_LIB_DIR)/kconfig/confdata.c    \
   167         $(CT_LIB_DIR)/kconfig/expr.c        \
   168         $(CT_LIB_DIR)/kconfig/menu.c        \
   169         $(CT_LIB_DIR)/kconfig/symbol.c      \
   170         $(CT_LIB_DIR)/kconfig/util.c
   171 
   172 $(obj)/mconf: $(SHIPPED) $(CT_LIB_DIR)/kconfig/mconf.c  \
   173               $(HEADERS) $(FILES)                       \
   174               $(CT_LIB_DIR)/kconfig/kconfig.mk
   175 	@echo '  LD   kconfig/mconf'
   176 	@$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{mconf.c,zconf.tab.c,lxdialog/*.c} \
   177 	     $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ccflags)              \
   178 	     $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ldflags $(HOST_CC))
   179 
   180 $(obj)/conf: $(SHIPPED) $(CT_LIB_DIR)/kconfig/conf.c    \
   181              $(HEADERS) $(FILES)                        \
   182              $(CT_LIB_DIR)/kconfig/kconfig.mk
   183 	@echo '  LD   kconfig/conf'
   184 	@$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{conf.c,zconf.tab.c}
   185 
   186 clean::
   187 	@rm -f $(CT_TOP_DIR)/kconfig/{,m}conf
   188 	@rmdir --ignore-fail-on-non-empty $(CT_TOP_DIR)/kconfig 2>/dev/null || true
   189 	@rm -f $(CT_TOP_DIR)/config 2>/dev/null || true
   190 	@rm -rf $(CT_TOP_DIR)/config.gen