scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Fri Jun 20 09:56:46 2008 +0000 (2008-06-20)
changeset 596 d1651a3f42a3
parent 583 44b87fb3f0d3
child 598 a2b23333b17a
permissions -rw-r--r--
Don't force building a gdbserver when only native gdb is selected.

/trunk/config/debug/gdb.in | 1 0 1 0 -
/trunk/scripts/build/debug/300-gdb.sh | 1 0 1 0 -
2 files changed, 2 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         find "${CT_DEBUG_INSTALL_DIR}" -type f -name gdbserver -exec rm -fv {} + 2>&1 |CT_DoLog ALL
   162 
   163         unset ac_cv_func_strncmp_works
   164 
   165         CT_EndStep
   166     fi
   167 
   168     if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
   169         CT_DoStep INFO "Installing gdbserver"
   170         CT_DoLog EXTRA "Configuring gdbserver"
   171 
   172         mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
   173         cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
   174 
   175         # Workaround for bad versions, where the configure
   176         # script for gdbserver is not executable...
   177         # Bah, GNU folks strike again... :-(
   178         chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
   179 
   180         gdbserver_LDFLAGS=
   181         if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then
   182             gdbserver_LDFLAGS=-static
   183         fi
   184 
   185         LDFLAGS="${gdbserver_LDFLAGS}"                  \
   186         "${gdb_src_dir}/gdb/gdbserver/configure"        \
   187             --build=${CT_BUILD}                         \
   188             --host=${CT_TARGET}                         \
   189             --target=${CT_TARGET}                       \
   190             --prefix=/usr                               \
   191             --sysconfdir=/etc                           \
   192             --localstatedir=/var                        \
   193             --includedir="${CT_HEADERS_DIR}"            \
   194             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   195             --program-prefix=                           \
   196             --without-uiout                             \
   197             --disable-tui                               \
   198             --disable-gdbtk                             \
   199             --without-x                                 \
   200             --without-included-gettext                  \
   201             --without-develop                           \
   202             ${extra_config}                             2>&1 |CT_DoLog ALL
   203 
   204         CT_DoLog EXTRA "Building gdbserver"
   205         make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL
   206 
   207         CT_DoLog EXTRA "Installing gdbserver"
   208         make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install  2>&1 |CT_DoLog ALL
   209 
   210         CT_EndStep
   211     fi
   212 }