config/config.mk
changeset 2537 95d470b5a6a9
parent 2529 7e191964d8f2
child 2981 80151a249b85
     1.1 --- a/config/config.mk	Sun Jul 03 09:08:30 2011 +0200
     1.2 +++ b/config/config.mk	Sun Jul 03 23:02:16 2011 +0200
     1.3 @@ -31,10 +31,13 @@
     1.4                     config.gen/libc.in     \
     1.5                     config.gen/debug.in
     1.6  # ... and how to access them:
     1.7 -# Generated files depends on config.mk (this file) because it has the
     1.8 -# functions needed to build the genrated files, and thus they might
     1.9 -# need re-generation if config.mk changes
    1.10 -$(GEN_CONFIG_FILES): config.gen                         \
    1.11 +# Generated files depends on the gen_in_frags script because it has the
    1.12 +# functions needed to build the genrated files, and thus they might need
    1.13 +# re-generation if it changes.
    1.14 +# They also depends on config.mk (this file) because it has the dependency
    1.15 +# rules, and thus they might need re-generation if the deps change.
    1.16 +$(GEN_CONFIG_FILES): config.gen                             \
    1.17 +                     $(CT_LIB_DIR)/scripts/gen_in_frags.sh  \
    1.18                       $(CT_LIB_DIR)/config/config.mk
    1.19  
    1.20  # Helper entry for the configurators
    1.21 @@ -61,133 +64,29 @@
    1.22  DEBUGS  = $(patsubst config/debug/%.in,%,$(DEBUG_CONFIG_FILES))
    1.23  
    1.24  #-----------------------------------------------------------
    1.25 -# Helper functions to ease building generated config files
    1.26 -
    1.27 -# The function 'build_gen_choice_in' builds a choice-menu of a list of
    1.28 -# components in the given list, also adding source-ing of associazted
    1.29 -# config files:
    1.30 -# $1 : destination file
    1.31 -# $2 : name for the entries family (eg. Architecture, kernel...)
    1.32 -# $3 : prefix for the choice entries (eg. ARCH, KERNEL...)
    1.33 -# $4 : base directory containing config files
    1.34 -# $5 : generate backend conditionals if Y, don't if anything else
    1.35 -# $6 : list of config entries (eg. for architectures: "alpha arm ia64"...,
    1.36 -#      and for kernels: "bare-metal linux"...)
    1.37 -# Example to build the kernels generated config file:
    1.38 -# $(call build_gen_choice_in,config.gen/kernel.in,Target OS,KERNEL,config/kernel,$(KERNELS))
    1.39 -define build_gen_choice_in
    1.40 -	@$(ECHO) '  IN    $(1)'
    1.41 -	$(SILENT)(echo "# $(2) menu";                                           \
    1.42 -	  echo "# Generated file, do not edit!!!";                              \
    1.43 -	  echo "";                                                              \
    1.44 -	  echo "choice GEN_CHOICE_$(3)";                                        \
    1.45 -	  echo "    bool";                                                      \
    1.46 -	  echo "    prompt \"$(2)\"";                                           \
    1.47 -	  echo "";                                                              \
    1.48 -	  for entry in $(6); do                                                 \
    1.49 -	    file="$(4)/$${entry}.in";                                           \
    1.50 -	    _entry=$$(echo "$${entry}" |$(sed) -r -s -e 's/[-.+]/_/g;');        \
    1.51 -	    echo "config $(3)_$${_entry}";                                      \
    1.52 -	    echo "    bool";                                                    \
    1.53 -	    echo "    prompt \"$${entry}\"";                                    \
    1.54 -	    if [ "$(5)" = "Y" ]; then                                           \
    1.55 -	      echo "    depends on $(3)_$${_entry}_AVAILABLE";                  \
    1.56 -	    fi;                                                                 \
    1.57 -	    $(sed) -r -e '/^## depends on /!d; s/^## /    /;' $${file} 2>/dev/null;     \
    1.58 -	    $(sed) -r -e '/^## select /!d; s/^## /    /;' $${file} 2>/dev/null;         \
    1.59 -	    if grep -E '^## help' $${file} >/dev/null 2>&1; then                        \
    1.60 -	      echo "    help";                                                          \
    1.61 -	      $(sed) -r -e '/^## help ?/!d; s/^## help ?/      /;' $${file} 2>/dev/null;\
    1.62 -	    fi;                                                                         \
    1.63 -	    echo "";                                                            \
    1.64 -	  done;                                                                 \
    1.65 -	  echo "endchoice";                                                     \
    1.66 -	  for entry in $(6); do                                                 \
    1.67 -	    file="$(4)/$${entry}.in";                                           \
    1.68 -	    _entry=$$(echo "$${entry}" |$(sed) -r -s -e 's/[-.+]/_/g;');        \
    1.69 -	    echo "";                                                            \
    1.70 -	    if [ "$(5)" = "Y" ]; then                                                                     \
    1.71 -	      echo "config $(3)_$${_entry}_AVAILABLE";                                                    \
    1.72 -	      echo "    bool";                                                                            \
    1.73 -	      echo "    default y if BACKEND_$(3) = \"$${entry}\" || BACKEND_$(3) = \"\" || ! BACKEND";   \
    1.74 -	    fi;                                                                                           \
    1.75 -	    echo "if $(3)_$${_entry}";                                          \
    1.76 -	    echo "config $(3)";                                                 \
    1.77 -	    echo "    default \"$${entry}\" if $(3)_$${_entry}";                \
    1.78 -	    echo "source \"$${file}\"";                                         \
    1.79 -	    echo "endif";                                                       \
    1.80 -	  done;                                                                 \
    1.81 -	 ) >$(1)
    1.82 -	$(SILENT)(echo "# $(2) second part options";                            \
    1.83 -	  echo "# Generated file, do not edit!!!";                              \
    1.84 -	  for entry in $(6); do                                                 \
    1.85 -	    file="$(4)/$${entry}.in";                                           \
    1.86 -	    _entry=$$(echo "$${entry}" |$(sed) -r -s -e 's/[-.+]/_/g;');        \
    1.87 -	    if [ -f "$${file}.2" ]; then                                        \
    1.88 -	      echo "";                                                          \
    1.89 -	      echo "if $(3)_$${_entry}";                                        \
    1.90 -	      echo "comment \"$${entry} other options\"";                       \
    1.91 -	      echo "source \"$${file}.2\"";                                     \
    1.92 -	      echo "endif";                                                     \
    1.93 -	    fi;                                                                 \
    1.94 -	  done;                                                                 \
    1.95 -	 ) >$(1).2
    1.96 -endef
    1.97 -
    1.98 -# The function 'build_gen_menu_in' builds a menuconfig for each component in
    1.99 -# the given list, source-ing the associated files conditionnaly:
   1.100 -# $1 : destination file
   1.101 -# $2 : name of entries family (eg. Tools, Debug...)
   1.102 -# $3 : prefix for the menu entries (eg. DEBUG)
   1.103 -# $4 : base directory containing config files
   1.104 -# $5 : list of config entries (eg. for debug: "dmalloc duma gdb"...)
   1.105 -# Example to build the generated debug config file:
   1.106 -# $(call build_gen_menu_in,config.gen/debug.in,Debug,DEBUG,config/debug,$(DEBUGS))
   1.107 -define build_gen_menu_in
   1.108 -	@$(ECHO) '  IN    $(1)'
   1.109 -	$(SILENT)(echo "# $(2) facilities menu";                                \
   1.110 -	  echo "# Generated file, do not edit!!!";                              \
   1.111 -	  echo "";                                                              \
   1.112 -	  for entry in $(5); do                                                 \
   1.113 -	    file="$(4)/$${entry}.in";                                           \
   1.114 -	    _entry=$$(echo "$${entry}" |$(sed) -r -s -e 's/[-.+]/_/g;');        \
   1.115 -	    echo "menuconfig $(3)_$${_entry}";                                  \
   1.116 -	    echo "    bool";                                                    \
   1.117 -	    echo "    prompt \"$${entry}\"";                                    \
   1.118 -	    $(sed) -r -e '/^## depends on /!d; s/^## /    /;' $${file} 2>/dev/null;     \
   1.119 -	    $(sed) -r -e '/^## select /!d; s/^## /    /;' $${file} 2>/dev/null;         \
   1.120 -	    if grep -E '^## help' $${file} >/dev/null 2>&1; then                        \
   1.121 -	      echo "    help";                                                          \
   1.122 -	      $(sed) -r -e '/^## help ?/!d; s/^## help ?/      /;' $${file} 2>/dev/null;\
   1.123 -	    fi;                                                                         \
   1.124 -	    echo "";                                                            \
   1.125 -	    echo "if $(3)_$${_entry}";                                          \
   1.126 -	    echo "source \"$${file}\"";                                         \
   1.127 -	    echo "endif";                                                       \
   1.128 -	    echo "";                                                            \
   1.129 -	  done;                                                                 \
   1.130 -	 ) >$(1)
   1.131 -endef
   1.132 -
   1.133 -#-----------------------------------------------------------
   1.134  # The rules for the generated config files
   1.135  
   1.136  # WARNING! If a .in file disapears between two runs, that will NOT be detected!
   1.137  
   1.138  config.gen/arch.in: $(ARCH_CONFIG_FILES) $(ARCH_CONFIG_FILES_2)
   1.139 -	$(call build_gen_choice_in,$@,Target Architecture,ARCH,config/arch,Y,$(ARCHS))
   1.140 +	@$(ECHO) '  IN    $(@)'
   1.141 +	$(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh choice "$@" "Target Architecture" "ARCH" "config/arch" "Y" $(ARCHS)
   1.142  
   1.143  config.gen/kernel.in: $(KERNEL_CONFIG_FILES) $(KERNEL_CONFIG_FILES_2)
   1.144 -	$(call build_gen_choice_in,$@,Target OS,KERNEL,config/kernel,Y,$(KERNELS))
   1.145 +	@$(ECHO) '  IN    $(@)'
   1.146 +	$(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh choice "$@" "Target OS" "KERNEL" "config/kernel" "Y" $(KERNELS)
   1.147  
   1.148  config.gen/cc.in: $(CC_CONFIG_FILES) $(CC_CONFIG_FILES_2)
   1.149 -	$(call build_gen_choice_in,$@,C compiler,CC,config/cc,,$(CCS))
   1.150 +	@$(ECHO) '  IN    $(@)'
   1.151 +	$(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh choice "$@" "C compiler" "CC" "config/cc" "N" $(CCS)
   1.152  
   1.153  config.gen/libc.in: $(LIBC_CONFIG_FILES) $(LIBC_CONFIG_FILES_2)
   1.154 -	$(call build_gen_choice_in,$@,C library,LIBC,config/libc,Y,$(LIBCS))
   1.155 +	@$(ECHO) '  IN    $(@)'
   1.156 +	$(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh choice "$@" "C library" "LIBC" "config/libc" "Y" $(LIBCS)
   1.157  
   1.158  config.gen/debug.in: $(DEBUG_CONFIG_FILES)
   1.159 -	$(call build_gen_menu_in,$@,Debug,DEBUG,config/debug,$(DEBUGS))
   1.160 +	@$(ECHO) '  IN    $(@)'
   1.161 +	$(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh menu "$@" "Debug facilities" "DEBUG" "config/debug" $(DEBUGS)
   1.162  
   1.163  #-----------------------------------------------------------
   1.164  # Cleaning up the mess...