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