scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Jan 03 23:40:22 2011 +0100 (2011-01-03)
changeset 2267 7af68e6083aa
parent 2101 f27cfe7ed56d
child 2275 9ab4392430ad
permissions -rw-r--r--
libc-glibc: remove 2.3.6

This is an obsolete version which is no longer used by any sample (the only
user, the ia64 sample, has been removed).

It also makes the code path a bit complex, with twists just to accomodate
that version. Removing the version will make those twists go away, and
will ease commonalisation of glibc and eglibc in the future (hopefully!).

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
yann@479
     1
# Build script for the gdb debug facility
yann@479
     2
yann@1743
     3
# The version of ncurses to use. Yes, it's hard-coded.
yann@1743
     4
# It's used only internally by crosstool-NG, and is
yann@1743
     5
# not exposed outside, so we don't care about providing
yann@1743
     6
# config options for this.
yann@1743
     7
CT_DEBUG_GDB_NCURSES_VERSION="5.7"
yann@1743
     8
yann@2101
     9
# Ditto for the expat library
yann@2101
    10
CT_DEBUG_GDB_EXPAT_VERSION="2.0.1"
yann@2101
    11
yann@821
    12
do_debug_gdb_parts() {
yann@821
    13
    do_gdb=
yann@821
    14
    do_ncurses=
yann@2101
    15
    do_expat=
yann@821
    16
yann@821
    17
    if [ "${CT_GDB_CROSS}" = y ]; then
yann@1916
    18
        do_gdb=y
yann@821
    19
    fi
yann@821
    20
yann@821
    21
    if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
yann@821
    22
        do_gdb=y
yann@821
    23
    fi
yann@821
    24
yann@821
    25
    if [ "${CT_GDB_NATIVE}" = "y" ]; then
yann@821
    26
        do_gdb=y
linux@2021
    27
        # GDB on Mingw depends on PDcurses, not ncurses
linux@2021
    28
        if [ "${CT_MINGW32}" != "y" ]; then
linux@2021
    29
            do_ncurses=y
linux@2021
    30
        fi
yann@2101
    31
        do_expat=y
yann@821
    32
    fi
yann@821
    33
}
yann@821
    34
yann@479
    35
do_debug_gdb_get() {
yann@821
    36
    do_debug_gdb_parts
yann@821
    37
yann@821
    38
    if [ "${do_gdb}" = "y" ]; then
yann@1899
    39
        CT_GetFile "gdb-${CT_GDB_VERSION}"                          \
yann@1899
    40
                   {ftp,http}://ftp.gnu.org/pub/gnu/gdb             \
yann@1899
    41
                   ftp://sources.redhat.com/pub/gdb/{,old-}releases
yann@821
    42
    fi
yann@821
    43
yann@821
    44
    if [ "${do_ncurses}" = "y" ]; then
yann@1743
    45
        CT_GetFile "ncurses-${CT_DEBUG_GDB_NCURSES_VERSION}" .tar.gz  \
yann@573
    46
                   {ftp,http}://ftp.gnu.org/pub/gnu/ncurses \
yann@573
    47
                   ftp://invisible-island.net/ncurses
yann@573
    48
    fi
yann@2101
    49
yann@2101
    50
    if [ "${do_expat}" = "y" ]; then
yann@2101
    51
        CT_GetFile "expat-${CT_DEBUG_GDB_EXPAT_VERSION}" .tar.gz    \
yann@2101
    52
                   http://mesh.dl.sourceforge.net/sourceforge/expat/expat/${CT_DEBUG_GDB_EXPAT_VERSION}
yann@2101
    53
    fi
yann@479
    54
}
yann@479
    55
yann@479
    56
