scripts/build/debug/300-gdb.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Aug 23 14:32:16 2010 +0200 (2010-08-23)
changeset 2100 f9fcfc002c8a
parent 2098 9a8f0e3fe605
child 2101 f27cfe7ed56d
permissions -rw-r--r--
debug/gdb: install dependable libs in a generic target static libs dir

For now, ncurses is the only dependable target library built for gdb.
But expat is coming, and there's no reason to install each library in
its own place.

So, install ncurses in a generic directory, where other dependable
libraries can be installed as well.

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@2100
   122
        local -a gdb_native_CFLAGS
yann@1481
   123
yann@573
   124
        CT_DoStep INFO "Installing native gdb"
yann@573
   125
yann@2100
   126
        native_extra_config=("${extra_config[@]}")
yann@2100
   127
linux@2021
   128
        # GDB on Mingw depends on PDcurses, not ncurses
linux@2021
   129
        if [ "${do_ncurses}" = "y" ]; then
linux@2021
   130
            CT_DoLog EXTRA "Building static target ncurses"
yann@1281
   131
linux@2021
   132
            [ "${CT_CC_LANG_CXX}" = "y" ] || ncurses_opts+=("--without-cxx" "--without-cxx-binding")
linux@2021
   133
            [ "${CT_CC_LANG_ADA}" = "y" ] || ncurses_opts+=("--without-ada")
yann@1281
   134
linux@2021
   135
            mkdir -p "${CT_BUILD_DIR}/build-ncurses-build-tic"
linux@2021
   136
            cd "${CT_BUILD_DIR}/build-ncurses-build-tic"
yann@1264
   137
linux@2021
   138
            # Use build = CT_REAL_BUILD so that configure thinks it is
linux@2021
   139
            # cross-compiling, and thus will use the ${CT_BUILD}-*
linux@2021
   140
            # tools instead of searching for the native ones...
linux@2021
   141
            CT_DoExecLog ALL                                                    \
linux@2021
   142
            "${CT_SRC_DIR}/ncurses-${CT_DEBUG_GDB_NCURSES_VERSION}/configure"   \
linux@2021
   143
                --build=${CT_BUILD}                                             \
linux@2021
   144
                --host=${CT_BUILD}                                              \
linux@2021
   145
                --prefix=/usr                                                   \
linux@2021
   146
                --without-shared                                                \
linux@2021
   147
                --enable-symlinks                                               \
linux@2021
   148
                --with-build-cc=${CT_REAL_BUILD}-gcc                            \
linux@2021
   149
                --with-build-cpp=${CT_REAL_BUILD}-gcc                           \
linux@2021
   150
                --with-build-cflags="${CT_CFLAGS_FOR_HOST}"                     \
linux@2021
   151
                "${ncurses_opts[@]}"
yann@1264
   152
linux@2021
   153
            # Under some operating systems (eg. Winblows), there is an
linux@2021
   154
            # extension appended to executables. Find that.
linux@2021
   155
            tic_ext=$(grep -E '^x[[:space:]]*=' progs/Makefile |sed -r -e 's/^.*=[[:space:]]*//;')
yann@1267
   156
linux@2021
   157
            CT_DoExecLog ALL make ${PARALLELMFLAGS} -C include
linux@2021
   158
            CT_DoExecLog ALL make ${PARALLELMFLAGS} -C progs "tic${tic_ext}"
yann@1264
   159
linux@2021
   160
            CT_DoExecLog ALL install -d -m 0755 "${CT_PREFIX_DIR}/buildtools"
linux@2021
   161
            CT_DoExecLog ALL install -m 0755 "progs/tic${tic_ext}" "${CT_PREFIX_DIR}/buildtools"
yann@1264
   162
linux@2021
   163
            mkdir -p "${CT_BUILD_DIR}/build-ncurses"
linux@2021
   164
            cd "${CT_BUILD_DIR}/build-ncurses"
yann@573
   165
linux@2021
   166
            CT_DoExecLog ALL                                                    \
