scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Jan 22 23:20:18 2011 +0100 (2011-01-22)
changeset 2305 2ed26c646568
parent 2275 9ab4392430ad
child 2326 3d0a8d386afd
permissions -rw-r--r--
scripts: create the makeinfo wrapper before we set PATH

If we set PATH to the tools wrappers before we create the
makeinfo wrapper, then we may well wrap an existing wrapper
from a previous run.

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