scripts/build/debug/gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Apr 27 10:25:02 2008 +0000 (2008-04-27)
changeset 457 578fdd250fcc
parent 237 131ee309e740
permissions -rw-r--r--
Offer an option to build a static cross-gdb.

/trunk/scripts/build/debug/gdb.sh | 9 9 0 0 +++++++++
/trunk/config/debug/gdb.in | 9 9 0 0 +++++++++
2 files changed, 18 insertions(+)
     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 }
     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_get() {
    18     CT_GetFile "gdb`do_debug_gdb_suffix`"                           \
    19                ftp://ftp.gnu.org/pub/gnu/gdb                        \
    20                ftp://sources.redhat.com/pub/gdb/releases            \
    21                ftp://sources.redhat.com/pub/gdb/old-releases        \
    22                ftp://sources.redhat.com/pub/gdb/snapshots/current 
    23 }
    24 
    25 do_debug_gdb_extract() {
    26     CT_ExtractAndPatch "gdb`do_debug_gdb_suffix`"
    27 }
    28 
    29 do_debug_gdb_build() {
    30     gdb_src_dir="${CT_SRC_DIR}/gdb`do_debug_gdb_suffix`"
    31 
    32     extra_config=
    33     # Version 6.3 and below behave badly with gdbmi
    34     case "${CT_GDB_VERSION}" in
    35         6.2*|6.3)   extra_config="${extra_config} --disable-gdbmi";;
    36     esac
    37 
    38     if [ "${CT_GDB_CROSS}" = "y" ]; then
    39         CT_DoStep INFO "Installing cross-gdb"
    40         CT_DoLog EXTRA "Configuring cross-gdb"
    41 
    42         mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
    43         cd "${CT_BUILD_DIR}/build-gdb-cross"
    44 
    45         CC_for_gdb=
    46         LD_for_gdb=
    47         if [ "${CT_GDB_CROSS_STATIC_GDBSERVER}" = "y" ]; then
    48             CC_for_gdb="gcc -static"
    49             LD_for_gdb="ld -static"
    50         fi
    51 
    52         CC="${CC_for_gdb}"                              \
    53         LD="${LD_forgdb}"                               \
    54         "${gdb_src_dir}/configure"                      \
    55             --build=${CT_BUILD}                         \
    56             --host=${CT_HOST}                           \
    57             --target=${CT_TARGET}                       \
    58             --prefix="${CT_PREFIX_DIR}"                 \
    59             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
    60             --enable-threads                            \
    61             ${extra_config}                             2>&1 |CT_DoLog ALL
    62 
    63         CT_DoLog EXTRA "Building cross-gdb"
    64         make ${PARALLELMFLAGS}                          2>&1 |CT_DoLog ALL
    65 
    66         CT_DoLog EXTRA "Installing cross-gdb"
    67         make install                                    2>&1 |CT_DoLog ALL
    68 
    69         CT_EndStep
    70 
    71         CT_DoStep INFO "Installing gdbserver"
    72         CT_DoLog EXTRA "Configuring gdbserver"
    73 
    74         mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
    75         cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
    76 
    77         # Workaround for bad versions, where the configure
    78         # script for gdbserver is not executable...
    79         # Bah, GNU folks strike again... :-(
    80         chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
    81 
    82         gdbserver_LDFLAGS=
    83         if [ "${CT_GDB_CROSS_STATIC_GDBSERVER}" = "y" ]; then
    84             gdbserver_LDFLAGS=-static
    85         fi
    86 
    87         LDFLAGS="${gdbserver_LDFLAGS}"                  \
    88         "${gdb_src_dir}/gdb/gdbserver/configure"        \
    89             --build=${CT_BUILD}                         \
    90             --host=${CT_TARGET}                         \
    91             --target=${CT_TARGET}                       \
    92             --prefix=/usr                               \
    93             --sysconfdir=/etc                           \
    94             --localstatedir=/var                        \
    95             --includedir="${CT_HEADERS_DIR}"            \
    96             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
    97             --program-prefix=                           \
    98             --without-uiout                             \
    99             --disable-tui                               \
   100             --disable-gdbtk                             \
   101             --without-x                                 \
   102             --without-included-gettext                  \
   103             ${extra_config}                             2>&1 |CT_DoLog ALL
   104 
   105         CT_DoLog EXTRA "Building gdbserver"
   106         make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL
   107 
   108         CT_DoLog EXTRA "Installing gdbserver"
   109         make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install  2>&1 |CT_DoLog ALL
   110 
   111         CT_EndStep
   112     fi
   113 
   114     if [ "${CT_GDB_NATIVE}" = "y" ]; then
   115         CT_DoStep EXTRA "Installing native gdb"
   116         CT_DoLog EXTRA "Configuring native gdb"
   117 
   118         mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
   119         cd "${CT_BUILD_DIR}/build-gdb-native"
   120 
   121         "${gdb_src_dir}/configure"                      \
   122             --build=${CT_BUILD}                         \
   123             --host=${CT_TARGET}                         \
   124             --target=${CT_TARGET}                       \
   125             --prefix=/usr                               \
   126             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   127             --without-uiout                             \
   128             --disable-tui                               \
   129             --disable-gdbtk                             \
   130             --without-x                                 \
   131             --disable-sim                               \
   132             --disable-gdbserver                          \
   133             --without-included-gettext                  \
   134             ${extra_config}                             2>&1 |CT_DoLog ALL
   135 
   136         CT_DoLog EXTRA "Building native gdb"
   137         make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL
   138 
   139         CT_DoLog EXTRA "Installing native gdb"
   140         make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install  2>&1 |CT_DoLog ALL
   141 
   142         CT_EndStep
   143     fi
   144 }