scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Jul 14 21:57:57 2008 +0000 (2008-07-14)
changeset 669 ca740b4c4262
parent 645 8e58024f8e37
child 801 abd105984689
permissions -rw-r--r--
Use CT_DoExecLog when building tools and debug utilities.

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