scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Aug 23 23:18:49 2010 +0200 (2010-08-23)
changeset 2099 1bb063c8a0ca
parent 2022 dc167f43e3dc
child 2100 f9fcfc002c8a
permissions -rw-r--r--
complibs: noone is using companion libs on the target; nuke them

As there's no longer any user of the companion libraries on the
target, nuke the build for the target.

Well, at least, there's libelf that's still needed by ltrace, so
we keep it.

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