scripts/build/debug/300-gdb.sh
changeset 479 05c62432ec19
child 486 92f6149c4275
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/scripts/build/debug/300-gdb.sh	Fri May 02 21:59:14 2008 +0000
     1.3 @@ -0,0 +1,144 @@
     1.4 +# Build script for the gdb debug facility
     1.5 +
     1.6 +is_enabled="${CT_GDB}"
     1.7 +
     1.8 +do_print_filename() {
     1.9 +    [ "${CT_GDB}" = "y" ] || return 0
    1.10 +    echo "gdb`do_debug_gdb_suffix`"
    1.11 +}
    1.12 +
    1.13 +do_debug_gdb_suffix() {
    1.14 +    case "${CT_GDB_VERSION}" in
    1.15 +        snapshot)   ;;
    1.16 +        *)          echo "-${CT_GDB_VERSION}";;
    1.17 +    esac
    1.18 +}
    1.19 +
    1.20 +do_debug_gdb_get() {
    1.21 +    CT_GetFile "gdb`do_debug_gdb_suffix`"                           \
    1.22 +               ftp://ftp.gnu.org/pub/gnu/gdb                        \
    1.23 +               ftp://sources.redhat.com/pub/gdb/releases            \
    1.24 +               ftp://sources.redhat.com/pub/gdb/old-releases        \
    1.25 +               ftp://sources.redhat.com/pub/gdb/snapshots/current 
    1.26 +}
    1.27 +
    1.28 +do_debug_gdb_extract() {
    1.29 +    CT_ExtractAndPatch "gdb`do_debug_gdb_suffix`"
    1.30 +}
    1.31 +
    1.32 +do_debug_gdb_build() {
    1.33 +    gdb_src_dir="${CT_SRC_DIR}/gdb`do_debug_gdb_suffix`"
    1.34 +
    1.35 +    extra_config=
    1.36 +    # Version 6.3 and below behave badly with gdbmi
    1.37 +    case "${CT_GDB_VERSION}" in
    1.38 +        6.2*|6.3)   extra_config="${extra_config} --disable-gdbmi";;
    1.39 +    esac
    1.40 +
    1.41 +    if [ "${CT_GDB_CROSS}" = "y" ]; then
    1.42 +        CT_DoStep INFO "Installing cross-gdb"
    1.43 +        CT_DoLog EXTRA "Configuring cross-gdb"
    1.44 +
    1.45 +        mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
    1.46 +        cd "${CT_BUILD_DIR}/build-gdb-cross"
    1.47 +
    1.48 +        CC_for_gdb=
    1.49 +        LD_for_gdb=
    1.50 +        if [ "${CT_GDB_CROSS_STATIC_GDBSERVER}" = "y" ]; then
    1.51 +            CC_for_gdb="gcc -static"
    1.52 +            LD_for_gdb="ld -static"
    1.53 +        fi
    1.54 +
    1.55 +        CC="${CC_for_gdb}"                              \
    1.56 +        LD="${LD_forgdb}"                               \
    1.57 +        "${gdb_src_dir}/configure"                      \
    1.58 +            --build=${CT_BUILD}                         \
    1.59 +            --host=${CT_HOST}                           \
    1.60 +            --target=${CT_TARGET}                       \
    1.61 +            --prefix="${CT_PREFIX_DIR}"                 \
    1.62 +            --with-build-sysroot="${CT_SYSROOT_DIR}"    \
    1.63 +            --enable-threads                            \
    1.64 +            ${extra_config}                             2>&1 |CT_DoLog ALL
    1.65 +
    1.66 +        CT_DoLog EXTRA "Building cross-gdb"
    1.67 +        make ${PARALLELMFLAGS}                          2>&1 |CT_DoLog ALL
    1.68 +
    1.69 +        CT_DoLog EXTRA "Installing cross-gdb"
    1.70 +        make install                                    2>&1 |CT_DoLog ALL
    1.71 +
    1.72 +        CT_EndStep
    1.73 +
    1.74 +        CT_DoStep INFO "Installing gdbserver"
    1.75 +        CT_DoLog EXTRA "Configuring gdbserver"
    1.76 +
    1.77 +        mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
    1.78 +        cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
    1.79 +
    1.80 +        # Workaround for bad versions, where the configure
    1.81 +        # script for gdbserver is not executable...
    1.82 +        # Bah, GNU folks strike again... :-(
    1.83 +        chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
    1.84 +
    1.85 +        gdbserver_LDFLAGS=
    1.86 +        if [ "${CT_GDB_CROSS_STATIC_GDBSERVER}" = "y" ]; then
    1.87 +            gdbserver_LDFLAGS=-static
    1.88 +        fi
    1.89 +
    1.90 +        LDFLAGS="${gdbserver_LDFLAGS}"                  \
    1.91 +        "${gdb_src_dir}/gdb/gdbserver/configure"        \
    1.92 +            --build=${CT_BUILD}                         \
    1.93 +            --host=${CT_TARGET}                         \
    1.94 +            --target=${CT_TARGET}                       \
    1.95 +            --prefix=/usr                               \
    1.96 +            --sysconfdir=/etc                           \
    1.97 +            --localstatedir=/var                        \
    1.98 +            --includedir="${CT_HEADERS_DIR}"            \
    1.99 +            --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   1.100 +            --program-prefix=                           \
   1.101 +            --without-uiout                             \
   1.102 +            --disable-tui                               \
   1.103 +            --disable-gdbtk                             \
   1.104 +            --without-x                                 \
   1.105 +            --without-included-gettext                  \
   1.106 +            ${extra_config}                             2>&1 |CT_DoLog ALL
   1.107 +
   1.108 +        CT_DoLog EXTRA "Building gdbserver"
   1.109 +        make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL
   1.110 +
   1.111 +        CT_DoLog EXTRA "Installing gdbserver"
   1.112 +        make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install  2>&1 |CT_DoLog ALL
   1.113 +
   1.114 +        CT_EndStep
   1.115 +    fi
   1.116 +
   1.117 +    if [ "${CT_GDB_NATIVE}" = "y" ]; then
   1.118 +        CT_DoStep EXTRA "Installing native gdb"
   1.119 +        CT_DoLog EXTRA "Configuring native gdb"
   1.120 +
   1.121 +        mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
   1.122 +        cd "${CT_BUILD_DIR}/build-gdb-native"
   1.123 +
   1.124 +        "${gdb_src_dir}/configure"                      \
   1.125 +            --build=${CT_BUILD}                         \
   1.126 +            --host=${CT_TARGET}                         \
   1.127 +            --target=${CT_TARGET}                       \
   1.128 +            --prefix=/usr                               \
   1.129 +            --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   1.130 +            --without-uiout                             \
   1.131 +            --disable-tui                               \
   1.132 +            --disable-gdbtk                             \
   1.133 +            --without-x                                 \
   1.134 +            --disable-sim                               \
   1.135 +            --disable-gdbserver                          \
   1.136 +            --without-included-gettext                  \
   1.137 +            ${extra_config}                             2>&1 |CT_DoLog ALL
   1.138 +
   1.139 +        CT_DoLog EXTRA "Building native gdb"
   1.140 +        make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL
   1.141 +
   1.142 +        CT_DoLog EXTRA "Installing native gdb"
   1.143 +        make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install  2>&1 |CT_DoLog ALL
   1.144 +
   1.145 +        CT_EndStep
   1.146 +    fi
   1.147 +}