scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Fri Jun 27 11:18:56 2008 +0000 (2008-06-27)
changeset 626 32af757a45f6
parent 622 259d3b95bfad
child 645 8e58024f8e37
permissions -rw-r--r--
Native gcc is picky about the CC and LD variables. Set them unconditionally, whether building static or not.

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