]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/configure.ac
gdbsupport: move libxxhash configure check to gdbsupport
[thirdparty/binutils-gdb.git] / gdb / configure.ac
CommitLineData
c906108c 1dnl Autoconf configure script for GDB, the GNU debugger.
213516ef 2dnl Copyright (C) 1995-2023 Free Software Foundation, Inc.
c906108c
SS
3dnl
4dnl This file is part of GDB.
4869db5e 5dnl
c906108c
SS
6dnl This program is free software; you can redistribute it and/or modify
7dnl it under the terms of the GNU General Public License as published by
5a0e3bd0 8dnl the Free Software Foundation; either version 3 of the License, or
c906108c 9dnl (at your option) any later version.
5a0e3bd0 10dnl
c906108c
SS
11dnl This program is distributed in the hope that it will be useful,
12dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14dnl GNU General Public License for more details.
5a0e3bd0 15dnl
c906108c 16dnl You should have received a copy of the GNU General Public License
5a0e3bd0 17dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c
SS
18
19dnl Process this file with autoconf to produce a configure script.
20
5593a99a 21AC_INIT
b686ecb5 22AC_CONFIG_MACRO_DIRS([.. ../config])
5593a99a 23AC_CONFIG_SRCDIR([main.c])
c5adaa19 24AC_CONFIG_HEADERS(config.h:config.in, [echo > stamp-h])
413ccac7 25AM_MAINTAINER_MODE
c906108c
SS
26
27AC_PROG_CC
3bc3d82a
PA
28AC_PROG_CXX
29
c462b41b 30AC_USE_SYSTEM_EXTENSIONS
da2f07f1 31ACX_LARGEFILE
4869db5e 32AM_PROG_INSTALL_STRIP
c906108c 33
e28b3332 34AC_CONFIG_AUX_DIR(..)
91e1a0ed
SM
35
36# Set build, build_cpu, build_vendor and build_os.
37AC_CANONICAL_BUILD
38
39# Set host, host_cpu, host_vendor, and host_os.
40AC_CANONICAL_HOST
41
42# Set target, target_cpu, target_vendor, and target_os.
43AC_CANONICAL_TARGET
44
b316465f
TT
45ACX_NONCANONICAL_TARGET
46
9009e1ae 47AC_ARG_PROGRAM
c906108c 48
b686ecb5
JM
49# We require libtool to link with the in-tree libtool libraries
50# the proper way.
51LT_INIT
5218fa9e
JM
52# ... and we need it soon, since it is used by some of the
53# link tests in the configure script.
54LT_OUTPUT
b686ecb5 55
0bcda685
PA
56# We require a C++11 compiler. Check if one is available, and if
57# necessary, set CXX_DIALECT to some -std=xxx switch.
58AX_CXX_COMPILE_STDCXX(11, , mandatory)
59
a417dc56
RW
60# Dependency checking.
61ZW_CREATE_DEPDIR
62ZW_PROG_COMPILER_DEPENDENCIES([CC])
63
ddc9cd0f
AC
64dnl List of object files and targets accumulated by configure.
65
66CONFIG_OBS=
67CONFIG_DEPS=
68CONFIG_SRCS=
69ENABLE_CFLAGS=
70
71CONFIG_ALL=
72CONFIG_CLEAN=
73CONFIG_INSTALL=
74CONFIG_UNINSTALL=
75
20e95c23
DJ
76dnl Set up for gettext.
77ZW_GNU_GETTEXT_SISTER_DIR
ddc9cd0f
AC
78
79localedir='${datadir}/locale'
80AC_SUBST(localedir)
81
20e95c23 82if test x"$USE_NLS" = xyes; then
ddc9cd0f 83 CONFIG_ALL="$CONFIG_ALL all-po"
4869db5e 84 CONFIG_CLEAN="$CONFIG_CLEAN clean-po"
ddc9cd0f
AC
85 CONFIG_INSTALL="$CONFIG_INSTALL install-po"
86 CONFIG_UNINSTALL="$CONFIG_UNINSTALL uninstall-po"
87fi
88
89PACKAGE=gdb
90AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package. ])
91AC_SUBST(PACKAGE)
0fbb3da7 92
f06e05e0
JK
93# We never need to detect it in this sub-configure.
94# But preserve it for config.status --recheck.
95AC_ARG_VAR(MAKEINFO,
96 [Parent configure detects if it is of sufficient version.])
97AC_ARG_VAR(MAKEINFOFLAGS,
98 [Parameters for MAKEINFO.])
5048e516
JK
99
100MAKEINFO_EXTRA_FLAGS=""
101AC_CACHE_CHECK([whether $MAKEINFO supports @click], gdb_cv_have_makeinfo_click,
102 [echo '@clicksequence{a @click{} b}' >conftest.texinfo
103 if eval "$MAKEINFO conftest.texinfo >&5 2>&5"; then
104 gdb_cv_have_makeinfo_click=yes
105 else
106 gdb_cv_have_makeinfo_click=no
107 fi])
108if test x"$gdb_cv_have_makeinfo_click" = xyes; then
109 MAKEINFO_EXTRA_FLAGS="$MAKEINFO_EXTRA_FLAGS -DHAVE_MAKEINFO_CLICK"
110fi
111AC_SUBST(MAKEINFO_EXTRA_FLAGS)
112
b14b1491
TT
113GDB_AC_WITH_DIR(DEBUGDIR, separate-debug-dir,
114 [look for global separate debug info in this path @<:@LIBDIR/debug@:>@],
115 [${libdir}/debug])
116
f83d8a90
DE
117# We can't pass paths as command line arguments.
118# Mingw32 tries to be clever and will convert the paths for us.
119# For example -DBINDIR="/usr/local/bin" passed on the command line may get
120# converted to -DBINDIR="E:/msys/mingw32/msys/1.0/local/bin".
121# This breaks GDB's relocatable path conversions since paths passed in
122# config.h would not get so translated, the path prefixes no longer match.
123AC_DEFINE_DIR(BINDIR, bindir, [Directory of programs.])
124
b14b1491
TT
125# GDB's datadir relocation
126
127GDB_AC_WITH_DIR(GDB_DATADIR, gdb-datadir,
128 [look for global separate data files in this path @<:@DATADIR/gdb@:>@],
129 [${datadir}/gdb])
aa28a74e 130
29b0e8a2 131AC_ARG_WITH(relocated-sources,
d2596e2e 132AS_HELP_STRING([--with-relocated-sources=PATH], [automatically relocate this path for source files]),
29b0e8a2
JM
133[reloc_srcdir="${withval}"
134 AC_DEFINE_DIR(RELOC_SRCDIR, reloc_srcdir,
135 [Relocated directory for source files. ])
136])
137
7349ff92
JK
138AC_MSG_CHECKING([for default auto-load directory])
139AC_ARG_WITH(auto-load-dir,
140AS_HELP_STRING([--with-auto-load-dir=PATH],
1564a261
JK
141 [directories from which to load auto-loaded scripts @<:@$debugdir:$datadir/auto-load@:>@]),,
142 [with_auto_load_dir='$debugdir:$datadir/auto-load'])
2861ee4f 143escape_dir=`echo $with_auto_load_dir | sed -e 's/[[$]]datadir\>/\\\\\\\\\\\\&/g' -e 's/[[$]]debugdir\>/\\\\\\\\\\\\&/g'`
7349ff92
JK
144AC_DEFINE_DIR(AUTO_LOAD_DIR, escape_dir,
145 [Directories from which to load auto-loaded scripts.])
146AC_MSG_RESULT([$with_auto_load_dir])
147
bccbefd2
JK
148AC_MSG_CHECKING([for default auto-load safe-path])
149AC_ARG_WITH(auto-load-safe-path,
6dea1fbd 150AS_HELP_STRING([--with-auto-load-safe-path=PATH],
aff139ff 151 [directories safe to hold auto-loaded files @<:@--with-auto-load-dir@:>@])
6dea1fbd
JK
152AS_HELP_STRING([--without-auto-load-safe-path],
153 [do not restrict auto-loaded files locations]),
154 [if test "$with_auto_load_safe_path" = "no"; then
155 with_auto_load_safe_path="/"
156 fi],
7349ff92 157[with_auto_load_safe_path="$with_auto_load_dir"])
2861ee4f 158escape_dir=`echo $with_auto_load_safe_path | sed -e 's/[[$]]datadir\>/\\\\\\\\\\\\&/g' -e 's/[[$]]debugdir\>/\\\\\\\\\\\\&/g'`
6dea1fbd 159AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir,
bccbefd2
JK
160 [Directories safe to hold auto-loaded files.])
161AC_MSG_RESULT([$with_auto_load_safe_path])
162
a100a945 163AC_CONFIG_SUBDIRS(testsuite)
96baa820 164
d0c678e6
UW
165# Check whether to support alternative target configurations
166AC_ARG_ENABLE(targets,
d2596e2e 167AS_HELP_STRING([--enable-targets=TARGETS], [alternative target configurations]),
d0c678e6 168[case "${enableval}" in
5593a99a 169 yes | "") AC_MSG_ERROR(enable-targets option must specify target names or 'all')
d0c678e6
UW
170 ;;
171 no) enable_targets= ;;
172 *) enable_targets=$enableval ;;
173esac])
174
1d5269c9 175BFD_64_BIT
c0993dbe 176
121ce6e5
DJ
177# Provide defaults for some variables set by the per-host and per-target
178# configuration.
179gdb_host_obs=posix-hdep.o
180
771b4502
UW
181if test "${target}" = "${host}"; then
182 gdb_native=yes
183else
184 gdb_native=no
185fi
186
27e9bf90 187. $srcdir/configure.host
c906108c 188
d0c678e6
UW
189# Accumulate some settings from configure.tgt over all enabled targets
190
191TARGET_OBS=
192all_targets=
b292c783 193HAVE_NATIVE_GCORE_TARGET=
d0c678e6
UW
194
195for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
196do
197 if test "$targ_alias" = "all"; then
198 all_targets=true
199 else
200 # Canonicalize the secondary target names.
201 result=`$ac_config_sub $targ_alias 2>/dev/null`
202 if test -n "$result"; then
203 targ=$result
204 else
205 targ=$targ_alias
206 fi
207
208 . ${srcdir}/configure.tgt
209
bf307134
JB
210 AS_IF([test -z "${gdb_target_obs}"],
211 [AC_MSG_ERROR([configuration ${targ} is unsupported.])])
212
d0c678e6
UW
213 # Target-specific object files
214 for i in ${gdb_target_obs}; do
215 case " $TARGET_OBS " in
216 *" ${i} "*) ;;
217 *)
218 TARGET_OBS="$TARGET_OBS ${i}"
219 ;;
220 esac
221 done
c0993dbe
UW
222
223 # Check whether this target needs 64-bit CORE_ADDR
1d5269c9 224 if test x${enable_64_bit_bfd} = xno; then
c0993dbe
UW
225 . ${srcdir}/../bfd/config.bfd
226 fi
b292c783
JK
227
228 # Check whether this target is native and supports gcore.
229 if test $gdb_native = yes -a "$targ_alias" = "$target_alias" \
230 && $gdb_have_gcore; then
231 HAVE_NATIVE_GCORE_TARGET=1
232 fi
d0c678e6
UW
233 fi
234done
235
236if test x${all_targets} = xtrue; then
1d5269c9 237 if test x${enable_64_bit_bfd} = xyes; then
c0993dbe
UW
238 TARGET_OBS='$(ALL_TARGET_OBS) $(ALL_64_TARGET_OBS)'
239 else
240 TARGET_OBS='$(ALL_TARGET_OBS)'
241 fi
d0c678e6
UW
242fi
243
244AC_SUBST(TARGET_OBS)
b292c783 245AC_SUBST(HAVE_NATIVE_GCORE_TARGET)
d0c678e6
UW
246
247# For other settings, only the main target counts.
248gdb_sim=
249gdb_osabi=
d0c678e6 250targ=$target; . ${srcdir}/configure.tgt
c906108c 251
27e9bf90
MK
252# Fetch the default architecture and default target vector from BFD.
253targ=$target; . $srcdir/../bfd/config.bfd
5c8cc331 254
27e9bf90
MK
255# We only want the first architecture, so strip off the others if
256# there is more than one.
257targ_archs=`echo $targ_archs | sed 's/ .*//'`
5c8cc331 258
27e9bf90
MK
259if test "x$targ_archs" != x; then
260 AC_DEFINE_UNQUOTED(DEFAULT_BFD_ARCH, $targ_archs,
261 [Define to BFD's default architecture. ])
1ba607ad 262fi
27e9bf90
MK
263if test "x$targ_defvec" != x; then
264 AC_DEFINE_UNQUOTED(DEFAULT_BFD_VEC, $targ_defvec,
265 [Define to BFD's default target vector. ])
1ba607ad
AC
266fi
267
627af7ea 268# Enable MI.
4fd404c2
SM
269AC_ARG_ENABLE([gdbmi],
270 [AS_HELP_STRING([--disable-gdbmi], [disable machine-interface (MI)])],
271 [GDB_CHECK_YES_NO_VAL([$enableval], [--enable-gdbmi])],
272 [enable_gdbmi=yes])
627af7ea 273if test x"$enable_gdbmi" = xyes; then
0ad6b8ee 274 if test -d "$srcdir/mi"; then
627af7ea
MK
275 CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_MI_OBS)"
276 CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_MI_DEPS)"
277 CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_MI_SRCS)"
627af7ea 278 ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_MI_CFLAGS)"
627af7ea
MK
279 fi
280fi
281
287c1a40
MK
282# Enable TUI.
283AC_ARG_ENABLE(tui,
4fd404c2
SM
284AS_HELP_STRING([--enable-tui],
285 [enable full-screen terminal user interface (TUI)]),
286 [GDB_CHECK_YES_NO_AUTO_VAL([$enableval], [--enable-tui])],
287 [enable_tui=auto])
287c1a40 288
8ee53726 289# Enable gdbtk.
4fd404c2
SM
290AC_ARG_ENABLE([gdbtk],
291 [AS_HELP_STRING([--enable-gdbtk], [enable gdbtk graphical user interface (GUI)])],
292 [GDB_CHECK_YES_NO_VAL([$enableval], [--enable-gdbtk])],
293 [if test -d "$srcdir/gdbtk"; then
294 enable_gdbtk=yes
295 else
296 enable_gdbtk=no
297 fi])
8ee53726
MK
298# We unconditionally disable gdbtk tests on selected platforms.
299case $host_os in
300 go32* | windows*)
301 AC_MSG_WARN([gdbtk isn't supported on $host; disabling])
302 enable_gdbtk=no ;;
303esac
304
0d79cdc4
AM
305# Handle optional debuginfod support
306AC_DEBUGINFOD
05e7c244 307
0d79cdc4 308# Libunwind support for ia64.
05e7c244
JK
309AC_ARG_WITH(libunwind-ia64,
310AS_HELP_STRING([--with-libunwind-ia64],
311 [use libunwind frame unwinding for ia64 targets]),,
312 [with_libunwind_ia64=auto])
313
314# Backward compatibility option.
315if test "${with_libunwind+set}" = set; then
316 if test x"$with_libunwind_ia64" != xauto; then
317 AC_MSG_ERROR(
318 [option --with-libunwind is deprecated, use --with-libunwind-ia64])
0e5d83e3 319 fi
05e7c244
JK
320 AC_MSG_WARN([option --with-libunwind is deprecated, use --with-libunwind-ia64])
321 with_libunwind_ia64="$with_libunwind"
322fi
323
324case "$with_libunwind_ia64" in
325 yes | no)
326 ;;
327 auto)
328 AC_CHECK_HEADERS(libunwind-ia64.h)
329 with_libunwind_ia64=$ac_cv_header_libunwind_ia64_h
330 ;;
331 *)
332 AC_MSG_ERROR(
333 [bad value $with_libunwind_ia64 for GDB --with-libunwind-ia64 option])
334 ;;
335esac
336
337if test x"$with_libunwind_ia64" = xyes; then
b54a8fd7 338 AC_CHECK_HEADERS(libunwind-ia64.h)
05e7c244
JK
339 if test x"$ac_cv_header_libunwind_ia64_h" != xyes; then
340 AC_MSG_ERROR([GDB option --with-libunwind-ia64 requires libunwind-ia64.h])
341 fi
342 CONFIG_OBS="$CONFIG_OBS ia64-libunwind-tdep.o"
343 CONFIG_DEPS="$CONFIG_DEPS ia64-libunwind-tdep.o"
344 CONFIG_SRCS="$CONFIG_SRCS ia64-libunwind-tdep.c"
0e5d83e3
JJ
345fi
346
cb01cfba 347opt_curses=no
d2596e2e 348AC_ARG_WITH(curses, AS_HELP_STRING([--with-curses], [use the curses library instead of the termcap library]), opt_curses=$withval)
cb01cfba 349
76a39ba7 350prefer_curses=no
cb01cfba 351if test "$opt_curses" = "yes"; then
76a39ba7 352 prefer_curses=yes
cb01cfba
JB
353fi
354
d28f9cdf 355# Profiling support.
4fd404c2
SM
356AC_ARG_ENABLE([profiling],
357 [AS_HELP_STRING([--enable-profiling], [enable profiling of GDB])],
358 [GDB_CHECK_YES_NO_VAL([$enableval], [--enable-profiling])],
359 [enable_profiling=no])
d28f9cdf 360
d9feb4e7 361AC_CHECK_FUNCS(monstartup _mcleanup)
5593a99a
SM
362AC_CACHE_CHECK(
363 [for _etext],
364 [ac_cv_var__etext],
365 [AC_LINK_IFELSE(
366 [AC_LANG_PROGRAM(
367 [#include <stdlib.h>
368 extern char _etext;],
369 [free (&_etext);]
370 )],
371 [ac_cv_var__etext=yes],
372 [ac_cv_var__etext=no]
373 )]
374)
0ad6b8ee 375if test "$ac_cv_var__etext" = yes; then
b0b1c2c0
MK
376 AC_DEFINE(HAVE__ETEXT, 1,
377 [Define to 1 if your system has the _etext variable. ])
378fi
5593a99a
SM
379AC_CACHE_CHECK(
380 [for etext],
381 [ac_cv_var_etext],
382 [AC_LINK_IFELSE(
383 [AC_LANG_PROGRAM(
384 [#include <stdlib.h>
385 extern char etext;],
386 [free (&etext);]
387 )],
388 [ac_cv_var_etext=yes],
389 [ac_cv_var_etext=no]
390 )]
391)
0ad6b8ee 392if test "$ac_cv_var_etext" = yes; then
01fe12f6
JB
393 AC_DEFINE(HAVE_ETEXT, 1,
394 [Define to 1 if your system has the etext variable. ])
395fi
d28f9cdf 396if test "$enable_profiling" = yes ; then
0ad6b8ee 397 if test "$ac_cv_func_monstartup" = no || test "$ac_cv_func__mcleanup" = no; then
d9feb4e7
DJ
398 AC_MSG_ERROR(--enable-profiling requires monstartup and _mcleanup)
399 fi
d28f9cdf
DJ
400 PROFILE_CFLAGS=-pg
401 OLD_CFLAGS="$CFLAGS"
402 CFLAGS="$CFLAGS $PROFILE_CFLAGS"
403
5593a99a
SM
404 AC_CACHE_CHECK(
405 [whether $CC supports -pg],
406 [ac_cv_cc_supports_pg],
407 [AC_COMPILE_IFELSE(
408 [AC_LANG_PROGRAM([], [int x;])],
409 [ac_cv_cc_supports_pg=yes],
410 [ac_cv_cc_supports_pg=no]
411 )]
412 )
d28f9cdf 413
0ad6b8ee 414 if test "$ac_cv_cc_supports_pg" = no; then
d9feb4e7
DJ
415 AC_MSG_ERROR(--enable-profiling requires a compiler which supports -pg)
416 fi
d28f9cdf
DJ
417
418 CFLAGS="$OLD_CFLAGS"
419fi
420
44cee4fd
TT
421CODESIGN_CERT=
422AC_ARG_ENABLE([codesign],
423 AS_HELP_STRING([--enable-codesign=CERT],
424 [sign gdb with 'codesign -s CERT']),
425 [CODESIGN_CERT=$enableval])
426AC_SUBST([CODESIGN_CERT])
427
c16158bc 428ACX_PKGVERSION([GDB])
112c22ed 429ACX_BUGURL([https://www.gnu.org/software/gdb/bugs/])
c16158bc
JM
430AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
431AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
432
8bb2c122
MK
433# --------------------- #
434# Checks for programs. #
435# --------------------- #
436
7a292a7a 437AC_PROG_AWK
c906108c 438AC_PROG_INSTALL
8bb2c122
MK
439AC_PROG_LN_S
440AC_PROG_RANLIB
441AC_PROG_YACC
442
c906108c 443AC_CHECK_TOOL(AR, ar)
95ca63c4
CF
444AC_CHECK_TOOL(DLLTOOL, dlltool)
445AC_CHECK_TOOL(WINDRES, windres)
c906108c 446
036c3acb
TS
447case $host_os in
448 gnu*)
449 # Needed for GNU Hurd hosts.
450 AC_CHECK_TOOL(MIG, mig)
451 if test x"$MIG" = x; then
452 AC_MSG_ERROR([MIG not found but required for $host hosts])
453 fi
454 ;;
455esac
75c6e08a 456
9a156167
MK
457# ---------------------- #
458# Checks for libraries. #
459# ---------------------- #
460
461# We might need to link with -lm; most simulators need it.
462AC_CHECK_LIB(m, main)
463
c890192f
MK
464# Some systems (e.g. Solaris) have `gethostbyname' in libnsl.
465AC_SEARCH_LIBS(gethostbyname, nsl)
466
9a156167
MK
467# Some systems (e.g. Solaris) have `socketpair' in libsocket.
468AC_SEARCH_LIBS(socketpair, socket)
469
2cac01e3
FS
470# Link in zlib/zstd if we can. This allows us to read compressed debug
471# sections.
b040ad30 472AM_ZLIB
2cac01e3 473AC_ZSTD
233a11ab 474
6c7a06a3
TT
475AM_ICONV
476
478aac75
DE
477# GDB may fork/exec the iconv program to get the list of supported character
478# sets. Allow the user to specify where to find it.
479# There are several factors affecting the choice of option name:
480# - There is already --with-libiconv-prefix but we can't use it, it specifies
481# the build-time location of libiconv files.
482# - The program we need to find is iconv, which comes with glibc. The user
483# doesn't necessarily have libiconv installed. Therefore naming this
484# --with-libiconv-foo feels wrong.
485# - We want the path to be relocatable, but GDB_AC_DEFINE_RELOCATABLE is
486# defined to work on directories not files (though it really doesn't know
487# the difference).
488# - Calling this --with-iconv-prefix is perceived to cause too much confusion
489# with --with-libiconv-prefix.
490# Putting these together is why the option name is --with-iconv-bin.
491
492AC_ARG_WITH(iconv-bin,
493AS_HELP_STRING([--with-iconv-bin=PATH], [specify where to find the iconv program]),
494[iconv_bin="${withval}"
495 AC_DEFINE_UNQUOTED([ICONV_BIN], ["${iconv_bin}"],
496 [Path of directory of iconv program.])
497 GDB_AC_DEFINE_RELOCATABLE(ICONV_BIN, iconv, ${iconv_bin})
498])
499
cb01cfba 500# For the TUI, we need enhanced curses functionality.
bd8a8e1b 501if test x"$enable_tui" != xno; then
cb01cfba
JB
502 prefer_curses=yes
503fi
504
505curses_found=no
506if test x"$prefer_curses" = xyes; then
507 # FIXME: kettenis/20040905: We prefer ncurses over the vendor-supplied
508 # curses library because the latter might not provide all the
509 # functionality we need. However, this leads to problems on systems
510 # where the linker searches /usr/local/lib, but the compiler doesn't
511 # search /usr/local/include, if ncurses is installed in /usr/local. A
512 # default installation of ncurses on alpha*-dec-osf* will lead to such
513 # a situation.
5007d765 514 AC_SEARCH_LIBS(waddstr, [ncursesw ncurses cursesX curses])
cb01cfba
JB
515
516 if test "$ac_cv_search_waddstr" != no; then
517 curses_found=yes
518 fi
519fi
520
77f120bf
JB
521# Check whether we should enable the TUI, but only do so if we really
522# can.
523if test x"$enable_tui" != xno; then
0ad6b8ee 524 if test -d "$srcdir/tui"; then
cb01cfba 525 if test "$curses_found" != no; then
77f120bf
JB
526 CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_TUI_OBS)"
527 CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_TUI_DEPS)"
528 CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_TUI_SRCS)"
529 ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_TUI_CFLAGS)"
77f120bf
JB
530 else
531 if test x"$enable_tui" = xyes; then
532 AC_MSG_ERROR([no enhanced curses library found; disable TUI])
533 else
534 AC_MSG_WARN([no enhanced curses library found; disabling TUI])
535 fi
536 fi
537 fi
538fi
539
4f0be353
MK
540# Since GDB uses Readline, we need termcap functionality. In many
541# cases this will be provided by the curses library, but some systems
96fe4562 542# have a separate termcap library, or no curses library at all.
287c1a40
MK
543
544case $host_os in
545 cygwin*)
0ad6b8ee 546 if test -d "$srcdir/libtermcap"; then
287c1a40
MK
547 LIBS="../libtermcap/libtermcap.a $LIBS"
548 ac_cv_search_tgetent="../libtermcap/libtermcap.a"
549 fi ;;
228a417c 550 go32* | *djgpp*)
287c1a40
MK
551 ac_cv_search_tgetent="none required"
552 ;;
287c1a40
MK
553esac
554
4f0be353 555# These are the libraries checked by Readline.
2578ecb1 556AC_SEARCH_LIBS(tgetent, [termcap tinfow tinfo curses ncursesw ncurses])
287c1a40
MK
557
558if test "$ac_cv_search_tgetent" = no; then
7a85168d 559 CONFIG_OBS="$CONFIG_OBS stub-termcap.o"
287c1a40
MK
560fi
561
6a30b0a5
AS
562AC_ARG_WITH([system-readline],
563 [AS_HELP_STRING([--with-system-readline],
564 [use installed readline library])])
565
566if test "$with_system_readline" = yes; then
7c26f8da
AH
567 AC_CHECK_HEADERS(readline/readline.h, [readline_h=yes], [readline_h=no])
568 if test "$readline_h" = "no"; then
569 AC_MSG_ERROR([readline development packages are probably missing])
570 fi
5593a99a
SM
571 AC_CACHE_CHECK(
572 [whether system readline is new enough],
573 [gdb_cv_readline_ok],
574 [AC_COMPILE_IFELSE(
575 [AC_LANG_PROGRAM(
576 [#include <stdio.h>
577 #include <readline/readline.h>],
578 [#if RL_VERSION_MAJOR < 7
579 # error "readline version 7 required"
580 #endif]
581 )],
582 [gdb_cv_readline_ok=yes],
583 [gdb_cv_readline_ok=no]
584 )]
585 )
86c6b807
TT
586 if test "$gdb_cv_readline_ok" != yes; then
587 AC_MSG_ERROR([system readline is not new enough])
588 fi
589
6a30b0a5
AS
590 READLINE=-lreadline
591 READLINE_DEPS=
592 READLINE_CFLAGS=
39037522 593 READLINE_TEXI_INCFLAG=
6a30b0a5
AS
594else
595 READLINE='$(READLINE_DIR)/libreadline.a'
596 READLINE_DEPS='$(READLINE)'
597 READLINE_CFLAGS='-I$(READLINE_SRC)/..'
39037522 598 READLINE_TEXI_INCFLAG='-I $(READLINE_DIR)'
6a30b0a5
AS
599fi
600AC_SUBST(READLINE)
601AC_SUBST(READLINE_DEPS)
602AC_SUBST(READLINE_CFLAGS)
39037522 603AC_SUBST(READLINE_TEXI_INCFLAG)
6a30b0a5 604
f997c383
SD
605# Generate jit-reader.h
606
607# This is typedeffed to GDB_CORE_ADDR in jit-reader.h
608TARGET_PTR=
609
610AC_CHECK_SIZEOF(unsigned long long)
611AC_CHECK_SIZEOF(unsigned long)
612AC_CHECK_SIZEOF(unsigned __int128)
613
614if test "x${ac_cv_sizeof_unsigned_long}" = "x8"; then
615 TARGET_PTR="unsigned long"
616elif test "x${ac_cv_sizeof_unsigned_long_long}" = "x8"; then
617 TARGET_PTR="unsigned long long"
618elif test "x${ac_cv_sizeof_unsigned___int128}" = "x16"; then
619 TARGET_PTR="unsigned __int128"
620else
621 TARGET_PTR="unsigned long"
622fi
623
624AC_SUBST(TARGET_PTR)
625AC_CONFIG_FILES([jit-reader.h:jit-reader.in])
626
a2d08b9e
SD
627AC_SEARCH_LIBS(dlopen, dl)
628
b8e0a31c
SD
629GDB_AC_WITH_DIR([JIT_READER_DIR], [jit-reader-dir],
630 [directory to load the JIT readers from],
631 [${libdir}/gdb])
632
5c39566f
DJ
633AC_ARG_WITH(expat,
634 AS_HELP_STRING([--with-expat], [include expat support (auto/yes/no)]),
635 [], [with_expat=auto])
636AC_MSG_CHECKING([whether to use expat])
637AC_MSG_RESULT([$with_expat])
638
639if test "${with_expat}" = no; then
640 AC_MSG_WARN([expat support disabled; some features may be unavailable.])
641 HAVE_LIBEXPAT=no
ca4ca11e 642else
5c39566f
DJ
643 AC_LIB_HAVE_LINKFLAGS([expat], [], [#include "expat.h"],
644 [XML_Parser p = XML_ParserCreate (0);])
645 if test "$HAVE_LIBEXPAT" != yes; then
646 if test "$with_expat" = yes; then
647 AC_MSG_ERROR([expat is missing or unusable])
648 else
649 AC_MSG_WARN([expat is missing or unusable; some features may be unavailable.])
650 fi
651 else
652 save_LIBS=$LIBS
653 LIBS="$LIBS $LIBEXPAT"
654 AC_CHECK_FUNCS(XML_StopParser)
655 LIBS=$save_LIBS
656 fi
7fa2210b
DJ
657fi
658
99118062
AP
659AC_ARG_VAR(GMPLIBS,[How to link GMP])
660AC_ARG_VAR(GMPINC,[How to find GMP include files])
2400729e 661
d344e670
DE
662# --------------------- #
663# Check for libpython. #
664# --------------------- #
665
d57a3c85 666dnl Utility to simplify finding libpython.
71737c43 667dnl $1 = the shell variable to assign the result to
ec685c5e 668dnl If libpython is found we store $version here.
71737c43
CB
669dnl $2 = additional flags to add to CPPFLAGS
670dnl $3 = additional flags to add to LIBS
ec685c5e 671
d57a3c85
TJB
672AC_DEFUN([AC_TRY_LIBPYTHON],
673[
71737c43
CB
674 define([have_libpython_var],$1)
675 new_CPPFLAGS=$2
676 new_LIBS=$3
677 AC_MSG_CHECKING([for python])
ec685c5e 678 save_CPPFLAGS=$CPPFLAGS
d57a3c85 679 save_LIBS=$LIBS
ec685c5e 680 CPPFLAGS="$CPPFLAGS $new_CPPFLAGS"
bf27f0e2 681 LIBS="$new_LIBS $LIBS"
ec685c5e 682 found_usable_python=no
d0ac1c44 683 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "Python.h"]],
edae3fd6
SM
684 [[
685 #if PY_MAJOR_VERSION != 3
686 # error "We only support Python 3"
687 #endif
688 Py_Initialize ();
689 ]])],
71737c43 690 [have_libpython_var=yes
ac534cba
JB
691 found_usable_python=yes
692 PYTHON_CPPFLAGS=$new_CPPFLAGS
693 PYTHON_LIBS=$new_LIBS])
694 CPPFLAGS=$save_CPPFLAGS
695 LIBS=$save_LIBS
ec685c5e 696 AC_MSG_RESULT([${found_usable_python}])
d57a3c85
TJB
697])
698
0c4a4063
DE
699dnl There are several different values for --with-python:
700dnl
701dnl no - Don't include python support.
702dnl yes - Include python support, error if it's missing.
703dnl If we find python in $PATH, use it to fetch configure options,
704dnl otherwise assume the compiler can find it with no help from us.
0c4a4063
DE
705dnl auto - Same as "yes", but if python is missing from the system,
706dnl fall back to "no".
707dnl /path/to/python/exec-prefix -
708dnl Use the python located in this directory.
709dnl If /path/to/python/exec-prefix/bin/python exists, use it to find
710dnl the compilation parameters. Otherwise use
711dnl -I/path/to/python/exec-prefix/include,
712dnl -L/path/to/python/exec-prefix/lib.
0c4a4063
DE
713dnl NOTE: This case is historical. It is what was done for 7.0/7.1
714dnl but is deprecated.
715dnl /path/to/python/executable -
716dnl Run python-config.py with this version of python to fetch the
717dnl compilation parameters.
718dnl NOTE: This needn't be the real python executable.
719dnl In a cross-compilation scenario (build != host), this could be
720dnl a shell script that provides what python-config.py provides for
721dnl --ldflags, --includes, --exec-prefix.
722dnl python-executable -
723dnl Find python-executable in $PATH, and then handle the same as
724dnl /path/to/python/executable.
725dnl
726dnl If a python program is specified, it is used to run python-config.py and
727dnl is passed --ldflags, --includes, --exec-prefix.
728
d57a3c85 729AC_ARG_WITH(python,
0c4a4063 730 AS_HELP_STRING([--with-python@<:@=PYTHON@:>@], [include python support (auto/yes/no/<python-program>)]),
d57a3c85
TJB
731 [], [with_python=auto])
732AC_MSG_CHECKING([whether to use python])
733AC_MSG_RESULT([$with_python])
734
735if test "${with_python}" = no; then
736 AC_MSG_WARN([python support disabled; some features may be unavailable.])
737 have_libpython=no
738else
739 case "${with_python}" in
8c85a4e2 740 [[\\/]]* | ?:[[\\/]]*)
0ad6b8ee 741 if test -d "${with_python}"; then
ec685c5e 742 # Assume the python binary is ${with_python}/bin/python.
ec685c5e 743 python_prog="${with_python}/bin/python"
0c4a4063 744 python_prefix=
9c4ea6c5
JB
745 # If python does not exit ${with_python}/bin, then try in
746 # ${with_python}. On Windows/MinGW, this is where the Python
747 # executable is.
748 if test ! -x "${python_prog}"; then
749 python_prog="${with_python}/python"
750 python_prefix=
751 fi
e7a30f46 752 if test ! -x "${python_prog}"; then
ec685c5e
DE
753 # Fall back to gdb 7.0/7.1 behaviour.
754 python_prog=missing
0c4a4063 755 python_prefix=${with_python}
ec685c5e 756 fi
e7a30f46 757 elif test -x "${with_python}"; then
ec685c5e
DE
758 # While we can't run python compiled for $host (unless host == build),
759 # the user could write a script that provides the needed information,
760 # so we support that.
ec685c5e 761 python_prog=${with_python}
0c4a4063 762 python_prefix=
ec685c5e 763 else
5593a99a 764 AC_MSG_ERROR(invalid value for --with-python)
ec685c5e 765 fi
d57a3c85 766 ;;
ec685c5e
DE
767 */*)
768 # Disallow --with-python=foo/bar.
5593a99a 769 AC_MSG_ERROR(invalid value for --with-python)
d57a3c85 770 ;;
ec685c5e
DE
771 *)
772 # The user has either specified auto, yes, or the name of the python
773 # program assumed to be in $PATH.
774 python_prefix=
775 case "${with_python}" in
776 yes | auto)
0ad6b8ee 777 if test "${build}" = "${host}"; then
602d2b52
AB
778 # Look first for 'python', then 'python3'.
779 AC_PATH_PROGS(python_prog_path, [python python3], missing)
ec685c5e
DE
780 if test "${python_prog_path}" = missing; then
781 python_prog=missing
782 else
783 python_prog=${python_prog_path}
784 fi
785 else
786 # Not much we can do except assume the cross-compiler will find the
787 # right files.
788 python_prog=missing
789 fi
790 ;;
791 *)
792 # While we can't run python compiled for $host (unless host == build),
793 # the user could write a script that provides the needed information,
794 # so we support that.
795 python_prog="${with_python}"
796 AC_PATH_PROG(python_prog_path, ${python_prog}, missing)
797 if test "${python_prog_path}" = missing; then
5593a99a 798 AC_MSG_ERROR(unable to find python program ${python_prog})
ec685c5e
DE
799 fi
800 ;;
801 esac
d57a3c85
TJB
802 esac
803
ec685c5e 804 if test "${python_prog}" != missing; then
e7a30f46
DE
805 # We have a python program to use, but it may be too old.
806 # Don't flag an error for --with-python=auto (the default).
807 have_python_config=yes
ec685c5e
DE
808 python_includes=`${python_prog} ${srcdir}/python/python-config.py --includes`
809 if test $? != 0; then
e7a30f46
DE
810 have_python_config=failed
811 if test "${with_python}" != auto; then
5593a99a 812 AC_MSG_ERROR(failure running python-config --includes)
e7a30f46 813 fi
d57a3c85 814 fi
ec685c5e
DE
815 python_libs=`${python_prog} ${srcdir}/python/python-config.py --ldflags`
816 if test $? != 0; then
e7a30f46
DE
817 have_python_config=failed
818 if test "${with_python}" != auto; then
5593a99a 819 AC_MSG_ERROR(failure running python-config --ldflags)
e7a30f46 820 fi
ec685c5e 821 fi
0c4a4063
DE
822 python_prefix=`${python_prog} ${srcdir}/python/python-config.py --exec-prefix`
823 if test $? != 0; then
e7a30f46
DE
824 have_python_config=failed
825 if test "${with_python}" != auto; then
5593a99a 826 AC_MSG_ERROR(failure running python-config --exec-prefix)
e7a30f46 827 fi
0c4a4063 828 fi
ec685c5e 829 else
ac534cba
JB
830 # We do not have a python executable we can use to determine where
831 # to find the Python headers and libs. We cannot guess the include
832 # path from the python_prefix either, because that include path
833 # depends on the Python version. So, there is nothing much we can
834 # do except assume that the compiler will be able to find those files.
835 python_includes=
836 python_libs=
0c4a4063 837 have_python_config=no
d57a3c85 838 fi
ec685c5e 839
ec685c5e
DE
840 # If we have python-config, only try the configuration it provides.
841 # Otherwise fallback on the old way of trying different versions of
842 # python in turn.
843
844 have_libpython=no
845 if test "${have_python_config}" = yes; then
71737c43
CB
846 AC_TRY_LIBPYTHON(have_libpython,
847 ${python_includes}, ${python_libs})
d57a3c85 848 fi
ec685c5e
DE
849
850 if test "${have_libpython}" = no; then
d57a3c85
TJB
851 case "${with_python}" in
852 yes)
853 AC_MSG_ERROR([python is missing or unusable])
854 ;;
855 auto)
856 AC_MSG_WARN([python is missing or unusable; some features may be unavailable.])
857 ;;
858 *)
859 AC_MSG_ERROR([no usable python found at ${with_python}])
860 ;;
861 esac
0c4a4063
DE
862 else
863 if test -n "${python_prefix}"; then
864 AC_DEFINE_UNQUOTED(WITH_PYTHON_PATH, "${python_prefix}",
865 [Define if --with-python provides a path, either directly or via python-config.py --exec-prefix.])
866 GDB_AC_DEFINE_RELOCATABLE(PYTHON_PATH, python, ${python_prefix})
867 fi
d57a3c85
TJB
868 fi
869fi
870
d13c7322
AB
871dnl Use --with-python-libdir to control where GDB looks for the Python
872dnl libraries.
873dnl
874dnl If this is not given then the default will be based on the value
875dnl passed to --with-python, which is in the python_prefix variable.
876dnl If the --with-python option wasn't given then the default value in
877dnl python_prefix is based on running the 'gdb/python/python-config
878dnl --exec-prefix' script.
879AC_ARG_WITH(python-libdir,
880 AS_HELP_STRING([--with-python-libdir@<:@=DIR@:>@], [search for python's libraries in DIR]),
881 [],[
882 # If no python libdir is specified then select one based on
883 # python's prefix path.
884 if test -n "${python_prefix}"; then
885 with_python_libdir=${python_prefix}/lib
886 fi
887 ])
888
ec685c5e 889if test "${have_libpython}" != no; then
d57a3c85
TJB
890 AC_DEFINE(HAVE_PYTHON, 1, [Define if Python interpreter is being linked in.])
891 CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_PYTHON_OBS)"
892 CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_PYTHON_DEPS)"
893 CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_PYTHON_SRCS)"
94f7449c 894 CONFIG_INSTALL="$CONFIG_INSTALL install-python"
d57a3c85
TJB
895 ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_PYTHON_CFLAGS)"
896
d13c7322
AB
897 if test -n "${with_python_libdir}"; then
898 AC_DEFINE_UNQUOTED(WITH_PYTHON_LIBDIR, "${with_python_libdir}",
899 [Directory containing Python's standard libraries from --with-python-libdir.])
900 GDB_AC_DEFINE_RELOCATABLE(PYTHON_LIBDIR, [python lib], ${with_python_libdir})
901 fi
902
d57a3c85
TJB
903 # Flags needed to compile Python code (taken from python-config --cflags).
904 # We cannot call python-config directly because it will output whatever was
905 # used when compiling the Python interpreter itself, including flags which
906 # would make the python-related objects be compiled differently from the
907 # rest of GDB (e.g., -O2 and -fPIC).
908 if test "${GCC}" = yes; then
ae292b3a
TT
909 tentative_python_cflags="-fno-strict-aliasing -fwrapv"
910 # Python headers recommend -DNDEBUG, but it's unclear if that just
911 # refers to building Python itself. In release mode, though, it
912 # doesn't hurt for the Python code in gdb to follow.
913 $development || tentative_python_cflags="$tentative_python_cflags -DNDEBUG"
d57a3c85
TJB
914 fi
915
916 if test "x${tentative_python_cflags}" != x; then
917 AC_MSG_CHECKING(compiler flags for python code)
918 for flag in ${tentative_python_cflags}; do
919 # Check that the compiler accepts it
920 saved_CFLAGS="$CFLAGS"
921 CFLAGS="$CFLAGS $flag"
5593a99a
SM
922 AC_COMPILE_IFELSE(
923 [AC_LANG_PROGRAM([], [])],
924 [PYTHON_CFLAGS="${PYTHON_CFLAGS} $flag"],
925 []
926 )
d57a3c85
TJB
927 CFLAGS="$saved_CFLAGS"
928 done
929 AC_MSG_RESULT(${PYTHON_CFLAGS})
930 fi
043b6510 931
c83393b9
JB
932 # On x64 Windows, Python's include headers, and pyconfig.h in
933 # particular, rely on MS_WIN64 macro to detect that it's a 64bit
934 # version of Windows. Unfortunately, MS_WIN64 is only defined if
935 # _MSC_VER, a Microsoft-specific macro, is defined. So, when
936 # building on x64 Windows with GCC, we define MS_WIN64 ourselves.
937 # The issue was reported to the Python community, but still isn't
938 # solved as of 2012-10-02 (http://bugs.python.org/issue4709).
939
043b6510 940 case "$gdb_host" in
c83393b9
JB
941 mingw64)
942 if test "${GCC}" = yes; then
943 CPPFLAGS="$CPPFLAGS -DMS_WIN64"
944 fi
945 ;;
043b6510 946 esac
d57a3c85 947else
6dddc817
DE
948 # Even if Python support is not compiled in, we need to have this file
949 # included so that the "python" command, et.al., still exists.
8fd8d003 950 CONFIG_OBS="$CONFIG_OBS python/python.o"
6dddc817 951 CONFIG_SRCS="$CONFIG_SRCS python/python.c"
d57a3c85 952fi
a4a1c157
PA
953
954# Work around Python http://bugs.python.org/issue10112. See also
955# http://bugs.python.org/issue11410, otherwise -Wl,--dynamic-list has
956# no effect. Note that the only test after this that uses Python is
957# the -rdynamic/-Wl,--dynamic-list test, and we do want that one to be
958# run without -export-dynamic too.
959PYTHON_LIBS=`echo $PYTHON_LIBS | sed -e 's/-Xlinker -export-dynamic//'`
960
d57a3c85 961AC_SUBST(PYTHON_CFLAGS)
ac534cba
JB
962AC_SUBST(PYTHON_CPPFLAGS)
963AC_SUBST(PYTHON_LIBS)
4df42755 964AM_CONDITIONAL(HAVE_PYTHON, test "${have_libpython}" != no)
d57a3c85 965
ed3ef339
DE
966# -------------------- #
967# Check for libguile. #
968# -------------------- #
969
ed3ef339
DE
970dnl Utility to simplify finding libguile.
971dnl $1 = pkg-config-program
972dnl $2 = space-separate list of guile versions to try
973dnl $3 = yes|no, indicating whether to flag errors or ignore them
974dnl $4 = the shell variable to assign the result to
975dnl If libguile is found we store "yes" here.
976
977AC_DEFUN([AC_TRY_LIBGUILE],
978[
979 pkg_config=$1
980 guile_version_list=$2
981 flag_errors=$3
982 define([have_libguile_var],$4)
ed3ef339
DE
983 found_usable_guile=checking
984 AC_MSG_CHECKING([for usable guile from ${pkg_config}])
985 for guile_version in ${guile_version_list}; do
986 ${pkg_config} --exists ${guile_version} 2>/dev/null
987 if test $? != 0; then
988 continue
989 fi
990 dnl pkg-config says the package exists, so if we get an error now,
991 dnl that's bad.
992 new_CPPFLAGS=`${pkg_config} --cflags ${guile_version}`
993 if test $? != 0; then
e1402065 994 AC_MSG_ERROR([failure running pkg-config --cflags ${guile_version}])
ed3ef339
DE
995 fi
996 new_LIBS=`${pkg_config} --libs ${guile_version}`
997 if test $? != 0; then
e1402065 998 AC_MSG_ERROR([failure running pkg-config --libs ${guile_version}])
ed3ef339
DE
999 fi
1000 dnl If we get this far, great.
1001 found_usable_guile=${guile_version}
1002 break
1003 done
1004 if test "${found_usable_guile}" = "checking"; then
1005 if test "${flag_errors}" = "yes"; then
e1402065 1006 AC_MSG_ERROR([unable to find usable guile version from "${guile_version_list}"])
ed3ef339
DE
1007 else
1008 found_usable_guile=no
1009 fi
1010 fi
1011 dnl One final sanity check.
1012 dnl The user could have said --with-guile=python-2.7.
1013 if test "${found_usable_guile}" != no; then
1014 save_CPPFLAGS=$CPPFLAGS
1015 save_LIBS=$LIBS
1016 CPPFLAGS="$CPPFLAGS $new_CPPFLAGS"
1017 LIBS="$LIBS $new_LIBS"
d0ac1c44
SM
1018 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "libguile.h"]],
1019 [[scm_init_guile ();]])],
ed3ef339
DE
1020 [have_libguile_var=yes
1021 GUILE_CPPFLAGS=$new_CPPFLAGS
1022 GUILE_LIBS=$new_LIBS],
1023 [found_usable_guile=no])
92fab5a6
AW
1024 dnl scm_set_automatic_finalization_enabled added in Guile 2.2.
1025 AC_CHECK_FUNC(scm_set_automatic_finalization_enabled,
1026 AC_DEFINE(HAVE_GUILE_MANUAL_FINALIZATION, 1,
1027 [Define if Guile supports manual finalization.])
1028 )
ed3ef339
DE
1029 CPPFLAGS=$save_CPPFLAGS
1030 LIBS=$save_LIBS
1031 if test "${found_usable_guile}" = no; then
1032 if test "${flag_errors}" = yes; then
e1402065 1033 AC_MSG_FAILURE([linking guile version ${guile_version} test program failed])
ed3ef339
DE
1034 fi
1035 fi
1036 fi
1037 AC_MSG_RESULT([${found_usable_guile}])
1038])
1039
1040dnl There are several different values for --with-guile:
1041dnl
1042dnl no - Don't include guile support.
1043dnl yes - Include guile support, error if it's missing.
1044dnl The pkg-config program must be in $PATH.
1045dnl auto - Same as "yes", but if guile is missing from the system,
1046dnl fall back to "no".
1047dnl guile-version [guile-version-choice-2 ...] -
1048dnl A space-separated list of guile package versions to try.
1049dnl These are passed to pkg-config as-is.
1050dnl E.g., guile-2.0 or guile-2.2-uninstalled
1051dnl This requires making sure PKG_CONFIG_PATH is set appropriately.
1052dnl /path/to/pkg-config -
1053dnl Use this pkg-config program.
1054dnl NOTE: This needn't be the "real" pkg-config program.
1055dnl It could be a shell script. It is invoked as:
1056dnl pkg-config --exists $version
1057dnl pkg-config --cflags $version
1058dnl pkg-config --libs $version
d342a0da
DE
1059dnl pkg-config --variable guild $version
1060dnl The script will be called with $version having each value in
1061dnl $try_guile_versions until --exists indicates success.
ed3ef339
DE
1062
1063AC_ARG_WITH(guile,
1064 AS_HELP_STRING([--with-guile@<:@=GUILE@:>@], [include guile support (auto/yes/no/<guile-version>/<pkg-config-program>)]),
1065 [], [with_guile=auto])
1066AC_MSG_CHECKING([whether to use guile])
1067AC_MSG_RESULT([$with_guile])
1068
e1402065
DE
1069dnl We check guile with pkg-config.
1070AC_PATH_PROG(pkg_config_prog_path, pkg-config, missing)
1071
ae5369e7 1072try_guile_versions="guile-3.0 guile-2.2 guile-2.0"
ed3ef339
DE
1073have_libguile=no
1074case "${with_guile}" in
1075no)
1076 AC_MSG_WARN([guile support disabled; some features will be unavailable.])
1077 ;;
1078auto)
e1402065
DE
1079 if test "${pkg_config_prog_path}" = "missing"; then
1080 AC_MSG_WARN([pkg-config not found, guile support disabled])
1081 else
1082 AC_TRY_LIBGUILE(${pkg_config_prog_path}, ${try_guile_versions}, no, have_libguile)
1083 fi
ed3ef339
DE
1084 ;;
1085yes)
e1402065
DE
1086 if test "${pkg_config_prog_path}" = "missing"; then
1087 AC_MSG_ERROR([pkg-config not found])
1088 fi
ed3ef339
DE
1089 AC_TRY_LIBGUILE(${pkg_config_prog_path}, ${try_guile_versions}, yes, have_libguile)
1090 ;;
1091[[\\/]]* | ?:[[\\/]]*)
e1402065
DE
1092 if test -x "${with_guile}"; then
1093 AC_TRY_LIBGUILE(${with_guile}, ${try_guile_versions}, yes, have_libguile)
1094 else
1095 AC_MSG_ERROR([Guile config program not executable: ${with_guile}])
1096 fi
ed3ef339
DE
1097 ;;
1098"" | */*)
1099 # Disallow --with=guile="" and --with-guile=foo/bar.
e1402065 1100 AC_MSG_ERROR([invalid value for --with-guile])
ed3ef339
DE
1101 ;;
1102*)
1103 # A space separate list of guile versions to try, in order.
e1402065
DE
1104 if test "${pkg_config_prog_path}" = "missing"; then
1105 AC_MSG_ERROR([pkg-config not found])
1106 fi
ed3ef339
DE
1107 AC_TRY_LIBGUILE(${pkg_config_prog_path}, ${with_guile}, yes, have_libguile)
1108 ;;
1109esac
1110
e76c5d17
DE
1111if test "${have_libguile}" != no; then
1112 dnl Get the name of the 'guild' program.
d342a0da
DE
1113 case "${with_guile}" in
1114 [[\\/]]* | ?:[[\\/]]*)
1115 GDB_GUILE_PROGRAM_NAMES(["${with_guile}"], ["${guile_version}"])
1116 ;;
1117 *)
1118 GDB_GUILE_PROGRAM_NAMES(["${pkg_config_prog_path}"], ["${guile_version}"])
1119 ;;
1120 esac
e76c5d17
DE
1121
1122 dnl Make sure guild can handle this host.
1123 GDB_TRY_GUILD([$srcdir/guile/lib/gdb/support.scm])
1124 dnl If not, disable guile support.
1125 if test "$ac_cv_guild_ok" = no; then
1126 have_libguile=no
1127 AC_MSG_WARN(disabling guile support, $GUILD fails compiling for $host)
1128 fi
1129fi
1130
ed3ef339
DE
1131if test "${have_libguile}" != no; then
1132 AC_DEFINE(HAVE_GUILE, 1, [Define if Guile interpreter is being linked in.])
1133 CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_GUILE_OBS)"
1134 CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_GUILE_DEPS)"
1135 CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_GUILE_SRCS)"
1136 CONFIG_INSTALL="$CONFIG_INSTALL install-guile"
1137 ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_GUILE_CFLAGS)"
16954d5d
LC
1138
1139 dnl The 'scm_new_smob' function appeared in Guile 2.0.6.
1140 save_LIBS="$LIBS"
1141 save_CPPFLAGS="$CPPFLAGS"
1142 LIBS="$GUILE_LIBS"
1143 CPPFLAGS="$GUILE_CPPFLAGS"
1144 AC_CHECK_FUNCS([scm_new_smob])
1145 LIBS="$save_LIBS"
1146 CPPFLAGS="$save_CPPFLAGS"
ed3ef339
DE
1147else
1148 # Even if Guile support is not compiled in, we need to have these files
1149 # included.
bd810fff 1150 CONFIG_OBS="$CONFIG_OBS guile/guile.o"
ed3ef339
DE
1151 CONFIG_SRCS="$CONFIG_SRCS guile/guile.c"
1152fi
1153AC_SUBST(GUILE_CPPFLAGS)
1154AC_SUBST(GUILE_LIBS)
4df42755 1155AM_CONDITIONAL(HAVE_GUILE, test "${have_libguile}" != no)
ed3ef339 1156
62f29fda
TT
1157# ---------------------------- #
1158# Check for source highlight. #
1159# ---------------------------- #
1160
1161SRCHIGH_LIBS=
1162SRCHIGH_CFLAGS=
189b8c2e 1163
4fd404c2
SM
1164AC_ARG_ENABLE([source-highlight],
1165 [AS_HELP_STRING([--enable-source-highlight],
1166 [enable source-highlight for source listings])],
1167 [GDB_CHECK_YES_NO_AUTO_VAL([$enableval], [--enable-source-highlight])],
1168 [enable_source_highlight=auto])
189b8c2e
ST
1169
1170if test "${enable_source_highlight}" != "no"; then
1171 AC_MSG_CHECKING([for the source-highlight library])
1172 if test "${pkg_config_prog_path}" = "missing"; then
1173 AC_MSG_RESULT([no - pkg-config not found])
1174 if test "${enable_source_highlight}" = "yes"; then
1175 AC_MSG_ERROR([pkg-config was not found in your system])
1176 fi
1177 else
0455b7d3
BE
1178 if ${pkg_config_prog_path} --exists source-highlight; then
1179 case "$LDFLAGS" in
1180 *static-libstdc*)
1181 AC_MSG_ERROR([source highlight is incompatible with -static-libstdc++; dnl
d806ea2d
TT
1182either use --disable-source-highlight or dnl
1183--without-static-standard-libraries])
0455b7d3
BE
1184 ;;
1185 esac
d806ea2d 1186
0f8f2de1
TV
1187 srchigh_pkg_cflags=`${pkg_config_prog_path} --cflags source-highlight`
1188 srchigh_pkg_libs=`${pkg_config_prog_path} --libs source-highlight`
1189
1190 # Now that we have found a source-highlight library, check if we can use
1191 # it. In particular, we're trying to detect the situation that the
1192 # library is using the new libstdc++ library abi ( see
1193 # https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )
1194 # while the compiler being used to compile gdb is using the old abi.
1195 # Such a situation will result in an undefined reference to
1196 # srchilite::SourceHighlight::SourceHighlight(std::string const&).
1197 # This situation can occur for instance when using a source highlight
1198 # library compiled with g++ 7.5.0 while building gdb with g++ 4.8.5.
1199 AC_LANG_PUSH(C++)
6a8fe633
RK
1200 save_CXXFLAGS="$CXXFLAGS"
1201 save_LIBS="$LIBS"
1202 CXXFLAGS="$CXXFLAGS $srchigh_pkg_cflags"
1203 LIBS="$LIBS $srchigh_pkg_libs"
0f8f2de1
TV
1204 AC_LINK_IFELSE(
1205 [AC_LANG_PROGRAM(
1206 [#include <srchilite/sourcehighlight.h>],
1207 [std::string outlang = "esc.outlang";
1208 new srchilite::SourceHighlight (outlang);]
1209 )],
1210 [have_usable_source_highlight=yes],
1211 [have_usable_source_highlight=no]
1212 )
6a8fe633
RK
1213 CXXFLAGS="$save_CXXFLAGS"
1214 LIBS="$save_LIBS"
0f8f2de1
TV
1215 AC_LANG_POP(C++)
1216
1217 if test "${have_usable_source_highlight}" = "yes"; then
1218 AC_DEFINE([HAVE_SOURCE_HIGHLIGHT], 1,
1219 [Define to 1 if the source-highlight library is available])
1220 AC_MSG_RESULT([yes])
1221 SRCHIGH_CFLAGS="$srchigh_pkg_cflags"
1222 SRCHIGH_LIBS="$srchigh_pkg_libs"
1223 else
1224 AC_MSG_RESULT([no])
1225 if test "${enable_source_highlight}" = "yes"; then
1226 AC_MSG_ERROR([source-highlight in your system could not be used])
1227 fi
1228 fi
189b8c2e 1229 else
62f29fda 1230 AC_MSG_RESULT([no])
189b8c2e
ST
1231 if test "${enable_source_highlight}" = "yes"; then
1232 AC_MSG_ERROR([source-highlight was not found in your system])
1233 fi
1234 fi
1235 fi
62f29fda
TT
1236fi
1237AC_SUBST(SRCHIGH_LIBS)
1238AC_SUBST(SRCHIGH_CFLAGS)
1239
5ee754fc
MK
1240# ------------------------- #
1241# Checks for header files. #
1242# ------------------------- #
c906108c
SS
1243
1244AC_HEADER_STDC
a9322a30 1245# elf_hp.h is for HP/UX 64-bit shared library support.
8ae8e197 1246AC_CHECK_HEADERS([nlist.h machine/reg.h \
05ea2a05 1247 thread_db.h \
a9322a30 1248 sys/file.h sys/filio.h sys/ioctl.h sys/param.h \
09db4332 1249 sys/procctl.h sys/resource.h sys/ptrace.h ptrace.h \
8ae8e197 1250 sys/reg.h sys/debugreg.h \
2d41fa11 1251 termios.h elf_hp.h])
7cb9022a
MK
1252AC_CHECK_HEADERS(sys/user.h, [], [],
1253[#if HAVE_SYS_PARAM_H
1254# include <sys/param.h>
1255#endif
1256])
5ee754fc 1257
5007d765 1258AC_CHECK_HEADERS(curses.h cursesX.h ncurses.h ncursesw/ncurses.h ncurses/ncurses.h ncurses/term.h)
c401b55a
MK
1259AC_CHECK_HEADERS(term.h, [], [],
1260[#if HAVE_CURSES_H
1261# include <curses.h>
1262#endif
1263])
5ee754fc 1264
95420d30 1265AC_CHECK_HEADERS([sys/socket.h])
05a6b8c2 1266AC_CHECK_HEADERS([ws2tcpip.h])
6aa4f97c 1267AC_CHECK_HEADERS([execinfo.h])
05a6b8c2 1268
b9362cc7
AC
1269# ------------------------- #
1270# Checks for declarations. #
1271# ------------------------- #
1272
07697489
PA
1273libiberty_INIT
1274
29d17e47 1275AC_CHECK_DECLS([snprintf])
a8111142 1276AM_LC_MESSAGES
b9362cc7 1277
5ee754fc
MK
1278# ------------------ #
1279# Checks for types. #
1280# ------------------ #
c906108c 1281
f9f87d2c
MK
1282AC_CHECK_TYPES(socklen_t, [], [],
1283[#include <sys/types.h>
05a6b8c2
EZ
1284#if HAVE_SYS_SOCKET_H
1285# include <sys/socket.h>
1286#elif HAVE_WS2TCPIP_H
1287# include <ws2tcpip.h>
1288#endif
f9f87d2c 1289])
5ee754fc
MK
1290
1291# ------------------------------------- #
1292# Checks for compiler characteristics. #
1293# ------------------------------------- #
c906108c
SS
1294
1295AC_C_CONST
bce58c09 1296AC_C_INLINE
9b913628 1297AC_C_BIGENDIAN
c906108c 1298
5ee754fc
MK
1299# ------------------------------ #
1300# Checks for library functions. #
1301# ------------------------------ #
1302
05ea2a05 1303AC_CHECK_FUNCS([getuid getgid \
8ae8e197 1304 pipe pread pread64 pwrite resize_term \
05ea2a05 1305 getpgid setsid \
c12d372d 1306 sigaction sigsetmask socketpair \
110ed339 1307 ttrace wborder wresize setlocale iconvlist libiconvlist btowc \
3332aaf2 1308 setrlimit getrlimit posix_madvise waitpid \
05ea2a05 1309 use_default_colors])
6c7a06a3 1310AM_LANGINFO_CODESET
3266f10b 1311GDB_AC_COMMON
97bf5e38 1312
eb7aa561
PA
1313# Check the return and argument types of ptrace.
1314GDB_AC_PTRACE
086ec9eb 1315
72473524
DJ
1316dnl AC_FUNC_SETPGRP does not work when cross compiling
1317dnl Instead, assume we will have a prototype for setpgrp if cross compiling.
1318if test "$cross_compiling" = no; then
1319 AC_FUNC_SETPGRP
1320else
5593a99a
SM
1321 AC_CACHE_CHECK(
1322 [whether setpgrp takes no argument],
1323 [ac_cv_func_setpgrp_void],
1324 [AC_COMPILE_IFELSE(
1325 [AC_LANG_PROGRAM(
1326 [#include <unistd.h>],
1327 [if (setpgrp(1,1) == -1)
1328 exit (0);
1329 else
1330 exit (1);]
1331 )],
1332 [ac_cv_func_setpgrp_void=no],
1333 [ac_cv_func_setpgrp_void=yes]
1334 )]
1335 )
0ad6b8ee 1336if test "$ac_cv_func_setpgrp_void" = yes; then
72473524
DJ
1337 AC_DEFINE(SETPGRP_VOID, 1)
1338fi
1339fi
c906108c 1340
5c45e068
MK
1341# Check if <sys/proc.h> defines `struct thread' with a td_pcb member.
1342AC_CHECK_MEMBERS([struct thread.td_pcb], [], [],
1343[#include <sys/param.h>
1344#include <sys/proc.h>
1345])
70f9f479 1346
da7d81e3 1347# See if <sys/lwp.h> defines `struct lwp`.
5593a99a
SM
1348AC_CACHE_CHECK(
1349 [for struct lwp],
1350 [gdb_cv_struct_lwp],
1351 [AC_COMPILE_IFELSE(
1352 [AC_LANG_PROGRAM(
1353 [#include <sys/param.h>
1354 #define _KMEMUSER
1355 #include <sys/lwp.h>],
1356 [struct lwp l;]
1357 )],
1358 [gdb_cv_struct_lwp=yes],
1359 [gdb_cv_struct_lwp=no]
1360 )]
1361)
0ad6b8ee 1362if test "$gdb_cv_struct_lwp" = yes; then
da7d81e3
NW
1363 AC_DEFINE(HAVE_STRUCT_LWP, 1,
1364 [Define to 1 if your system has struct lwp.])
1365fi
1366
78434e59 1367# See if <machine/reg.h> degines `struct reg'.
5593a99a
SM
1368AC_CACHE_CHECK(
1369 [for struct reg in machine/reg.h],
1370 [gdb_cv_struct_reg],
1371 [AC_COMPILE_IFELSE(
1372 [AC_LANG_PROGRAM(
1373 [#include <sys/types.h>
1374 #include <machine/reg.h>],
1375 [struct reg r;]
1376 )],
1377 [gdb_cv_struct_reg=yes],
1378 [gdb_cv_struct_reg=no]
1379 )]
1380)
0ad6b8ee 1381if test "$gdb_cv_struct_reg" = yes; then
78434e59
MK
1382 AC_DEFINE(HAVE_STRUCT_REG, 1,
1383 [Define to 1 if your system has struct reg in <machine/reg.h>.])
1384fi
1385
0afdd437 1386# See if <machine/reg.h> supports the %fs and %gs i386 segment registers.
7dfa765c 1387# Older i386 BSD's don't have the r_fs and r_gs members of `struct reg'.
5c45e068 1388AC_CHECK_MEMBERS([struct reg.r_fs, struct reg.r_gs], [], [],
a6e69c1f
JB
1389 [#include <sys/types.h>
1390#include <machine/reg.h>])
7dfa765c 1391
0afdd437 1392# See if <sys/ptrace.h> provides the PTRACE_GETREGS request.
f60300e7 1393AC_MSG_CHECKING(for PTRACE_GETREGS)
5593a99a
SM
1394AC_CACHE_VAL(
1395 [gdb_cv_have_ptrace_getregs],
1396 [AC_COMPILE_IFELSE(
1397 [AC_LANG_PROGRAM([#include <sys/ptrace.h>], [PTRACE_GETREGS;])],
1398 [gdb_cv_have_ptrace_getregs=yes],
1399 [gdb_cv_have_ptrace_getregs=no]
1400 )]
1401)
f60300e7 1402AC_MSG_RESULT($gdb_cv_have_ptrace_getregs)
0ad6b8ee 1403if test "$gdb_cv_have_ptrace_getregs" = yes; then
4869db5e 1404 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
60ca704f 1405 [Define if sys/ptrace.h defines the PTRACE_GETREGS request.])
f60300e7
MK
1406fi
1407
0afdd437 1408# See if <sys/ptrace.h> provides the PTRACE_GETFPXREGS request.
6ce2ac0b 1409AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
5593a99a
SM
1410AC_CACHE_VAL(
1411 [gdb_cv_have_ptrace_getfpxregs],
1412 [AC_COMPILE_IFELSE(
1413 [AC_LANG_PROGRAM([#include <sys/ptrace.h>], [PTRACE_GETFPXREGS;])],
1414 [gdb_cv_have_ptrace_getfpxregs=yes],
1415 [gdb_cv_have_ptrace_getfpxregs=no]
1416 )]
1417)
6ce2ac0b 1418AC_MSG_RESULT($gdb_cv_have_ptrace_getfpxregs)
0ad6b8ee 1419if test "$gdb_cv_have_ptrace_getfpxregs" = yes; then
60ca704f
SE
1420 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
1421 [Define if sys/ptrace.h defines the PTRACE_GETFPXREGS request.])
5c44784c
JM
1422fi
1423
0afdd437
MK
1424# See if <sys/ptrace.h> provides the PT_GETDBREGS request.
1425AC_MSG_CHECKING(for PT_GETDBREGS)
5593a99a
SM
1426AC_CACHE_VAL(
1427 [gdb_cv_have_pt_getdbregs],
1428 [AC_COMPILE_IFELSE(
1429 [AC_LANG_PROGRAM(
1430 [#include <sys/types.h>
1431 #include <sys/ptrace.h>],
1432 [PT_GETDBREGS;]
1433 )],
1434 [gdb_cv_have_pt_getdbregs=yes],
1435 [gdb_cv_have_pt_getdbregs=no]
1436 )]
1437)
0afdd437 1438AC_MSG_RESULT($gdb_cv_have_pt_getdbregs)
0ad6b8ee 1439if test "$gdb_cv_have_pt_getdbregs" = yes; then
60ca704f
SE
1440 AC_DEFINE(HAVE_PT_GETDBREGS, 1,
1441 [Define if sys/ptrace.h defines the PT_GETDBREGS request.])
0afdd437
MK
1442fi
1443
6e9567fe
JB
1444# See if <sys/ptrace.h> supports LWP names on FreeBSD
1445# Older FreeBSD versions don't have the pl_tdname member of
1446# `struct ptrace_lwpinfo'.
1447AC_CHECK_MEMBERS([struct ptrace_lwpinfo.pl_tdname], [], [],
1448 [#include <sys/ptrace.h>])
1449
e6cdd38e
JB
1450# See if <sys/ptrace.h> supports syscall fields on FreeBSD. The
1451# pl_syscall_code member of `struct ptrace_lwpinfo' was added in
1452# FreeBSD 10.3.
1453AC_CHECK_MEMBERS([struct ptrace_lwpinfo.pl_syscall_code], [], [],
1454 [#include <sys/ptrace.h>])
6e9567fe 1455
bc8bcb4b
MK
1456# Check if the compiler supports the `long long' type.
1457
1458AC_CACHE_CHECK([for long long support in compiler], gdb_cv_c_long_long,
1459 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1460[[extern long long foo;]],
1461[[switch (foo & 2) { case 0: return 1; }]])],
1462 gdb_cv_c_long_long=yes,
1463 gdb_cv_c_long_long=no)])
0ad6b8ee 1464if test "$gdb_cv_c_long_long" != yes; then
74a0d9f6
JK
1465 # libdecnumber requires long long.
1466 AC_MSG_ERROR([Compiler must support long long for GDB.])
c906108c
SS
1467fi
1468
1a619819
LM
1469# Check if the compiler and runtime support printing decfloats.
1470
1471AC_CACHE_CHECK([for decfloat support in printf],
1472 gdb_cv_printf_has_decfloat,
1473 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1474[[char buf[64];
1475 _Decimal32 d32 = 1.2345df;
1476 _Decimal64 d64 = 1.2345dd;
1477 _Decimal128 d128 = 1.2345dl;
1478 sprintf (buf, "Decimal32: %H\nDecimal64: %D\nDecimal128: %DD", d32, d64, d128);
1479 return (strcmp ("Decimal32: 1.2345\nDecimal64: 1.2345\nDecimal128: 1.2345", buf));]])],
1480 gdb_cv_printf_has_decfloat=yes,
1481 gdb_cv_printf_has_decfloat=no,
1482 gdb_cv_printf_has_decfloat=no)])
0ad6b8ee 1483if test "$gdb_cv_printf_has_decfloat" = yes; then
1a619819
LM
1484 AC_DEFINE(PRINTF_HAS_DECFLOAT, 1,
1485 [Define to 1 if the "%H, %D and %DD" formats work to print decfloats.])
1486fi
1487
bc8bcb4b
MK
1488# Check if the compiler supports the `long double' type. We can't use
1489# AC_C_LONG_DOUBLE because that one does additional checks on the
1490# constants defined in <float.h> that fail on some systems,
1491# e.g. FreeBSD/i386 4.7 and OpenBSD/i386 3.6.
c906108c 1492
bc8bcb4b
MK
1493AC_CACHE_CHECK([for long double support in compiler], gdb_cv_c_long_double,
1494 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[long double foo;]])],
1495 gdb_cv_c_long_double=yes,
1496 gdb_cv_c_long_double=no)])
0ad6b8ee 1497if test "$gdb_cv_c_long_double" = yes; then
bc8bcb4b
MK
1498 AC_DEFINE(HAVE_LONG_DOUBLE, 1,
1499 [Define to 1 if the compiler supports long double.])
c906108c
SS
1500fi
1501
bc8bcb4b 1502# Check if the compiler and runtime support printing long doubles.
c906108c 1503
bc8bcb4b
MK
1504AC_CACHE_CHECK([for long double support in printf],
1505 gdb_cv_printf_has_long_double,
1506 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1507[[char buf[16];
c906108c
SS
1508 long double f = 3.141592653;
1509 sprintf (buf, "%Lg", f);
bc8bcb4b
MK
1510 return (strncmp ("3.14159", buf, 7));]])],
1511 gdb_cv_printf_has_long_double=yes,
1512 gdb_cv_printf_has_long_double=no,
1513 gdb_cv_printf_has_long_double=no)])
0ad6b8ee 1514if test "$gdb_cv_printf_has_long_double" = yes; then
bc8bcb4b
MK
1515 AC_DEFINE(PRINTF_HAS_LONG_DOUBLE, 1,
1516 [Define to 1 if the "%Lg" format works to print long doubles.])
c906108c 1517fi
c906108c 1518
bc8bcb4b 1519# Check if the compiler and runtime support scanning long doubles.
c906108c 1520
4869db5e 1521AC_CACHE_CHECK([for long double support in scanf],
bc8bcb4b
MK
1522 gdb_cv_scanf_has_long_double,
1523 [AC_RUN_IFELSE([AC_LANG_PROGRAM(
1524[[#include <stdio.h>]],
1525[[char *buf = "3.141592653";
c906108c
SS
1526 long double f = 0;
1527 sscanf (buf, "%Lg", &f);
bc8bcb4b
MK
1528 return !(f > 3.14159 && f < 3.14160);]])],
1529 gdb_cv_scanf_has_long_double=yes,
1530 gdb_cv_scanf_has_long_double=no,
1531 gdb_cv_scanf_has_long_double=no)])
0ad6b8ee 1532if test "$gdb_cv_scanf_has_long_double" = yes; then
bc8bcb4b
MK
1533 AC_DEFINE(SCANF_HAS_LONG_DOUBLE, 1,
1534 [Define to 1 if the "%Lg" format works to scan long doubles.])
c906108c 1535fi
c906108c 1536
438013df
AO
1537case ${host_os} in
1538aix*)
5593a99a
SM
1539 AC_CACHE_CHECK(
1540 [for -bbigtoc option], [gdb_cv_bigtoc],
1541 [SAVE_LDFLAGS=$LDFLAGS
1542
1543 case $GCC in
1544 yes) gdb_cv_bigtoc=-Wl,-bbigtoc ;;
1545 *) gdb_cv_bigtoc=-bbigtoc ;;
1546 esac
1547
1548 LDFLAGS=$LDFLAGS\ $gdb_cv_bigtoc
1549 AC_LINK_IFELSE(
1550 [AC_LANG_PROGRAM([], [int i;])],
1551 [],
1552 [gdb_cv_bigtoc=]
1553 )
1554 LDFLAGS="${SAVE_LDFLAGS}"]
1555 )
438013df
AO
1556 CONFIG_LDFLAGS="${CONFIG_LDFLAGS} ${gdb_cv_bigtoc}"
1557 ;;
1558esac
1559
38f6b338
JK
1560AC_MSG_CHECKING(for the dynamic export flag)
1561dynamic_list=false
0407b3f1 1562if test "${gdb_native}" = yes; then
38f6b338
JK
1563 # The dynamically loaded libthread_db needs access to symbols in the gdb
1564 # executable. Older GNU ld supports --export-dynamic but --dynamic-list
1565 # may not be supported there.
1566 old_LDFLAGS="$LDFLAGS"
1567 # Older GNU ld supports --export-dynamic but --dynamic-list it does not.
1568 RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
1569 LDFLAGS="$LDFLAGS $RDYNAMIC"
1570 if test "${have_libpython}" = no; then
5593a99a
SM
1571 AC_LINK_IFELSE(
1572 [AC_LANG_PROGRAM([], [])],
1573 [dynamic_list=true],
1574 []
1575 )
38f6b338
JK
1576 else
1577 # Workaround http://bugs.python.org/issue4434 where static
1578 # libpythonX.Y.a would get its symbols required for
1579 # pythonX.Y/lib-dynload/*.so modules hidden by -Wl,--dynamic-list.
1580 # Problem does not happen for the recommended libpythonX.Y.so linkage.
a4a1c157
PA
1581
1582 # Note the workaround for Python
1583 # http://bugs.python.org/issue10112 earlier has removed
1584 # -export-dynamic from PYTHON_LIBS. That's exactly what we want
1585 # here too, as otherwise it'd make this -Wl,--dynamic-list test
1586 # always pass.
38f6b338
JK
1587 old_CFLAGS="$CFLAGS"
1588 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
8c1fb155
JK
1589 old_LIBS="$LIBS"
1590 LIBS="$LIBS $PYTHON_LIBS"
1b4f615e
PA
1591 old_CPPFLAGS="$CPPFLAGS"
1592 CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
38f6b338 1593 AC_RUN_IFELSE(
d0ac1c44 1594 [AC_LANG_PROGRAM(
1b4f615e 1595 [#include "Python.h"],
38f6b338
JK
1596 [int err;
1597 Py_Initialize ();
3fed4c0b 1598 err = PyRun_SimpleString ("import ctypes\n");
38f6b338 1599 Py_Finalize ();
d0ac1c44 1600 return err == 0 ? 0 : 1;])],
38f6b338 1601 [dynamic_list=true], [], [true])
8c1fb155 1602 LIBS="$old_LIBS"
38f6b338 1603 CFLAGS="$old_CFLAGS"
1b4f615e 1604 CPPFLAGS="$old_CPPFLAGS"
f6528abd 1605 fi
38f6b338
JK
1606 LDFLAGS="$old_LDFLAGS"
1607fi
1608if $dynamic_list; then
1609 found="-Wl,--dynamic-list"
1610 RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'
1611else
1612 found="-rdynamic"
1613 RDYNAMIC="-rdynamic"
0407b3f1 1614fi
38f6b338
JK
1615AC_SUBST(RDYNAMIC)
1616AC_MSG_RESULT($found)
0407b3f1 1617
6aa4f97c
AB
1618AC_CACHE_CHECK(
1619 [whether execinfo.h backtrace is available],
1620 gdb_cv_execinfo_backtrace,
1621 [AC_LINK_IFELSE(
1622 [AC_LANG_PROGRAM(
1623 [
1624 #include <execinfo.h>
1625 ],
1626 [
1627 int f;
1628 void *b[[2]];
1629 f = backtrace (b, 2);
1630 backtrace_symbols_fd (b, f, 2);
1631 ])],
1632 [gdb_cv_execinfo_backtrace=yes],
1633 [gdb_cv_execinfo_backtrace=no])])
1634if test "$gdb_cv_execinfo_backtrace" = yes; then
1635 AC_DEFINE(HAVE_EXECINFO_BACKTRACE, 1,
1636 [Define to 1 if execinfo.h backtrace functions are available.])
1637fi
1638
0407b3f1
AS
1639dnl For certain native configurations, we need to check whether thread
1640dnl support can be built in or not.
1641dnl
1642dnl Note that we only want this if we are both native (host == target),
1643dnl and not doing a canadian cross build (build == host).
f6528abd 1644
0ad6b8ee 1645if test "${build}" = "${host}" -a "${host}" = "${target}" ; then
c906108c 1646 case ${host_os} in
d92419e5
JB
1647 aix*)
1648 AC_MSG_CHECKING(for AiX thread debugging library)
5593a99a
SM
1649 AC_CACHE_VAL(
1650 [gdb_cv_have_aix_thread_debug],
1651 [AC_COMPILE_IFELSE(
1652 [AC_LANG_PROGRAM(
1653 [#include <sys/pthdebug.h>],
1654 [#ifndef PTHDB_VERSION_3
1655 #error
1656 #endif]
1657 )],
1658 [gdb_cv_have_aix_thread_debug=yes],
1659 [gdb_cv_have_aix_thread_debug=no]
1660 )]
1661 )
d92419e5 1662 AC_MSG_RESULT($gdb_cv_have_aix_thread_debug)
0ad6b8ee 1663 if test "$gdb_cv_have_aix_thread_debug" = yes; then
d92419e5 1664 CONFIG_SRCS="${CONFIG_SRCS} aix-thread.c"
3483b318 1665 CONFIG_OBS="${CONFIG_OBS} aix-thread.o"
7f533142 1666 LIBS="$LIBS -lpthdebug"
d645e32e
JB
1667
1668 # Older versions of AIX do not provide the declaration for
1669 # the getthrds function (it appears that it was introduced
1670 # with AIX 6.x).
1671 AC_CHECK_DECLS(getthrds, [], [], [[#include <procinfo.h>]])
d92419e5
JB
1672 fi
1673 ;;
c906108c
SS
1674 esac
1675 AC_SUBST(CONFIG_LDFLAGS)
1676fi
1677
59f80f10
DJ
1678dnl See if we have a thread_db header file that has TD_NOTALLOC and
1679dnl other error codes.
3f47be5c 1680if test "x$ac_cv_header_thread_db_h" = "xyes"; then
5593a99a
SM
1681 AC_CACHE_CHECK(
1682 [whether <thread_db.h> has TD_NOTALLOC],
1683 [gdb_cv_thread_db_h_has_td_notalloc],
1684 [AC_COMPILE_IFELSE(
1685 [AC_LANG_PROGRAM(
1686 [#include <thread_db.h>],
1687 [int i = TD_NOTALLOC;]
1688 )],
1689 [gdb_cv_thread_db_h_has_td_notalloc=yes],
1690 [gdb_cv_thread_db_h_has_td_notalloc=no]
1691 )]
1692 )
1693
1694 AC_CACHE_CHECK(
1695 [whether <thread_db.h> has TD_VERSION],
1696 [gdb_cv_thread_db_h_has_td_version],
1697 [AC_COMPILE_IFELSE(
1698 [AC_LANG_PROGRAM(
1699 [#include <thread_db.h>],
1700 [int i = TD_VERSION;]
1701 )],
1702 [gdb_cv_thread_db_h_has_td_version=yes],
1703 [gdb_cv_thread_db_h_has_td_version=no]
1704 )]
1705 )
1706
1707 AC_CACHE_CHECK(
1708 [whether <thread_db.h> has TD_NOTLS],
1709 [gdb_cv_thread_db_h_has_td_notls],
1710 [AC_COMPILE_IFELSE(
1711 [AC_LANG_PROGRAM(
1712 [#include <thread_db.h>],
1713 [int i = TD_NOTLS;]
1714 )],
1715 [gdb_cv_thread_db_h_has_td_notls=yes],
1716 [gdb_cv_thread_db_h_has_td_notls=no]
1717 )]
1718 )
3f47be5c
EZ
1719fi
1720if test "x$gdb_cv_thread_db_h_has_td_notalloc" = "xyes"; then
1721 AC_DEFINE(THREAD_DB_HAS_TD_NOTALLOC, 1,
1722 [Define if <thread_db.h> has the TD_NOTALLOC error code.])
1723fi
59f80f10
DJ
1724if test "x$gdb_cv_thread_db_h_has_td_version" = "xyes"; then
1725 AC_DEFINE(THREAD_DB_HAS_TD_VERSION, 1,
1726 [Define if <thread_db.h> has the TD_VERSION error code.])
1727fi
1728if test "x$gdb_cv_thread_db_h_has_td_notls" = "xyes"; then
1729 AC_DEFINE(THREAD_DB_HAS_TD_NOTLS, 1,
1730 [Define if <thread_db.h> has the TD_NOTLS error code.])
1731fi
3f47be5c 1732
e655c1a2
PA
1733dnl Set the host's .gdbinit filename.
1734case $host_os in
1735 go32* | *djgpp*)
1736 gdbinit=gdb.ini
1737 ;;
1738 *)
1739 gdbinit=.gdbinit
1740 ;;
1741esac
1742AC_DEFINE_UNQUOTED(GDBINIT,"$gdbinit",[The .gdbinit filename.])
1743
92e4e97a
AB
1744dnl Set the host's .gdbearlyinit filename
1745AC_DEFINE_UNQUOTED(GDBEARLYINIT,".gdbearlyinit",[The .gdbearlyinit filename.])
1746
c906108c 1747dnl Handle optional features that can be enabled.
fb40c209 1748
f83d8a90
DE
1749# Support for --with-sysroot is a copy of GDB_AC_WITH_DIR,
1750# except that the argument to --with-sysroot is optional.
1751# --with-sysroot (or --with-sysroot=yes) sets the default sysroot path.
1752if test "x$with_sysroot" = xyes; then
1753 with_sysroot="${exec_prefix}/${target_alias}/sys-root"
1754fi
030292b7 1755AC_ARG_WITH(sysroot,
f83d8a90
DE
1756 AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@],
1757 [search for usr/lib et al within DIR]),
1758 [TARGET_SYSTEM_ROOT=$withval], [TARGET_SYSTEM_ROOT=])
1759AC_DEFINE_DIR(TARGET_SYSTEM_ROOT, TARGET_SYSTEM_ROOT,
1760 [search for usr/lib et al within DIR])
030292b7 1761AC_SUBST(TARGET_SYSTEM_ROOT)
f83d8a90 1762GDB_AC_DEFINE_RELOCATABLE(TARGET_SYSTEM_ROOT, sysroot, ${ac_define_dir})
030292b7 1763
b14b1491
TT
1764GDB_AC_WITH_DIR(SYSTEM_GDBINIT, system-gdbinit,
1765 [automatically load a system-wide gdbinit file],
1766 [])
ed2a2229
CB
1767GDB_AC_WITH_DIR(SYSTEM_GDBINIT_DIR, system-gdbinit-dir,
1768 [automatically load system-wide gdbinit files from this directory],
1769 [])
16e7150e 1770
4b74833d 1771AM_GDB_COMPILER_TYPE
b835bb52 1772AM_GDB_WARNINGS
f35d5ade 1773AM_GDB_UBSAN
3bc3d82a 1774
7a292a7a
SS
1775# In the Cygwin environment, we need some additional flags.
1776AC_CACHE_CHECK([for cygwin], gdb_cv_os_cygwin,
92a021de 1777[AC_EGREP_CPP(^lose$, [
7a292a7a
SS
1778#if defined (__CYGWIN__) || defined (__CYGWIN32__)
1779lose
1780#endif],[gdb_cv_os_cygwin=yes],[gdb_cv_os_cygwin=no])])
1781
aff38e61
AC
1782
1783dnl Figure out which of the many generic ser-*.c files the _host_ supports.
3eb25fda 1784SER_HARDWIRE="ser-base.o ser-unix.o ser-pipe.o ser-tcp.o"
aff38e61 1785case ${host} in
95cbc983
AC
1786 *go32* ) SER_HARDWIRE=ser-go32.o ;;
1787 *djgpp* ) SER_HARDWIRE=ser-go32.o ;;
0ea3f30e 1788 *mingw32*) SER_HARDWIRE="ser-base.o ser-tcp.o ser-mingw.o" ;;
c1168a2f 1789 *) SER_HARDWIRE="$SER_HARDWIRE ser-uds.o" ;;
aff38e61
AC
1790esac
1791AC_SUBST(SER_HARDWIRE)
1792
cd0fc7c3
SS
1793# libreadline needs libuser32.a in a cygwin environment
1794WIN32LIBS=
0ad6b8ee 1795if test x"$gdb_cv_os_cygwin" = xyes; then
c5394b80
JM
1796 WIN32LIBS="-luser32"
1797 case "${target}" in
1798 *cygwin*) WIN32LIBS="$WIN32LIBS -limagehlp"
1799 ;;
1800 esac
cd0fc7c3 1801fi
b4505029
MM
1802
1803# The ser-tcp.c module requires sockets.
b2ceabe8
TT
1804# Note that WIN32APILIBS is set by GDB_AC_COMMON.
1805WIN32LIBS="$WIN32LIBS $WIN32APILIBS"
7a292a7a 1806
31d99776 1807# Add ELF support to GDB, but only if BFD includes ELF support.
def63ff0
TT
1808GDB_AC_CHECK_BFD([for ELF support in BFD], gdb_cv_var_elf,
1809 [bfd_get_elf_phdr_upper_bound (NULL)], elf-bfd.h)
0ad6b8ee 1810if test "$gdb_cv_var_elf" = yes; then
fb8f3fc0
AB
1811 CONFIG_OBS="$CONFIG_OBS elfread.o stap-probe.o dtrace-probe.o \
1812 gcore-elf.o elf-none-tdep.o"
31d99776
DJ
1813 AC_DEFINE(HAVE_ELF, 1,
1814 [Define if ELF support should be included.])
075ff26d
JK
1815 # -ldl is provided by bfd/Makfile.am (LIBDL) <PLUGINS>.
1816 if test "$plugins" = "yes"; then
a48b32c0 1817 AC_SEARCH_LIBS(dlopen, dl)
075ff26d 1818 fi
31d99776 1819fi
31d99776 1820
4f05add4
TT
1821# Add macho support to GDB, but only if BFD includes it.
1822GDB_AC_CHECK_BFD([for Mach-O support in BFD], gdb_cv_var_macho,
1823 [bfd_mach_o_lookup_command (NULL, 0, NULL)], mach-o.h)
0ad6b8ee 1824if test "$gdb_cv_var_macho" = yes; then
4f05add4
TT
1825 CONFIG_OBS="$CONFIG_OBS machoread.o"
1826fi
1827
121ce6e5
DJ
1828# Add any host-specific objects to GDB.
1829CONFIG_OBS="${CONFIG_OBS} ${gdb_host_obs}"
1830
608e2dbb 1831# If building on ELF, look for lzma support for embedded compressed debug info.
0ad6b8ee 1832if test "$gdb_cv_var_elf" = yes; then
608e2dbb
TT
1833 AC_ARG_WITH(lzma,
1834 AS_HELP_STRING([--with-lzma], [support lzma compression (auto/yes/no)]),
1835 [], [with_lzma=auto])
1836 AC_MSG_CHECKING([whether to use lzma])
1837 AC_MSG_RESULT([$with_lzma])
1838
1839 if test "${with_lzma}" != no; then
1840 AC_LIB_HAVE_LINKFLAGS([lzma], [], [#include "lzma.h"],
1841 [lzma_index_iter iter;
1842 lzma_index_iter_init (&iter, 0);
1843 lzma_mf_is_supported (LZMA_MF_HC3);])
1844 if test "$HAVE_LIBLZMA" != yes; then
1845 if test "$with_lzma" = yes; then
1846 AC_MSG_ERROR([missing liblzma for --with-lzma])
1847 fi
1848 fi
1849 fi
1850fi
1851
3fc11d3e
JM
1852LIBGUI="../libgui/src/libgui.a"
1853GUI_CFLAGS_X="-I${srcdir}/../libgui/src"
1854AC_SUBST(LIBGUI)
1855AC_SUBST(GUI_CFLAGS_X)
7a292a7a 1856
3fc11d3e
JM
1857WIN32LDAPP=
1858AC_SUBST(WIN32LIBS)
1859AC_SUBST(WIN32LDAPP)
1860
d91670b9 1861case "${host}" in
686a5eed 1862*-*-cygwin* | *-*-mingw* )
d91670b9
CV
1863 configdir="win"
1864 ;;
1865*)
1866 configdir="unix"
1867 ;;
1868esac
3fc11d3e
JM
1869
1870GDBTKLIBS=
1871if test "${enable_gdbtk}" = "yes"; then
1872
d1c3b63a
KS
1873 # Gdbtk must have an absolute path to srcdir in order to run
1874 # properly when not installed.
1875 here=`pwd`
1876 cd ${srcdir}
1877 GDBTK_SRC_DIR=`pwd`
1878 cd $here
1879
5062cc19 1880 SC_PATH_TCLCONFIG
85541719
DE
1881
1882 # If $no_tk is nonempty, then we can't do Tk, and there is no
1883 # point to doing Tcl.
1884 SC_PATH_TKCONFIG
1885
1886 if test -z "${no_tcl}" -a -z "${no_tk}"; then
5062cc19
KS
1887 SC_LOAD_TCLCONFIG
1888
1889 # Check for in-tree tcl
1890 here=`pwd`
1891 cd ${srcdir}/..
1892 topdir=`pwd`
1893 cd ${here}
1894
1895 intree="no"
1896 if test "${TCL_SRC_DIR}" = "${topdir}/tcl"; then
1897 intree="yes"
1898 fi
1899
1900 # Find Tcl private headers
1901 if test x"${intree}" = xno; then
1902 CY_AC_TCL_PRIVATE_HEADERS
1903 TCL_INCLUDE="${TCL_INCLUDE_SPEC} ${TCL_PRIVATE_INCLUDE}"
1904 TCL_LIBRARY="${TCL_LIB_SPEC}"
1905 TCL_DEPS=""
1906 else
1907 # If building tcl in the same src tree, private headers
1908 # are not needed, but we need to be sure to use the right
1909 # headers library
4869db5e 1910 TCL_INCLUDE="-I${TCL_SRC_DIR}/generic"
5062cc19
KS
1911 TCL_LIBRARY="${TCL_BUILD_LIB_SPEC}"
1912 TCL_DEPS="../tcl/${configdir}${TCL_LIB_FILE}"
1913 fi
1914 AC_SUBST(TCL_INCLUDE)
1915 AC_SUBST(TCL_LIBRARY)
1916 AC_SUBST(TCL_DEPS)
dd2504ab 1917
85541719
DE
1918 SC_LOAD_TKCONFIG
1919
1920 # Check for in-tree Tk
1921 intree="no"
1922 if test "${TK_SRC_DIR}" = "${topdir}/tk"; then
4869db5e 1923 intree="yes"
85541719
DE
1924 fi
1925
1926 # Find Tk private headers
1927 if test x"${intree}" = xno; then
1928 CY_AC_TK_PRIVATE_HEADERS
1929 TK_INCLUDE="${TK_INCLUDE_SPEC} ${TK_PRIVATE_INCLUDE}"
1930 TK_LIBRARY=${TK_LIB_SPEC}
1931 TK_DEPS=""
1932 else
1933 TK_INCLUDE="-I${TK_SRC_DIR}/generic"
1934 TK_LIBRARY="${TK_BUILD_LIB_SPEC}"
1935 TK_DEPS="../tk/${configdir}/${TK_LIB_FILE}"
1936 fi
1937 AC_SUBST(TK_INCLUDE)
1938 AC_SUBST(TK_LIBRARY)
1939 AC_SUBST(TK_DEPS)
1940 AC_SUBST(TK_XINCLUDES)
1941
1942 ENABLE_CFLAGS="${ENABLE_CFLAGS} \$(SUBDIR_GDBTK_CFLAGS)"
1943
1944 # Include some libraries that Tcl and Tk want.
1945 TCL_LIBS='$(LIBGUI) $(TK) $(TCL) $(X11_LDFLAGS) $(X11_LIBS)'
1946 # Yes, the ordering seems wrong here. But it isn't.
1947 # TK_LIBS is the list of libraries that need to be linked
1948 # after Tcl/Tk. Note that this isn't put into LIBS. If it
1949 # were in LIBS then any link tests after this point would
1950 # try to include things like `$(LIBGUI)', which wouldn't work.
1951 GDBTKLIBS="${TCL_LIBS} ${TK_LIBS}"
1952
1953 CONFIG_OBS="${CONFIG_OBS} \$(SUBDIR_GDBTK_OBS)"
1954 CONFIG_DEPS="${CONFIG_DEPS} \$(SUBDIR_GDBTK_DEPS)"
1955 CONFIG_SRCS="${CONFIG_SRCS} \$(SUBDIR_GDBTK_SRCS)"
1956 CONFIG_ALL="${CONFIG_ALL} all-gdbtk"
1957 CONFIG_CLEAN="${CONFIG_CLEAN} clean-gdbtk"
1958 CONFIG_INSTALL="${CONFIG_INSTALL} install-gdbtk"
1959 CONFIG_UNINSTALL="${CONFIG_UNINSTALL} uninstall-gdbtk"
1960
0ad6b8ee 1961 if test x"$gdb_cv_os_cygwin" = xyes; then
85541719
DE
1962 WIN32LIBS="${WIN32LIBS} -lshell32 -lgdi32 -lcomdlg32 -ladvapi32"
1963 WIN32LDAPP="-Wl,--subsystem,console"
1964 CONFIG_OBS="${CONFIG_OBS} gdbres.o"
3fc11d3e 1965 fi
ffc6a242 1966
85541719
DE
1967 AC_CONFIG_SUBDIRS(gdbtk)
1968 fi
3fc11d3e
JM
1969fi
1970
3fc11d3e
JM
1971AC_SUBST(X_CFLAGS)
1972AC_SUBST(X_LDFLAGS)
1973AC_SUBST(X_LIBS)
3fc11d3e
JM
1974AC_SUBST(GDBTKLIBS)
1975AC_SUBST(GDBTK_CFLAGS)
d1c3b63a 1976AC_SUBST(GDBTK_SRC_DIR)
8b93c638 1977
c906108c
SS
1978AC_PATH_X
1979
4869db5e
RM
1980# Unlike the sim directory, whether a simulator is linked is controlled by
1981# presence of a gdb_sim definition in the target configure.tgt entry.
7a292a7a
SS
1982# This code just checks for a few cases where we'd like to ignore those
1983# definitions, even when they're present in the '.mt' file. These cases
1984# are when --disable-sim is specified, or if the simulator directory is
6c5cfe5b 1985# not part of the source tree.
7a292a7a
SS
1986#
1987AC_ARG_ENABLE(sim,
d2596e2e 1988AS_HELP_STRING([--enable-sim], [link gdb with simulator]),
7a292a7a
SS
1989[echo "enable_sim = $enable_sim";
1990 echo "enableval = ${enableval}";
1991 case "${enableval}" in
1992 yes) ignore_sim=false ;;
1993 no) ignore_sim=true ;;
1994 *) ignore_sim=false ;;
1995 esac],
1996[ignore_sim=false])
1997
1998if test ! -d "${srcdir}/../sim"; then
1999 ignore_sim=true
2000fi
2001
9b624dbe
UW
2002SIM=
2003SIM_OBS=
2004if test "${ignore_sim}" = "false"; then
2005 if test x"${gdb_sim}" != x ; then
2006 SIM="${gdb_sim}"
2007 SIM_OBS="remote-sim.o"
976102cd
PA
2008
2009 # Some tdep code should only be compiled in when the ppc sim is
2010 # built. PR sim/13418.
2011 case $target in
2012 powerpc*-*-*)
2013 AC_DEFINE(WITH_PPC_SIM, 1, [Define if the PPC simulator is being linked in.])
2014 ;;
2015 esac
9b624dbe 2016 fi
7a292a7a 2017fi
9b624dbe
UW
2018AC_SUBST(SIM)
2019AC_SUBST(SIM_OBS)
7a292a7a 2020
c906108c 2021AC_SUBST(ENABLE_CFLAGS)
d28f9cdf 2022AC_SUBST(PROFILE_CFLAGS)
c906108c
SS
2023
2024AC_SUBST(CONFIG_OBS)
2025AC_SUBST(CONFIG_DEPS)
2026AC_SUBST(CONFIG_SRCS)
b3a90332
AC
2027AC_SUBST(CONFIG_ALL)
2028AC_SUBST(CONFIG_CLEAN)
e56ac5c3
AC
2029AC_SUBST(CONFIG_INSTALL)
2030AC_SUBST(CONFIG_UNINSTALL)
c906108c 2031
c35f4ffc
AC
2032# List of host floatformats.
2033AC_DEFINE_UNQUOTED(GDB_HOST_FLOAT_FORMAT,$gdb_host_float_format,[Host float floatformat])
2034AC_DEFINE_UNQUOTED(GDB_HOST_DOUBLE_FORMAT,$gdb_host_double_format,[Host double floatformat])
2035AC_DEFINE_UNQUOTED(GDB_HOST_LONG_DOUBLE_FORMAT,$gdb_host_long_double_format,[Host long double floatformat])
2036
c906108c
SS
2037# target_subdir is used by the testsuite to find the target libraries.
2038target_subdir=
2039if test "${host}" != "${target}"; then
2040 target_subdir="${target_alias}/"
2041fi
2042AC_SUBST(target_subdir)
2043
21ea5acd 2044# Import nat definitions.
2b351b19 2045nat_makefile_frag=/dev/null
771b4502 2046if test "${gdb_native}" = "yes"; then
21ea5acd
SDJ
2047 . ${srcdir}/configure.nat
2048 nativefile=$NAT_FILE
c906108c 2049fi
c906108c 2050
21ea5acd
SDJ
2051AC_SUBST(NAT_FILE)
2052AC_SUBST(NATDEPFILES)
2053AC_SUBST(NAT_CDEPS)
2054AC_SUBST(LOADLIBES)
2055AC_SUBST(MH_CFLAGS)
2056AC_SUBST(XM_CLIBS)
2057AC_SUBST(NAT_GENERATED_FILES)
2058AC_SUBST(HAVE_NATIVE_GCORE_HOST)
2b351b19 2059AC_SUBST_FILE(nat_makefile_frag)
c906108c 2060
b00a8037
DJ
2061if test x"${gdb_osabi}" != x ; then
2062 AC_DEFINE_UNQUOTED(GDB_OSABI_DEFAULT, $gdb_osabi,
2063 [Define to the default OS ABI for this configuration.])
2064fi
2065
abbbd4a3
AB
2066# Setup possible use of libbacktrace.
2067AC_ARG_ENABLE([libbacktrace],
4fd404c2
SM
2068 [AS_HELP_STRING([--enable-libbacktrace],
2069 [use libbacktrace to write a backtrace after a fatal signal.])],
2070 [GDB_CHECK_YES_NO_VAL([$enableval], [--enable-libbacktrace])],
2071 [enable_libbacktrace=yes])
abbbd4a3 2072
c714aff1 2073if test "${enable_libbacktrace}" = "yes"; then
abbbd4a3 2074 LIBBACKTRACE_INC="-I$srcdir/../libbacktrace/ -I../libbacktrace/"
b686ecb5 2075 LIBBACKTRACE_LIB=../libbacktrace/libbacktrace.la
abbbd4a3
AB
2076 AC_DEFINE(HAVE_LIBBACKTRACE, 1, [Define if libbacktrace is being used.])
2077else
2078 LIBBACKTRACE_INC=
2079 LIBBACKTRACE_LIB=
2080fi
2081
2082AC_SUBST(LIBBACKTRACE_INC)
2083AC_SUBST(LIBBACKTRACE_LIB)
2084
393fd4c3
YQ
2085# Check for babeltrace and babeltrace-ctf
2086AC_ARG_WITH(babeltrace,
5593a99a 2087 AS_HELP_STRING([--with-babeltrace], [include babeltrace support (auto/yes/no)]),
393fd4c3
YQ
2088 [], [with_babeltrace=auto])
2089AC_MSG_CHECKING([whether to use babeltrace])
2090AC_MSG_RESULT([$with_babeltrace])
2091
2092if test "x$with_babeltrace" = "xno"; then
2093 AC_MSG_WARN([babletrace support disabled; GDB is unable to read CTF data.])
2094else
2095 # Append -Werror to CFLAGS so that configure can catch the warning
2096 # "assignment from incompatible pointer type", which is related to
2097 # the babeltrace change from 1.0.3 to 1.1.0. Babeltrace 1.1.0 works
2098 # in GDB, while babeltrace 1.0.3 is broken.
2099 # AC_LIB_HAVE_LINKFLAGS may modify CPPFLAGS in it, so it should be
2100 # safe to save and restore CFLAGS here.
2101 saved_CFLAGS=$CFLAGS
2102 CFLAGS="$CFLAGS -Werror"
2103 AC_LIB_HAVE_LINKFLAGS([babeltrace], [babeltrace-ctf],
2104 [#include <babeltrace/babeltrace.h>
2105 #include <babeltrace/ctf/events.h>
2106 #include <babeltrace/ctf/iterator.h>],
2107 [struct bt_iter_pos *pos = bt_iter_get_pos (bt_ctf_get_iter (NULL));
2108 struct bt_ctf_event *event = NULL;
2109 const struct bt_definition *scope;
2110
13cdc2af 2111 pos->type = BT_SEEK_BEGIN;
65c749e7 2112 bt_iter_set_pos (bt_ctf_get_iter (NULL), pos);
4869db5e 2113 scope = bt_ctf_get_top_level_scope (event,
393fd4c3
YQ
2114 BT_STREAM_EVENT_HEADER);
2115 bt_ctf_get_uint64 (bt_ctf_get_field (event, scope, "id"));
2116 ])
2117 CFLAGS=$saved_CFLAGS
2118
2119 if test "$HAVE_LIBBABELTRACE" != yes; then
2120 if test "$with_babeltrace" = yes; then
2121 AC_MSG_ERROR([babeltrace is missing or unusable])
2122 else
2123 AC_MSG_WARN([babeltrace is missing or unusable; GDB is unable to read CTF data.])
2124 fi
2125 fi
2126fi
2127
1776e3e5 2128GCC_ENABLE([libctf], [yes], [], [Handle .ctf type-info sections])
1776e3e5
NA
2129if test "${enable_libctf}" = yes; then
2130 AC_DEFINE(ENABLE_LIBCTF, 1, [Handle .ctf type-info sections])
b686ecb5
JM
2131 LIBCTF="../libctf/libctf.la"
2132 CTF_DEPS="../libctf/libctf.la"
1776e3e5
NA
2133else
2134 LIBCTF=
2135 CTF_DEPS=
2136fi
1776e3e5
NA
2137AC_SUBST(LIBCTF)
2138AC_SUBST(CTF_DEPS)
2139
2140# If nativefile (NAT_FILE) is not set in configure.nat, we link to an
2141# empty version.
2142
a0a461e5 2143NM_H=
c906108c
SS
2144rm -f nm.h
2145if test "${nativefile}" != ""; then
0f475e27
AC
2146 case "${nativefile}" in
2147 nm-*.h ) GDB_NM_FILE="config/${gdb_host_cpu}/${nativefile}" ;;
2148 * ) GDB_NM_FILE="${nativefile}"
2149 esac
a0a461e5
TT
2150 AC_CONFIG_LINKS([nm.h:$GDB_NM_FILE], [echo > stamp-nmh],
2151 [GDB_NM_FILE=$GDB_NM_FILE])
60ca704f 2152 AC_DEFINE_UNQUOTED(GDB_NM_FILE, "${GDB_NM_FILE}", [nativefile])
a0a461e5 2153 NM_H=nm.h
c906108c 2154fi
cfd53605 2155AC_SUBST(GDB_NM_FILE)
a0a461e5 2156AC_SUBST(NM_H)
5a2402b8 2157
e3487908
GKB
2158dnl Add dependency for xsltproc if building with maintainer-mode enabled.
2159AC_PATH_PROGS(XSLTPROC, xsltproc, missing)
2160if test "x$USE_MAINTAINER_MODE" = xyes; then
2161 if test "${XSLTPROC}" = missing; then
5593a99a 2162 AC_MSG_ERROR(unable to find xsltproc. maintainer-mode requires xsltproc.)
e3487908
GKB
2163 fi
2164fi
2165AC_SUBST(XSLTPROC)
2166
c906108c
SS
2167dnl Check for exe extension set on certain hosts (e.g. Win32)
2168AC_EXEEXT
2169
234b45d4 2170dnl Detect the character set used by this host.
6c7a06a3
TT
2171dnl At the moment, we just assume it's UTF-8.
2172AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8",
234b45d4
KB
2173 [Define to be a string naming the default host character set.])
2174
8ecfd7bd 2175GDB_AC_SELFTEST([
74cd3f9d
SM
2176 CONFIG_OBS="$CONFIG_OBS \$(SELFTESTS_OBS)"
2177 CONFIG_SRCS="$CONFIG_SRCS \$(SELFTESTS_SRCS)"
8ecfd7bd 2178])
dcd1f979 2179
f6a88844
JM
2180GDB_AC_TRANSFORM([gdb], [GDB_TRANSFORM_NAME])
2181GDB_AC_TRANSFORM([gcore], [GCORE_TRANSFORM_NAME])
b292c783 2182AC_CONFIG_FILES([gcore], [chmod +x gcore])
c5adaa19 2183AC_CONFIG_FILES([Makefile gdb-gdb.gdb gdb-gdb.py doc/Makefile data-directory/Makefile])
c906108c 2184
1e94266c 2185AC_OUTPUT