scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed Jun 18 12:33:32 2008 +0000 (2008-06-18)
changeset 573 2a1803b98186
parent 523 010f6f4e4dd6
child 577 c9775d1d713d
permissions -rw-r--r--
Fix building native gdb: download, extract, patch, build and install the ncurses library (that is needed by gdb)

/trunk/scripts/build/debug/300-gdb.sh | 46 42 4 0 +++++++++++++++++++++++++++++++++++++----
/trunk/config/debug/gdb.in | 26 25 1 0 ++++++++++++++++++++++-
2 files changed, 67 insertions(+), 5 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     [ "${CT_GDB_NATIVE}" = "y" ] && echo "ncurses-${CT_NCURSES_VERSION}"
     9 }
    10 
    11 do_debug_gdb_suffix() {
    12     case "${CT_GDB_VERSION}" in
    13         snapshot)   ;;
    14         *)          echo "-${CT_GDB_VERSION}";;
    15     esac
    16 }
    17 
    18 do_debug_gdb_get() {
    19     CT_GetFile "gdb$(do_debug_gdb_suffix)"              \
    20                {ftp,http}://ftp.gnu.org/pub/gnu/gdb     \
    21                ftp://sources.redhat.com/pub/gdb/{{,old-}releases,snapshots/current}
    22     if [ "${CT_GDB_NATIVE}" = "y" ]; then
    23         CT_GetFile "ncurses-${CT_NCURSES_VERSION}"          \
    24                    {ftp,http}://ftp.gnu.org/pub/gnu/ncurses \
    25                    ftp://invisible-island.net/ncurses
    26     fi
    27 }
    28 
    29 do_debug_gdb_extract() {
    30     CT_ExtractAndPatch "gdb$(do_debug_gdb_suffix)"
    31     [ "${CT_GDB_NATIVE}" = "y" ] && CT_ExtractAndPatch "ncurses-${CT_NCURSES_VERSION}"
    32 }
    33 
    34 do_debug_gdb_build() {
    35     gdb_src_dir="${CT_SRC_DIR}/gdb$(do_debug_gdb_suffix)"
    36 
    37     extra_config=
    38     # Version 6.3 and below behave badly with gdbmi
    39     case "${CT_GDB_VERSION}" in
    40         6.2*|6.3)   extra_config="${extra_config} --disable-gdbmi";;
    41     esac
    42 
    43     if [ "${CT_GDB_CROSS}" = "y" ]; then
    44         CT_DoStep INFO "Installing cross-gdb"
    45         CT_DoLog EXTRA "Configuring cross-gdb"
    46 
    47         mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
    48         cd "${CT_BUILD_DIR}/build-gdb-cross"
    49 
    50         CC_for_gdb=
    51         LD_for_gdb=
    52         if [ "${CT_GDB_CROSS_STATIC_GDBSERVER}" = "y" ]; then
    53             CC_for_gdb="gcc -static"
    54             LD_for_gdb="ld -static"
    55         fi
    56 
    57         CC="${CC_for_gdb}"                              \
    58         LD="${LD_forgdb}"                               \
    59         "${gdb_src_dir}/configure"                      \
    60             --build=${CT_BUILD}                         \
    61             --host=${CT_HOST}                           \
    62             --target=${CT_TARGET}                       \
    63             --prefix="${CT_PREFIX_DIR}"                 \
    64             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
    65             --enable-threads                            \
    66             ${extra_config}                             2>&1 |CT_DoLog ALL
    67 
    68         CT_DoLog EXTRA "Building cross-gdb"
    69         make ${PARALLELMFLAGS}                          2>&1 |CT_DoLog ALL
    70 
    71         CT_DoLog EXTRA "Installing cross-gdb"
    72         make install                                    2>&1 |CT_DoLog ALL
    73 
    74         CT_EndStep
    75 
    76         CT_DoStep INFO "Installing gdbserver"
    77         CT_DoLog EXTRA "Configuring gdbserver"
    78 
    79         mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
    80         cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
    81 
    82         # Workaround for bad versions, where the configure
    83         # script for gdbserver is not executable...
    84         # Bah, GNU folks strike again... :-(
    85         chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
    86 
    87         gdbserver_LDFLAGS=
    88         if [ "${CT_GDB_CROSS_STATIC_GDBSERVER}" = "y" ]; then
    89             gdbserver_LDFLAGS=-static
    90         fi
    91 
    92         LDFLAGS="${gdbserver_LDFLAGS}"                  \
    93         "${gdb_src_dir}/gdb/gdbserver/configure"        \
    94             --build=${CT_BUILD}                         \
    95             --host=${CT_TARGET}                         \
    96             --target=${CT_TARGET}                       \
    97             --prefix=/usr                               \
    98             --sysconfdir=/etc                           \
    99             --localstatedir=/var                        \
   100             --includedir="${CT_HEADERS_DIR}"            \
   101             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   102             --program-prefix=                           \
   103             --without-uiout                             \
   104             --disable-tui                               \
   105             --disable-gdbtk                             \
   106             --without-x                                 \
   107             --without-included-gettext                  \
   108             ${extra_config}                             2>&1 |CT_DoLog ALL
   109 
   110         CT_DoLog EXTRA "Building gdbserver"
   111         make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL
   112 
   113         CT_DoLog EXTRA "Installing gdbserver"
   114         make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install  2>&1 |CT_DoLog ALL
   115 
   116         CT_EndStep
   117     fi
   118 
   119     if [ "${CT_GDB_NATIVE}" = "y" ]; then
   120         CT_DoStep INFO "Installing native gdb"
   121 
   122         CT_DoStep INFO "Installing ncurses library"
   123         CT_DoLog EXTRA "Configuring ncurses"
   124         mkdir -p "${CT_BUILD_DIR}/build-ncurses"
   125         cd "${CT_BUILD_DIR}/build-ncurses"
   126 
   127         ncurses_opts=
   128         [ "${CT_CC_LANG_CXX}" = "y" ] || ncurses_opts="${ncurses_opts} --without-cxx --without-cxx-binding"
   129 
   130         "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}/configure" \
   131             --build=${CT_BUILD}                                 \
   132             --host=${CT_TARGET}                                 \
   133             --with-build-cc=${CT_CC}                            \
   134             --with-build-cpp=${CT_CC}                           \
   135             --with-build-cflags="${CT_CFLAGS_FOR_HOST}"         \
   136             --prefix=/usr                                       \
   137             --with-shared                                       \
   138             --without-sysmouse                                  \
   139             --without-progs                                     \
   140             --enable-termcap                                    \
   141             --without-develop                                   \
   142             ${ncurses_opts}                                     2>&1 |CT_DoLog ALL
   143 
   144         CT_DoLog EXTRA "Building ncurses"
   145         make ${PARALLELMFLAGS}  2>&1 |CT_DoLog ALL
   146 
   147         CT_DoLog EXTRA "Installing ncurses"
   148         make DESTDIR="${CT_SYSROOT_DIR}" install    2>&1 |CT_DoLog ALL
   149 
   150         CT_EndStep
   151 
   152         CT_DoLog EXTRA "Configuring native gdb"
   153 
   154         mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
   155         cd "${CT_BUILD_DIR}/build-gdb-native"
   156 
   157         "${gdb_src_dir}/configure"                      \
   158             --build=${CT_BUILD}                         \
   159             --host=${CT_TARGET}                         \
   160             --target=${CT_TARGET}                       \
   161             --prefix=/usr                               \
   162             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   163             --without-uiout                             \
   164             --disable-tui                               \
   165             --disable-gdbtk                             \
   166             --without-x                                 \
   167             --disable-sim                               \
   168             --disable-gdbserver                         \
   169             --without-included-gettext                  \
   170             ${extra_config}                             2>&1 |CT_DoLog ALL
   171 
   172         CT_DoLog EXTRA "Building native gdb"
   173         make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL
   174 
   175         CT_DoLog EXTRA "Installing native gdb"
   176         make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install  2>&1 |CT_DoLog ALL
   177 
   178         CT_EndStep
   179     fi
   180 }