do_debug_gdb_extract() {
yann@821
    57
    do_debug_gdb_parts
yann@821
    58
yann@821
    59
    if [ "${do_gdb}" = "y" ]; then
yann@1899
    60
        CT_Extract "gdb-${CT_GDB_VERSION}"
yann@1901
    61
        CT_Patch "gdb" "${CT_GDB_VERSION}"
yann@821
    62
    fi
yann@821
    63
yann@821
    64
    if [ "${do_ncurses}" = "y" ]; then
yann@1743
    65
        CT_Extract "ncurses-${CT_DEBUG_GDB_NCURSES_VERSION}"
yann@1901
    66
        CT_Patch "ncurses" "${CT_DEBUG_GDB_NCURSES_VERSION}"
yann@598
    67
    fi
yann@2101
    68
yann@2101
    69
    if [ "${do_expat}" = "y" ]; then
yann@2101
    70
        CT_Extract "expat-${CT_DEBUG_GDB_EXPAT_VERSION}"
yann@2101
    71
        CT_Patch "expat" "${CT_DEBUG_GDB_EXPAT_VERSION}"
yann@2101
    72
    fi
yann@479
    73
}
yann@479
    74
yann@479
    75
do_debug_gdb_build() {
yann@1481
    76
    local -a extra_config
yann@1481
    77
linux@2021
    78
    do_debug_gdb_parts
linux@2021
    79
yann@1899
    80
    gdb_src_dir="${CT_SRC_DIR}/gdb-${CT_GDB_VERSION}"
yann@479
    81
yann@479
    82
    # Version 6.3 and below behave badly with gdbmi
yann@479
    83
    case "${CT_GDB_VERSION}" in
yann@1481
    84
        6.2*|6.3)   extra_config+=("--disable-gdbmi");;
yann@479
    85
    esac
yann@479
    86
yann@479
    87
    if [ "${CT_GDB_CROSS}" = "y" ]; then
yann@1481
    88
        local -a cross_extra_config
yann@1481
    89
yann@479
    90
        CT_DoStep INFO "Installing cross-gdb"
yann@479
    91
        CT_DoLog EXTRA "Configuring cross-gdb"
yann@479
    92
yann@479
    93
        mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
yann@479
    94
        cd "${CT_BUILD_DIR}/build-gdb-cross"
yann@479
    95
yann@1481
    96
        cross_extra_config=("${extra_config[@]}")
yann@583
    97
        case "${CT_THREADS}" in
yann@1481
    98
            none)   cross_extra_config+=("--disable-threads");;
yann@1481
    99
            *)      cross_extra_config+=("--enable-threads");;
yann@583
   100
        esac
yann@583
   101
yann@479
   102
        CC_for_gdb=
yann@479
   103
        LD_for_gdb=
yann@583
   104
        if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then
yann@479
   105
            CC_for_gdb="gcc -static"
yann@479
   106
            LD_for_gdb="ld -static"
yann@479
   107
        fi
yann@479
   108
yann@821
   109
        gdb_cross_configure="${gdb_src_dir}/configure"
yann@821
   110
yann@1481
   111
        CT_DoLog DEBUG "Extra config passed: '${cross_extra_config[*]}'"
yann@602
   112
yann@479
   113
        CC="${CC_for_gdb}"                              \
yann@583
   114
        LD="${LD_for_gdb}"                              \
anthony@2154
   115
        CT_DoExecLog CFG                                \
yann@821
   116
        "${gdb_cross_configure}"                        \
yann@479
   117
            --build=${CT_BUILD}                         \
yann@479
   118
            --host=${CT_HOST}                           \
yann@479
   119
            --target=${CT_TARGET}                       \
yann@479
   120
            --prefix="${CT_PREFIX_DIR}"                 \
yann@479
   121
            --with-build-sysroot="${CT_SYSROOT_DIR}"    \
yann@801
   122
            --disable-werror                            \
yann@1481
   123
            "${cross_extra_config[@]}"
yann@479
   124
yann@479
   125
        CT_DoLog EXTRA "Building cross-gdb"
yann@669
   126
        CT_DoExecLog ALL make ${PARALLELMFLAGS}
yann@479
   127
yann@479
   128
        CT_DoLog EXTRA "Installing cross-gdb"
yann@669
   129
        CT_DoExecLog ALL make install
yann@479
   130
yann@479
   131
        CT_EndStep
yann@479
   132
    fi
yann@479
   133
yann@479
   134
    if [ "${CT_GDB_NATIVE}" = "y" ]; then
yann@1481
   135
        local -a native_extra_config
yann@1481
   136
        local -a ncurses_opt
yann@2100
   137
        local -a gdb_native_CFLAGS
yann@1481
   138
yann@573
   139
        CT_DoStep INFO "Installing native gdb"
yann@573
   140
