scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Thu Jun 19 15:33:33 2008 +0000 (2008-06-19)
changeset 583 44b87fb3f0d3
parent 577 c9775d1d713d
child 596 d1651a3f42a3
permissions -rw-r--r--
A bunch of fixes/improvements to the gdb build:
- allow native builds (both shared and static)
- fix enabling threads
- better handle the gdbserver case
- introduce the ncurses library to allow native builds
- re-order config options adequately

/trunk/scripts/build/debug/300-gdb.sh | 126 79 47 0 ++++++++++++++++++++++++++---------------
/trunk/config/debug/gdb.in | 45 33 12 0 +++++++++++----
2 files changed, 112 insertions(+), 59 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         if [ "${CT_CC_GCC_GMP_MPFR}" = "y" ]; then
    51             extra_config="${extra_config} --with-gmp=${CT_PREFIX_DIR} --with-mpfr=${CT_PREFIX_DIR}"
    52         fi
    53         case "${CT_THREADS}" in
    54             none)   extra_config="${extra_config} --disable-threads";;
    55             *)      extra_config="${extra_config} --enable-threads";;
    56         esac
    57 
    58         CC_for_gdb=
    59         LD_for_gdb=
    60         if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then
    61             CC_for_gdb="gcc -static"
    62             LD_for_gdb="ld -static"
    63         fi
    64 
    65         CC="${CC_for_gdb}"                              \
    66         LD="${LD_for_gdb}"                              \
    67         "${gdb_src_dir}/configure"                      \
    68             --build=${CT_BUILD}                         \
    69             --host=${CT_HOST}                           \
    70             --target=${CT_TARGET}                       \
    71             --prefix="${CT_PREFIX_DIR}"                 \
    72             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
    73             ${extra_config}                             2>&1 |CT_DoLog ALL
    74 
    75         CT_DoLog EXTRA "Building cross-gdb"
    76         make ${PARALLELMFLAGS}                          2>&1 |CT_DoLog ALL
    77 
    78         CT_DoLog EXTRA "Installing cross-gdb"
    79         make install                                    2>&1 |CT_DoLog ALL
    80 
    81         CT_EndStep
    82     fi
    83 
    84     if [ "${CT_GDB_NATIVE}" = "y" ]; then
    85         CT_DoStep INFO "Installing native gdb"
    86 
    87         CT_DoStep INFO "Installing ncurses library"
    88         CT_DoLog EXTRA "Configuring ncurses"
    89         mkdir -p "${CT_BUILD_DIR}/build-ncurses"
    90         cd "${CT_BUILD_DIR}/build-ncurses"
    91 
    92         ncurses_opts=
    93         [ "${CT_CC_LANG_CXX}" = "y" ] || ncurses_opts="${ncurses_opts} --without-cxx --without-cxx-binding"
    94 
    95         "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}/configure" \
    96             --build=${CT_BUILD}                                 \
    97             --host=${CT_TARGET}                                 \
    98             --with-build-cc=${CT_CC}                            \
    99             --with-build-cpp=${CT_CC}                           \
   100             --with-build-cflags="${CT_CFLAGS_FOR_HOST}"         \
   101             --prefix=/usr                                       \
   102             --with-shared                                       \
   103             --without-sysmouse                                  \
   104             --without-progs                                     \
   105             --enable-termcap                                    \
   106             ${ncurses_opts}                                     2>&1 |CT_DoLog ALL
   107 
   108         CT_DoLog EXTRA "Building ncurses"
   109         make ${PARALLELMFLAGS}  2>&1 |CT_DoLog ALL
   110 
   111         CT_DoLog EXTRA "Installing ncurses"
   112         mkdir -p -v "${CT_SYSROOT_DIR}/usr/bin"     2>&1 |CT_DoLog ALL
   113         make DESTDIR="${CT_SYSROOT_DIR}" install    2>&1 |CT_DoLog ALL
   114 
   115         CT_EndStep
   116 
   117         CT_DoLog EXTRA "Configuring native gdb"
   118 
   119         mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
   120         cd "${CT_BUILD_DIR}/build-gdb-native"
   121 
   122         case "${CT_THREADS}" in
   123             none)   extra_config="${extra_config} --disable-threads";;
   124             *)      extra_config="${extra_config} --enable-threads";;
   125         esac
   126 
   127         CC_for_gdb=
   128         LD_for_gdb=
   129         if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then
   130             CC_for_gdb="${CT_TARGET}-gcc -static"
   131             LD_for_gdb="${CT_TARGET}-ld -static"
   132         fi
   133 
   134         export ac_cv_func_strncmp_works=yes
   135 
   136         CC="${CC_for_gdb}"                              \
   137         LD="${LD_for_gdb}"                              \
   138         "${gdb_src_dir}/configure"                      \
   139             --build=${CT_BUILD}                         \
   140             --host=${CT_TARGET}                         \
   141             --target=${CT_TARGET}                       \
   142             --prefix=/usr                               \
   143             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   144             --without-uiout                             \
   145             --disable-tui                               \
   146             --disable-gdbtk                             \
   147             --without-x                                 \
   148             --disable-sim                               \
   149             --disable-werror                            \
   150             --without-included-gettext                  \
   151             --without-develop                           \
   152             ${extra_config}                             2>&1 |CT_DoLog ALL
   153 
   154         CT_DoLog EXTRA "Building native gdb"
   155         make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL
   156 
   157         CT_DoLog EXTRA "Installing native gdb"
   158         make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install  2>&1 |CT_DoLog ALL
   159 
   160         # Building a native gdb also builds a gdbserver
   161         CT_DoLog DEBUG "Removing spurious gdbserver"
   162         find "${CT_DEBUG_INSTALL_DIR}" -type f -name gdbserver -exec rm -fv {} + 2>&1 |CT_DoLog ALL
   163 
   164         unset ac_cv_func_strncmp_works
   165 
   166         CT_EndStep
   167     fi
   168 
   169     if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
   170         CT_DoStep INFO "Installing gdbserver"
   171         CT_DoLog EXTRA "Configuring gdbserver"
   172 
   173         mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
   174         cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
   175 
   176         # Workaround for bad versions, where the configure
   177         # script for gdbserver is not executable...
   178         # Bah, GNU folks strike again... :-(
   179         chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
   180 
   181         gdbserver_LDFLAGS=
   182         if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then
   183             gdbserver_LDFLAGS=-static
   184         fi
   185 
   186         LDFLAGS="${gdbserver_LDFLAGS}"                  \
   187         "${gdb_src_dir}/gdb/gdbserver/configure"        \
   188             --build=${CT_BUILD}                         \
   189             --host=${CT_TARGET}                         \
   190             --target=${CT_TARGET}                       \
   191             --prefix=/usr                               \
   192             --sysconfdir=/etc                           \
   193             --localstatedir=/var                        \
   194             --includedir="${CT_HEADERS_DIR}"            \
   195             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   196             --program-prefix=                           \
   197             --without-uiout                             \
   198             --disable-tui                               \
   199             --disable-gdbtk                             \
   200             --without-x                                 \
   201             --without-included-gettext                  \
   202             --without-develop                           \
   203             ${extra_config}                             2>&1 |CT_DoLog ALL
   204 
   205         CT_DoLog EXTRA "Building gdbserver"
   206         make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL
   207 
   208         CT_DoLog EXTRA "Installing gdbserver"
   209         make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install  2>&1 |CT_DoLog ALL
   210 
   211         CT_EndStep
   212     fi
   213 }