scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Sep 02 10:47:44 2008 +0000 (2008-09-02)
changeset 821 4c073dd24c1d
parent 818 7f65fde1eb5b
child 916 68af6b83ff7e
permissions -rw-r--r--
Add support for building Insight instead of gdb (only for the cross-gdb).

/trunk/scripts/build/debug/300-gdb.sh | 62 55 7 0 ++++++++++++++++++++++++++++++++++++-----
/trunk/config/debug/gdb.in | 13 13 0 0 +++++++++
2 files changed, 68 insertions(+), 7 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_parts() {
    21     do_gdb=
    22     do_insight=
    23     do_ncurses=
    24 
    25     if [ "${CT_GDB_CROSS}" = y ]; then
    26         if [ "${CT_GDB_CROSS_INSIGHT}" = "y" ]; then
    27             do_insight=y
    28         else
    29             do_gdb=y
    30         fi
    31     fi
    32 
    33     if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
    34         do_gdb=y
    35     fi
    36 
    37     if [ "${CT_GDB_NATIVE}" = "y" ]; then
    38         do_gdb=y
    39         do_ncurses=y
    40     fi
    41 }
    42 
    43 do_debug_gdb_get() {
    44     do_debug_gdb_parts
    45 
    46     if [ "${do_gdb}" = "y" ]; then
    47         CT_GetFile "gdb$(do_debug_gdb_suffix)"              \
    48                    {ftp,http}://ftp.gnu.org/pub/gnu/gdb     \
    49                    ftp://sources.redhat.com/pub/gdb/{{,old-}releases,snapshots/current}
    50     fi
    51 
    52     if [ "${do_insight}" = "y" ]; then
    53         CT_GetFile "insight-${CT_GDB_VERSION}"                                              \
    54                    ftp://sourceware.org/pub/insight/releases                                \
    55                    {ftp,http}://ftp.twaren.net/Unix/Sourceware/insight/releases             \
    56                    {ftp,http}://ftp.gwdg.de/pub/linux/sources.redhat.com/insight/releases
    57     fi
    58 
    59     if [ "${do_ncurses}" = "y" ]; then
    60         CT_GetFile "ncurses-${CT_NCURSES_VERSION}"          \
    61                    {ftp,http}://ftp.gnu.org/pub/gnu/ncurses \
    62                    ftp://invisible-island.net/ncurses
    63     fi
    64 }
    65 
    66 do_debug_gdb_extract() {
    67     do_debug_gdb_parts
    68 
    69     if [ "${do_gdb}" = "y" ]; then
    70         CT_ExtractAndPatch "gdb$(do_debug_gdb_suffix)"
    71     fi
    72 
    73     if [ "${do_insight}" = "y" ]; then
    74         CT_ExtractAndPatch "insight-${CT_GDB_VERSION}"
    75     fi
    76 
    77     if [ "${do_ncurses}" = "y" ]; then
    78         CT_ExtractAndPatch "ncurses-${CT_NCURSES_VERSION}"
    79     fi
    80 }
    81 
    82 do_debug_gdb_build() {
    83     gdb_src_dir="${CT_SRC_DIR}/gdb$(do_debug_gdb_suffix)"
    84     insight_src_dir="${CT_SRC_DIR}/insight-${CT_GDB_VERSION}"
    85 
    86     extra_config=
    87     # Version 6.3 and below behave badly with gdbmi
    88     case "${CT_GDB_VERSION}" in
    89         6.2*|6.3)   extra_config="${extra_config} --disable-gdbmi";;
    90     esac
    91 
    92     if [ "${CT_GDB_CROSS}" = "y" ]; then
    93         CT_DoStep INFO "Installing cross-gdb"
    94         CT_DoLog EXTRA "Configuring cross-gdb"
    95 
    96         mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
    97         cd "${CT_BUILD_DIR}/build-gdb-cross"
    98 
    99         cross_extra_config="${extra_config}"
   100         if [ "${CT_GMP_MPFR}" = "y" ]; then
   101             cross_extra_config="${cross_extra_config} --with-gmp=${CT_PREFIX_DIR} --with-mpfr=${CT_PREFIX_DIR}"
   102         fi
   103         case "${CT_THREADS}" in
   104             none)   cross_extra_config="${cross_extra_config} --disable-threads";;
   105             *)      cross_extra_config="${cross_extra_config} --enable-threads";;
   106         esac
   107 
   108         CC_for_gdb=
   109         LD_for_gdb=
   110         if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then
   111             CC_for_gdb="gcc -static"
   112             LD_for_gdb="ld -static"
   113         fi
   114 
   115         gdb_cross_configure="${gdb_src_dir}/configure"
   116         [ "${CT_GDB_CROSS_INSIGHT}" = "y" ] && gdb_cross_configure="${insight_src_dir}/configure"
   117 
   118         CT_DoLog DEBUG "Extra config passed: '${cross_extra_config# }'"
   119 
   120         CC="${CC_for_gdb}"                              \
   121         LD="${LD_for_gdb}"                              \
   122         CT_DoExecLog ALL                                \
   123         "${gdb_cross_configure}"                        \
   124             --build=${CT_BUILD}                         \
   125             --host=${CT_HOST}                           \
   126             --target=${CT_TARGET}                       \
   127             --prefix="${CT_PREFIX_DIR}"                 \
   128             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   129             --disable-werror                            \
   130             ${cross_extra_config}
   131 
   132         CT_DoLog EXTRA "Building cross-gdb"
   133         CT_DoExecLog ALL make ${PARALLELMFLAGS}
   134 
   135         CT_DoLog EXTRA "Installing cross-gdb"
   136         CT_DoExecLog ALL make install
   137 
   138         CT_EndStep
   139     fi
   140 
   141     if [ "${CT_GDB_NATIVE}" = "y" ]; then
   142         CT_DoStep INFO "Installing native gdb"
   143 
   144         CT_DoStep INFO "Installing ncurses library"
   145         CT_DoLog EXTRA "Configuring ncurses"
   146         mkdir -p "${CT_BUILD_DIR}/build-ncurses"
   147         cd "${CT_BUILD_DIR}/build-ncurses"
   148 
   149         ncurses_opts=
   150         [ "${CT_CC_LANG_CXX}" = "y" ] || ncurses_opts="${ncurses_opts} --without-cxx --without-cxx-binding"
   151         [ "${CT_CC_LANG_ADA}" = "y" ] || ncurses_opts="${ncurses_opts} --without-ada"
   152 
   153         CT_DoExecLog ALL                                        \
   154         "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}/configure" \
   155             --build=${CT_BUILD}                                 \
   156             --host=${CT_TARGET}                                 \
   157             --with-build-cc=${CT_CC}                            \
   158             --with-build-cpp=${CT_CC}                           \
   159             --with-build-cflags="${CT_CFLAGS_FOR_HOST}"         \
   160             --prefix=/usr                                       \
   161             --with-shared                                       \
   162             --without-sysmouse                                  \
   163             --without-progs                                     \
   164             --enable-termcap                                    \
   165             ${ncurses_opts}
   166 
   167         CT_DoLog EXTRA "Building ncurses"
   168         CT_DoExecLog ALL make ${PARALLELMFLAGS}
   169 
   170         CT_DoLog EXTRA "Installing ncurses"
   171         mkdir -p "${CT_SYSROOT_DIR}/usr/bin"
   172         CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install
   173 
   174         CT_EndStep
   175 
   176         CT_DoLog EXTRA "Configuring native gdb"
   177 
   178         mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
   179         cd "${CT_BUILD_DIR}/build-gdb-native"
   180 
   181         native_extra_config="${extra_config}"
   182         case "${CT_THREADS}" in
   183             none)   native_extra_config="${native_extra_config} --disable-threads";;
   184             *)      native_extra_config="${native_extra_config} --enable-threads";;
   185         esac
   186         if [ "${CT_GDB_NATIVE_USE_GMP_MPFR}" = "y" ]; then
   187             native_extra_config="${native_extra_config} --with-gmp=${CT_SYSROOT_DIR}/usr --with-mpfr=${CT_SYSROOT_DIR}/usr"
   188         fi
   189 
   190         if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then
   191             CC_for_gdb="${CT_TARGET}-gcc -static"
   192             LD_for_gdb="${CT_TARGET}-ld -static"
   193         else
   194             CC_for_gdb="${CT_TARGET}-gcc"
   195             LD_for_gdb="${CT_TARGET}-ld"
   196         fi
   197 
   198         export ac_cv_func_strncmp_works=yes
   199 
   200         CT_DoLog DEBUG "Extra config passed: '${native_extra_config# }'"
   201 
   202         CC="${CC_for_gdb}"                              \
   203         LD="${LD_for_gdb}"                              \
   204         CT_DoExecLog ALL                                \
   205         "${gdb_src_dir}/configure"                      \
   206             --build=${CT_BUILD}                         \
   207             --host=${CT_TARGET}                         \
   208             --target=${CT_TARGET}                       \
   209             --prefix=/usr                               \
   210             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   211             --without-uiout                             \
   212             --disable-tui                               \
   213             --disable-gdbtk                             \
   214             --without-x                                 \
   215             --disable-sim                               \
   216             --disable-werror                            \
   217             --without-included-gettext                  \
   218             --without-develop                           \
   219             ${native_extra_config}
   220 
   221         CT_DoLog EXTRA "Building native gdb"
   222         CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
   223 
   224         CT_DoLog EXTRA "Installing native gdb"
   225         CT_DoExecLog ALL make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install
   226 
   227         # Building a native gdb also builds a gdbserver
   228         find "${CT_DEBUG_INSTALL_DIR}" -type f -name gdbserver -exec rm -fv {} \; 2>&1 |CT_DoLog ALL
   229 
   230         unset ac_cv_func_strncmp_works
   231 
   232         CT_EndStep
   233     fi
   234 
   235     if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
   236         CT_DoStep INFO "Installing gdbserver"
   237         CT_DoLog EXTRA "Configuring gdbserver"
   238 
   239         mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
   240         cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
   241 
   242         # Workaround for bad versions, where the configure
   243         # script for gdbserver is not executable...
   244         # Bah, GNU folks strike again... :-(
   245         chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
   246 
   247         gdbserver_LDFLAGS=
   248         if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then
   249             gdbserver_LDFLAGS=-static
   250         fi
   251 
   252         gdbserver_extra_config="${extra_config}"
   253 
   254         LDFLAGS="${gdbserver_LDFLAGS}"                  \
   255         CT_DoExecLog ALL                                \
   256         "${gdb_src_dir}/gdb/gdbserver/configure"        \
   257             --build=${CT_BUILD}                         \
   258             --host=${CT_TARGET}                         \
   259             --target=${CT_TARGET}                       \
   260             --prefix=/usr                               \
   261             --sysconfdir=/etc                           \
   262             --localstatedir=/var                        \
   263             --includedir="${CT_HEADERS_DIR}"            \
   264             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   265             --program-prefix=                           \
   266             --without-uiout                             \
   267             --disable-tui                               \
   268             --disable-gdbtk                             \
   269             --without-x                                 \
   270             --without-included-gettext                  \
   271             --without-develop                           \
   272             --disable-werror                            \
   273             ${gdbserver_extra_config}
   274 
   275         CT_DoLog EXTRA "Building gdbserver"
   276         CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
   277 
   278         CT_DoLog EXTRA "Installing gdbserver"
   279         CT_DoExecLog ALL make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install
   280 
   281         CT_EndStep
   282     fi
   283 }