1 # Build script for the gdb debug facility
6 [ "${CT_GDB}" = "y" ] || return 0
7 echo "gdb$(do_debug_gdb_suffix)"
8 if [ "${CT_GDB_NATIVE}" = "y" ]; then
9 echo "ncurses-${CT_NCURSES_VERSION}"
13 do_debug_gdb_suffix() {
14 case "${CT_GDB_VERSION}" in
16 *) echo "-${CT_GDB_VERSION}";;
20 do_debug_gdb_parts() {
25 if [ "${CT_GDB_CROSS}" = y ]; then
26 if [ "${CT_GDB_CROSS_INSIGHT}" = "y" ]; then
33 if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
37 if [ "${CT_GDB_NATIVE}" = "y" ]; then
46 if [ "${do_gdb}" = "y" ]; then
47 CT_GetFile "gdb$(do_debug_gdb_suffix)" \
48 {ftp,http}://ftp.gnu.org/pub/gnu/gdb \
49 ftp://sources.redhat.com/pub/gdb/{{,old-}releases,snapshots/current}
52 if [ "${do_insight}" = "y" ]; then
53 CT_GetFile "insight-${CT_GDB_VERSION}" \
54 ftp://sourceware.org/pub/insight/releases \
55 {ftp,http}://ftp.twaren.net/Unix/Sourceware/insight/releases \
56 {ftp,http}://ftp.gwdg.de/pub/linux/sources.redhat.com/insight/releases
59 if [ "${do_ncurses}" = "y" ]; then
60 CT_GetFile "ncurses-${CT_NCURSES_VERSION}" \
61 {ftp,http}://ftp.gnu.org/pub/gnu/ncurses \
62 ftp://invisible-island.net/ncurses
66 do_debug_gdb_extract() {
69 if [ "${do_gdb}" = "y" ]; then
70 CT_ExtractAndPatch "gdb$(do_debug_gdb_suffix)"
73 if [ "${do_insight}" = "y" ]; then
74 CT_ExtractAndPatch "insight-${CT_GDB_VERSION}"
77 if [ "${do_ncurses}" = "y" ]; then
78 CT_ExtractAndPatch "ncurses-${CT_NCURSES_VERSION}"
82 do_debug_gdb_build() {
83 gdb_src_dir="${CT_SRC_DIR}/gdb$(do_debug_gdb_suffix)"
84 insight_src_dir="${CT_SRC_DIR}/insight-${CT_GDB_VERSION}"
87 # Version 6.3 and below behave badly with gdbmi
88 case "${CT_GDB_VERSION}" in
89 6.2*|6.3) extra_config="${extra_config} --disable-gdbmi";;
92 if [ "${CT_GDB_CROSS}" = "y" ]; then
93 CT_DoStep INFO "Installing cross-gdb"
94 CT_DoLog EXTRA "Configuring cross-gdb"
96 mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
97 cd "${CT_BUILD_DIR}/build-gdb-cross"
99 cross_extra_config="${extra_config}"
100 if [ "${CT_GMP_MPFR}" = "y" ]; then
101 cross_extra_config="${cross_extra_config} --with-gmp=${CT_PREFIX_DIR} --with-mpfr=${CT_PREFIX_DIR}"
103 case "${CT_THREADS}" in
104 none) cross_extra_config="${cross_extra_config} --disable-threads";;
105 *) cross_extra_config="${cross_extra_config} --enable-threads";;
110 if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then
111 CC_for_gdb="gcc -static"
112 LD_for_gdb="ld -static"
115 gdb_cross_configure="${gdb_src_dir}/configure"
116 [ "${CT_GDB_CROSS_INSIGHT}" = "y" ] && gdb_cross_configure="${insight_src_dir}/configure"
118 CT_DoLog DEBUG "Extra config passed: '${cross_extra_config# }'"
123 "${gdb_cross_configure}" \
124 --build=${CT_BUILD} \
126 --target=${CT_TARGET} \
127 --prefix="${CT_PREFIX_DIR}" \
128 --with-build-sysroot="${CT_SYSROOT_DIR}" \
130 ${cross_extra_config}
132 CT_DoLog EXTRA "Building cross-gdb"
133 CT_DoExecLog ALL make ${PARALLELMFLAGS}
135 CT_DoLog EXTRA "Installing cross-gdb"
136 CT_DoExecLog ALL make install
141 if [ "${CT_GDB_NATIVE}" = "y" ]; then
142 CT_DoStep INFO "Installing native gdb"
144 CT_DoStep INFO "Installing ncurses library"
145 CT_DoLog EXTRA "Configuring ncurses"
146 mkdir -p "${CT_BUILD_DIR}/build-ncurses"
147 cd "${CT_BUILD_DIR}/build-ncurses"
150 [ "${CT_CC_LANG_CXX}" = "y" ] || ncurses_opts="${ncurses_opts} --without-cxx --without-cxx-binding"
151 [ "${CT_CC_LANG_ADA}" = "y" ] || ncurses_opts="${ncurses_opts} --without-ada"
154 "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}/configure" \
155 --build=${CT_BUILD} \
156 --host=${CT_TARGET} \
157 --with-build-cc=${CT_CC} \
158 --with-build-cpp=${CT_CC} \
159 --with-build-cflags="${CT_CFLAGS_FOR_HOST}" \
167 CT_DoLog EXTRA "Building ncurses"
168 CT_DoExecLog ALL make ${PARALLELMFLAGS}
170 CT_DoLog EXTRA "Installing ncurses"
171 mkdir -p "${CT_SYSROOT_DIR}/usr/bin"
172 CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install
176 CT_DoLog EXTRA "Configuring native gdb"
178 mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
179 cd "${CT_BUILD_DIR}/build-gdb-native"
181 native_extra_config="${extra_config}"
182 case "${CT_THREADS}" in
183 none) native_extra_config="${native_extra_config} --disable-threads";;
184 *) native_extra_config="${native_extra_config} --enable-threads";;
186 if [ "${CT_GDB_NATIVE_USE_GMP_MPFR}" = "y" ]; then
187 native_extra_config="${native_extra_config} --with-gmp=${CT_SYSROOT_DIR}/usr --with-mpfr=${CT_SYSROOT_DIR}/usr"
190 if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then
191 CC_for_gdb="${CT_TARGET}-gcc -static"
192 LD_for_gdb="${CT_TARGET}-ld -static"
194 CC_for_gdb="${CT_TARGET}-gcc"
195 LD_for_gdb="${CT_TARGET}-ld"
198 export ac_cv_func_strncmp_works=yes
200 CT_DoLog DEBUG "Extra config passed: '${native_extra_config# }'"
205 "${gdb_src_dir}/configure" \
206 --build=${CT_BUILD} \
207 --host=${CT_TARGET} \
208 --target=${CT_TARGET} \
210 --with-build-sysroot="${CT_SYSROOT_DIR}" \
217 --without-included-gettext \
219 ${native_extra_config}
221 CT_DoLog EXTRA "Building native gdb"
222 CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
224 CT_DoLog EXTRA "Installing native gdb"
225 CT_DoExecLog ALL make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install
227 # Building a native gdb also builds a gdbserver
228 find "${CT_DEBUG_INSTALL_DIR}" -type f -name gdbserver -exec rm -fv {} \; 2>&1 |CT_DoLog ALL
230 unset ac_cv_func_strncmp_works
235 if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
236 CT_DoStep INFO "Installing gdbserver"
237 CT_DoLog EXTRA "Configuring gdbserver"
239 mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
240 cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
242 # Workaround for bad versions, where the configure
243 # script for gdbserver is not executable...
244 # Bah, GNU folks strike again... :-(
245 chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
248 if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then
249 gdbserver_LDFLAGS=-static
252 gdbserver_extra_config="${extra_config}"
254 LDFLAGS="${gdbserver_LDFLAGS}" \
256 "${gdb_src_dir}/gdb/gdbserver/configure" \
257 --build=${CT_BUILD} \
258 --host=${CT_TARGET} \
259 --target=${CT_TARGET} \
262 --localstatedir=/var \
263 --includedir="${CT_HEADERS_DIR}" \
264 --with-build-sysroot="${CT_SYSROOT_DIR}" \
270 --without-included-gettext \
273 ${gdbserver_extra_config}
275 CT_DoLog EXTRA "Building gdbserver"
276 CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
278 CT_DoLog EXTRA "Installing gdbserver"
279 CT_DoExecLog ALL make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install