A bunch of fixes/improvements to the gdb build:
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Thu Jun 19 15:33:33 2008 +0000 (2008-06-19)
changeset 58344b87fb3f0d3
parent 582 522e4fe1ca75
child 584 b46de4c38396
A bunch of fixes/improvements to the gdb build:
- allow native builds (both shared and static)
- fix enabling threads
- better handle the gdbserver case
- introduce the ncurses library to allow native builds
- re-order config options adequately

/trunk/scripts/build/debug/300-gdb.sh | 126 79 47 0 ++++++++++++++++++++++++++---------------
/trunk/config/debug/gdb.in | 45 33 12 0 +++++++++++----
2 files changed, 112 insertions(+), 59 deletions(-)
config/debug/gdb.in
scripts/build/debug/300-gdb.sh
     1.1 --- a/config/debug/gdb.in	Thu Jun 19 15:31:04 2008 +0000
     1.2 +++ b/config/debug/gdb.in	Thu Jun 19 15:33:33 2008 +0000
     1.3 @@ -13,38 +13,59 @@
     1.4      bool
     1.5      prompt "Cross-gdb"
     1.6      default y
     1.7 +    select GDB_GDBSERVER
     1.8      help
     1.9 -      Build and install a cross-gdb for the target, and to run on host.
    1.10 +      Build and install a cross-gdb for the target, to run on host.
    1.11  
    1.12 -config GDB_CROSS_STATIC_GDB
    1.13 +config GDB_CROSS_STATIC
    1.14      bool
    1.15      prompt "Build a static cross gdb"
    1.16      default n
    1.17      depends on GDB_CROSS
    1.18      help
    1.19        A static cross gdb can be usefull if you debug on a machine that is
    1.20 -      not the one that is used to compile.
    1.21 +      not the one that is used to compile the toolchain.
    1.22  
    1.23 -config GDB_CROSS_STATIC_GDBSERVER
    1.24 +      That way, you can share the cross-gdb without installing a toolchain
    1.25 +      on every machine that will be used to debug target programs.
    1.26 +
    1.27 +config GDB_NATIVE
    1.28 +    bool
    1.29 +    prompt "Native gdb"
    1.30 +    default n
    1.31 +    select GDB_GDBSERVER
    1.32 +    help
    1.33 +      Build and install a native gdb for the target, to run on the target.
    1.34 +
    1.35 +config GDB_NATIVE_STATIC
    1.36 +    bool
    1.37 +    prompt "Build a static native gdb"
    1.38 +    default n
    1.39 +    depends on GDB_NATIVE
    1.40 +    help
    1.41 +      In case you have trouble with dynamic loading of shared libraries,
    1.42 +      you will find that a static gdb comes in handy.
    1.43 +
    1.44 +config GDB_GDBSERVER
    1.45 +    bool
    1.46 +    prompt "gdbserver"
    1.47 +    default n
    1.48 +    help
    1.49 +      Build and install a gdbserver for the target, to run on the target.
    1.50 +
    1.51 +config GDB_GDBSERVER_STATIC
    1.52      bool
    1.53      prompt "Build a static gdbserver"
    1.54      default n
    1.55 -    depends on GDB_CROSS
    1.56 +    depends on GDB_GDBSERVER
    1.57      help
    1.58        In case you have trouble with dynamic loading of shared libraries,
    1.59        you will find that a static gdbserver comes in handy.
    1.60  
    1.61 -config GDB_NATIVE
    1.62 -    bool
    1.63 -    prompt "Native gdb (EXPERIMENTAL)"
    1.64 -    default n
    1.65 -    depends on EXPERIMENTAL
    1.66 -    help
    1.67 -      Build and install a native gdb for the target, to run on the target.
    1.68 -
    1.69  choice
    1.70      bool
    1.71      prompt "gdb version"
    1.72 +    depends on GDB_CROSS || GDB_NATIVE || GDB_GDBSERVER
    1.73  
    1.74  config GDB_V_snapshot
    1.75      bool
    1.76 @@ -118,6 +139,6 @@
    1.77      default "4.2" if NCURSES_V_4_2
    1.78      default "5.6" if NCURSES_V_5_6
    1.79  
    1.80 -endif # ncurses
    1.81 +endif # GDB_NATIVE --> ncurses
    1.82  
    1.83  endif
     2.1 --- a/scripts/build/debug/300-gdb.sh	Thu Jun 19 15:31:04 2008 +0000
     2.2 +++ b/scripts/build/debug/300-gdb.sh	Thu Jun 19 15:33:33 2008 +0000
     2.3 @@ -47,22 +47,29 @@
     2.4          mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
     2.5          cd "${CT_BUILD_DIR}/build-gdb-cross"
     2.6  
     2.7 +        if [ "${CT_CC_GCC_GMP_MPFR}" = "y" ]; then
     2.8 +            extra_config="${extra_config} --with-gmp=${CT_PREFIX_DIR} --with-mpfr=${CT_PREFIX_DIR}"
     2.9 +        fi
    2.10 +        case "${CT_THREADS}" in
    2.11 +            none)   extra_config="${extra_config} --disable-threads";;
    2.12 +            *)      extra_config="${extra_config} --enable-threads";;
    2.13 +        esac
    2.14 +
    2.15          CC_for_gdb=
    2.16          LD_for_gdb=
    2.17 -        if [ "${CT_GDB_CROSS_STATIC_GDBSERVER}" = "y" ]; then
    2.18 +        if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then
    2.19              CC_for_gdb="gcc -static"
    2.20              LD_for_gdb="ld -static"
    2.21          fi
    2.22  
    2.23          CC="${CC_for_gdb}"                              \
    2.24 -        LD="${LD_forgdb}"                               \
    2.25 +        LD="${LD_for_gdb}"                              \
    2.26          "${gdb_src_dir}/configure"                      \
    2.27              --build=${CT_BUILD}                         \
    2.28              --host=${CT_HOST}                           \
    2.29              --target=${CT_TARGET}                       \
    2.30              --prefix="${CT_PREFIX_DIR}"                 \
    2.31              --with-build-sysroot="${CT_SYSROOT_DIR}"    \
    2.32 -            --enable-threads                            \
    2.33              ${extra_config}                             2>&1 |CT_DoLog ALL
    2.34  
    2.35          CT_DoLog EXTRA "Building cross-gdb"
    2.36 @@ -72,48 +79,6 @@
    2.37          make install                                    2>&1 |CT_DoLog ALL
    2.38  
    2.39          CT_EndStep
    2.40 -
    2.41 -        CT_DoStep INFO "Installing gdbserver"
    2.42 -        CT_DoLog EXTRA "Configuring gdbserver"
    2.43 -
    2.44 -        mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
    2.45 -        cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
    2.46 -
    2.47 -        # Workaround for bad versions, where the configure
    2.48 -        # script for gdbserver is not executable...
    2.49 -        # Bah, GNU folks strike again... :-(
    2.50 -        chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
    2.51 -
    2.52 -        gdbserver_LDFLAGS=
    2.53 -        if [ "${CT_GDB_CROSS_STATIC_GDBSERVER}" = "y" ]; then
    2.54 -            gdbserver_LDFLAGS=-static
    2.55 -        fi
    2.56 -
    2.57 -        LDFLAGS="${gdbserver_LDFLAGS}"                  \
    2.58 -        "${gdb_src_dir}/gdb/gdbserver/configure"        \
    2.59 -            --build=${CT_BUILD}                         \
    2.60 -            --host=${CT_TARGET}                         \
    2.61 -            --target=${CT_TARGET}                       \
    2.62 -            --prefix=/usr                               \
    2.63 -            --sysconfdir=/etc                           \
    2.64 -            --localstatedir=/var                        \
    2.65 -            --includedir="${CT_HEADERS_DIR}"            \
    2.66 -            --with-build-sysroot="${CT_SYSROOT_DIR}"    \
    2.67 -            --program-prefix=                           \
    2.68 -            --without-uiout                             \
    2.69 -            --disable-tui                               \
    2.70 -            --disable-gdbtk                             \
    2.71 -            --without-x                                 \
    2.72 -            --without-included-gettext                  \
    2.73 -            ${extra_config}                             2>&1 |CT_DoLog ALL
    2.74 -
    2.75 -        CT_DoLog EXTRA "Building gdbserver"
    2.76 -        make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL
    2.77 -
    2.78 -        CT_DoLog EXTRA "Installing gdbserver"
    2.79 -        make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install  2>&1 |CT_DoLog ALL
    2.80 -
    2.81 -        CT_EndStep
    2.82      fi
    2.83  
    2.84      if [ "${CT_GDB_NATIVE}" = "y" ]; then
    2.85 @@ -138,7 +103,6 @@
    2.86              --without-sysmouse                                  \
    2.87              --without-progs                                     \
    2.88              --enable-termcap                                    \
    2.89 -            --without-develop                                   \
    2.90              ${ncurses_opts}                                     2>&1 |CT_DoLog ALL
    2.91  
    2.92          CT_DoLog EXTRA "Building ncurses"
    2.93 @@ -155,6 +119,22 @@
    2.94          mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
    2.95          cd "${CT_BUILD_DIR}/build-gdb-native"
    2.96  
    2.97 +        case "${CT_THREADS}" in
    2.98 +            none)   extra_config="${extra_config} --disable-threads";;
    2.99 +            *)      extra_config="${extra_config} --enable-threads";;
   2.100 +        esac
   2.101 +
   2.102 +        CC_for_gdb=
   2.103 +        LD_for_gdb=
   2.104 +        if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then
   2.105 +            CC_for_gdb="${CT_TARGET}-gcc -static"
   2.106 +            LD_for_gdb="${CT_TARGET}-ld -static"
   2.107 +        fi
   2.108 +
   2.109 +        export ac_cv_func_strncmp_works=yes
   2.110 +
   2.111 +        CC="${CC_for_gdb}"                              \
   2.112 +        LD="${LD_for_gdb}"                              \
   2.113          "${gdb_src_dir}/configure"                      \
   2.114              --build=${CT_BUILD}                         \
   2.115              --host=${CT_TARGET}                         \
   2.116 @@ -166,8 +146,9 @@
   2.117              --disable-gdbtk                             \
   2.118              --without-x                                 \
   2.119              --disable-sim                               \
   2.120 -            --disable-gdbserver                         \
   2.121 +            --disable-werror                            \
   2.122              --without-included-gettext                  \
   2.123 +            --without-develop                           \
   2.124              ${extra_config}                             2>&1 |CT_DoLog ALL
   2.125  
   2.126          CT_DoLog EXTRA "Building native gdb"
   2.127 @@ -176,6 +157,57 @@
   2.128          CT_DoLog EXTRA "Installing native gdb"
   2.129          make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install  2>&1 |CT_DoLog ALL
   2.130  
   2.131 +        # Building a native gdb also builds a gdbserver
   2.132 +        CT_DoLog DEBUG "Removing spurious gdbserver"
   2.133 +        find "${CT_DEBUG_INSTALL_DIR}" -type f -name gdbserver -exec rm -fv {} + 2>&1 |CT_DoLog ALL
   2.134 +
   2.135 +        unset ac_cv_func_strncmp_works
   2.136 +
   2.137 +        CT_EndStep
   2.138 +    fi
   2.139 +
   2.140 +    if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
   2.141 +        CT_DoStep INFO "Installing gdbserver"
   2.142 +        CT_DoLog EXTRA "Configuring gdbserver"
   2.143 +
   2.144 +        mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
   2.145 +        cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
   2.146 +
   2.147 +        # Workaround for bad versions, where the configure
   2.148 +        # script for gdbserver is not executable...
   2.149 +        # Bah, GNU folks strike again... :-(
   2.150 +        chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
   2.151 +
   2.152 +        gdbserver_LDFLAGS=
   2.153 +        if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then
   2.154 +            gdbserver_LDFLAGS=-static
   2.155 +        fi
   2.156 +
   2.157 +        LDFLAGS="${gdbserver_LDFLAGS}"                  \
   2.158 +        "${gdb_src_dir}/gdb/gdbserver/configure"        \
   2.159 +            --build=${CT_BUILD}                         \
   2.160 +            --host=${CT_TARGET}                         \
   2.161 +            --target=${CT_TARGET}                       \
   2.162 +            --prefix=/usr                               \
   2.163 +            --sysconfdir=/etc                           \
   2.164 +            --localstatedir=/var                        \
   2.165 +            --includedir="${CT_HEADERS_DIR}"            \
   2.166 +            --with-build-sysroot="${CT_SYSROOT_DIR}"    \
   2.167 +            --program-prefix=                           \
   2.168 +            --without-uiout                             \
   2.169 +            --disable-tui                               \
   2.170 +            --disable-gdbtk                             \
   2.171 +            --without-x                                 \
   2.172 +            --without-included-gettext                  \
   2.173 +            --without-develop                           \
   2.174 +            ${extra_config}                             2>&1 |CT_DoLog ALL
   2.175 +
   2.176 +        CT_DoLog EXTRA "Building gdbserver"
   2.177 +        make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC} 2>&1 |CT_DoLog ALL
   2.178 +
   2.179 +        CT_DoLog EXTRA "Installing gdbserver"
   2.180 +        make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install  2>&1 |CT_DoLog ALL
   2.181 +
   2.182          CT_EndStep
   2.183      fi
   2.184  }