From 82c9d1aceb9b59f06f9f16496184ec16133447be Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Fri, 10 Oct 2008 14:30:44 +0000 Subject: 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(-) diff --git a/config/config.in b/config/config.in index cd73a3e..16a62f2 100644 --- a/config/config.in +++ b/config/config.in @@ -6,5 +6,5 @@ source config/gmp_mpfr.in source config/binutils.in source config/cc.in source config/libc.in -source config.gen/tools.in -source config.gen/debug.in +source config/tools.in +source config/debug.in diff --git a/config/debug/dmalloc.in b/config/debug/dmalloc.in index 692c229..7f4751f 100644 --- a/config/debug/dmalloc.in +++ b/config/debug/dmalloc.in @@ -1,12 +1,7 @@ # dmalloc debug facility -menuconfig DMALLOC +config DEBUG_dmalloc bool - prompt "dmalloc" - default n - depends on ! BARE_METAL - -if DMALLOC choice bool @@ -31,5 +26,3 @@ config DMALLOC_VERSION default "5.5.2" if DMALLOC_V_5_5_2 # CT_INSERT_VERSION_STRING_ABOVE # Don't remove above line! - -endif diff --git a/config/debug/duma.in b/config/debug/duma.in index 5de4e7c..eebb621 100644 --- a/config/debug/duma.in +++ b/config/debug/duma.in @@ -1,17 +1,11 @@ # D.U.M.A. - Detect Unintended Memory Access - Memory checker -menuconfig DUMA - bool - prompt "D.U.M.A." - default n - depends on ! BARE_METAL +config DEBUG_duma help D.U.M.A. - Detect Unintended Memory Access A memory bound checker, with additional features. Formerly known as Electric Fence. -if DUMA - config DUMA_A bool prompt "Build a static library" @@ -55,5 +49,3 @@ config DUMA_VERSION default "2_5_14" if DUMA_V_2_5_14 # CT_INSERT_VERSION_STRING_ABOVE # Don't remove above line! - -endif diff --git a/config/debug/gdb.in b/config/debug/gdb.in index 0d01583..41702bf 100644 --- a/config/debug/gdb.in +++ b/config/debug/gdb.in @@ -1,14 +1,9 @@ # GDB menu -menuconfig GDB - bool - prompt "gdb" - default n +config DEBUG_gdb help Enable gdb for the target -if GDB - config GDB_CROSS bool prompt "Cross-gdb" @@ -167,5 +162,3 @@ config NCURSES_VERSION default "5.6" if NCURSES_V_5_6 endif # GDB_NATIVE --> ncurses - -endif diff --git a/config/debug/ltrace.in b/config/debug/ltrace.in index dbc90ea..ebe00e8 100644 --- a/config/debug/ltrace.in +++ b/config/debug/ltrace.in @@ -1,20 +1,14 @@ +# EXPERIMENTAL # ltrace -menuconfig LTRACE - bool - prompt "ltrace (EXPERIMENTAL)" - default n - depends on EXPERIMENTAL - depends on ! BARE_METAL - select LIBELF +config DEBUG_ltrace + select TOOL_libelf help ltrace is currently BROKEN! It depends on libelf, and I don't know how to configure/compile that so that ltrace can successfully use it. If you manage to build ltrace (and libelf!), please be so kind as to tell me! Thank you! -if LTRACE - choice bool prompt "ltrace version" @@ -38,5 +32,3 @@ config LTRACE_VERSION default "0.4" if LTRACE_V_0_4 # CT_INSERT_VERSION_STRING_ABOVE # # Don't remove above line! - -endif diff --git a/config/debug/strace.in b/config/debug/strace.in index 055bb22..49be38c 100644 --- a/config/debug/strace.in +++ b/config/debug/strace.in @@ -1,12 +1,6 @@ # strace -menuconfig STRACE - bool - prompt "strace" - default n - depends on ! BARE_METAL - -if STRACE +config DEBUG_strace choice bool @@ -42,5 +36,3 @@ config STRACE_VERSION default "4.5.16" if STRACE_V_4_5_16 # CT_INSERT_VERSION_STRING_ABOVE # # Don't remove above line! - -endif diff --git a/config/tools/libelf.in b/config/tools/libelf.in index 213fdc5..91579f7 100644 --- a/config/tools/libelf.in +++ b/config/tools/libelf.in @@ -1,11 +1,7 @@ +# EXPERIMENTAL # libelf config file -menuconfig LIBELF - bool - prompt "libelf (BROKEN)" - default n - depends on EXPERIMENTAL - depends on ! BARE_METAL +config TOOL_libelf help libelf lets you read, modify or create ELF files in an architecture-independent way. @@ -14,8 +10,6 @@ menuconfig LIBELF please be so kind as to tell me. (By working, I mean it is useable at least by ltrace.) Thank you! -if LIBELF - choice bool prompt "libelf version" @@ -44,5 +38,3 @@ config LIBELF_VERSION default "0.8.10" if LIBELF_V_0_8_10 # CT_INSERT_VERSION_STRING_ABOVE # Don't remove above line! - -endif diff --git a/config/tools/sstrip.in b/config/tools/sstrip.in index 9b7d9d6..f78330f 100644 --- a/config/tools/sstrip.in +++ b/config/tools/sstrip.in @@ -1,16 +1,10 @@ # Configuration file for sstrip tool facility -menuconfig SSTRIP - bool - prompt "sstrip" - depends on ! BARE_METAL - default n +config TOOL_sstrip help The sstrip utility, to maximise the striping of ELF binaries (executables and libraries). -if SSTRIP - choice bool prompt "Use sstrip from:" @@ -44,5 +38,3 @@ config SSTRIP_ELFKICKERS_VERSION default "2.0a" endif - -endif diff --git a/kconfig/kconfig.mk b/kconfig/kconfig.mk index 50398c2..701b435 100644 --- a/kconfig/kconfig.mk +++ b/kconfig/kconfig.mk @@ -22,19 +22,21 @@ endif ARCH_CONFIG_FILES = $(wildcard $(CT_LIB_DIR)/config/arch/*.in) KERNEL_CONFIG_FILES = $(wildcard $(CT_LIB_DIR)/config/kernel/*.in) DEBUG_CONFIG_FILES = $(wildcard $(CT_LIB_DIR)/config/debug/*.in) -TOOLS_CONFIG_FILES = $(wildcard $(CT_LIB_DIR)/config/tools/*.in) +TOOL_CONFIG_FILES = $(wildcard $(CT_LIB_DIR)/config/tools/*.in) STATIC_CONFIG_FILES = $(shell find $(CT_LIB_DIR)/config -type f -name '*.in') -GEN_CONFIG_FILES=$(CT_TOP_DIR)/config.gen/arch.in \ - $(CT_TOP_DIR)/config.gen/kernel.in \ - $(CT_TOP_DIR)/config.gen/debug.in \ - $(CT_TOP_DIR)/config.gen/tools.in +GEN_CONFIG_FILES=$(CT_TOP_DIR)/config.gen/arch.in \ + $(CT_TOP_DIR)/config.gen/kernel.in \ + $(CT_TOP_DIR)/config.gen/tools.in \ + $(CT_TOP_DIR)/config.gen/debug.in CONFIG_FILES=$(STATIC_CONFIG_FILES) $(GEN_CONFIG_FILES) # Build list of items ARCHS = $(patsubst $(CT_LIB_DIR)/config/arch/%.in,%,$(ARCH_CONFIG_FILES)) KERNELS = $(patsubst $(CT_LIB_DIR)/config/kernel/%.in,%,$(KERNEL_CONFIG_FILES)) +DEBUGS = $(patsubst $(CT_LIB_DIR)/config/debug/%.in,%,$(DEBUG_CONFIG_FILES)) +TOOLS = $(patsubst $(CT_LIB_DIR)/config/tools/%.in,%,$(TOOL_CONFIG_FILES)) $(GEN_CONFIG_FILES): $(CT_TOP_DIR)/config.gen \ $(CT_LIB_DIR)/kconfig/kconfig.mk @@ -84,27 +86,45 @@ $(CT_TOP_DIR)/config.gen/arch.in: $(ARCH_CONFIG_FILES) $(CT_TOP_DIR)/config.gen/kernel.in: $(KERNEL_CONFIG_FILES) $(call build_gen_choice_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Kernel,KERNEL,config/kernel,$(KERNELS)) -$(CT_TOP_DIR)/config.gen/debug.in: $(DEBUG_CONFIG_FILES) - @echo ' IN config.gen/debug.in' - @(echo "# Debug facilities menu"; \ +# Function build_gen_menu_in: +# $1 : destination file +# $2 : name of entries family (eg. Tools, Debug...) +# $3 : prefix for the menu entries (eg. TOOL, DEBUG) +# $4 : base directory containing config files +# $5 : list of config entries (eg. for tools: "libelf sstrip"..., and for +# debug: "dmalloc duma gdb"...) +# Example to build the tools generated config file: +# $(call build_gen_menu_in,config.gen/tools.in,Tools,TOOL,config/tools,$(TOOLS)) +define build_gen_menu_in + @echo ' IN $(1)' + @(echo "# $(2) facilities menu"; \ echo "# Generated file, do not edit!!!"; \ - echo "menu \"Debug facilities\""; \ - for f in $(patsubst $(CT_LIB_DIR)/%,%,$(DEBUG_CONFIG_FILES)); do \ - echo "source $${f}"; \ + echo ""; \ + for entry in $(5); do \ + file="$(4)/$${entry}.in"; \ + _entry=$$(echo "$${entry}" |sed -r -s -e 's/[-.+]/_/g;'); \ + echo "menuconfig $(3)_$${_entry}"; \ + echo " bool"; \ + printf " prompt \"$${entry}"; \ + if grep -E '^# +EXPERIMENTAL$$' $${file} >/dev/null 2>&1; then \ + echo " (EXPERIMENTAL)\""; \ + echo " depends on EXPERIMENTAL"; \ + else \ + echo "\""; \ + fi; \ + echo "if $(3)_$${_entry}"; \ + echo "source $${file}"; \ + echo "endif"; \ + echo ""; \ done; \ - echo "endmenu"; \ - ) >$@ + ) >$(1) +endef -$(CT_TOP_DIR)/config.gen/tools.in: $(TOOLS_CONFIG_FILES) - @echo ' IN config.gen/tools.in' - @(echo "# Tools facilities menu"; \ - echo "# Generated file, do not edit!!!"; \ - echo "menu \"Tools facilities\""; \ - for f in $(patsubst $(CT_LIB_DIR)/%,%,$(TOOLS_CONFIG_FILES)); do \ - echo "source $${f}"; \ - done; \ - echo "endmenu"; \ - ) >$@ +$(CT_TOP_DIR)/config.gen/tools.in: $(TOOL_CONFIG_FILES) + $(call build_gen_menu_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Tools,TOOL,config/tools,$(TOOLS)) + +$(CT_TOP_DIR)/config.gen/debug.in: $(DEBUG_CONFIG_FILES) + $(call build_gen_menu_in,$(patsubst $(CT_TOP_DIR)/%,%,$@),Debug,DEBUG,config/debug,$(DEBUGS)) config menuconfig oldconfig defoldconfig: $(KCONFIG_TOP) diff --git a/scripts/build/debug.sh b/scripts/build/debug.sh index 5441229..f07b295 100644 --- a/scripts/build/debug.sh +++ b/scripts/build/debug.sh @@ -3,11 +3,15 @@ # List all debug facilities, and parse their scripts CT_DEBUG_FACILITY_LIST= for f in "${CT_LIB_DIR}/scripts/build/debug/"*.sh; do - is_enabled= - . "${f}" - f=$(basename "${f}" .sh) - if [ "${is_enabled}" = "y" ]; then - CT_DEBUG_FACILITY_LIST="${CT_DEBUG_FACILITY_LIST} ${f#???-}" + _f="$(basename "${f}" .sh)" + _f="${_f#???-}" + __f="CT_DEBUG_${_f}" + if [ "${!__f}" = "y" ]; then + CT_DoLog DEBUG "Enabling debug '${_f}'" + . "${f}" + CT_DEBUG_FACILITY_LIST="${CT_DEBUG_FACILITY_LIST} ${_f}" + else + CT_DoLog DEBUG "Disabling debug '${_f}'" fi done diff --git a/scripts/build/debug/000-template.sh b/scripts/build/debug/000-template.sh index 0e63d7e..b6eaa9a 100644 --- a/scripts/build/debug/000-template.sh +++ b/scripts/build/debug/000-template.sh @@ -1,19 +1,12 @@ # Template file for a debug utility -# Check here wether your debug tool is enabled or not. -# This will get redefined over and over again for each tool, so don't -# count on it in the functions below. -is_enabled="${CT_FOOBAR}" - # Small function to print the filename # Note that this function gets redefined over and over for each tool # It's of no use when building the toolchain proper, but shows all its # usefullness when saving the toolchain and building the tarball. -# You shall not echo anything if you're not enabled! # Echo the name of the file, without the extension, below. do_print_filename() { # For example: - # [ "${CT_FOOBAR}" = "y" ] || return 0 # echo "foobar-${CT_FOOBAR_VERSION}" : } diff --git a/scripts/build/debug/100-dmalloc.sh b/scripts/build/debug/100-dmalloc.sh index 59b25b3..fcb6f9d 100644 --- a/scripts/build/debug/100-dmalloc.sh +++ b/scripts/build/debug/100-dmalloc.sh @@ -1,9 +1,6 @@ # Build script for the dmalloc debug library facility -is_enabled="${CT_DMALLOC}" - do_print_filename() { - [ "${CT_DMALLOC}" = "y" ] || return 0 echo "dmalloc-${CT_DMALLOC_VERSION}" } diff --git a/scripts/build/debug/200-duma.sh b/scripts/build/debug/200-duma.sh index 954aa83..b14485d 100644 --- a/scripts/build/debug/200-duma.sh +++ b/scripts/build/debug/200-duma.sh @@ -1,9 +1,6 @@ # Build script for D.U.M.A. -is_enabled="${CT_DUMA}" - do_print_filename() { - [ "${CT_DUMA}" = "y" ] || return 0 echo "duma_${CT_DUMA_VERSION}" } diff --git a/scripts/build/debug/300-gdb.sh b/scripts/build/debug/300-gdb.sh index e00841b..321e13a 100644 --- a/scripts/build/debug/300-gdb.sh +++ b/scripts/build/debug/300-gdb.sh @@ -1,9 +1,6 @@ # Build script for the gdb debug facility -is_enabled="${CT_GDB}" - do_print_filename() { - [ "${CT_GDB}" = "y" ] || return 0 echo "gdb$(do_debug_gdb_suffix)" if [ "${CT_GDB_NATIVE}" = "y" ]; then echo "ncurses-${CT_NCURSES_VERSION}" diff --git a/scripts/build/debug/400-ltrace.sh b/scripts/build/debug/400-ltrace.sh index 12f610c..32e11ea 100644 --- a/scripts/build/debug/400-ltrace.sh +++ b/scripts/build/debug/400-ltrace.sh @@ -1,9 +1,6 @@ # Build script for ltrace -is_enabled="${CT_LTRACE}" - do_print_filename() { - [ "${CT_LTRACE}" = "y" ] || return 0 echo "ltrace-${CT_LTRACE_VERSION}.orig" } diff --git a/scripts/build/debug/500-strace.sh b/scripts/build/debug/500-strace.sh index 26fcc99..ee1fc2c 100644 --- a/scripts/build/debug/500-strace.sh +++ b/scripts/build/debug/500-strace.sh @@ -1,9 +1,6 @@ # Build script for strace -is_enabled="${CT_STRACE}" - do_print_filename() { - [ "${CT_STRACE}" = "y" ] || return 0 echo "strace-${CT_STRACE_VERSION}" } diff --git a/scripts/build/tools.sh b/scripts/build/tools.sh index 693893c..bb07c9a 100644 --- a/scripts/build/tools.sh +++ b/scripts/build/tools.sh @@ -3,11 +3,15 @@ # List all tools facilities, and parse their scripts CT_TOOLS_FACILITY_LIST= for f in "${CT_LIB_DIR}/scripts/build/tools/"*.sh; do - is_enabled= - . "${f}" - f=$(basename "${f}" .sh) - if [ "${is_enabled}" = "y" ]; then - CT_TOOLS_FACILITY_LIST="${CT_TOOLS_FACILITY_LIST} ${f#???-}" + _f="$(basename "${f}" .sh)" + _f="${_f#???-}" + __f="CT_TOOL_${_f}" + if [ "${!__f}" = "y" ]; then + CT_DoLog DEBUG "Enabling tool '${_f}'" + . "${f}" + CT_TOOLS_FACILITY_LIST="${CT_TOOLS_FACILITY_LIST} ${_f}" + else + CT_DoLog DEBUG "Disabling tool '${_f}'" fi done diff --git a/scripts/build/tools/000-template.sh b/scripts/build/tools/000-template.sh index 7edc807..4a27801 100644 --- a/scripts/build/tools/000-template.sh +++ b/scripts/build/tools/000-template.sh @@ -1,19 +1,12 @@ # Template file for a tool utility -# Check here wether your tool is enabled or not. -# This will get redefined over and over again for each tool, so don't -# count on it in the functions below. -is_enabled="${CT_FOOBAR}" - # Small function to print the filename # Note that this function gets redefined over and over again for each tool. # It's of no use when building the toolchain proper, but shows all its # usefullness when saving the toolchain and building the tarball. -# You shall not echo anything if you're not enabled! # Echo the name of the file, without the extension, below. do_print_filename() { # For example: - # [ "{CT_FOOBAR}" = "y" ] || return 0 # echo "foobar-${CT_FOOBAR_VERSION}" : } diff --git a/scripts/build/tools/100-libelf.sh b/scripts/build/tools/100-libelf.sh index eeb4b3c..e8cd986 100644 --- a/scripts/build/tools/100-libelf.sh +++ b/scripts/build/tools/100-libelf.sh @@ -1,9 +1,6 @@ # Build script for libelf -is_enabled="${CT_LIBELF}" - do_print_filename() { - [ "{CT_LIBELF}" = "y" ] || return 0 echo "libelf-${CT_LIBELF_VERSION}" } diff --git a/scripts/build/tools/200-sstrip.sh b/scripts/build/tools/200-sstrip.sh index b8a9d4b..461dfcf 100644 --- a/scripts/build/tools/200-sstrip.sh +++ b/scripts/build/tools/200-sstrip.sh @@ -1,7 +1,5 @@ # This will build and install sstrip to run on host and sstrip target files -is_enabled="${CT_SSTRIP}" - case "${CT_SSTRIP_FROM}" in ELFkickers) do_print_filename() { diff --git a/scripts/crosstool.sh b/scripts/crosstool.sh index 8f344d2..cc4ed2a 100755 --- a/scripts/crosstool.sh +++ b/scripts/crosstool.sh @@ -362,8 +362,8 @@ fi . "${CT_LIB_DIR}/scripts/build/binutils.sh" . "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh" . "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh" -. "${CT_LIB_DIR}/scripts/build/debug.sh" . "${CT_LIB_DIR}/scripts/build/tools.sh" +. "${CT_LIB_DIR}/scripts/build/debug.sh" if [ -z "${CT_RESTART}" ]; then CT_DoStep INFO "Retrieving needed toolchain components' tarballs" -- cgit v0.10.2-6-g49f6