duma: fix version string.
DUMA uses '_' not '.' for major/minor/sub separation.
1 # Build script for the gdb debug facility
3 do_debug_gdb_suffix() {
4 case "${CT_GDB_VERSION}" in
6 *) echo "-${CT_GDB_VERSION}";;
10 do_debug_gdb_parts() {
15 if [ "${CT_GDB_CROSS}" = y ]; then
16 if [ "${CT_GDB_CROSS_INSIGHT}" = "y" ]; then
23 if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
27 if [ "${CT_GDB_NATIVE}" = "y" ]; then
36 if [ "${do_gdb}" = "y" ]; then
37 CT_GetFile "gdb$(do_debug_gdb_suffix)" \
38 {ftp,http}://ftp.gnu.org/pub/gnu/gdb \
39 ftp://sources.redhat.com/pub/gdb/{{,old-}releases,snapshots/current}
42 if [ "${do_insight}" = "y" ]; then
43 CT_GetFile "insight-${CT_GDB_VERSION}" \
44 ftp://sourceware.org/pub/insight/releases \
45 {ftp,http}://ftp.twaren.net/Unix/Sourceware/insight/releases \
46 {ftp,http}://ftp.gwdg.de/pub/linux/sources.redhat.com/insight/releases
49 if [ "${do_ncurses}" = "y" ]; then
50 CT_GetFile "ncurses-${CT_NCURSES_VERSION}" \
51 {ftp,http}://ftp.gnu.org/pub/gnu/ncurses \
52 ftp://invisible-island.net/ncurses
56 do_debug_gdb_extract() {
59 if [ "${do_gdb}" = "y" ]; then
60 CT_Extract "gdb$(do_debug_gdb_suffix)"
61 CT_Patch "gdb$(do_debug_gdb_suffix)"
64 if [ "${do_insight}" = "y" ]; then
65 CT_Extract "insight-${CT_GDB_VERSION}"
66 CT_Patch "insight-${CT_GDB_VERSION}"
69 if [ "${do_ncurses}" = "y" ]; then
70 CT_Extract "ncurses-${CT_NCURSES_VERSION}"
71 CT_Patch "ncurses-${CT_NCURSES_VERSION}"
75 do_debug_gdb_build() {
78 gdb_src_dir="${CT_SRC_DIR}/gdb$(do_debug_gdb_suffix)"
79 insight_src_dir="${CT_SRC_DIR}/insight-${CT_GDB_VERSION}"
81 # Version 6.3 and below behave badly with gdbmi
82 case "${CT_GDB_VERSION}" in
83 6.2*|6.3) extra_config+=("--disable-gdbmi");;
86 if [ "${CT_GDB_CROSS}" = "y" ]; then
87 local -a cross_extra_config
89 CT_DoStep INFO "Installing cross-gdb"
90 CT_DoLog EXTRA "Configuring cross-gdb"
92 mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
93 cd "${CT_BUILD_DIR}/build-gdb-cross"
95 cross_extra_config=("${extra_config[@]}")
96 if [ "${CT_GMP_MPFR}" = "y" ]; then
97 cross_extra_config+=("--with-gmp=${CT_PREFIX_DIR}" "--with-mpfr=${CT_PREFIX_DIR}")
99 case "${CT_THREADS}" in
100 none) cross_extra_config+=("--disable-threads");;
101 *) cross_extra_config+=("--enable-threads");;
106 if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then
107 CC_for_gdb="gcc -static"
108 LD_for_gdb="ld -static"
111 gdb_cross_configure="${gdb_src_dir}/configure"
112 [ "${CT_GDB_CROSS_INSIGHT}" = "y" ] && gdb_cross_configure="${insight_src_dir}/configure"
114 CT_DoLog DEBUG "Extra config passed: '${cross_extra_config[*]}'"
119 "${gdb_cross_configure}" \
120 --build=${CT_BUILD} \
122 --target=${CT_TARGET} \
123 --prefix="${CT_PREFIX_DIR}" \
124 --with-build-sysroot="${CT_SYSROOT_DIR}" \
126 "${cross_extra_config[@]}"
128 CT_DoLog EXTRA "Building cross-gdb"
129 CT_DoExecLog ALL make ${PARALLELMFLAGS}
131 CT_DoLog EXTRA "Installing cross-gdb"
132 CT_DoExecLog ALL make install
137 if [ "${CT_GDB_NATIVE}" = "y" ]; then
138 local -a native_extra_config
141 CT_DoStep INFO "Installing native gdb"
143 CT_DoStep INFO "Installing ncurses library"
145 [ "${CT_CC_LANG_CXX}" = "y" ] || ncurses_opts+=("--without-cxx" "--without-cxx-binding")
146 [ "${CT_CC_LANG_ADA}" = "y" ] || ncurses_opts+=("--without-ada")
148 CT_DoStep INFO "Installing native ncurses tic"
149 CT_DoLog EXTRA "Configuring ncurses tic"
150 mkdir -p "${CT_BUILD_DIR}/build-ncurses-build-tic"
151 cd "${CT_BUILD_DIR}/build-ncurses-build-tic"
153 # Use build = CT_REAL_BUILD so that configure thinks it is
154 # cross-compiling, and thus will use the ${CT_BUILD}-*
155 # tools instead of searching for the native ones...
157 "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}/configure" \
158 --build=${CT_REAL_BUILD} \
163 --with-build-cc=${CT_REAL_BUILD}-gcc \
164 --with-build-cpp=${CT_REAL_BUILD}-gcc \
165 --with-build-cflags="${CT_CFLAGS_FOR_HOST}" \
168 # Under some operating systems (eg. Winblows), there is an
169 # extension appended to executables. Find that.
170 tic_ext=$(grep -E '^x[[:space:]]*=' progs/Makefile |sed -r -e 's/^.*=[[:space:]]*//;')
172 CT_DoLog EXTRA "Building ncurses tic"
173 CT_DoExecLog ALL make ${PARALLELMFLAGS} -C include
174 CT_DoExecLog ALL make ${PARALLELMFLAGS} -C progs "tic${tic_ext}"
176 CT_DoLog EXTRA "Installing ncurses tic"
177 CT_DoExecLog ALL install -d -m 0755 "${CT_PREFIX_DIR}/bin"
178 CT_DoExecLog ALL install -m 0755 "progs/tic${tic_ext}" "${CT_PREFIX_DIR}/bin"
180 CT_EndStep # tic build
182 CT_DoLog EXTRA "Configuring ncurses"
183 mkdir -p "${CT_BUILD_DIR}/build-ncurses"
184 cd "${CT_BUILD_DIR}/build-ncurses"
187 "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}/configure" \
188 --build=${CT_BUILD} \
189 --host=${CT_TARGET} \
190 --with-build-cc=${CT_BUILD}-gcc \
191 --with-build-cpp=${CT_BUILD}-gcc \
192 --with-build-cflags="${CT_CFLAGS_FOR_HOST}" \
200 CT_DoLog EXTRA "Building ncurses"
201 CT_DoExecLog ALL make ${PARALLELMFLAGS}
203 CT_DoLog EXTRA "Installing ncurses"
204 mkdir -p "${CT_SYSROOT_DIR}/usr/bin"
205 CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install
207 # We no longer need the temporary tic. Remove it
208 CT_DoExecLog DEBUG rm -fv "${CT_PREFIX_DIR}/bin/tic"
210 CT_EndStep # ncurses build
212 CT_DoLog EXTRA "Configuring native gdb"
214 mkdir -p "${CT_BUILD_DIR}/build-gdb-native"
215 cd "${CT_BUILD_DIR}/build-gdb-native"
217 native_extra_config=("${extra_config[@]}")
218 case "${CT_THREADS}" in
219 none) native_extra_config+=("--disable-threads");;
220 *) native_extra_config+=("--enable-threads");;
222 if [ "${CT_GDB_NATIVE_USE_GMP_MPFR}" = "y" ]; then
223 native_extra_config+=("--with-gmp=${CT_SYSROOT_DIR}/usr" "--with-mpfr=${CT_SYSROOT_DIR}/usr")
226 if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then
227 CC_for_gdb="${CT_TARGET}-gcc -static"
228 LD_for_gdb="${CT_TARGET}-ld -static"
230 CC_for_gdb="${CT_TARGET}-gcc"
231 LD_for_gdb="${CT_TARGET}-ld"
234 export ac_cv_func_strncmp_works=yes
236 CT_DoLog DEBUG "Extra config passed: '${native_extra_config[*]}'"
241 "${gdb_src_dir}/configure" \
242 --build=${CT_BUILD} \
243 --host=${CT_TARGET} \
244 --target=${CT_TARGET} \
246 --with-build-sysroot="${CT_SYSROOT_DIR}" \
253 --without-included-gettext \
255 "${native_extra_config[@]}"
257 CT_DoLog EXTRA "Building native gdb"
258 CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
260 CT_DoLog EXTRA "Installing native gdb"
261 CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install
263 # Building a native gdb also builds a gdbserver
264 find "${CT_DEBUGROOT_DIR}" -type f -name gdbserver -exec rm -fv {} \; 2>&1 |CT_DoLog ALL
266 unset ac_cv_func_strncmp_works
268 CT_EndStep # native gdb build
271 if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
272 local -a gdbserver_extra_config
274 CT_DoStep INFO "Installing gdbserver"
275 CT_DoLog EXTRA "Configuring gdbserver"
277 mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
278 cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
280 # Workaround for bad versions, where the configure
281 # script for gdbserver is not executable...
282 # Bah, GNU folks strike again... :-(
283 chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
286 if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then
287 gdbserver_LDFLAGS=-static
290 gdbserver_extra_config=("${extra_config[@]}")
292 LDFLAGS="${gdbserver_LDFLAGS}" \
294 "${gdb_src_dir}/gdb/gdbserver/configure" \
295 --build=${CT_BUILD} \
296 --host=${CT_TARGET} \
297 --target=${CT_TARGET} \
300 --localstatedir=/var \
301 --includedir="${CT_HEADERS_DIR}" \
302 --with-build-sysroot="${CT_SYSROOT_DIR}" \
308 --without-included-gettext \
311 "${gdbserver_extra_config[@]}"
313 CT_DoLog EXTRA "Building gdbserver"
314 CT_DoExecLog ALL make ${PARALLELMFLAGS} CC=${CT_TARGET}-${CT_CC}
316 CT_DoLog EXTRA "Installing gdbserver"
317 CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install