scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Sep 01 09:15:31 2008 +0000 (2008-09-01)
changeset 818 7f65fde1eb5b
parent 801 abd105984689
child 821 4c073dd24c1d
permissions -rw-r--r--
Be gentle to older findutils that don't have the "{} +" construct, and simply use "{} \;" instead.

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