yann@2100
   141
        native_extra_config=("${extra_config[@]}")
yann@2100
   142
linux@2021
   143
        # GDB on Mingw depends on PDcurses, not ncurses
linux@2021
   144
        if [ "${do_ncurses}" = "y" ]; then
linux@2021
   145
            CT_DoLog EXTRA "Building static target ncurses"
yann@1281
   146
linux@2021
   147
            [ "${CT_CC_LANG_CXX}" = "y" ] || ncurses_opts+=("--without-cxx" "--without-cxx-binding")
linux@2021
   148
            [ "${CT_CC_LANG_ADA}" = "y" ] || ncurses_opts+=("--without-ada")
yann@1281
   149
linux@2021
   150
            mkdir -p "${CT_BUILD_DIR}/build-ncurses-build-tic"
linux@2021
   151
            cd "${CT_BUILD_DIR}/build-ncurses-build-tic"
yann@1264
   152
linux@2021
   153
            # Use build = CT_REAL_BUILD so that configure thinks it is
linux@2021
   154
            # cross-compiling, and thus will use the ${CT_BUILD}-*
linux@2021
   155
            # tools instead of searching for the native ones...
anthony@2154
   156
            CT_DoExecLog CFG                                                    \
linux@2021
   157
            "${CT_SRC_DIR}/ncurses-${CT_DEBUG_GDB_NCURSES_VERSION}/configure"   \
linux@2021
   158
                --build=${CT_BUILD}                                             \
linux@2021
   159
                --host=${CT_BUILD}                                              \
linux@2021
   160
                --prefix=/usr                                                   \
linux@2021
   161
                --without-shared                                                \
linux@2021
   162
                --enable-symlinks                                               \
linux@2021
   163
                --with-build-cc=${CT_REAL_BUILD}-gcc                            \
linux@2021
   164
                --with-build-cpp=${CT_REAL_BUILD}-gcc                           \
linux@2021
   165
                --with-build-cflags="${CT_CFLAGS_FOR_HOST}"                     \
linux@2021
   166
                "${ncurses_opts[@]}"
yann@1264
   167
linux@2021
   168
            # Under some operating systems (eg. Winblows), there is an
linux@2021
   169
            # extension appended to executables. Find that.
linux@2021
   170
            tic_ext=$(grep -E '^x[[:space:]]*=' progs/Makefile |sed -r -e 's/^.*=[[:space:]]*//;')
yann@1267
   171
linux@2021
   172
            CT_DoExecLog ALL make ${PARALLELMFLAGS} -C include
linux@2021
   173
            CT_DoExecLog ALL make ${PARALLELMFLAGS} -C progs "tic${tic_ext}"
yann@1264
   174
linux@2021
   175
            CT_DoExecLog ALL install -d -m 0755 "${CT_PREFIX_DIR}/buildtools"
linux@2021
   176
            CT_DoExecLog ALL install -m 0755 "progs/tic${tic_ext}" "${CT_PREFIX_DIR}/buildtools"
yann@1264
   177
linux@2021
   178
            mkdir -p "${CT_BUILD_DIR}/build-ncurses"
linux@2021
   179
            cd "${CT_BUILD_DIR}/build-ncurses"
yann@573
   180
anthony@2154
   181
            CT_DoExecLog CFG                                                    \
linux@2021
   182
            "${CT_SRC_DIR}/ncurses-${CT_DEBUG_GDB_NCURSES_VERSION}/configure"   \
linux@2021
   183
                --build=${CT_BUILD}                                             \
linux@2021
   184
                --host=${CT_TARGET}                                             \
linux@2021
   185
                --with-build-cc=${CT_BUILD}-gcc                                 \
linux@2021
   186
                --with-build-cpp=${CT_BUILD}-gcc                                \
linux@2021
   187
                --with-build-cflags="${CT_CFLAGS_FOR_HOST}"                     \
yann@2100
   188
                --prefix="${CT_BUILD_DIR}/static-target"                        \
linux@2021
   189
                --without-shared                                                \
linux@2021
   190
                --without-sysmouse                                              \
linux@2021
   191
                --without-progs                                                 \
linux@2021
   192
                --enable-termcap                                                \
linux@2021
   193
                "${ncurses_opts[@]}"
yann@573
   194