linux@2021
   167
            "${CT_SRC_DIR}/ncurses-${CT_DEBUG_GDB_NCURSES_VERSION}/configure"   \
linux@2021
   168
                --build=${CT_BUILD}                                             \
linux@2021
   169
                --host=${CT_TARGET}                                             \
linux@2021
   170
                --with-build-cc=${CT_BUILD}-gcc                                 \
linux@2021
   171
                --with-build-cpp=${CT_BUILD}-gcc                                \
linux@2021
   172
                --with-build-cflags="${CT_CFLAGS_FOR_HOST}"                     \
yann@2100
   173
                --prefix="${CT_BUILD_DIR}/static-target"                        \
linux@2021
   174
                --without-shared                                                \
linux@2021
   175
                --without-sysmouse                                              \
linux@2021
   176
                --without-progs                                                 \
linux@2021
   177
                --enable-termcap                                                \
linux@2021
   178
                "${ncurses_opts[@]}"
yann@573
   179
linux@2021
   180
            CT_DoExecLog ALL make ${PARALLELMFLAGS}
yann@573
   181
linux@2021
   182
            CT_DoExecLog ALL make install
yann@573
   183
linux@2021
   184
            # We no longer need the temporary tic. Remove it
yann@2022
   185
            CT_DoExecLog DEBUG rm -fv "${CT_PREFIX_DIR}/buildtools/tic${tic_ext}"
yann@2100
   186
yann@2100
   187
            native_extra_config+=("--with-curses")
yann@2100
   188
            # There's no better way to tell gdb where to find -lcurses... :-(
yann@2100
   189
            gdb_native_CFLAGS+=("-I${CT_BUILD_DIR}/static-target/include")
yann@2100
   190
            gdb_native_CFLAGS+=("-L${CT_BUILD_DIR}/static-target/lib")
linux@2021
   191
        fi # do_ncurses
yann@1281
   192
yann@479
   193
        CT_DoLog EXTRA "Configuring native gdb"
yann@479
   194
yann@479
   195
        mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
yann@479
   196
        cd "${CT_BUILD_DIR}/build-gdb-native"
yann@479
   197
yann@583
   198
        case "${CT_THREADS}" in
yann@1481
   199
            none)   native_extra_config+=("--disable-threads");;
yann@1481
   200
            *)      native_extra_config+=("--enable-threads");;
yann@583
   201
        esac
yann@583
   202
yann@583
   203
        if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then
yann@583
   204
            CC_for_gdb="${CT_TARGET}-gcc -static"
yann@583
   205
            LD_for_gdb="${CT_TARGET}-ld -static"
yann@626
   206
        else
yann@626
   207
            CC_for_gdb="${CT_TARGET}-gcc"
yann@626
   208
            LD_for_gdb="${CT_TARGET}-ld"
yann@583
   209
        fi
yann@583
   210
yann@583
   211
        export ac_cv_func_strncmp_works=yes
yann@583
   212
yann@1481
   213
        CT_DoLog DEBUG "Extra config passed: '${native_extra_config[*]}'"
yann@602
   214
yann@583
   215
        CC="${CC_for_gdb}"                              \
yann@583
   216
        LD="${LD_for_gdb}"                              \
yann@2100
   217
        CFLAGS="${gdb_native_CFLAGS[@]}"                \
yann@669
   218
        CT_DoExecLog ALL                                \
yann@479
   219
        "${gdb_src_dir}/configure"                      \
yann@479
   220
            --build=${CT_BUILD}                         \
yann@479
   221
            --host=${CT_TARGET}                         \
yann@479
   222
            --target=${CT_TARGET}                       \
yann@479
   223
            --prefix=/usr                               \
yann@479
   224
            --with-build-sysroot="${CT_SYSROOT_DIR}"    \
yann@479
   225
            --without-uiout                             \
yann@479
   226
            --disable-tui                               \
yann@479
   227
            --disable-gdbtk                             \
yann@479
   228
            --without-x                                 \
yann@479
   229
            --disable-sim                               \
yann@583
   230
            --disable-werror                            \
