scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Fri Jun 20 15:16:43 2008 +0000 (2008-06-20)
changeset 602 1968d150a34f
parent 598 a2b23333b17a
child 609 dc9314e3d72d
permissions -rw-r--r--
GMP and MPFR are no longer a sub-component of gcc (config-wise).
Build and install GMP and MPFR for the target.
Use the target GMP and MPFR to build the native gdb.
Have separate extra_config for cross gdb, native gdb and gdbserver.
Check native GMP and MPFR in //.

/trunk/scripts/build/debug/300-gdb.sh | 27 19 8 0 ++++++++++++++++-------
/trunk/scripts/build/gmp.sh | 47 39 8 0 ++++++++++++++++++++++++++++++++-------
/trunk/scripts/build/mpfr.sh | 49 40 9 0 +++++++++++++++++++++++++++++++++--------
/trunk/steps.mk | 2 2 0 0 ++
/trunk/config/cc/gcc.in | 18 1 17 0 +--------------
/trunk/config/debug/gdb.in | 6 1 5 0 +----
/trunk/config/config.in | 1 1 0 0 +
/trunk/config/gmp_mpfr.in | 34 34 0 0 ++++++++++++++++++++++++++++
8 files changed, 137 insertions(+), 47 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 
   102         "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}/configure" \
   103             --build=${CT_BUILD}                                 \
   104             --host=${CT_TARGET}                                 \
   105             --with-build-cc=${CT_CC}                            \
   106             --with-build-cpp=${CT_CC}                           \
   107             --with-build-cflags="${CT_CFLAGS_FOR_HOST}"         \
   108             --prefix=/usr                                       \
   109             --with-shared                                       \
   110             --without-sysmouse                                  \
   111             --without-progs                                     \
   112             --enable-termcap                                    \
   113             ${ncurses_opts}                                     2>&1 |CT_DoLog ALL
   114 
   115         CT_DoLog EXTRA "Building ncurses"
   116         make ${PARALLELMFLAGS}  2>&1 |CT_DoLog ALL
   117 
   118         CT_DoLog EXTRA "Installing ncurses"
   119         mkdir -p -v "${CT_SYSROOT_DIR}/usr/bin"     2>&1 |CT_DoLog ALL
   120         make DESTDIR="${CT_SYSROOT_DIR}" install    2>&1 |CT_DoLog ALL
   121 
   122         CT_EndStep
   123 
   124         CT_DoLog EXTRA "Configuring native gdb"
   125 
   126         mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
   127         cd "${CT_BUILD_DIR}/build-gdb-native"
   128 
   129         native_extra_config="${extra_config}"
   130         case "${CT_THREADS}" in
   131             none)   native_extra_config="${native_extra_config} --disable-threads";;
   132             *)      native_extra_config="${native_extra_config} --enable-threads";;
   133         esac
   134         if [ "${CT_GMP_MPFR_TARGET}" = "y" ]; then
   135             native_extra_config="${native_extra_config} --with-gmp=${CT_SYSROOT_DIR}/usr --with-mpfr=${CT_SYSROOT_DIR}/usr"
   136         fi
   137 
   138         CC_for_gdb=
   139         LD_for_gdb=
   140         if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then
   141             CC_for_gdb="${CT_TARGET}-gcc -static"
   142             LD_for_gdb="${CT_TARGET}-ld -static"
   143         fi
   144 
   145         export ac_cv_func_strncmp_works=yes
   146 
   147         CT_DoLog DEBUG "Extra config passed: '${native_extra_config# }'"
   148 
   149         CC="${CC_for_gdb}"                              \
   150         LD="${LD_for_gdb}"                              \
   151         "${gdb_src_dir}/configure"                      \
   152             --build=${CT_BUILD}                         \
   153             --host=${CT_TARGET}                         \
   154             --target=${CT_TARGET}                       \
   155             --prefix=/usr                               \
   156             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   157             --without-uiout                             \
   158             --disable-tui                               \
   159             --disable-gdbtk                             \
   160             --without-x                                 \
   161             --disable-sim                               \
   162             --disable-werror                            \
   163             --without-included-gettext                  \
   164             --without-develop                           \
   165             ${native_extra_config}                      2>&1 |CT_DoLog ALL
   166 
   167         CT_DoLog EXTRA "Building native gdb"
   168         make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL
   169 
   170         CT_DoLog EXTRA "Installing native gdb"
   171         make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install  2>&1 |CT_DoLog ALL
   172 
   173         # Building a native gdb also builds a gdbserver
   174         find "${CT_DEBUG_INSTALL_DIR}" -type f -name gdbserver -exec rm -fv {} + 2>&1 |CT_DoLog ALL
   175 
   176         unset ac_cv_func_strncmp_works
   177 
   178         CT_EndStep
   179     fi
   180 
   181     if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
   182         CT_DoStep INFO "Installing gdbserver"
   183         CT_DoLog EXTRA "Configuring gdbserver"
   184 
   185         mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
   186         cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
   187 
   188         # Workaround for bad versions, where the configure
   189         # script for gdbserver is not executable...
   190         # Bah, GNU folks strike again... :-(
   191         chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
   192 
   193         gdbserver_LDFLAGS=
   194         if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then
   195             gdbserver_LDFLAGS=-static
   196         fi
   197 
   198         gdbserver_extra_config="${extra_config}"
   199 
   200         LDFLAGS="${gdbserver_LDFLAGS}"                  \
   201         "${gdb_src_dir}/gdb/gdbserver/configure"        \
   202             --build=${CT_BUILD}                         \
   203             --host=${CT_TARGET}                         \
   204             --target=${CT_TARGET}                       \
   205             --prefix=/usr                               \
   206             --sysconfdir=/etc                           \
   207             --localstatedir=/var                        \
   208             --includedir="${CT_HEADERS_DIR}"            \
   209             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   210             --program-prefix=                           \
   211             --without-uiout                             \
   212             --disable-tui                               \
   213             --disable-gdbtk                             \
   214             --without-x                                 \
   215             --without-included-gettext                  \
   216             --without-develop                           \
   217             ${gdbserver_extra_config}                   2>&1 |CT_DoLog ALL
   218 
   219         CT_DoLog EXTRA "Building gdbserver"
   220         make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL
   221 
   222         CT_DoLog EXTRA "Installing gdbserver"
   223         make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install  2>&1 |CT_DoLog ALL
   224 
   225         CT_EndStep
   226     fi
   227 }