linux@2021
   195
            CT_DoExecLog ALL make ${PARALLELMFLAGS}
yann@573
   196
linux@2021
   197
            CT_DoExecLog ALL make install
yann@573
   198
linux@2021
   199
            # We no longer need the temporary tic. Remove it
yann@2022
   200
            CT_DoExecLog DEBUG rm -fv "${CT_PREFIX_DIR}/buildtools/tic${tic_ext}"
yann@2100
   201
yann@2100
   202
            native_extra_config+=("--with-curses")
yann@2100
   203
            # There's no better way to tell gdb where to find -lcurses... :-(
yann@2100
   204
            gdb_native_CFLAGS+=("-I${CT_BUILD_DIR}/static-target/include")
yann@2100
   205
            gdb_native_CFLAGS+=("-L${CT_BUILD_DIR}/static-target/lib")
linux@2021
   206
        fi # do_ncurses
yann@1281
   207
yann@2101
   208
        if [ "${do_expat}" = "y" ]; then
yann@2101
   209
            CT_DoLog EXTRA "Building static target expat"
yann@2101
   210
yann@2101
   211
            mkdir -p "${CT_BUILD_DIR}/expat-build"
yann@2101
   212
            cd "${CT_BUILD_DIR}/expat-build"
yann@2101
   213
anthony@2154
   214
            CT_DoExecLog CFG                                                \
yann@2101
   215
            "${CT_SRC_DIR}/expat-${CT_DEBUG_GDB_EXPAT_VERSION}/configure"   \
yann@2101
   216
                --build=${CT_BUILD}                                         \
yann@2101
   217
                --host=${CT_TARGET}                                         \
yann@2101
   218
                --prefix="${CT_BUILD_DIR}/static-target"                    \
yann@2101
   219
                --enable-static                                             \
yann@2101
   220
                --disable-shared
yann@2101
   221
yann@2101
   222
            CT_DoExecLog ALL make ${PARALLELMFLAGS}
yann@2101
   223
            CT_DoExecLog ALL make install
yann@2101
   224
yann@2101
   225
            native_extra_config+=("--with-expat")
yann@2101
   226
            native_extra_config+=("--with-libexpat-prefix=${CT_BUILD_DIR}/static-target")
yann@2101
   227
        fi # do_expat
yann@2101
   228
yann@479
   229
        CT_DoLog EXTRA "Configuring native gdb"
yann@479
   230
yann@479
   231
        mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
yann@479
   232
        cd "${CT_BUILD_DIR}/build-gdb-native"
yann@479
   233
yann@583
   234
        case "${CT_THREADS}" in
yann@1481
   235
            none)   native_extra_config+=("--disable-threads");;
yann@1481
   236
            *)      native_extra_config+=("--enable-threads");;
yann@583
   237
        esac
yann@583
   238
yann@583
   239
        if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then
yann@583
   240
            CC_for_gdb="${CT_TARGET}-gcc -static"
yann@583
   241
            LD_for_gdb="${CT_TARGET}-ld -static"
yann@626
   242
        else
yann@626
   243
            CC_for_gdb="${CT_TARGET}-gcc"
yann@626
   244
            LD_for_gdb="${CT_TARGET}-ld"
yann@583
   245
        fi
yann@583
   246
yann@583
   247
        export ac_cv_func_strncmp_works=yes
yann@583
   248
yann@1481
   249
        CT_DoLog DEBUG "Extra config passed: '${native_extra_config[*]}'"
yann@602
   250
yann@583
   251
        CC="${CC_for_gdb}"                              \
yann@583
   252
        LD="${LD_for_gdb}"                              \
yann@2100
   253
        CFLAGS="${gdb_native_CFLAGS[@]}"                \
anthony@2154
   254
        CT_DoExecLog CFG                                \
yann@479
   255
        "${gdb_src_dir}/configure"                      \
yann@479
   256
            --build=${CT_BUILD}                         \
yann@479
   257
            --host=${CT_TARGET}                         \
yann@479
   258
            --target=${CT_TARGET}                       \
yann@479
   259
            --prefix=/usr                               \
yann@479
   260
            --with-build-sysroot="${CT_SYSROOT_DIR}"    \
yann@479
   261
            --without-uiout                             \
yann@479
   262
            --disable-tui                               \