yann@479
   231
            --without-included-gettext                  \
yann@583
   232
            --without-develop                           \
yann@1481
   233
            "${native_extra_config[@]}"
yann@479
   234
yann@479
   235
        CT_DoLog EXTRA "Building native gdb"
yann@669
   236
        CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
yann@479
   237
yann@479
   238
        CT_DoLog EXTRA "Installing native gdb"
yann@1219
   239
        CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install
yann@479
   240
yann@583
   241
        # Building a native gdb also builds a gdbserver
yann@1219
   242
        find "${CT_DEBUGROOT_DIR}" -type f -name gdbserver -exec rm -fv {} \; 2>&1 |CT_DoLog ALL
yann@583
   243
yann@583
   244
        unset ac_cv_func_strncmp_works
yann@583
   245
linux@2021
   246
        # GDB on Mingw depends on PDcurses, not ncurses
linux@2021
   247
        if [ "${CT_MINGW32}" != "y" ]; then
linux@2021
   248
            CT_DoLog EXTRA "Cleaning up ncurses"
linux@2021
   249
            cd "${CT_BUILD_DIR}/build-ncurses"
linux@2021
   250
            CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" uninstall
yann@1555
   251
linux@2021
   252
            CT_DoExecLog DEBUG rm -rf "${CT_BUILD_DIR}/ncurses"
linux@2021
   253
        fi
yann@1733
   254
yann@1281
   255
        CT_EndStep # native gdb build
yann@583
   256
    fi
yann@583
   257
yann@583
   258
    if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
yann@1481
   259
        local -a gdbserver_extra_config
yann@1481
   260
yann@583
   261
        CT_DoStep INFO "Installing gdbserver"
yann@583
   262
        CT_DoLog EXTRA "Configuring gdbserver"
yann@583
   263
yann@583
   264
        mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
yann@583
   265
        cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
yann@583
   266
yann@583
   267
        # Workaround for bad versions, where the configure
yann@583
   268
        # script for gdbserver is not executable...
yann@583
   269
        # Bah, GNU folks strike again... :-(
yann@583
   270
        chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
yann@583
   271
yann@583
   272
        gdbserver_LDFLAGS=
yann@583
   273
        if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then
yann@583
   274
            gdbserver_LDFLAGS=-static
yann@583
   275
        fi
yann@583
   276
yann@1481
   277
        gdbserver_extra_config=("${extra_config[@]}")
yann@602
   278
yann@583
   279
        LDFLAGS="${gdbserver_LDFLAGS}"                  \
yann@669
   280
        CT_DoExecLog ALL                                \
yann@583
   281
        "${gdb_src_dir}/gdb/gdbserver/configure"        \
yann@583
   282
            --build=${CT_BUILD}                         \
yann@583
   283
            --host=${CT_TARGET}                         \
yann@583
   284
            --target=${CT_TARGET}                       \
yann@583
   285
            --prefix=/usr                               \
yann@583
   286
            --sysconfdir=/etc                           \
yann@583
   287
            --localstatedir=/var                        \
yann@583
   288
            --includedir="${CT_HEADERS_DIR}"            \
yann@583
   289
            --with-build-sysroot="${CT_SYSROOT_DIR}"    \
yann@583
   290
            --program-prefix=                           \
yann@583
   291
            --without-uiout                             \
yann@583
   292
            --disable-tui                               \
yann@583
   293
            --disable-gdbtk                             \
yann@583
   294
            --without-x                                 \
yann@583
   295
            --without-included-gettext                  \
yann@583
   296
            --without-develop                           \
yann@801
   297
            --disable-werror                            \
yann@1481
   298
            "${gdbserver_extra_config[@]}"
yann@583
   299
yann@583
   300
        CT_DoLog EXTRA "Building gdbserver"
yann@669
   301
        CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
yann@583
   302
yann@583
   303
        CT_DoLog EXTRA "Installing gdbserver"
yann@1219
   304
        CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install
yann@583
   305
yann@479
   306
        CT_EndStep
yann@479
   307
    fi
yann@479
   308
}