scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Fri Jun 20 10:58:45 2008 +0000 (2008-06-20)
changeset 598 a2b23333b17a
parent 596 d1651a3f42a3
child 602 1968d150a34f
permissions -rw-r--r--
Really don't re-build MPFR autotools files at each run.

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