yann@479
   263
            --disable-gdbtk                             \
yann@479
   264
            --without-x                                 \
yann@479
   265
            --disable-sim                               \
yann@583
   266
            --disable-werror                            \
yann@479
   267
            --without-included-gettext                  \
yann@583
   268
            --without-develop                           \
yann@1481
   269
            "${native_extra_config[@]}"
yann@479
   270
yann@479
   271
        CT_DoLog EXTRA "Building native gdb"
yann@669
   272
        CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
yann@479
   273
yann@479
   274
        CT_DoLog EXTRA "Installing native gdb"
yann@1219
   275
        CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install
yann@479
   276
yann@583
   277
        # Building a native gdb also builds a gdbserver
yann@1219
   278
        find "${CT_DEBUGROOT_DIR}" -type f -name gdbserver -exec rm -fv {} \; 2>&1 |CT_DoLog ALL
yann@583
   279
yann@583
   280
        unset ac_cv_func_strncmp_works
yann@583
   281
linux@2021
   282
        # GDB on Mingw depends on PDcurses, not ncurses
linux@2021
   283
        if [ "${CT_MINGW32}" != "y" ]; then
linux@2021
   284
            CT_DoLog EXTRA "Cleaning up ncurses"
linux@2021
   285
            cd "${CT_BUILD_DIR}/build-ncurses"
linux@2021
   286
            CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" uninstall
yann@1555
   287
linux@2021
   288
            CT_DoExecLog DEBUG rm -rf "${CT_BUILD_DIR}/ncurses"
linux@2021
   289
        fi
yann@1733
   290
yann@1281
   291
        CT_EndStep # native gdb build
yann@583
   292
    fi
yann@583
   293
yann@583
   294
    if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
yann@1481
   295
        local -a gdbserver_extra_config
yann@1481
   296
yann@583
   297
        CT_DoStep INFO "Installing gdbserver"
yann@583
   298
        CT_DoLog EXTRA "Configuring gdbserver"
yann@583
   299
yann@583
   300
        mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
yann@583
   301
        cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
yann@583
   302
yann@583
   303
        # Workaround for bad versions, where the configure
yann@583
   304
        # script for gdbserver is not executable...
yann@583
   305
        # Bah, GNU folks strike again... :-(
yann@583
   306
        chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
yann@583
   307
yann@583
   308
        gdbserver_LDFLAGS=
yann@583
   309
        if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then
yann@583
   310
            gdbserver_LDFLAGS=-static
yann@583
   311
        fi
yann@583
   312
yann@1481
   313
        gdbserver_extra_config=("${extra_config[@]}")
yann@602
   314
yann@583
   315
        LDFLAGS="${gdbserver_LDFLAGS}"                  \
anthony@2154
   316
        CT_DoExecLog CFG                                \
yann@583
   317
        "${gdb_src_dir}/gdb/gdbserver/configure"        \
yann@583
   318
            --build=${CT_BUILD}                         \
yann@583
   319
            --host=${CT_TARGET}                         \
yann@583
   320
            --target=${CT_TARGET}                       \
yann@583
   321
            --prefix=/usr                               \
yann@583
   322
            --sysconfdir=/etc                           \
yann@583
   323
            --localstatedir=/var                        \
yann@583
   324
            --includedir="${CT_HEADERS_DIR}"            \
yann@583
   325
            --with-build-sysroot="${CT_SYSROOT_DIR}"    \
yann@583
   326
            --program-prefix=                           \
yann@583
   327
            --without-uiout                             \
yann@583
   328
            --disable-tui                               \
yann@583
   329
            --disable-gdbtk                             \
yann@583
   330
            --without-x                                 \
yann@583
   331
            --without-included-gettext                  \
yann@583
   332
            --without-develop                           \
yann@801
   333
            --disable-werror                            \
yann@1481
   334
            "${gdbserver_extra_config[@]}"
yann@583
   335
yann@583
   336
        CT_DoLog EXTRA "Building gdbserver"
yann@669
   337
        CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
yann@583
   338
yann@583
   339
        CT_DoLog EXTRA "Installing gdbserver"
yann@1219
   340
        CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install
yann@583
   341
yann@479
   342
        CT_EndStep
yann@479
   343
    fi
yann@479
   344
}