scripts/build/debug/300-gdb.sh
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 821 4c073dd24c1d
child 1112 c72aecd1a9ef
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 # Build script for the gdb debug facility
     2 
     3 do_print_filename() {
     4     echo "gdb$(do_debug_gdb_suffix)"
     5     if [ "${CT_GDB_NATIVE}" = "y" ]; then
     6         echo "ncurses-${CT_NCURSES_VERSION}"
     7     fi
     8 }
     9 
    10 do_debug_gdb_suffix() {
    11     case "${CT_GDB_VERSION}" in
    12         snapshot)   ;;
    13         *)          echo "-${CT_GDB_VERSION}";;
    14     esac
    15 }
    16 
    17 do_debug_gdb_parts() {
    18     do_gdb=
    19     do_insight=
    20     do_ncurses=
    21 
    22     if [ "${CT_GDB_CROSS}" = y ]; then
    23         if [ "${CT_GDB_CROSS_INSIGHT}" = "y" ]; then
    24             do_insight=y
    25         else
    26             do_gdb=y
    27         fi
    28     fi
    29 
    30     if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
    31         do_gdb=y
    32     fi
    33 
    34     if [ "${CT_GDB_NATIVE}" = "y" ]; then
    35         do_gdb=y
    36         do_ncurses=y
    37     fi
    38 }
    39 
    40 do_debug_gdb_get() {
    41     do_debug_gdb_parts
    42 
    43     if [ "${do_gdb}" = "y" ]; then
    44         CT_GetFile "gdb$(do_debug_gdb_suffix)"              \
    45                    {ftp,http}://ftp.gnu.org/pub/gnu/gdb     \
    46                    ftp://sources.redhat.com/pub/gdb/{{,old-}releases,snapshots/current}
    47     fi
    48 
    49     if [ "${do_insight}" = "y" ]; then
    50         CT_GetFile "insight-${CT_GDB_VERSION}"                                              \
    51                    ftp://sourceware.org/pub/insight/releases                                \
    52                    {ftp,http}://ftp.twaren.net/Unix/Sourceware/insight/releases             \
    53                    {ftp,http}://ftp.gwdg.de/pub/linux/sources.redhat.com/insight/releases
    54     fi
    55 
    56     if [ "${do_ncurses}" = "y" ]; then
    57         CT_GetFile "ncurses-${CT_NCURSES_VERSION}"          \
    58                    {ftp,http}://ftp.gnu.org/pub/gnu/ncurses \
    59                    ftp://invisible-island.net/ncurses
    60     fi
    61 }
    62 
    63 do_debug_gdb_extract() {
    64     do_debug_gdb_parts
    65 
    66     if [ "${do_gdb}" = "y" ]; then
    67         CT_ExtractAndPatch "gdb$(do_debug_gdb_suffix)"
    68     fi
    69 
    70     if [ "${do_insight}" = "y" ]; then
    71         CT_ExtractAndPatch "insight-${CT_GDB_VERSION}"
    72     fi
    73 
    74     if [ "${do_ncurses}" = "y" ]; then
    75         CT_ExtractAndPatch "ncurses-${CT_NCURSES_VERSION}"
    76     fi
    77 }
    78 
    79 do_debug_gdb_build() {
    80     gdb_src_dir="${CT_SRC_DIR}/gdb$(do_debug_gdb_suffix)"
    81     insight_src_dir="${CT_SRC_DIR}/insight-${CT_GDB_VERSION}"
    82 
    83     extra_config=
    84     # Version 6.3 and below behave badly with gdbmi
    85     case "${CT_GDB_VERSION}" in
    86         6.2*|6.3)   extra_config="${extra_config} --disable-gdbmi";;
    87     esac
    88 
    89     if [ "${CT_GDB_CROSS}" = "y" ]; then
    90         CT_DoStep INFO "Installing cross-gdb"
    91         CT_DoLog EXTRA "Configuring cross-gdb"
    92 
    93         mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
    94         cd "${CT_BUILD_DIR}/build-gdb-cross"
    95 
    96         cross_extra_config="${extra_config}"
    97         if [ "${CT_GMP_MPFR}" = "y" ]; then
    98             cross_extra_config="${cross_extra_config} --with-gmp=${CT_PREFIX_DIR} --with-mpfr=${CT_PREFIX_DIR}"
    99         fi
   100         case "${CT_THREADS}" in
   101             none)   cross_extra_config="${cross_extra_config} --disable-threads";;
   102             *)      cross_extra_config="${cross_extra_config} --enable-threads";;
   103         esac
   104 
   105         CC_for_gdb=
   106         LD_for_gdb=
   107         if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then
   108             CC_for_gdb="gcc -static"
   109             LD_for_gdb="ld -static"
   110         fi
   111 
   112         gdb_cross_configure="${gdb_src_dir}/configure"
   113         [ "${CT_GDB_CROSS_INSIGHT}" = "y" ] && gdb_cross_configure="${insight_src_dir}/configure"
   114 
   115         CT_DoLog DEBUG "Extra config passed: '${cross_extra_config# }'"
   116 
   117         CC="${CC_for_gdb}"                              \
   118         LD="${LD_for_gdb}"                              \
   119         CT_DoExecLog ALL                                \
   120         "${gdb_cross_configure}"                        \
   121             --build=${CT_BUILD}                         \
   122             --host=${CT_HOST}                           \
   123             --target=${CT_TARGET}                       \
   124             --prefix="${CT_PREFIX_DIR}"                 \
   125             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   126             --disable-werror                            \
   127             ${cross_extra_config}
   128 
   129         CT_DoLog EXTRA "Building cross-gdb"
   130         CT_DoExecLog ALL make ${PARALLELMFLAGS}
   131 
   132         CT_DoLog EXTRA "Installing cross-gdb"
   133         CT_DoExecLog ALL make install
   134 
   135         CT_EndStep
   136     fi
   137 
   138     if [ "${CT_GDB_NATIVE}" = "y" ]; then
   139         CT_DoStep INFO "Installing native gdb"
   140 
   141         CT_DoStep INFO "Installing ncurses library"
   142         CT_DoLog EXTRA "Configuring ncurses"
   143         mkdir -p "${CT_BUILD_DIR}/build-ncurses"
   144         cd "${CT_BUILD_DIR}/build-ncurses"
   145 
   146         ncurses_opts=
   147         [ "${CT_CC_LANG_CXX}" = "y" ] || ncurses_opts="${ncurses_opts} --without-cxx --without-cxx-binding"
   148         [ "${CT_CC_LANG_ADA}" = "y" ] || ncurses_opts="${ncurses_opts} --without-ada"
   149 
   150         CT_DoExecLog ALL                                        \
   151         "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}/configure" \
   152             --build=${CT_BUILD}                                 \
   153             --host=${CT_TARGET}                                 \
   154             --with-build-cc=${CT_CC}                            \
   155             --with-build-cpp=${CT_CC}                           \
   156             --with-build-cflags="${CT_CFLAGS_FOR_HOST}"         \
   157             --prefix=/usr                                       \
   158             --with-shared                                       \
   159             --without-sysmouse                                  \
   160             --without-progs                                     \
   161             --enable-termcap                                    \
   162             ${ncurses_opts}
   163 
   164         CT_DoLog EXTRA "Building ncurses"
   165         CT_DoExecLog ALL make ${PARALLELMFLAGS}
   166 
   167         CT_DoLog EXTRA "Installing ncurses"
   168         mkdir -p "${CT_SYSROOT_DIR}/usr/bin"
   169         CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install
   170 
   171         CT_EndStep
   172 
   173         CT_DoLog EXTRA "Configuring native gdb"
   174 
   175         mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
   176         cd "${CT_BUILD_DIR}/build-gdb-native"
   177 
   178         native_extra_config="${extra_config}"
   179         case "${CT_THREADS}" in
   180             none)   native_extra_config="${native_extra_config} --disable-threads";;
   181             *)      native_extra_config="${native_extra_config} --enable-threads";;
   182         esac
   183         if [ "${CT_GDB_NATIVE_USE_GMP_MPFR}" = "y" ]; then
   184             native_extra_config="${native_extra_config} --with-gmp=${CT_SYSROOT_DIR}/usr --with-mpfr=${CT_SYSROOT_DIR}/usr"
   185         fi
   186 
   187         if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then
   188             CC_for_gdb="${CT_TARGET}-gcc -static"
   189             LD_for_gdb="${CT_TARGET}-ld -static"
   190         else
   191             CC_for_gdb="${CT_TARGET}-gcc"
   192             LD_for_gdb="${CT_TARGET}-ld"
   193         fi
   194 
   195         export ac_cv_func_strncmp_works=yes
   196 
   197         CT_DoLog DEBUG "Extra config passed: '${native_extra_config# }'"
   198 
   199         CC="${CC_for_gdb}"                              \
   200         LD="${LD_for_gdb}"                              \
   201         CT_DoExecLog ALL                                \
   202         "${gdb_src_dir}/configure"                      \
   203             --build=${CT_BUILD}                         \
   204             --host=${CT_TARGET}                         \
   205             --target=${CT_TARGET}                       \
   206             --prefix=/usr                               \
   207             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   208             --without-uiout                             \
   209             --disable-tui                               \
   210             --disable-gdbtk                             \
   211             --without-x                                 \
   212             --disable-sim                               \
   213             --disable-werror                            \
   214             --without-included-gettext                  \
   215             --without-develop                           \
   216             ${native_extra_config}
   217 
   218         CT_DoLog EXTRA "Building native gdb"
   219         CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
   220 
   221         CT_DoLog EXTRA "Installing native gdb"
   222         CT_DoExecLog ALL make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install
   223 
   224         # Building a native gdb also builds a gdbserver
   225         find "${CT_DEBUG_INSTALL_DIR}" -type f -name gdbserver -exec rm -fv {} \; 2>&1 |CT_DoLog ALL
   226 
   227         unset ac_cv_func_strncmp_works
   228 
   229         CT_EndStep
   230     fi
   231 
   232     if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
   233         CT_DoStep INFO "Installing gdbserver"
   234         CT_DoLog EXTRA "Configuring gdbserver"
   235 
   236         mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
   237         cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
   238 
   239         # Workaround for bad versions, where the configure
   240         # script for gdbserver is not executable...
   241         # Bah, GNU folks strike again... :-(
   242         chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
   243 
   244         gdbserver_LDFLAGS=
   245         if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then
   246             gdbserver_LDFLAGS=-static
   247         fi
   248 
   249         gdbserver_extra_config="${extra_config}"
   250 
   251         LDFLAGS="${gdbserver_LDFLAGS}"                  \
   252         CT_DoExecLog ALL                                \
   253         "${gdb_src_dir}/gdb/gdbserver/configure"        \
   254             --build=${CT_BUILD}                         \
   255             --host=${CT_TARGET}                         \
   256             --target=${CT_TARGET}                       \
   257             --prefix=/usr                               \
   258             --sysconfdir=/etc                           \
   259             --localstatedir=/var                        \
   260             --includedir="${CT_HEADERS_DIR}"            \
   261             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   262             --program-prefix=                           \
   263             --without-uiout                             \
   264             --disable-tui                               \
   265             --disable-gdbtk                             \
   266             --without-x                                 \
   267             --without-included-gettext                  \
   268             --without-develop                           \
   269             --disable-werror                            \
   270             ${gdbserver_extra_config}
   271 
   272         CT_DoLog EXTRA "Building gdbserver"
   273         CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
   274 
   275         CT_DoLog EXTRA "Installing gdbserver"
   276         CT_DoExecLog ALL make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install
   277 
   278         CT_EndStep
   279     fi
   280 }