scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Aug 30 00:57:40 2009 +0200 (2009-08-30)
changeset 1495 2542421e3321
parent 1281 12a2991fcffb
child 1555 3445f45e6c37
permissions -rw-r--r--
tools wrapper: introduce the silent WRAPPER_NEEDED config option

Add the WRAPPER_NEEDED silent config option, that can be selected by
components that require it (companion libs so far).
Rely on this config option when deciding to install the wrapper,
instead of checking GMP/MPFR or PPL/CLoog/MPC.
     1 # Build script for the gdb debug facility
     2 
     3 do_debug_gdb_suffix() {
     4     case "${CT_GDB_VERSION}" in
     5         snapshot)   ;;
     6         *)          echo "-${CT_GDB_VERSION}";;
     7     esac
     8 }
     9 
    10 do_debug_gdb_parts() {
    11     do_gdb=
    12     do_insight=
    13     do_ncurses=
    14 
    15     if [ "${CT_GDB_CROSS}" = y ]; then
    16         if [ "${CT_GDB_CROSS_INSIGHT}" = "y" ]; then
    17             do_insight=y
    18         else
    19             do_gdb=y
    20         fi
    21     fi
    22 
    23     if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
    24         do_gdb=y
    25     fi
    26 
    27     if [ "${CT_GDB_NATIVE}" = "y" ]; then
    28         do_gdb=y
    29         do_ncurses=y
    30     fi
    31 }
    32 
    33 do_debug_gdb_get() {
    34     do_debug_gdb_parts
    35 
    36     if [ "${do_gdb}" = "y" ]; then
    37         CT_GetFile "gdb$(do_debug_gdb_suffix)"              \
    38                    {ftp,http}://ftp.gnu.org/pub/gnu/gdb     \
    39                    ftp://sources.redhat.com/pub/gdb/{{,old-}releases,snapshots/current}
    40     fi
    41 
    42     if [ "${do_insight}" = "y" ]; then
    43         CT_GetFile "insight-${CT_GDB_VERSION}"                                              \
    44                    ftp://sourceware.org/pub/insight/releases                                \
    45                    {ftp,http}://ftp.twaren.net/Unix/Sourceware/insight/releases             \
    46                    {ftp,http}://ftp.gwdg.de/pub/linux/sources.redhat.com/insight/releases
    47     fi
    48 
    49     if [ "${do_ncurses}" = "y" ]; then
    50         CT_GetFile "ncurses-${CT_NCURSES_VERSION}"          \
    51                    {ftp,http}://ftp.gnu.org/pub/gnu/ncurses \
    52                    ftp://invisible-island.net/ncurses
    53     fi
    54 }
    55 
    56 do_debug_gdb_extract() {
    57     do_debug_gdb_parts
    58 
    59     if [ "${do_gdb}" = "y" ]; then
    60         CT_Extract "gdb$(do_debug_gdb_suffix)"
    61         CT_Patch "gdb$(do_debug_gdb_suffix)"
    62     fi
    63 
    64     if [ "${do_insight}" = "y" ]; then
    65         CT_Extract "insight-${CT_GDB_VERSION}"
    66         CT_Patch "insight-${CT_GDB_VERSION}"
    67     fi
    68 
    69     if [ "${do_ncurses}" = "y" ]; then
    70         CT_Extract "ncurses-${CT_NCURSES_VERSION}"
    71         CT_Patch "ncurses-${CT_NCURSES_VERSION}"
    72     fi
    73 }
    74 
    75 do_debug_gdb_build() {
    76     local -a extra_config
    77 
    78     gdb_src_dir="${CT_SRC_DIR}/gdb$(do_debug_gdb_suffix)"
    79     insight_src_dir="${CT_SRC_DIR}/insight-${CT_GDB_VERSION}"
    80 
    81     # Version 6.3 and below behave badly with gdbmi
    82     case "${CT_GDB_VERSION}" in
    83         6.2*|6.3)   extra_config+=("--disable-gdbmi");;
    84     esac
    85 
    86     if [ "${CT_GDB_CROSS}" = "y" ]; then
    87         local -a cross_extra_config
    88 
    89         CT_DoStep INFO "Installing cross-gdb"
    90         CT_DoLog EXTRA "Configuring cross-gdb"
    91 
    92         mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
    93         cd "${CT_BUILD_DIR}/build-gdb-cross"
    94 
    95         cross_extra_config=("${extra_config[@]}")
    96         if [ "${CT_GMP_MPFR}" = "y" ]; then
    97             cross_extra_config+=("--with-gmp=${CT_PREFIX_DIR}" "--with-mpfr=${CT_PREFIX_DIR}")
    98         fi
    99         case "${CT_THREADS}" in
   100             none)   cross_extra_config+=("--disable-threads");;
   101             *)      cross_extra_config+=("--enable-threads");;
   102         esac
   103 
   104         CC_for_gdb=
   105         LD_for_gdb=
   106         if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then
   107             CC_for_gdb="gcc -static"
   108             LD_for_gdb="ld -static"
   109         fi
   110 
   111         gdb_cross_configure="${gdb_src_dir}/configure"
   112         [ "${CT_GDB_CROSS_INSIGHT}" = "y" ] && gdb_cross_configure="${insight_src_dir}/configure"
   113 
   114         CT_DoLog DEBUG "Extra config passed: '${cross_extra_config[*]}'"
   115 
   116         CC="${CC_for_gdb}"                              \
   117         LD="${LD_for_gdb}"                              \
   118         CT_DoExecLog ALL                                \
   119         "${gdb_cross_configure}"                        \
   120             --build=${CT_BUILD}                         \
   121             --host=${CT_HOST}                           \
   122             --target=${CT_TARGET}                       \
   123             --prefix="${CT_PREFIX_DIR}"                 \
   124             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   125             --disable-werror                            \
   126             "${cross_extra_config[@]}"
   127 
   128         CT_DoLog EXTRA "Building cross-gdb"
   129         CT_DoExecLog ALL make ${PARALLELMFLAGS}
   130 
   131         CT_DoLog EXTRA "Installing cross-gdb"
   132         CT_DoExecLog ALL make install
   133 
   134         CT_EndStep
   135     fi
   136 
   137     if [ "${CT_GDB_NATIVE}" = "y" ]; then
   138         local -a native_extra_config
   139         local -a ncurses_opt
   140 
   141         CT_DoStep INFO "Installing native gdb"
   142 
   143         CT_DoStep INFO "Installing ncurses library"
   144 
   145         [ "${CT_CC_LANG_CXX}" = "y" ] || ncurses_opts+=("--without-cxx" "--without-cxx-binding")
   146         [ "${CT_CC_LANG_ADA}" = "y" ] || ncurses_opts+=("--without-ada")
   147 
   148         CT_DoStep INFO "Installing native ncurses tic"
   149         CT_DoLog EXTRA "Configuring ncurses tic"
   150         mkdir -p "${CT_BUILD_DIR}/build-ncurses-build-tic"
   151         cd "${CT_BUILD_DIR}/build-ncurses-build-tic"
   152 
   153         # Use build = CT_REAL_BUILD so that configure thinks it is
   154         # cross-compiling, and thus will use the ${CT_BUILD}-*
   155         # tools instead of searching for the native ones...
   156         CT_DoExecLog ALL                                        \
   157         "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}/configure" \
   158             --build=${CT_REAL_BUILD}                            \
   159             --host=${CT_BUILD}                                  \
   160             --prefix=/usr                                       \
   161             --without-shared                                    \
   162             --enable-symlinks                                   \
   163             --with-build-cc=${CT_REAL_BUILD}-gcc                \
   164             --with-build-cpp=${CT_REAL_BUILD}-gcc               \
   165             --with-build-cflags="${CT_CFLAGS_FOR_HOST}"         \
   166             "${ncurses_opts[@]}"
   167 
   168         # Under some operating systems (eg. Winblows), there is an
   169         # extension appended to executables. Find that.
   170         tic_ext=$(grep -E '^x[[:space:]]*=' progs/Makefile |sed -r -e 's/^.*=[[:space:]]*//;')
   171 
   172         CT_DoLog EXTRA "Building ncurses tic"
   173         CT_DoExecLog ALL make ${PARALLELMFLAGS} -C include
   174         CT_DoExecLog ALL make ${PARALLELMFLAGS} -C progs "tic${tic_ext}"
   175 
   176         CT_DoLog EXTRA "Installing ncurses tic"
   177         CT_DoExecLog ALL install -d -m 0755 "${CT_PREFIX_DIR}/bin"
   178         CT_DoExecLog ALL install -m 0755 "progs/tic${tic_ext}" "${CT_PREFIX_DIR}/bin"
   179 
   180         CT_EndStep # tic build
   181 
   182         CT_DoLog EXTRA "Configuring ncurses"
   183         mkdir -p "${CT_BUILD_DIR}/build-ncurses"
   184         cd "${CT_BUILD_DIR}/build-ncurses"
   185 
   186         CT_DoExecLog ALL                                        \
   187         "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}/configure" \
   188             --build=${CT_BUILD}                                 \
   189             --host=${CT_TARGET}                                 \
   190             --with-build-cc=${CT_BUILD}-gcc                     \
   191             --with-build-cpp=${CT_BUILD}-gcc                    \
   192             --with-build-cflags="${CT_CFLAGS_FOR_HOST}"         \
   193             --prefix=/usr                                       \
   194             --with-shared                                       \
   195             --without-sysmouse                                  \
   196             --without-progs                                     \
   197             --enable-termcap                                    \
   198             "${ncurses_opts[@]}"
   199 
   200         CT_DoLog EXTRA "Building ncurses"
   201         CT_DoExecLog ALL make ${PARALLELMFLAGS}
   202 
   203         CT_DoLog EXTRA "Installing ncurses"
   204         mkdir -p "${CT_SYSROOT_DIR}/usr/bin"
   205         CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install
   206 
   207         # We no longer need the temporary tic. Remove it
   208         CT_DoExecLog DEBUG rm -fv "${CT_PREFIX_DIR}/bin/tic"
   209 
   210         CT_EndStep # ncurses build
   211 
   212         CT_DoLog EXTRA "Configuring native gdb"
   213 
   214         mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
   215         cd "${CT_BUILD_DIR}/build-gdb-native"
   216 
   217         native_extra_config=("${extra_config[@]}")
   218         case "${CT_THREADS}" in
   219             none)   native_extra_config+=("--disable-threads");;
   220             *)      native_extra_config+=("--enable-threads");;
   221         esac
   222         if [ "${CT_GDB_NATIVE_USE_GMP_MPFR}" = "y" ]; then
   223             native_extra_config+=("--with-gmp=${CT_SYSROOT_DIR}/usr" "--with-mpfr=${CT_SYSROOT_DIR}/usr")
   224         fi
   225 
   226         if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then
   227             CC_for_gdb="${CT_TARGET}-gcc -static"
   228             LD_for_gdb="${CT_TARGET}-ld -static"
   229         else
   230             CC_for_gdb="${CT_TARGET}-gcc"
   231             LD_for_gdb="${CT_TARGET}-ld"
   232         fi
   233 
   234         export ac_cv_func_strncmp_works=yes
   235 
   236         CT_DoLog DEBUG "Extra config passed: '${native_extra_config[*]}'"
   237 
   238         CC="${CC_for_gdb}"                              \
   239         LD="${LD_for_gdb}"                              \
   240         CT_DoExecLog ALL                                \
   241         "${gdb_src_dir}/configure"                      \
   242             --build=${CT_BUILD}                         \
   243             --host=${CT_TARGET}                         \
   244             --target=${CT_TARGET}                       \
   245             --prefix=/usr                               \
   246             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   247             --without-uiout                             \
   248             --disable-tui                               \
   249             --disable-gdbtk                             \
   250             --without-x                                 \
   251             --disable-sim                               \
   252             --disable-werror                            \
   253             --without-included-gettext                  \
   254             --without-develop                           \
   255             "${native_extra_config[@]}"
   256 
   257         CT_DoLog EXTRA "Building native gdb"
   258         CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
   259 
   260         CT_DoLog EXTRA "Installing native gdb"
   261         CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install
   262 
   263         # Building a native gdb also builds a gdbserver
   264         find "${CT_DEBUGROOT_DIR}" -type f -name gdbserver -exec rm -fv {} \; 2>&1 |CT_DoLog ALL
   265 
   266         unset ac_cv_func_strncmp_works
   267 
   268         CT_EndStep # native gdb build
   269     fi
   270 
   271     if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
   272         local -a gdbserver_extra_config
   273 
   274         CT_DoStep INFO "Installing gdbserver"
   275         CT_DoLog EXTRA "Configuring gdbserver"
   276 
   277         mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
   278         cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
   279 
   280         # Workaround for bad versions, where the configure
   281         # script for gdbserver is not executable...
   282         # Bah, GNU folks strike again... :-(
   283         chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
   284 
   285         gdbserver_LDFLAGS=
   286         if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then
   287             gdbserver_LDFLAGS=-static
   288         fi
   289 
   290         gdbserver_extra_config=("${extra_config[@]}")
   291 
   292         LDFLAGS="${gdbserver_LDFLAGS}"                  \
   293         CT_DoExecLog ALL                                \
   294         "${gdb_src_dir}/gdb/gdbserver/configure"        \
   295             --build=${CT_BUILD}                         \
   296             --host=${CT_TARGET}                         \
   297             --target=${CT_TARGET}                       \
   298             --prefix=/usr                               \
   299             --sysconfdir=/etc                           \
   300             --localstatedir=/var                        \
   301             --includedir="${CT_HEADERS_DIR}"            \
   302             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   303             --program-prefix=                           \
   304             --without-uiout                             \
   305             --disable-tui                               \
   306             --disable-gdbtk                             \
   307             --without-x                                 \
   308             --without-included-gettext                  \
   309             --without-develop                           \
   310             --disable-werror                            \
   311             "${gdbserver_extra_config[@]}"
   312 
   313         CT_DoLog EXTRA "Building gdbserver"
   314         CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
   315 
   316         CT_DoLog EXTRA "Installing gdbserver"
   317         CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install
   318 
   319         CT_EndStep
   320     fi
   321 }