scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Jun 24 15:44:55 2008 +0000 (2008-06-24)
changeset 609 dc9314e3d72d
parent 602 1968d150a34f
child 622 259d3b95bfad
permissions -rw-r--r--
Don't build ncurses ADA bindings if an ADA x-compiler was not built.

/trunk/scripts/build/debug/300-gdb.sh | 1 1 0 0 +
1 file changed, 1 insertion(+)
     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_GMP_MPFR_TARGET}" = "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         CC_for_gdb=
   140         LD_for_gdb=
   141         if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then
   142             CC_for_gdb="${CT_TARGET}-gcc -static"
   143             LD_for_gdb="${CT_TARGET}-ld -static"
   144         fi
   145 
   146         export ac_cv_func_strncmp_works=yes
   147 
   148         CT_DoLog DEBUG "Extra config passed: '${native_extra_config# }'"
   149 
   150         CC="${CC_for_gdb}"                              \
   151         LD="${LD_for_gdb}"                              \
   152         "${gdb_src_dir}/configure"                      \
   153             --build=${CT_BUILD}                         \
   154             --host=${CT_TARGET}                         \
   155             --target=${CT_TARGET}                       \
   156             --prefix=/usr                               \
   157             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   158             --without-uiout                             \
   159             --disable-tui                               \
   160             --disable-gdbtk                             \
   161             --without-x                                 \
   162             --disable-sim                               \
   163             --disable-werror                            \
   164             --without-included-gettext                  \
   165             --without-develop                           \
   166             ${native_extra_config}                      2>&1 |CT_DoLog ALL
   167 
   168         CT_DoLog EXTRA "Building native gdb"
   169         make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL
   170 
   171         CT_DoLog EXTRA "Installing native gdb"
   172         make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install  2>&1 |CT_DoLog ALL
   173 
   174         # Building a native gdb also builds a gdbserver
   175         find "${CT_DEBUG_INSTALL_DIR}" -type f -name gdbserver -exec rm -fv {} + 2>&1 |CT_DoLog ALL
   176 
   177         unset ac_cv_func_strncmp_works
   178 
   179         CT_EndStep
   180     fi
   181 
   182     if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
   183         CT_DoStep INFO "Installing gdbserver"
   184         CT_DoLog EXTRA "Configuring gdbserver"
   185 
   186         mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
   187         cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
   188 
   189         # Workaround for bad versions, where the configure
   190         # script for gdbserver is not executable...
   191         # Bah, GNU folks strike again... :-(
   192         chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
   193 
   194         gdbserver_LDFLAGS=
   195         if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then
   196             gdbserver_LDFLAGS=-static
   197         fi
   198 
   199         gdbserver_extra_config="${extra_config}"
   200 
   201         LDFLAGS="${gdbserver_LDFLAGS}"                  \
   202         "${gdb_src_dir}/gdb/gdbserver/configure"        \
   203             --build=${CT_BUILD}                         \
   204             --host=${CT_TARGET}                         \
   205             --target=${CT_TARGET}                       \
   206             --prefix=/usr                               \
   207             --sysconfdir=/etc                           \
   208             --localstatedir=/var                        \
   209             --includedir="${CT_HEADERS_DIR}"            \
   210             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   211             --program-prefix=                           \
   212             --without-uiout                             \
   213             --disable-tui                               \
   214             --disable-gdbtk                             \
   215             --without-x                                 \
   216             --without-included-gettext                  \
   217             --without-develop                           \
   218             ${gdbserver_extra_config}                   2>&1 |CT_DoLog ALL
   219 
   220         CT_DoLog EXTRA "Building gdbserver"
   221         make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL
   222 
   223         CT_DoLog EXTRA "Installing gdbserver"
   224         make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install  2>&1 |CT_DoLog ALL
   225 
   226         CT_EndStep
   227     fi
   228 }