scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Jan 05 23:02:43 2009 +0000 (2009-01-05)
changeset 1126 1ab3d2e08c8b
parent 1112 c72aecd1a9ef
child 1219 2b875ed306c2
permissions -rw-r--r--
Split CT_ExtractAndPatch in two: CT_Extract and CT_Patch:
- it is unworkable to have CT_ExtactAndPAtch cope with all those silly glibc addons:
- they can have 'short' (as 'ports') or 'long' (as glibc-ports-2.7) names
- patches are against eithe the short or long name, but non-uniformly use one or the other
- it is the reposibility of the component (glibc in this case) to handle corner cases such as those
- update all components to use the new functions

/trunk/scripts/build/tools/000-template.sh | 3 2 1 0 +-
/trunk/scripts/build/tools/100-libelf.sh | 3 2 1 0 +-
/trunk/scripts/build/tools/200-sstrip.sh | 3 2 1 0 +-
/trunk/scripts/build/kernel/linux.sh | 3 2 1 0 +-
/trunk/scripts/build/binutils.sh | 3 2 1 0 +-
/trunk/scripts/build/cc/gcc.sh | 3 2 1 0 +-
/trunk/scripts/build/debug/000-template.sh | 3 2 1 0 +-
/trunk/scripts/build/debug/100-dmalloc.sh | 3 2 1 0 +-
/trunk/scripts/build/debug/400-ltrace.sh | 3 2 1 0 +-
/trunk/scripts/build/debug/300-gdb.sh | 9 6 3 0 +++--
/trunk/scripts/build/debug/500-strace.sh | 7 3 4 0 ++--
/trunk/scripts/build/debug/200-duma.sh | 19 8 11 0 ++++------
/trunk/scripts/build/libc/glibc.sh | 14 12 2 0 ++++++-
/trunk/scripts/build/libc/uClibc.sh | 13 9 4 0 +++++--
/trunk/scripts/build/libc/eglibc.sh | 14 12 2 0 ++++++-
/trunk/scripts/build/gmp.sh | 3 2 1 0 +-
/trunk/scripts/build/mpfr.sh | 3 2 1 0 +-
/trunk/scripts/functions | 68 36 32 0 +++++++++++++++++++-----------------
18 files changed, 108 insertions(+), 69 deletions(-)
     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     gdb_src_dir="${CT_SRC_DIR}/gdb$(do_debug_gdb_suffix)"
    77     insight_src_dir="${CT_SRC_DIR}/insight-${CT_GDB_VERSION}"
    78 
    79     extra_config=
    80     # Version 6.3 and below behave badly with gdbmi
    81     case "${CT_GDB_VERSION}" in
    82         6.2*|6.3)   extra_config="${extra_config} --disable-gdbmi";;
    83     esac
    84 
    85     if [ "${CT_GDB_CROSS}" = "y" ]; then
    86         CT_DoStep INFO "Installing cross-gdb"
    87         CT_DoLog EXTRA "Configuring cross-gdb"
    88 
    89         mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
    90         cd "${CT_BUILD_DIR}/build-gdb-cross"
    91 
    92         cross_extra_config="${extra_config}"
    93         if [ "${CT_GMP_MPFR}" = "y" ]; then
    94             cross_extra_config="${cross_extra_config} --with-gmp=${CT_PREFIX_DIR} --with-mpfr=${CT_PREFIX_DIR}"
    95         fi
    96         case "${CT_THREADS}" in
    97             none)   cross_extra_config="${cross_extra_config} --disable-threads";;
    98             *)      cross_extra_config="${cross_extra_config} --enable-threads";;
    99         esac
   100 
   101         CC_for_gdb=
   102         LD_for_gdb=
   103         if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then
   104             CC_for_gdb="gcc -static"
   105             LD_for_gdb="ld -static"
   106         fi
   107 
   108         gdb_cross_configure="${gdb_src_dir}/configure"
   109         [ "${CT_GDB_CROSS_INSIGHT}" = "y" ] && gdb_cross_configure="${insight_src_dir}/configure"
   110 
   111         CT_DoLog DEBUG "Extra config passed: '${cross_extra_config# }'"
   112 
   113         CC="${CC_for_gdb}"                              \
   114         LD="${LD_for_gdb}"                              \
   115         CT_DoExecLog ALL                                \
   116         "${gdb_cross_configure}"                        \
   117             --build=${CT_BUILD}                         \
   118             --host=${CT_HOST}                           \
   119             --target=${CT_TARGET}                       \
   120             --prefix="${CT_PREFIX_DIR}"                 \
   121             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   122             --disable-werror                            \
   123             ${cross_extra_config}
   124 
   125         CT_DoLog EXTRA "Building cross-gdb"
   126         CT_DoExecLog ALL make ${PARALLELMFLAGS}
   127 
   128         CT_DoLog EXTRA "Installing cross-gdb"
   129         CT_DoExecLog ALL make install
   130 
   131         CT_EndStep
   132     fi
   133 
   134     if [ "${CT_GDB_NATIVE}" = "y" ]; then
   135         CT_DoStep INFO "Installing native gdb"
   136 
   137         CT_DoStep INFO "Installing ncurses library"
   138         CT_DoLog EXTRA "Configuring ncurses"
   139         mkdir -p "${CT_BUILD_DIR}/build-ncurses"
   140         cd "${CT_BUILD_DIR}/build-ncurses"
   141 
   142         ncurses_opts=
   143         [ "${CT_CC_LANG_CXX}" = "y" ] || ncurses_opts="${ncurses_opts} --without-cxx --without-cxx-binding"
   144         [ "${CT_CC_LANG_ADA}" = "y" ] || ncurses_opts="${ncurses_opts} --without-ada"
   145 
   146         CT_DoExecLog ALL                                        \
   147         "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}/configure" \
   148             --build=${CT_BUILD}                                 \
   149             --host=${CT_TARGET}                                 \
   150             --with-build-cc=${CT_CC}                            \
   151             --with-build-cpp=${CT_CC}                           \
   152             --with-build-cflags="${CT_CFLAGS_FOR_HOST}"         \
   153             --prefix=/usr                                       \
   154             --with-shared                                       \
   155             --without-sysmouse                                  \
   156             --without-progs                                     \
   157             --enable-termcap                                    \
   158             ${ncurses_opts}
   159 
   160         CT_DoLog EXTRA "Building ncurses"
   161         CT_DoExecLog ALL make ${PARALLELMFLAGS}
   162 
   163         CT_DoLog EXTRA "Installing ncurses"
   164         mkdir -p "${CT_SYSROOT_DIR}/usr/bin"
   165         CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install
   166 
   167         CT_EndStep
   168 
   169         CT_DoLog EXTRA "Configuring native gdb"
   170 
   171         mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
   172         cd "${CT_BUILD_DIR}/build-gdb-native"
   173 
   174         native_extra_config="${extra_config}"
   175         case "${CT_THREADS}" in
   176             none)   native_extra_config="${native_extra_config} --disable-threads";;
   177             *)      native_extra_config="${native_extra_config} --enable-threads";;
   178         esac
   179         if [ "${CT_GDB_NATIVE_USE_GMP_MPFR}" = "y" ]; then
   180             native_extra_config="${native_extra_config} --with-gmp=${CT_SYSROOT_DIR}/usr --with-mpfr=${CT_SYSROOT_DIR}/usr"
   181         fi
   182 
   183         if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then
   184             CC_for_gdb="${CT_TARGET}-gcc -static"
   185             LD_for_gdb="${CT_TARGET}-ld -static"
   186         else
   187             CC_for_gdb="${CT_TARGET}-gcc"
   188             LD_for_gdb="${CT_TARGET}-ld"
   189         fi
   190 
   191         export ac_cv_func_strncmp_works=yes
   192 
   193         CT_DoLog DEBUG "Extra config passed: '${native_extra_config# }'"
   194 
   195         CC="${CC_for_gdb}"                              \
   196         LD="${LD_for_gdb}"                              \
   197         CT_DoExecLog ALL                                \
   198         "${gdb_src_dir}/configure"                      \
   199             --build=${CT_BUILD}                         \
   200             --host=${CT_TARGET}                         \
   201             --target=${CT_TARGET}                       \
   202             --prefix=/usr                               \
   203             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   204             --without-uiout                             \
   205             --disable-tui                               \
   206             --disable-gdbtk                             \
   207             --without-x                                 \
   208             --disable-sim                               \
   209             --disable-werror                            \
   210             --without-included-gettext                  \
   211             --without-develop                           \
   212             ${native_extra_config}
   213 
   214         CT_DoLog EXTRA "Building native gdb"
   215         CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
   216 
   217         CT_DoLog EXTRA "Installing native gdb"
   218         CT_DoExecLog ALL make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install
   219 
   220         # Building a native gdb also builds a gdbserver
   221         find "${CT_DEBUG_INSTALL_DIR}" -type f -name gdbserver -exec rm -fv {} \; 2>&1 |CT_DoLog ALL
   222 
   223         unset ac_cv_func_strncmp_works
   224 
   225         CT_EndStep
   226     fi
   227 
   228     if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
   229         CT_DoStep INFO "Installing gdbserver"
   230         CT_DoLog EXTRA "Configuring gdbserver"
   231 
   232         mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
   233         cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
   234 
   235         # Workaround for bad versions, where the configure
   236         # script for gdbserver is not executable...
   237         # Bah, GNU folks strike again... :-(
   238         chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
   239 
   240         gdbserver_LDFLAGS=
   241         if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then
   242             gdbserver_LDFLAGS=-static
   243         fi
   244 
   245         gdbserver_extra_config="${extra_config}"
   246 
   247         LDFLAGS="${gdbserver_LDFLAGS}"                  \
   248         CT_DoExecLog ALL                                \
   249         "${gdb_src_dir}/gdb/gdbserver/configure"        \
   250             --build=${CT_BUILD}                         \
   251             --host=${CT_TARGET}                         \
   252             --target=${CT_TARGET}                       \
   253             --prefix=/usr                               \
   254             --sysconfdir=/etc                           \
   255             --localstatedir=/var                        \
   256             --includedir="${CT_HEADERS_DIR}"            \
   257             --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   258             --program-prefix=                           \
   259             --without-uiout                             \
   260             --disable-tui                               \
   261             --disable-gdbtk                             \
   262             --without-x                                 \
   263             --without-included-gettext                  \
   264             --without-develop                           \
   265             --disable-werror                            \
   266             ${gdbserver_extra_config}
   267 
   268         CT_DoLog EXTRA "Building gdbserver"
   269         CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
   270 
   271         CT_DoLog EXTRA "Installing gdbserver"
   272         CT_DoExecLog ALL make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install
   273 
   274         CT_EndStep
   275     fi
   276 }