xref: /dflybsd-src/contrib/gdb-7/gdb/configure.ac (revision fda7d3889b1114d34ad3a52a7257a2b80fe24e4c)
1dnl Autoconf configure script for GDB, the GNU debugger.
2dnl Copyright (C) 1995-2012 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
21AC_PREREQ(2.59)dnl
22AC_INIT(main.c)
23AC_CONFIG_HEADER(config.h:config.in)
24AM_MAINTAINER_MODE
25
26AC_PROG_CC
27AC_USE_SYSTEM_EXTENSIONS
28gl_EARLY
29ACX_LARGEFILE
30AM_PROG_CC_STDC
31
32AC_CONFIG_AUX_DIR(..)
33AC_CANONICAL_SYSTEM
34
35# Dependency checking.
36ZW_CREATE_DEPDIR
37ZW_PROG_COMPILER_DEPENDENCIES([CC])
38
39# Check for the 'make' the user wants to use.
40AC_CHECK_PROGS(MAKE, make)
41MAKE_IS_GNU=
42case "`$MAKE --version 2>&1 | sed 1q`" in
43  *GNU*)
44    MAKE_IS_GNU=yes
45    ;;
46esac
47AM_CONDITIONAL(GMAKE, test "$MAKE_IS_GNU" = yes)
48AC_PROG_MAKE_SET
49
50dnl List of object files and targets accumulated by configure.
51
52CONFIG_OBS=
53CONFIG_DEPS=
54CONFIG_SRCS=
55ENABLE_CFLAGS=
56
57CONFIG_ALL=
58CONFIG_CLEAN=
59CONFIG_INSTALL=
60CONFIG_UNINSTALL=
61
62dnl Set up for gettext.
63ZW_GNU_GETTEXT_SISTER_DIR
64
65localedir='${datadir}/locale'
66AC_SUBST(localedir)
67
68if test x"$USE_NLS" = xyes; then
69   CONFIG_ALL="$CONFIG_ALL all-po"
70   CONFIG_CLEAN="$CONFIG_CLEAN clean-po"
71   CONFIG_INSTALL="$CONFIG_INSTALL install-po"
72   CONFIG_UNINSTALL="$CONFIG_UNINSTALL uninstall-po"
73fi
74
75gl_INIT
76
77# For Makefile dependencies.
78GNULIB_STDINT_H=
79if test x"$STDINT_H" != x; then
80  GNULIB_STDINT_H=gnulib/$STDINT_H
81fi
82AC_SUBST(GNULIB_STDINT_H)
83
84PACKAGE=gdb
85AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package. ])
86AC_SUBST(PACKAGE)
87
88# We never need to detect it in this sub-configure.
89# But preserve it for config.status --recheck.
90AC_ARG_VAR(MAKEINFO,
91  [Parent configure detects if it is of sufficient version.])
92AC_ARG_VAR(MAKEINFOFLAGS,
93  [Parameters for MAKEINFO.])
94
95MAKEINFO_EXTRA_FLAGS=""
96AC_CACHE_CHECK([whether $MAKEINFO supports @click], gdb_cv_have_makeinfo_click,
97  [echo '@clicksequence{a @click{} b}' >conftest.texinfo
98  if eval "$MAKEINFO conftest.texinfo >&5 2>&5"; then
99    gdb_cv_have_makeinfo_click=yes
100  else
101    gdb_cv_have_makeinfo_click=no
102  fi])
103if test x"$gdb_cv_have_makeinfo_click" = xyes; then
104  MAKEINFO_EXTRA_FLAGS="$MAKEINFO_EXTRA_FLAGS -DHAVE_MAKEINFO_CLICK"
105fi
106AC_SUBST(MAKEINFO_EXTRA_FLAGS)
107
108# GDB does not use automake, but gnulib does.  This line lets us
109# generate its Makefile.in.
110AM_INIT_AUTOMAKE(gdb, UNUSED-VERSION, [no-define])
111
112GDB_AC_WITH_DIR(DEBUGDIR, separate-debug-dir,
113    [look for global separate debug info in this path @<:@LIBDIR/debug@:>@],
114    [${libdir}/debug])
115
116# GDB's datadir relocation
117
118GDB_AC_WITH_DIR(GDB_DATADIR, gdb-datadir,
119    [look for global separate data files in this path @<:@DATADIR/gdb@:>@],
120    [${datadir}/gdb])
121
122AC_ARG_WITH(relocated-sources,
123AS_HELP_STRING([--with-relocated-sources=PATH], [automatically relocate this path for source files]),
124[reloc_srcdir="${withval}"
125 AC_DEFINE_DIR(RELOC_SRCDIR, reloc_srcdir,
126              [Relocated directory for source files. ])
127])
128
129AC_CONFIG_SUBDIRS(testsuite)
130
131# Check whether to support alternative target configurations
132AC_ARG_ENABLE(targets,
133AS_HELP_STRING([--enable-targets=TARGETS], [alternative target configurations]),
134[case "${enableval}" in
135  yes | "") AC_ERROR(enable-targets option must specify target names or 'all')
136            ;;
137  no)       enable_targets= ;;
138  *)        enable_targets=$enableval ;;
139esac])
140
141# Check whether to enable 64-bit support on 32-bit hosts
142AC_ARG_ENABLE(64-bit-bfd,
143AS_HELP_STRING([--enable-64-bit-bfd], [64-bit support (on hosts with narrower word sizes)]),
144[case "${enableval}" in
145  yes)  want64=true  ;;
146  no)   want64=false ;;
147  *)    AC_MSG_ERROR(bad value ${enableval} for 64-bit-bfd option) ;;
148esac],[want64=false])dnl
149
150# Provide defaults for some variables set by the per-host and per-target
151# configuration.
152gdb_host_obs=posix-hdep.o
153
154if test "${target}" = "${host}"; then
155  gdb_native=yes
156else
157  gdb_native=no
158fi
159
160. $srcdir/configure.host
161
162# Accumulate some settings from configure.tgt over all enabled targets
163
164TARGET_OBS=
165all_targets=
166
167for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
168do
169  if test "$targ_alias" = "all"; then
170    all_targets=true
171  else
172    # Canonicalize the secondary target names.
173    result=`$ac_config_sub $targ_alias 2>/dev/null`
174    if test -n "$result"; then
175        targ=$result
176    else
177        targ=$targ_alias
178    fi
179
180    . ${srcdir}/configure.tgt
181
182    AS_IF([test -z "${gdb_target_obs}"],
183      [AC_MSG_ERROR([configuration ${targ} is unsupported.])])
184
185    # Target-specific object files
186    for i in ${gdb_target_obs}; do
187        case " $TARGET_OBS " in
188        *" ${i} "*) ;;
189        *)
190          TARGET_OBS="$TARGET_OBS ${i}"
191          ;;
192        esac
193    done
194
195    # Check whether this target needs 64-bit CORE_ADDR
196    if test x${want64} = xfalse; then
197      . ${srcdir}/../bfd/config.bfd
198    fi
199  fi
200done
201
202if test x${all_targets} = xtrue; then
203
204  # We want all 64-bit targets if we either:
205  #  - run on a 64-bit host  or
206  #  - already require 64-bit support for some other target  or
207  #  - the --enable-64-bit-bfd option was supplied
208  # Otherwise we only support all 32-bit targets.
209  #
210  # NOTE: This test must be in sync with the corresponding
211  #       tests in BFD!
212
213  if test x${want64} = xfalse; then
214    AC_CHECK_SIZEOF(long)
215    if test "x${ac_cv_sizeof_long}" = "x8"; then
216      want64=true
217    fi
218  fi
219  if test x${want64} = xtrue; then
220    TARGET_OBS='$(ALL_TARGET_OBS) $(ALL_64_TARGET_OBS)'
221  else
222    TARGET_OBS='$(ALL_TARGET_OBS)'
223  fi
224fi
225
226AC_SUBST(TARGET_OBS)
227
228# For other settings, only the main target counts.
229gdb_sim=
230gdb_osabi=
231build_gdbserver=
232targ=$target; . ${srcdir}/configure.tgt
233
234# Fetch the default architecture and default target vector from BFD.
235targ=$target; . $srcdir/../bfd/config.bfd
236
237# We only want the first architecture, so strip off the others if
238# there is more than one.
239targ_archs=`echo $targ_archs | sed 's/ .*//'`
240
241if test "x$targ_archs" != x; then
242  AC_DEFINE_UNQUOTED(DEFAULT_BFD_ARCH, $targ_archs,
243    [Define to BFD's default architecture. ])
244fi
245if test "x$targ_defvec" != x; then
246  AC_DEFINE_UNQUOTED(DEFAULT_BFD_VEC, $targ_defvec,
247    [Define to BFD's default target vector. ])
248fi
249
250# The CLI cannot be disabled yet, but may be in the future.
251
252# Enable CLI.
253AC_ARG_ENABLE(gdbcli,
254AS_HELP_STRING([--disable-gdbcli], [disable command-line interface (CLI)]),
255  [case $enableval in
256    yes)
257      ;;
258    no)
259      AC_MSG_ERROR([the command-line interface cannot be disabled yet]) ;;
260    *)
261      AC_MSG_ERROR([bad value $enableval for --enable-gdbcli]) ;;
262  esac],
263  [enable_gdbcli=yes])
264if test x"$enable_gdbcli" = xyes; then
265  if test -d $srcdir/cli; then
266    CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_CLI_OBS)"
267    CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_CLI_DEPS)"
268    CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_CLI_SRCS)"
269    ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_CLI_CFLAGS)"
270  fi
271fi
272
273# Enable MI.
274AC_ARG_ENABLE(gdbmi,
275AS_HELP_STRING([--disable-gdbmi], [disable machine-interface (MI)]),
276  [case $enableval in
277    yes | no)
278      ;;
279    *)
280      AC_MSG_ERROR([bad value $enableval for --enable-gdbmi]) ;;
281  esac],
282  [enable_gdbmi=yes])
283if test x"$enable_gdbmi" = xyes; then
284  if test -d $srcdir/mi; then
285    CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_MI_OBS)"
286    CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_MI_DEPS)"
287    CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_MI_SRCS)"
288    ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_MI_CFLAGS)"
289  fi
290fi
291
292# Enable TUI.
293AC_ARG_ENABLE(tui,
294AS_HELP_STRING([--enable-tui], [enable full-screen terminal user interface (TUI)]),
295  [case $enableval in
296    yes | no | auto)
297      ;;
298    *)
299      AC_MSG_ERROR([bad value $enableval for --enable-tui]) ;;
300  esac],enable_tui=auto)
301
302# Enable gdbtk.
303AC_ARG_ENABLE(gdbtk,
304AS_HELP_STRING([--enable-gdbtk], [enable gdbtk graphical user interface (GUI)]),
305  [case $enableval in
306    yes | no)
307      ;;
308    *)
309      AC_MSG_ERROR([bad value $enableval for --enable-gdbtk]) ;;
310  esac],
311  [if test -d $srcdir/gdbtk; then
312    enable_gdbtk=yes
313  else
314    enable_gdbtk=no
315  fi])
316# We unconditionally disable gdbtk tests on selected platforms.
317case $host_os in
318  go32* | windows*)
319    AC_MSG_WARN([gdbtk isn't supported on $host; disabling])
320    enable_gdbtk=no ;;
321esac
322
323# Libunwind support.
324AC_ARG_WITH(libunwind,
325AS_HELP_STRING([--with-libunwind], [use libunwind frame unwinding support]),
326[case "${withval}" in
327  yes)  enable_libunwind=yes ;;
328  no)   enable_libunwind=no ;;
329  *)    AC_MSG_ERROR(bad value ${withval} for GDB with-libunwind option) ;;
330esac],[
331  AC_CHECK_HEADERS(libunwind.h libunwind-ia64.h)
332  if test x"$ac_cv_header_libunwind_h" = xyes -a x"$ac_cv_header_libunwind_ia64_h" = xyes; then
333    enable_libunwind=yes;
334  fi
335])
336
337if test x"$enable_libunwind" = xyes; then
338  AC_CHECK_HEADERS(libunwind.h libunwind-ia64.h)
339  AC_DEFINE(HAVE_LIBUNWIND, 1, [Define if libunwind library is being used.])
340  CONFIG_OBS="$CONFIG_OBS libunwind-frame.o"
341  CONFIG_DEPS="$CONFIG_DEPS libunwind-frame.o"
342  CONFIG_SRCS="$CONFIG_SRCS libunwind-frame.c"
343fi
344
345opt_curses=no
346AC_ARG_WITH(curses, AS_HELP_STRING([--with-curses], [use the curses library instead of the termcap library]), opt_curses=$withval)
347
348prefer_curses=no
349if test "$opt_curses" = "yes"; then
350  prefer_curses=yes
351fi
352
353# Profiling support.
354AC_ARG_ENABLE(profiling,
355AS_HELP_STRING([--enable-profiling], [enable profiling of GDB]),
356  [case $enableval in
357    yes | no)
358      ;;
359    *)
360      AC_MSG_ERROR([bad value $enableval for --enable-profile]) ;;
361  esac],
362 [enable_profiling=no])
363
364AC_CHECK_FUNCS(monstartup _mcleanup)
365AC_CACHE_CHECK([for _etext], ac_cv_var__etext,
366[AC_TRY_LINK(
367[#include <stdlib.h>
368extern char _etext;
369],
370[free (&_etext);], ac_cv_var__etext=yes, ac_cv_var__etext=no)])
371if test $ac_cv_var__etext = yes; then
372  AC_DEFINE(HAVE__ETEXT, 1,
373            [Define to 1 if your system has the _etext variable. ])
374fi
375AC_CACHE_CHECK([for etext], ac_cv_var_etext,
376[AC_TRY_LINK(
377[#include <stdlib.h>
378extern char etext;
379],
380[free (&etext);], ac_cv_var_etext=yes, ac_cv_var_etext=no)])
381if test $ac_cv_var_etext = yes; then
382  AC_DEFINE(HAVE_ETEXT, 1,
383            [Define to 1 if your system has the etext variable. ])
384fi
385if test "$enable_profiling" = yes ; then
386  if test $ac_cv_func_monstartup = no || test $ac_cv_func__mcleanup = no; then
387    AC_MSG_ERROR(--enable-profiling requires monstartup and _mcleanup)
388  fi
389  PROFILE_CFLAGS=-pg
390  OLD_CFLAGS="$CFLAGS"
391  CFLAGS="$CFLAGS $PROFILE_CFLAGS"
392
393  AC_CACHE_CHECK([whether $CC supports -pg], ac_cv_cc_supports_pg,
394    [AC_TRY_COMPILE([], [int x;], ac_cv_cc_supports_pg=yes,
395     ac_cv_cc_supports_pg=no)])
396
397  if test $ac_cv_cc_supports_pg = no; then
398    AC_MSG_ERROR(--enable-profiling requires a compiler which supports -pg)
399  fi
400
401  CFLAGS="$OLD_CFLAGS"
402fi
403
404ACX_PKGVERSION([GDB])
405ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
406AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
407AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
408
409# --------------------- #
410# Checks for programs.  #
411# --------------------- #
412
413AC_PROG_AWK
414AC_PROG_INSTALL
415AC_PROG_LN_S
416AC_PROG_RANLIB
417AC_PROG_YACC
418
419AC_CHECK_TOOL(AR, ar)
420AC_CHECK_TOOL(DLLTOOL, dlltool)
421AC_CHECK_TOOL(WINDRES, windres)
422
423# Needed for GNU/Hurd.
424AC_CHECK_TOOL(MIG, mig)
425
426# ---------------------- #
427# Checks for libraries.  #
428# ---------------------- #
429
430# We might need to link with -lm; most simulators need it.
431AC_CHECK_LIB(m, main)
432
433# We need to link with -lw to get `wctype' on Solaris before Solaris
434# 2.6.  Solaris 2.6 and beyond have this function in libc, and have a
435# libw that some versions of the GNU linker cannot hanle (GNU ld 2.9.1
436# is known to have this problem).  Therefore we avoid libw if we can.
437AC_CHECK_FUNC(wctype, [],
438  [AC_CHECK_LIB(w, wctype)])
439
440# Some systems (e.g. Solaris) have `gethostbyname' in libnsl.
441AC_SEARCH_LIBS(gethostbyname, nsl)
442
443# Some systems (e.g. Solaris) have `socketpair' in libsocket.
444AC_SEARCH_LIBS(socketpair, socket)
445
446# Link in zlib if we can.  This allows us to read compressed debug sections.
447AM_ZLIB
448
449# On HP/UX we may need libxpdl for dlgetmodinfo (used by solib-pa64.c).
450AC_SEARCH_LIBS(dlgetmodinfo, [dl xpdl])
451
452AM_ICONV
453
454# GDB may fork/exec the iconv program to get the list of supported character
455# sets.  Allow the user to specify where to find it.
456# There are several factors affecting the choice of option name:
457# - There is already --with-libiconv-prefix but we can't use it, it specifies
458#   the build-time location of libiconv files.
459# - The program we need to find is iconv, which comes with glibc.  The user
460#   doesn't necessarily have libiconv installed.  Therefore naming this
461#   --with-libiconv-foo feels wrong.
462# - We want the path to be relocatable, but GDB_AC_DEFINE_RELOCATABLE is
463#   defined to work on directories not files (though it really doesn't know
464#   the difference).
465# - Calling this --with-iconv-prefix is perceived to cause too much confusion
466#   with --with-libiconv-prefix.
467# Putting these together is why the option name is --with-iconv-bin.
468
469AC_ARG_WITH(iconv-bin,
470AS_HELP_STRING([--with-iconv-bin=PATH], [specify where to find the iconv program]),
471[iconv_bin="${withval}"
472 AC_DEFINE_UNQUOTED([ICONV_BIN], ["${iconv_bin}"],
473                    [Path of directory of iconv program.])
474 GDB_AC_DEFINE_RELOCATABLE(ICONV_BIN, iconv, ${iconv_bin})
475])
476
477# On alpha-osf, it appears that libtermcap and libcurses are not compatible.
478# There is a very specific comment in /usr/include/curses.h explaining that
479# termcap routines built into libcurses must not be used.
480#
481# The symptoms we observed so far is GDB unexpectedly changing
482# the terminal settings when tgetent is called - this is particularly
483# visible as the output is missing carriage returns, and so rapidly
484# becomes very hard to read.
485#
486# The readline configure script has already decided that libtermcap
487# was enough for its purposes, and so decided to build readline using
488# libtermcap.  Since the TUI mode requires curses, building GDB with
489# TUI enabled results in both libraries to be used at the same time,
490# which is not allowed.  This basically means that GDB with TUI is
491# broken on alpha-osf.
492
493case $host_os in
494  osf* )
495    if test x"$enable_tui" = xyes; then
496      AC_MSG_ERROR([Building GDB with TUI mode is not supported on this host])
497    fi
498    if test x"$enable_tui" = xauto; then
499      enable_tui=no
500    fi
501    ;;
502esac
503
504# For the TUI, we need enhanced curses functionality.
505if test x"$enable_tui" != xno; then
506  prefer_curses=yes
507fi
508
509curses_found=no
510if test x"$prefer_curses" = xyes; then
511  # FIXME: kettenis/20040905: We prefer ncurses over the vendor-supplied
512  # curses library because the latter might not provide all the
513  # functionality we need.  However, this leads to problems on systems
514  # where the linker searches /usr/local/lib, but the compiler doesn't
515  # search /usr/local/include, if ncurses is installed in /usr/local.  A
516  # default installation of ncurses on alpha*-dec-osf* will lead to such
517  # a situation.
518  AC_SEARCH_LIBS(waddstr, [ncurses cursesX curses])
519
520  if test "$ac_cv_search_waddstr" != no; then
521    curses_found=yes
522  fi
523fi
524
525# Check whether we should enable the TUI, but only do so if we really
526# can.
527if test x"$enable_tui" != xno; then
528  if test -d $srcdir/tui; then
529    if test "$curses_found" != no; then
530      CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_TUI_OBS)"
531      CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_TUI_DEPS)"
532      CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_TUI_SRCS)"
533      ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_TUI_CFLAGS)"
534      CONFIG_ALL="${CONFIG_ALL} all-tui"
535      CONFIG_CLEAN="${CONFIG_CLEAN} clean-tui"
536      CONFIG_INSTALL="${CONFIG_INSTALL} install-tui"
537      CONFIG_UNINSTALL="${CONFIG_UNINSTALL} uninstall-tui"
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 seperate 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    ;;
561  *mingw32*)
562    ac_cv_search_tgetent="none required"
563    CONFIG_OBS="$CONFIG_OBS windows-termcap.o"
564    ;;
565esac
566
567# These are the libraries checked by Readline.
568AC_SEARCH_LIBS(tgetent, [termcap tinfo curses ncurses])
569
570if test "$ac_cv_search_tgetent" = no; then
571  AC_MSG_ERROR([no termcap library found])
572fi
573
574AC_ARG_WITH([system-readline],
575  [AS_HELP_STRING([--with-system-readline],
576                  [use installed readline library])])
577
578if test "$with_system_readline" = yes; then
579  READLINE=-lreadline
580  READLINE_DEPS=
581  READLINE_CFLAGS=
582  READLINE_TEXI_INCFLAG=
583else
584  READLINE='$(READLINE_DIR)/libreadline.a'
585  READLINE_DEPS='$(READLINE)'
586  READLINE_CFLAGS='-I$(READLINE_SRC)/..'
587  READLINE_TEXI_INCFLAG='-I $(READLINE_DIR)'
588fi
589AC_SUBST(READLINE)
590AC_SUBST(READLINE_DEPS)
591AC_SUBST(READLINE_CFLAGS)
592AC_SUBST(READLINE_TEXI_INCFLAG)
593
594# Generate jit-reader.h
595
596# This is typedeffed to GDB_CORE_ADDR in jit-reader.h
597TARGET_PTR=
598
599AC_CHECK_SIZEOF(unsigned long long)
600AC_CHECK_SIZEOF(unsigned long)
601AC_CHECK_SIZEOF(unsigned __int128)
602
603if test "x${ac_cv_sizeof_unsigned_long}" = "x8"; then
604  TARGET_PTR="unsigned long"
605elif test "x${ac_cv_sizeof_unsigned_long_long}" = "x8"; then
606  TARGET_PTR="unsigned long long"
607elif test "x${ac_cv_sizeof_unsigned___int128}" = "x16"; then
608  TARGET_PTR="unsigned __int128"
609else
610  TARGET_PTR="unsigned long"
611fi
612
613AC_SUBST(TARGET_PTR)
614AC_CONFIG_FILES([jit-reader.h:jit-reader.in])
615
616AC_SEARCH_LIBS(dlopen, dl)
617
618GDB_AC_WITH_DIR([JIT_READER_DIR], [jit-reader-dir],
619                [directory to load the JIT readers from],
620                [${libdir}/gdb])
621
622AC_ARG_WITH(expat,
623  AS_HELP_STRING([--with-expat], [include expat support (auto/yes/no)]),
624  [], [with_expat=auto])
625AC_MSG_CHECKING([whether to use expat])
626AC_MSG_RESULT([$with_expat])
627
628if test "${with_expat}" = no; then
629  AC_MSG_WARN([expat support disabled; some features may be unavailable.])
630  HAVE_LIBEXPAT=no
631else
632  AC_LIB_HAVE_LINKFLAGS([expat], [], [#include "expat.h"],
633			[XML_Parser p = XML_ParserCreate (0);])
634  if test "$HAVE_LIBEXPAT" != yes; then
635    if test "$with_expat" = yes; then
636      AC_MSG_ERROR([expat is missing or unusable])
637    else
638      AC_MSG_WARN([expat is missing or unusable; some features may be unavailable.])
639    fi
640  else
641    save_LIBS=$LIBS
642    LIBS="$LIBS $LIBEXPAT"
643    AC_CHECK_FUNCS(XML_StopParser)
644    LIBS=$save_LIBS
645  fi
646fi
647
648dnl Utility to simplify finding libpython.
649dnl $1 = pythonX.Y
650dnl $2 = the shell variable to assign the result to
651dnl      If libpython is found we store $version here.
652dnl $3 = additional flags to add to CPPFLAGS
653dnl $4 = additional flags to add to LIBS
654
655AC_DEFUN([AC_TRY_LIBPYTHON],
656[
657  version=$1
658  define([have_libpython_var],$2)
659  new_CPPFLAGS=$3
660  new_LIBS=$4
661  AC_MSG_CHECKING([for ${version}])
662  save_CPPFLAGS=$CPPFLAGS
663  save_LIBS=$LIBS
664  CPPFLAGS="$CPPFLAGS $new_CPPFLAGS"
665  LIBS="$LIBS $new_LIBS"
666  found_usable_python=no
667  AC_LINK_IFELSE(AC_LANG_PROGRAM([[#include "Python.h"]],
668                                 [[Py_Initialize ();]]),
669                 [have_libpython_var=${version}
670                  found_usable_python=yes
671                  PYTHON_CPPFLAGS=$new_CPPFLAGS
672                  PYTHON_LIBS=$new_LIBS])
673  CPPFLAGS=$save_CPPFLAGS
674  LIBS=$save_LIBS
675  AC_MSG_RESULT([${found_usable_python}])
676])
677
678dnl There are several different values for --with-python:
679dnl
680dnl no -   Don't include python support.
681dnl yes -  Include python support, error if it's missing.
682dnl        If we find python in $PATH, use it to fetch configure options,
683dnl        otherwise assume the compiler can find it with no help from us.
684dnl        Python 2.7, 2.6, 2.5, and then 2.4 are tried in turn.
685dnl auto - Same as "yes", but if python is missing from the system,
686dnl        fall back to "no".
687dnl /path/to/python/exec-prefix -
688dnl        Use the python located in this directory.
689dnl        If /path/to/python/exec-prefix/bin/python exists, use it to find
690dnl        the compilation parameters.  Otherwise use
691dnl        -I/path/to/python/exec-prefix/include,
692dnl        -L/path/to/python/exec-prefix/lib.
693dnl        Python 2.7, 2.6, 2.5, and then 2.4 are tried in turn.
694dnl        NOTE: This case is historical.  It is what was done for 7.0/7.1
695dnl        but is deprecated.
696dnl /path/to/python/executable -
697dnl        Run python-config.py with this version of python to fetch the
698dnl        compilation parameters.
699dnl        NOTE: This needn't be the real python executable.
700dnl        In a cross-compilation scenario (build != host), this could be
701dnl        a shell script that provides what python-config.py provides for
702dnl        --ldflags, --includes, --exec-prefix.
703dnl python-executable -
704dnl        Find python-executable in $PATH, and then handle the same as
705dnl        /path/to/python/executable.
706dnl
707dnl If a python program is specified, it is used to run python-config.py and
708dnl is passed --ldflags, --includes, --exec-prefix.
709
710AC_ARG_WITH(python,
711  AS_HELP_STRING([--with-python@<:@=PYTHON@:>@], [include python support (auto/yes/no/<python-program>)]),
712  [], [with_python=auto])
713AC_MSG_CHECKING([whether to use python])
714AC_MSG_RESULT([$with_python])
715
716if test "${with_python}" = no; then
717  AC_MSG_WARN([python support disabled; some features may be unavailable.])
718  have_libpython=no
719else
720  case "${with_python}" in
721  /*)
722    if test -d ${with_python}; then
723      # Assume the python binary is ${with_python}/bin/python.
724      python_prog="${with_python}/bin/python"
725      python_prefix=
726      # If python does not exit ${with_python}/bin, then try in
727      # ${with_python}.  On Windows/MinGW, this is where the Python
728      # executable is.
729      if test ! -x "${python_prog}"; then
730        python_prog="${with_python}/python"
731        python_prefix=
732      fi
733      if test ! -x "${python_prog}"; then
734        # Fall back to gdb 7.0/7.1 behaviour.
735        python_prog=missing
736        python_prefix=${with_python}
737      fi
738    elif test -x "${with_python}"; then
739      # While we can't run python compiled for $host (unless host == build),
740      # the user could write a script that provides the needed information,
741      # so we support that.
742      python_prog=${with_python}
743      python_prefix=
744    else
745      AC_ERROR(invalid value for --with-python)
746    fi
747    ;;
748  */*)
749    # Disallow --with-python=foo/bar.
750    AC_ERROR(invalid value for --with-python)
751    ;;
752  *)
753    # The user has either specified auto, yes, or the name of the python
754    # program assumed to be in $PATH.
755    python_prefix=
756    case "${with_python}" in
757    yes | auto)
758      if test ${build} = ${host}; then
759        AC_PATH_PROG(python_prog_path, python, missing)
760        if test "${python_prog_path}" = missing; then
761          python_prog=missing
762        else
763          python_prog=${python_prog_path}
764        fi
765      else
766        # Not much we can do except assume the cross-compiler will find the
767        # right files.
768        python_prog=missing
769      fi
770      ;;
771    *)
772      # While we can't run python compiled for $host (unless host == build),
773      # the user could write a script that provides the needed information,
774      # so we support that.
775      python_prog="${with_python}"
776      AC_PATH_PROG(python_prog_path, ${python_prog}, missing)
777      if test "${python_prog_path}" = missing; then
778        AC_ERROR(unable to find python program ${python_prog})
779      fi
780      ;;
781    esac
782  esac
783
784  if test "${python_prog}" != missing; then
785    # We have a python program to use, but it may be too old.
786    # Don't flag an error for --with-python=auto (the default).
787    have_python_config=yes
788    python_includes=`${python_prog} ${srcdir}/python/python-config.py --includes`
789    if test $? != 0; then
790      have_python_config=failed
791      if test "${with_python}" != auto; then
792        AC_ERROR(failure running python-config --includes)
793      fi
794    fi
795    python_libs=`${python_prog} ${srcdir}/python/python-config.py --ldflags`
796    if test $? != 0; then
797      have_python_config=failed
798      if test "${with_python}" != auto; then
799        AC_ERROR(failure running python-config --ldflags)
800      fi
801    fi
802    python_prefix=`${python_prog} ${srcdir}/python/python-config.py --exec-prefix`
803    if test $? != 0; then
804      have_python_config=failed
805      if test "${with_python}" != auto; then
806        AC_ERROR(failure running python-config --exec-prefix)
807      fi
808    fi
809  else
810    # We do not have a python executable we can use to determine where
811    # to find the Python headers and libs.  We cannot guess the include
812    # path from the python_prefix either, because that include path
813    # depends on the Python version.  So, there is nothing much we can
814    # do except assume that the compiler will be able to find those files.
815    python_includes=
816    python_libs=
817    have_python_config=no
818  fi
819
820  # If we have python-config, only try the configuration it provides.
821  # Otherwise fallback on the old way of trying different versions of
822  # python in turn.
823
824  have_libpython=no
825  if test "${have_python_config}" = yes; then
826    # Determine the Python version by extracting "-lpython<version>"
827    # part of the python_libs. <version> is usually X.Y with X and Y
828    # being decimal numbers, but can also be XY (seen on Windows).
829    #
830    # The extraction is performed using sed with a regular expression.
831    # Initially, the regexp used was using the '?' quantifier to make
832    # the dot in the version number optional.  Unfortunately, this
833    # does not work with non-GNU versions of sed because, because of
834    # what looks like a limitation (the '?' quantifier does not work
835    # with back-references).  We work around this limitation by using
836    # the '*' quantifier instead.  It means that, in theory, we might
837    # match unexpected version strings such as "-lpython2..7", but
838    # this seems unlikely in practice.  And even if that happens,
839    # an error will be triggered later on, when checking that version
840    # number.
841    python_version=`echo " ${python_libs} " \
842                         | sed -e 's,^.* -l\(python[[0-9]]*[[.]]*[[0-9]]*\).*$,\1,'`
843    case "${python_version}" in
844    python*)
845      AC_TRY_LIBPYTHON(${python_version}, have_libpython,
846                       ${python_includes}, ${python_libs})
847      ;;
848    *)
849      AC_MSG_ERROR([unable to determine python version from ${python_libs}])
850      ;;
851    esac
852  elif test "${have_python_config}" != failed; then
853    if test "${have_libpython}" = no; then
854      AC_TRY_LIBPYTHON(python2.7, have_libpython,
855                       ${python_includes}, "${python_libs} -lpython2.7")
856    fi
857    if test "${have_libpython}" = no; then
858      AC_TRY_LIBPYTHON(python2.6, have_libpython,
859                       ${python_includes}, "${python_libs} -lpython2.6")
860    fi
861    if test ${have_libpython} = no; then
862      AC_TRY_LIBPYTHON(python2.5, have_libpython,
863                       ${python_includes}, "${python_libs} -lpython2.5")
864    fi
865    if test ${have_libpython} = no; then
866      AC_TRY_LIBPYTHON(python2.4, have_libpython,
867                       ${python_includes}, "${python_libs} -lpython2.4")
868    fi
869  fi
870  if test "${have_libpython}" = python2.7 -o "${have_libpython}" = python27; then
871    AC_DEFINE(HAVE_LIBPYTHON2_7, 1, [Define if Python 2.7 is being used.])
872  elif test "${have_libpython}" = python2.6 -o "${have_libpython}" = python26; then
873    AC_DEFINE(HAVE_LIBPYTHON2_6, 1, [Define if Python 2.6 is being used.])
874  elif test "${have_libpython}" = python2.5 -o "${have_libpython}" = python25; then
875    AC_DEFINE(HAVE_LIBPYTHON2_5, 1, [Define if Python 2.5 is being used.])
876  elif test "${have_libpython}" = python2.4 -o "${have_libpython}" = python24; then
877    AC_DEFINE(HAVE_LIBPYTHON2_4, 1, [Define if Python 2.4 is being used.])
878  fi
879
880  if test "${have_libpython}" = no; then
881    case "${with_python}" in
882    yes)
883      AC_MSG_ERROR([python is missing or unusable])
884      ;;
885    auto)
886      AC_MSG_WARN([python is missing or unusable; some features may be unavailable.])
887      ;;
888    *)
889      AC_MSG_ERROR([no usable python found at ${with_python}])
890      ;;
891    esac
892  else
893    if test -n "${python_prefix}"; then
894      AC_DEFINE_UNQUOTED(WITH_PYTHON_PATH, "${python_prefix}",
895                         [Define if --with-python provides a path, either directly or via python-config.py --exec-prefix.])
896      GDB_AC_DEFINE_RELOCATABLE(PYTHON_PATH, python, ${python_prefix})
897    fi
898  fi
899fi
900
901if test "${have_libpython}" != no; then
902  AC_DEFINE(HAVE_PYTHON, 1, [Define if Python interpreter is being linked in.])
903  CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_PYTHON_OBS)"
904  CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_PYTHON_DEPS)"
905  CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_PYTHON_SRCS)"
906  CONFIG_INSTALL="$CONFIG_INSTALL install-python"
907  ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_PYTHON_CFLAGS)"
908
909  # Flags needed to compile Python code (taken from python-config --cflags).
910  # We cannot call python-config directly because it will output whatever was
911  # used when compiling the Python interpreter itself, including flags which
912  # would make the python-related objects be compiled differently from the
913  # rest of GDB (e.g., -O2 and -fPIC).
914  if test "${GCC}" = yes; then
915    tentative_python_cflags="-fno-strict-aliasing -DNDEBUG -fwrapv"
916  fi
917
918  if test "x${tentative_python_cflags}" != x; then
919    AC_MSG_CHECKING(compiler flags for python code)
920    for flag in ${tentative_python_cflags}; do
921      # Check that the compiler accepts it
922      saved_CFLAGS="$CFLAGS"
923      CFLAGS="$CFLAGS $flag"
924      AC_TRY_COMPILE([],[],PYTHON_CFLAGS="${PYTHON_CFLAGS} $flag",)
925      CFLAGS="$saved_CFLAGS"
926    done
927    AC_MSG_RESULT(${PYTHON_CFLAGS})
928  fi
929
930  # On IRIX, type siginfo is not defined.  Instead, sys/siginfo.h provides:
931  #    #if _SGIAPI
932  #    #define siginfo __siginfo
933  #    #endif
934  # The problem is that including Python causes some XOPEN macros to be
935  # unilaterally defined, and that in turn causes _SGIAPI to evaluate
936  # to false.  So, we work around this issue by defining siginfo ourself
937  # though the command-line.
938  case "$gdb_host" in
939    irix*) if test "${GCC}" = yes; then
940             CPPFLAGS="$CPPFLAGS -Dsiginfo=__siginfo"
941           fi
942           ;;
943  esac
944else
945  # Even if Python support is not compiled in, we need to have these files
946  # included.
947  CONFIG_OBS="$CONFIG_OBS python.o py-value.o py-prettyprint.o py-auto-load.o"
948  CONFIG_SRCS="$CONFIG_SRCS python/python.c python/py-value.c \
949	python/py-prettyprint.c python/py-auto-load.c"
950fi
951AC_SUBST(PYTHON_CFLAGS)
952AC_SUBST(PYTHON_CPPFLAGS)
953AC_SUBST(PYTHON_LIBS)
954
955# ------------------------- #
956# Checks for header files.  #
957# ------------------------- #
958
959AC_HEADER_DIRENT
960AC_HEADER_STAT
961AC_HEADER_STDC
962# elf_hp.h is for HP/UX 64-bit shared library support.
963# FIXME: kettenis/20030102: In most cases we include these (ctype.h, time.h)
964# unconditionally, so what's the point in checking these?
965AC_CHECK_HEADERS([nlist.h machine/reg.h poll.h sys/poll.h proc_service.h \
966                  thread_db.h gnu/libc-version.h signal.h stddef.h \
967		  stdlib.h string.h memory.h strings.h sys/fault.h \
968		  sys/file.h sys/filio.h sys/ioctl.h sys/param.h \
969		  sys/resource.h sys/procfs.h sys/ptrace.h ptrace.h \
970		  sys/reg.h sys/debugreg.h sys/select.h sys/syscall.h \
971		  sys/types.h sys/wait.h wait.h termios.h termio.h \
972		  sgtty.h unistd.h elf_hp.h ctype.h time.h locale.h \
973		  dlfcn.h])
974AC_CHECK_HEADERS(link.h, [], [],
975[#if HAVE_SYS_TYPES_H
976# include <sys/types.h>
977#endif
978#if HAVE_NLIST_H
979# include <nlist.h>
980#endif
981])
982AC_CHECK_HEADERS(sys/proc.h, [], [],
983[#if HAVE_SYS_PARAM_H
984# include <sys/param.h>
985#endif
986])
987AC_CHECK_HEADERS(sys/user.h, [], [],
988[#if HAVE_SYS_PARAM_H
989# include <sys/param.h>
990#endif
991])
992
993# On Solaris 2.[789], we need to define _MSE_INT_H to avoid a clash
994# between <widec.h> and <wchar.h> that would cause AC_CHECK_HEADERS to
995# think that we don't have <curses.h> if we're using GCC.
996case $host_os in
997  solaris2.[[789]])
998    if test "$GCC" = yes; then
999      AC_DEFINE(_MSE_INT_H, 1,
1000        [Define to 1 to avoid a clash between <widec.h> and <wchar.h> on
1001   Solaris 2.[789] when using GCC. ])
1002    fi ;;
1003esac
1004AC_CHECK_HEADERS(curses.h cursesX.h ncurses.h ncurses/ncurses.h ncurses/term.h)
1005AC_CHECK_HEADERS(term.h, [], [],
1006[#if HAVE_CURSES_H
1007# include <curses.h>
1008#endif
1009])
1010
1011# ------------------------- #
1012# Checks for declarations.  #
1013# ------------------------- #
1014
1015AC_CHECK_DECLS([free, malloc, realloc, strerror, strstr, getopt,
1016                snprintf, vsnprintf])
1017AM_LC_MESSAGES
1018
1019# ----------------------- #
1020# Checks for structures.  #
1021# ----------------------- #
1022
1023AC_CHECK_MEMBERS([struct stat.st_blocks, struct stat.st_blksize])
1024
1025# ------------------ #
1026# Checks for types.  #
1027# ------------------ #
1028
1029AC_TYPE_SIGNAL
1030AC_CHECK_TYPES(socklen_t, [], [],
1031[#include <sys/types.h>
1032#include <sys/socket.h>
1033])
1034
1035# ------------------------------------- #
1036# Checks for compiler characteristics.  #
1037# ------------------------------------- #
1038
1039AC_C_CONST
1040AC_C_INLINE
1041AC_C_BIGENDIAN
1042
1043# ------------------------------ #
1044# Checks for library functions.  #
1045# ------------------------------ #
1046
1047AC_FUNC_ALLOCA
1048AC_FUNC_MMAP
1049AC_FUNC_VFORK
1050AC_CHECK_FUNCS([canonicalize_file_name realpath getrusage getuid \
1051		getgid pipe poll pread64 resize_term sbrk setpgid setpgrp setsid \
1052		sigaction sigprocmask sigsetmask socketpair syscall \
1053		ttrace wborder wresize setlocale iconvlist libiconvlist btowc \
1054		setrlimit getrlimit posix_madvise waitpid])
1055AM_LANGINFO_CODESET
1056
1057# Check the return and argument types of ptrace.  No canned test for
1058# this, so roll our own.
1059gdb_ptrace_headers='
1060#if HAVE_SYS_TYPES_H
1061# include <sys/types.h>
1062#endif
1063#if HAVE_SYS_PTRACE_H
1064# include <sys/ptrace.h>
1065#endif
1066#if HAVE_UNISTD_H
1067# include <unistd.h>
1068#endif
1069'
1070# There is no point in checking if we don't have a prototype.
1071AC_CHECK_DECLS(ptrace, [], [
1072  : ${gdb_cv_func_ptrace_ret='int'}
1073  : ${gdb_cv_func_ptrace_args='int,int,long,long'}
1074], $gdb_ptrace_headers)
1075# Check return type.  Varargs (used on GNU/Linux) conflict with the
1076# empty argument list, so check for that explicitly.
1077AC_CACHE_CHECK([return type of ptrace], gdb_cv_func_ptrace_ret,
1078  AC_TRY_COMPILE($gdb_ptrace_headers,
1079    [extern long ptrace (enum __ptrace_request, ...);],
1080    gdb_cv_func_ptrace_ret='long',
1081    AC_TRY_COMPILE($gdb_ptrace_headers,
1082      [extern int ptrace ();],
1083      gdb_cv_func_ptrace_ret='int',
1084      gdb_cv_func_ptrace_ret='long')))
1085AC_DEFINE_UNQUOTED(PTRACE_TYPE_RET, $gdb_cv_func_ptrace_ret,
1086  [Define as the return type of ptrace.])
1087# Check argument types.
1088AC_CACHE_CHECK([types of arguments for ptrace], gdb_cv_func_ptrace_args, [
1089  AC_TRY_COMPILE($gdb_ptrace_headers,
1090    [extern long ptrace (enum __ptrace_request, ...);],
1091    [gdb_cv_func_ptrace_args='int,int,long,long'],[
1092for gdb_arg1 in 'int' 'long'; do
1093 for gdb_arg2 in 'pid_t' 'int' 'long'; do
1094  for gdb_arg3 in 'int *' 'caddr_t' 'int' 'long' 'void *'; do
1095   for gdb_arg4 in 'int' 'long'; do
1096     AC_TRY_COMPILE($gdb_ptrace_headers, [
1097extern $gdb_cv_func_ptrace_ret
1098  ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4);
1099], [gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4";
1100    break 4;])
1101    for gdb_arg5 in 'int *' 'int' 'long'; do
1102     AC_TRY_COMPILE($gdb_ptrace_headers, [
1103extern $gdb_cv_func_ptrace_ret
1104  ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4, $gdb_arg5);
1105], [
1106gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4,$gdb_arg5";
1107    break 5;])
1108    done
1109   done
1110  done
1111 done
1112done
1113# Provide a safe default value.
1114: ${gdb_cv_func_ptrace_args='int,int,long,long'}
1115])])
1116ac_save_IFS=$IFS; IFS=','
1117set dummy `echo "$gdb_cv_func_ptrace_args" | sed 's/\*/\*/g'`
1118IFS=$ac_save_IFS
1119shift
1120AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG3, $[3],
1121  [Define to the type of arg 3 for ptrace.])
1122if test -n "$[5]"; then
1123  AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG5, $[5],
1124    [Define to the type of arg 5 for ptrace.])
1125fi
1126
1127dnl AC_FUNC_SETPGRP does not work when cross compiling
1128dnl Instead, assume we will have a prototype for setpgrp if cross compiling.
1129if test "$cross_compiling" = no; then
1130  AC_FUNC_SETPGRP
1131else
1132  AC_CACHE_CHECK([whether setpgrp takes no argument], ac_cv_func_setpgrp_void,
1133    [AC_TRY_COMPILE([
1134#include <unistd.h>
1135], [
1136  if (setpgrp(1,1) == -1)
1137    exit (0);
1138  else
1139    exit (1);
1140], ac_cv_func_setpgrp_void=no, ac_cv_func_setpgrp_void=yes)])
1141if test $ac_cv_func_setpgrp_void = yes; then
1142  AC_DEFINE(SETPGRP_VOID, 1)
1143fi
1144fi
1145
1146# Check if sigsetjmp is available.  Using AC_CHECK_FUNCS won't do
1147# since sigsetjmp might only be defined as a macro.
1148AC_CACHE_CHECK([for sigsetjmp], gdb_cv_func_sigsetjmp,
1149[AC_TRY_COMPILE([
1150#include <setjmp.h>
1151], [sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);],
1152gdb_cv_func_sigsetjmp=yes, gdb_cv_func_sigsetjmp=no)])
1153if test $gdb_cv_func_sigsetjmp = yes; then
1154  AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ])
1155fi
1156
1157# Assume we'll default to using the included libiberty regex.
1158gdb_use_included_regex=yes
1159
1160# However, if the system regex is GNU regex, then default to *not*
1161# using the included regex.
1162AC_CACHE_CHECK(
1163  [for GNU regex],
1164  [gdb_cv_have_gnu_regex],
1165  [AC_TRY_COMPILE(
1166    [#include <gnu-versions.h>],
1167    [#define REGEX_INTERFACE_VERSION 1
1168#if _GNU_REGEX_INTERFACE_VERSION != REGEX_INTERFACE_VERSION
1169# error "Version mismatch"
1170#endif],
1171    gdb_cv_have_gnu_regex=yes,
1172    gdb_cv_have_gnu_regex=no)])
1173if test $gdb_cv_have_gnu_regex = yes; then
1174  gdb_use_included_regex=no
1175fi
1176
1177AC_ARG_WITH(included-regex,
1178  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)]),
1179  gdb_with_regex=$withval,
1180  gdb_with_regex=$gdb_use_included_regex)
1181if test "$gdb_with_regex" = yes; then
1182  AC_DEFINE(USE_INCLUDED_REGEX, 1,
1183    [Define to 1 if the regex included in libiberty should be used.])
1184fi
1185
1186# Check if <sys/proc.h> defines `struct thread' with a td_pcb member.
1187AC_CHECK_MEMBERS([struct thread.td_pcb], [], [],
1188[#include <sys/param.h>
1189#include <sys/proc.h>
1190])
1191
1192# See if <sys/lwp.h> defines `struct lwp`.
1193AC_CACHE_CHECK([for struct lwp], gdb_cv_struct_lwp,
1194[AC_TRY_COMPILE([#include <sys/param.h>
1195#include <sys/lwp.h>], [struct lwp l;],
1196gdb_cv_struct_lwp=yes, gdb_cv_struct_lwp=no)])
1197if test $gdb_cv_struct_lwp = yes; then
1198  AC_DEFINE(HAVE_STRUCT_LWP, 1,
1199            [Define to 1 if your system has struct lwp.])
1200fi
1201
1202# See if <machine/reg.h> degines `struct reg'.
1203AC_CACHE_CHECK([for struct reg in machine/reg.h], gdb_cv_struct_reg,
1204[AC_TRY_COMPILE([#include <sys/types.h>
1205#include <machine/reg.h>], [struct reg r;],
1206gdb_cv_struct_reg=yes, gdb_cv_struct_reg=no)])
1207if test $gdb_cv_struct_reg = yes; then
1208  AC_DEFINE(HAVE_STRUCT_REG, 1,
1209            [Define to 1 if your system has struct reg in <machine/reg.h>.])
1210fi
1211
1212# See if <machine/reg.h> supports the %fs and %gs i386 segment registers.
1213# Older i386 BSD's don't have the r_fs and r_gs members of `struct reg'.
1214AC_CHECK_MEMBERS([struct reg.r_fs, struct reg.r_gs], [], [],
1215                 [#include <machine/reg.h>])
1216
1217# See if <sys/ptrace.h> provides the PTRACE_GETREGS request.
1218AC_MSG_CHECKING(for PTRACE_GETREGS)
1219AC_CACHE_VAL(gdb_cv_have_ptrace_getregs,
1220[AC_TRY_COMPILE([#include <sys/ptrace.h>],
1221		[PTRACE_GETREGS;],
1222		[gdb_cv_have_ptrace_getregs=yes],
1223		[gdb_cv_have_ptrace_getregs=no])])
1224AC_MSG_RESULT($gdb_cv_have_ptrace_getregs)
1225if test $gdb_cv_have_ptrace_getregs = yes; then
1226  AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
1227  [Define if sys/ptrace.h defines the PTRACE_GETREGS request.])
1228fi
1229
1230# See if <sys/ptrace.h> provides the PTRACE_GETFPXREGS request.
1231AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
1232AC_CACHE_VAL(gdb_cv_have_ptrace_getfpxregs,
1233[AC_TRY_COMPILE([#include <sys/ptrace.h>],
1234		[PTRACE_GETFPXREGS;],
1235		[gdb_cv_have_ptrace_getfpxregs=yes],
1236		[gdb_cv_have_ptrace_getfpxregs=no])])
1237AC_MSG_RESULT($gdb_cv_have_ptrace_getfpxregs)
1238if test $gdb_cv_have_ptrace_getfpxregs = yes; then
1239  AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
1240  [Define if sys/ptrace.h defines the PTRACE_GETFPXREGS request.])
1241fi
1242
1243# See if <sys/ptrace.h> provides the PT_GETDBREGS request.
1244AC_MSG_CHECKING(for PT_GETDBREGS)
1245AC_CACHE_VAL(gdb_cv_have_pt_getdbregs,
1246[AC_TRY_COMPILE([#include <sys/types.h>
1247#include <sys/ptrace.h>],
1248		[PT_GETDBREGS;],
1249		[gdb_cv_have_pt_getdbregs=yes],
1250		[gdb_cv_have_pt_getdbregs=no])])
1251AC_MSG_RESULT($gdb_cv_have_pt_getdbregs)
1252if test $gdb_cv_have_pt_getdbregs = yes; then
1253  AC_DEFINE(HAVE_PT_GETDBREGS, 1,
1254  [Define if sys/ptrace.h defines the PT_GETDBREGS request.])
1255fi
1256
1257# See if <sys/ptrace.h> provides the PT_GETXMMREGS request.
1258AC_MSG_CHECKING(for PT_GETXMMREGS)
1259AC_CACHE_VAL(gdb_cv_have_pt_getxmmregs,
1260[AC_TRY_COMPILE([#include <sys/types.h>
1261#include <sys/ptrace.h>],
1262		[PT_GETXMMREGS;],
1263		[gdb_cv_have_pt_getxmmregs=yes],
1264		[gdb_cv_have_pt_getxmmregs=no])])
1265AC_MSG_RESULT($gdb_cv_have_pt_getxmmregs)
1266if test $gdb_cv_have_pt_getxmmregs = yes; then
1267  AC_DEFINE(HAVE_PT_GETXMMREGS, 1,
1268  [Define if sys/ptrace.h defines the PT_GETXMMREGS request.])
1269fi
1270
1271# Detect which type of /proc is in use, such as for Unixware or Solaris.
1272
1273if test "${target}" = "${host}"; then
1274  case "${host}" in
1275  *-*-unixware* | *-*-sysv4.2* | *-*-sysv5* | *-*-interix* )
1276      AC_DEFINE(NEW_PROC_API, 1,
1277      [Define if you want to use new multi-fd /proc interface
1278       (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros).])
1279      ;;
1280  *-*-solaris2.[[6789]] | *-*-solaris2.1[[0-9]]*)
1281      AC_DEFINE(NEW_PROC_API, 1,
1282      [Define if you want to use new multi-fd /proc interface
1283       (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros).])
1284      ;;
1285  mips-sgi-irix5*)
1286      # Work around <sys/proc.h> needing _KMEMUSER problem on IRIX 5.
1287      AC_DEFINE([_KMEMUSER], 1,
1288      [Define to 1 so <sys/proc.h> gets a definition of anon_hdl.  Works
1289       around a <sys/proc.h> problem on IRIX 5.])
1290      ;;
1291  esac
1292fi
1293
1294if test "$ac_cv_header_sys_procfs_h" = yes; then
1295  BFD_HAVE_SYS_PROCFS_TYPE(pstatus_t)
1296  BFD_HAVE_SYS_PROCFS_TYPE(prrun_t)
1297  BFD_HAVE_SYS_PROCFS_TYPE(gregset_t)
1298  BFD_HAVE_SYS_PROCFS_TYPE(fpregset_t)
1299  BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
1300  BFD_HAVE_SYS_PROCFS_TYPE(prfpregset_t)
1301  BFD_HAVE_SYS_PROCFS_TYPE(prgregset32_t)
1302  BFD_HAVE_SYS_PROCFS_TYPE(prfpregset32_t)
1303  BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
1304  BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
1305  BFD_HAVE_SYS_PROCFS_TYPE(prsysent_t)
1306  BFD_HAVE_SYS_PROCFS_TYPE(pr_sigset_t)
1307  BFD_HAVE_SYS_PROCFS_TYPE(pr_sigaction64_t)
1308  BFD_HAVE_SYS_PROCFS_TYPE(pr_siginfo64_t)
1309
1310
1311  dnl Check for broken prfpregset_t type
1312
1313  dnl For Linux/i386, glibc 2.1.3 was released with a bogus
1314  dnl prfpregset_t type (it's a typedef for the pointer to a struct
1315  dnl instead of the struct itself).  We detect this here, and work
1316  dnl around it in gdb_proc_service.h.
1317
1318  if test $bfd_cv_have_sys_procfs_type_prfpregset_t = yes; then
1319    AC_MSG_CHECKING(whether prfpregset_t type is broken)
1320    AC_CACHE_VAL(gdb_cv_prfpregset_t_broken,
1321      [AC_TRY_RUN([#include <sys/procfs.h>
1322       int main ()
1323       {
1324         if (sizeof (prfpregset_t) == sizeof (void *))
1325           return 1;
1326         return 0;
1327       }],
1328       gdb_cv_prfpregset_t_broken=no,
1329       gdb_cv_prfpregset_t_broken=yes,
1330       gdb_cv_prfpregset_t_broken=yes)])
1331    AC_MSG_RESULT($gdb_cv_prfpregset_t_broken)
1332    if test $gdb_cv_prfpregset_t_broken = yes; then
1333      AC_DEFINE(PRFPREGSET_T_BROKEN, 1,
1334      [Define if the prfpregset_t type is broken.])
1335    fi
1336  fi
1337
1338  dnl Check for PIOCSET ioctl entry
1339
1340  AC_MSG_CHECKING(for PIOCSET ioctl entry in sys/procfs.h)
1341  AC_CACHE_VAL(gdb_cv_have_procfs_piocset,
1342  [AC_TRY_COMPILE([#include <unistd.h>
1343#include <sys/types.h>
1344#include <sys/procfs.h>
1345], [
1346    int dummy;;
1347    dummy = ioctl(0, PIOCSET, &dummy);
1348  ],
1349  gdb_cv_have_procfs_piocset=yes, gdb_cv_have_procfs_piocset=no)])
1350  AC_MSG_RESULT($gdb_cv_have_procfs_piocset)
1351  if test $gdb_cv_have_procfs_piocset = yes; then
1352    AC_DEFINE(HAVE_PROCFS_PIOCSET, 1,
1353    [Define if ioctl argument PIOCSET is available.])
1354  fi
1355fi
1356
1357dnl For native ports (host == target), check to see what kind of
1358dnl legacy link.h support is needed.  (See solib-legacy.c.)
1359if test ${host} = ${target} ; then
1360  dnl Check for struct link_map with l_ members which are indicative
1361  dnl of SVR4-like shared libraries
1362
1363  AC_MSG_CHECKING(for member l_addr in struct link_map)
1364  AC_CACHE_VAL(gdb_cv_have_struct_link_map_with_l_members,
1365    [AC_TRY_COMPILE([#include <link.h>],
1366                    [struct link_map lm; (void) lm.l_addr;],
1367                    gdb_cv_have_struct_link_map_with_l_members=yes,
1368                    gdb_cv_have_struct_link_map_with_l_members=no)])
1369  AC_MSG_RESULT($gdb_cv_have_struct_link_map_with_l_members)
1370  if test $gdb_cv_have_struct_link_map_with_l_members = yes; then
1371    AC_DEFINE(HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS,1,
1372    [Define if <link.h> exists and defines struct link_map which has
1373     members with an ``l_'' prefix.  (For Solaris, SVR4, and
1374     SVR4-like systems.)])
1375  fi
1376
1377  dnl Check for struct link_map with lm_ members which are indicative
1378  dnl of SunOS-like shared libraries
1379
1380  AC_MSG_CHECKING(for member lm_addr in struct link_map)
1381  AC_CACHE_VAL(gdb_cv_have_struct_link_map_with_lm_members,
1382    [AC_TRY_COMPILE([#include <sys/types.h>
1383#include <link.h>],
1384                    [struct link_map lm; (void) lm.lm_addr;],
1385                    gdb_cv_have_struct_link_map_with_lm_members=yes,
1386                    gdb_cv_have_struct_link_map_with_lm_members=no)])
1387  AC_MSG_RESULT($gdb_cv_have_struct_link_map_with_lm_members)
1388  if test $gdb_cv_have_struct_link_map_with_lm_members = yes; then
1389    AC_DEFINE(HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS, 1,
1390    [Define if <link.h> exists and defines struct link_map which has
1391     members with an ``lm_'' prefix.  (For SunOS.)])
1392  fi
1393
1394  dnl Check for struct so_map with som_ members which are found on
1395  dnl some *BSD systems.
1396
1397  AC_MSG_CHECKING(for member som_addr in struct so_map)
1398  AC_CACHE_VAL(gdb_cv_have_struct_so_map_with_som_members,
1399    [AC_TRY_COMPILE([#include <sys/types.h>
1400#ifdef HAVE_NLIST_H
1401#include <nlist.h>
1402#endif
1403#include <link.h>],
1404                    [struct so_map lm; (void) lm.som_addr;],
1405                    gdb_cv_have_struct_so_map_with_som_members=yes,
1406                    gdb_cv_have_struct_so_map_with_som_members=no)])
1407  AC_MSG_RESULT($gdb_cv_have_struct_so_map_with_som_members)
1408  if test $gdb_cv_have_struct_so_map_with_som_members = yes; then
1409    AC_DEFINE(HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS, 1,
1410    [Define if <link.h> exists and defines a struct so_map which has
1411     members with an ``som_'' prefix.  (Found on older *BSD systems.)])
1412  fi
1413
1414  dnl Check for struct link_map32 type, which allows a 64-bit Solaris
1415  dnl debugger to debug a 32-bit Solaris app with 32-bit shared libraries.
1416
1417  AC_MSG_CHECKING(for struct link_map32 in sys/link.h)
1418  AC_CACHE_VAL(gdb_cv_have_struct_link_map32,
1419    [AC_TRY_COMPILE([#define _SYSCALL32
1420#include <sys/link.h>], [struct link_map32 l;],
1421     gdb_cv_have_struct_link_map32=yes,
1422     gdb_cv_have_struct_link_map32=no)])
1423  AC_MSG_RESULT($gdb_cv_have_struct_link_map32)
1424  if test $gdb_cv_have_struct_link_map32 = yes; then
1425    AC_DEFINE(HAVE_STRUCT_LINK_MAP32, 1,
1426    [Define if <sys/link.h> has struct link_map32])
1427    AC_DEFINE(_SYSCALL32, 1,
1428    [Define if <sys/link.h> has link_map32 (solaris sparc-64 target)])
1429  fi
1430fi
1431
1432# Check if the compiler supports the `long long' type.
1433
1434AC_CACHE_CHECK([for long long support in compiler], gdb_cv_c_long_long,
1435               [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1436[[extern long long foo;]],
1437[[switch (foo & 2) { case 0: return 1; }]])],
1438                                  gdb_cv_c_long_long=yes,
1439                                  gdb_cv_c_long_long=no)])
1440if test $gdb_cv_c_long_long = yes; then
1441  AC_DEFINE(CC_HAS_LONG_LONG, 1,
1442            [Define to 1 if the compiler supports long long.])
1443fi
1444
1445# Check if the compiler and runtime support printing long longs.
1446
1447AC_CACHE_CHECK([for long long support in printf],
1448               gdb_cv_printf_has_long_long,
1449               [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1450[[char buf[32];
1451  long long l = 0;
1452  l = (l << 16) + 0x0123;
1453  l = (l << 16) + 0x4567;
1454  l = (l << 16) + 0x89ab;
1455  l = (l << 16) + 0xcdef;
1456  sprintf (buf, "0x%016llx", l);
1457  return (strcmp ("0x0123456789abcdef", buf));]])],
1458                              gdb_cv_printf_has_long_long=yes,
1459                              gdb_cv_printf_has_long_long=no,
1460                              gdb_cv_printf_has_long_long=no)])
1461if test $gdb_cv_printf_has_long_long = yes; then
1462  AC_DEFINE(PRINTF_HAS_LONG_LONG, 1,
1463            [Define to 1 if the "%ll" format works to print long longs.])
1464fi
1465
1466# Check if the compiler and runtime support printing decfloats.
1467
1468AC_CACHE_CHECK([for decfloat support in printf],
1469               gdb_cv_printf_has_decfloat,
1470               [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1471[[char buf[64];
1472  _Decimal32 d32 = 1.2345df;
1473  _Decimal64 d64 = 1.2345dd;
1474  _Decimal128 d128 = 1.2345dl;
1475  sprintf (buf, "Decimal32: %H\nDecimal64: %D\nDecimal128: %DD", d32, d64, d128);
1476  return (strcmp ("Decimal32: 1.2345\nDecimal64: 1.2345\nDecimal128: 1.2345", buf));]])],
1477                              gdb_cv_printf_has_decfloat=yes,
1478                              gdb_cv_printf_has_decfloat=no,
1479                              gdb_cv_printf_has_decfloat=no)])
1480if test $gdb_cv_printf_has_decfloat = yes; then
1481  AC_DEFINE(PRINTF_HAS_DECFLOAT, 1,
1482            [Define to 1 if the "%H, %D and %DD" formats work to print decfloats.])
1483fi
1484
1485# Check if the compiler supports the `long double' type.  We can't use
1486# AC_C_LONG_DOUBLE because that one does additional checks on the
1487# constants defined in <float.h> that fail on some systems,
1488# e.g. FreeBSD/i386 4.7 and OpenBSD/i386 3.6.
1489
1490AC_CACHE_CHECK([for long double support in compiler], gdb_cv_c_long_double,
1491               [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[long double foo;]])],
1492                                  gdb_cv_c_long_double=yes,
1493                                  gdb_cv_c_long_double=no)])
1494if test $gdb_cv_c_long_double = yes; then
1495  AC_DEFINE(HAVE_LONG_DOUBLE, 1,
1496           [Define to 1 if the compiler supports long double.])
1497fi
1498
1499# Check if the compiler and runtime support printing long doubles.
1500
1501AC_CACHE_CHECK([for long double support in printf],
1502               gdb_cv_printf_has_long_double,
1503               [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1504[[char buf[16];
1505  long double f = 3.141592653;
1506  sprintf (buf, "%Lg", f);
1507  return (strncmp ("3.14159", buf, 7));]])],
1508                              gdb_cv_printf_has_long_double=yes,
1509                              gdb_cv_printf_has_long_double=no,
1510                              gdb_cv_printf_has_long_double=no)])
1511if test $gdb_cv_printf_has_long_double = yes; then
1512  AC_DEFINE(PRINTF_HAS_LONG_DOUBLE, 1,
1513            [Define to 1 if the "%Lg" format works to print long doubles.])
1514fi
1515
1516# Check if the compiler and runtime support scanning long doubles.
1517
1518AC_CACHE_CHECK([for long double support in scanf],
1519               gdb_cv_scanf_has_long_double,
1520               [AC_RUN_IFELSE([AC_LANG_PROGRAM(
1521[[#include <stdio.h>]],
1522[[char *buf = "3.141592653";
1523  long double f = 0;
1524  sscanf (buf, "%Lg", &f);
1525  return !(f > 3.14159 && f < 3.14160);]])],
1526                              gdb_cv_scanf_has_long_double=yes,
1527                              gdb_cv_scanf_has_long_double=no,
1528                              gdb_cv_scanf_has_long_double=no)])
1529if test $gdb_cv_scanf_has_long_double = yes; then
1530  AC_DEFINE(SCANF_HAS_LONG_DOUBLE, 1,
1531            [Define to 1 if the "%Lg" format works to scan long doubles.])
1532fi
1533
1534case ${host_os} in
1535aix*)
1536  AC_CACHE_CHECK([for -bbigtoc option], [gdb_cv_bigtoc], [
1537    SAVE_LDFLAGS=$LDFLAGS
1538
1539    case $GCC in
1540    yes) gdb_cv_bigtoc=-Wl,-bbigtoc ;;
1541    *) gdb_cv_bigtoc=-bbigtoc ;;
1542    esac
1543
1544    LDFLAGS=$LDFLAGS\ $gdb_cv_bigtoc
1545    AC_TRY_LINK([], [int i;], [], [gdb_cv_bigtoc=])
1546    LDFLAGS="${SAVE_LDFLAGS}"
1547  ])
1548  CONFIG_LDFLAGS="${CONFIG_LDFLAGS} ${gdb_cv_bigtoc}"
1549  ;;
1550esac
1551
1552AC_MSG_CHECKING(for the dynamic export flag)
1553dynamic_list=false
1554if test "${gdb_native}" = yes; then
1555   # The dynamically loaded libthread_db needs access to symbols in the gdb
1556   # executable.  Older GNU ld supports --export-dynamic but --dynamic-list
1557   # may not be supported there.
1558   old_LDFLAGS="$LDFLAGS"
1559   # Older GNU ld supports --export-dynamic but --dynamic-list it does not.
1560   RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
1561   LDFLAGS="$LDFLAGS $RDYNAMIC"
1562   if test "${have_libpython}" = no; then
1563     AC_TRY_LINK([], [], [dynamic_list=true])
1564   else
1565     # Workaround http://bugs.python.org/issue4434 where static
1566     # libpythonX.Y.a would get its symbols required for
1567     # pythonX.Y/lib-dynload/*.so modules hidden by -Wl,--dynamic-list.
1568     # Problem does not happen for the recommended libpythonX.Y.so linkage.
1569     old_CFLAGS="$CFLAGS"
1570     CFLAGS="$CFLAGS $PYTHON_CFLAGS"
1571     AC_RUN_IFELSE(
1572       AC_LANG_PROGRAM(
1573         [#include "]${have_libpython}[/Python.h"],
1574         [int err;
1575          Py_Initialize ();
1576          err = PyRun_SimpleString ("import itertools\n");
1577          Py_Finalize ();
1578          return err == 0 ? 0 : 1;]),
1579       [dynamic_list=true], [], [true])
1580     CFLAGS="$old_CFLAGS"
1581   fi
1582   LDFLAGS="$old_LDFLAGS"
1583fi
1584if $dynamic_list; then
1585  found="-Wl,--dynamic-list"
1586  RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'
1587else
1588  found="-rdynamic"
1589  RDYNAMIC="-rdynamic"
1590fi
1591AC_SUBST(RDYNAMIC)
1592AC_MSG_RESULT($found)
1593
1594dnl For certain native configurations, we need to check whether thread
1595dnl support can be built in or not.
1596dnl
1597dnl Note that we only want this if we are both native (host == target),
1598dnl and not doing a canadian cross build (build == host).
1599
1600if test ${build} = ${host} -a ${host} = ${target} ; then
1601   case ${host_os} in
1602   solaris*)
1603      # See if thread_db library is around for Solaris thread debugging.
1604      # Note that we must explicitly test for version 1 of the library
1605      # because version 0 (present on Solaris 2.4 or earlier) doesn't have
1606      # the same API.
1607      AC_MSG_CHECKING(for Solaris thread debugging library)
1608      if test -f /usr/lib/libthread_db.so.1 ; then
1609         AC_MSG_RESULT(yes)
1610         AC_DEFINE(HAVE_THREAD_DB_LIB, 1,
1611         [Define if using Solaris thread debugging.])
1612         CONFIG_OBS="${CONFIG_OBS} sol-thread.o"
1613         CONFIG_SRCS="${CONFIG_SRCS} sol-thread.c"
1614         AC_CHECK_LIB(dl, dlopen)
1615	 CONFIG_LDFLAGS="${CONFIG_LDFLAGS} $RDYNAMIC"
1616	 # Sun randomly tweaked the prototypes in <proc_service.h>
1617	 # at one point.
1618	 AC_MSG_CHECKING(if <proc_service.h> is old)
1619	 AC_CACHE_VAL(gdb_cv_proc_service_is_old,[
1620	    AC_TRY_COMPILE([
1621		#include <proc_service.h>
1622		ps_err_e ps_pdwrite
1623		    (struct ps_prochandle*, psaddr_t, const void*, size_t);
1624	    ],, gdb_cv_proc_service_is_old=no,
1625	        gdb_cv_proc_service_is_old=yes)
1626	 ])
1627	 AC_MSG_RESULT($gdb_cv_proc_service_is_old)
1628	 if test $gdb_cv_proc_service_is_old = yes; then
1629	    AC_DEFINE(PROC_SERVICE_IS_OLD, 1,
1630            [Define if <proc_service.h> on solaris uses int instead of
1631             size_t, and assorted other type changes.])
1632	 fi
1633      else
1634         AC_MSG_RESULT(no)
1635      fi
1636      ;;
1637   aix*)
1638      AC_MSG_CHECKING(for AiX thread debugging library)
1639      AC_CACHE_VAL(gdb_cv_have_aix_thread_debug,
1640                   [AC_TRY_COMPILE([#include <sys/pthdebug.h>],
1641                                   [#ifndef PTHDB_VERSION_3
1642                                    #error
1643                                    #endif],
1644                                   gdb_cv_have_aix_thread_debug=yes,
1645                                   gdb_cv_have_aix_thread_debug=no)])
1646      AC_MSG_RESULT($gdb_cv_have_aix_thread_debug)
1647      if test $gdb_cv_have_aix_thread_debug = yes; then
1648         CONFIG_SRCS="${CONFIG_SRCS} aix-thread.c"
1649         CONFIG_OBS="${CONFIG_OBS} aix-thread.o"
1650         CONFIG_LDFLAGS="${CONFIG_LDFLAGS} -lpthdebug"
1651
1652         # Older versions of AIX do not provide the declaration for
1653         # the getthrds function (it appears that it was introduced
1654         # with AIX 6.x).
1655         AC_CHECK_DECLS(getthrds, [], [], [[#include <procinfo.h>]])
1656      fi
1657      ;;
1658   esac
1659   AC_SUBST(CONFIG_LDFLAGS)
1660fi
1661
1662dnl See if we have a thread_db header file that has TD_NOTALLOC and
1663dnl other error codes.
1664if test "x$ac_cv_header_thread_db_h" = "xyes"; then
1665   AC_CACHE_CHECK([whether <thread_db.h> has TD_NOTALLOC],
1666                  gdb_cv_thread_db_h_has_td_notalloc,
1667     AC_TRY_COMPILE(
1668       [#include <thread_db.h>],
1669       [int i = TD_NOTALLOC;],
1670       gdb_cv_thread_db_h_has_td_notalloc=yes,
1671       gdb_cv_thread_db_h_has_td_notalloc=no
1672     )
1673   )
1674   AC_CACHE_CHECK([whether <thread_db.h> has TD_VERSION],
1675                  gdb_cv_thread_db_h_has_td_version,
1676     AC_TRY_COMPILE(
1677       [#include <thread_db.h>],
1678       [int i = TD_VERSION;],
1679       gdb_cv_thread_db_h_has_td_version=yes,
1680       gdb_cv_thread_db_h_has_td_version=no
1681     )
1682   )
1683   AC_CACHE_CHECK([whether <thread_db.h> has TD_NOTLS],
1684                  gdb_cv_thread_db_h_has_td_notls,
1685     AC_TRY_COMPILE(
1686       [#include <thread_db.h>],
1687       [int i = TD_NOTLS;],
1688       gdb_cv_thread_db_h_has_td_notls=yes,
1689       gdb_cv_thread_db_h_has_td_notls=no
1690     )
1691   )
1692fi
1693if test "x$gdb_cv_thread_db_h_has_td_notalloc" = "xyes"; then
1694  AC_DEFINE(THREAD_DB_HAS_TD_NOTALLOC, 1,
1695            [Define if <thread_db.h> has the TD_NOTALLOC error code.])
1696fi
1697if test "x$gdb_cv_thread_db_h_has_td_version" = "xyes"; then
1698  AC_DEFINE(THREAD_DB_HAS_TD_VERSION, 1,
1699            [Define if <thread_db.h> has the TD_VERSION error code.])
1700fi
1701if test "x$gdb_cv_thread_db_h_has_td_notls" = "xyes"; then
1702  AC_DEFINE(THREAD_DB_HAS_TD_NOTLS, 1,
1703            [Define if <thread_db.h> has the TD_NOTLS error code.])
1704fi
1705
1706dnl See if we have a sys/syscall header file that has __NR_tkill.
1707if test "x$ac_cv_header_sys_syscall_h" = "xyes"; then
1708   AC_CACHE_CHECK([whether <sys/syscall.h> has __NR_tkill],
1709                  gdb_cv_sys_syscall_h_has_tkill,
1710     AC_TRY_COMPILE(
1711       [#include <sys/syscall.h>],
1712       [int i = __NR_tkill;],
1713       gdb_cv_sys_syscall_h_has_tkill=yes,
1714       gdb_cv_sys_syscall_h_has_tkill=no
1715     )
1716   )
1717fi
1718dnl See if we can issue tkill syscall.
1719if test "x$gdb_cv_sys_syscall_h_has_tkill" = "xyes" && test "x$ac_cv_func_syscall" = "xyes"; then
1720  AC_DEFINE(HAVE_TKILL_SYSCALL, 1, [Define if you support the tkill syscall.])
1721fi
1722
1723dnl Check if we can disable the virtual address space randomization.
1724dnl The functionality of setarch -R.
1725AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
1726define([PERSONALITY_TEST], [AC_LANG_PROGRAM([#include <sys/personality.h>], [
1727#      if !HAVE_DECL_ADDR_NO_RANDOMIZE
1728#       define ADDR_NO_RANDOMIZE 0x0040000
1729#      endif
1730       /* Test the flag could be set and stays set.  */
1731       personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
1732       if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
1733	   return 1])])
1734AC_RUN_IFELSE([PERSONALITY_TEST],
1735	      [have_personality=true],
1736	      [have_personality=false],
1737	      [AC_LINK_IFELSE([PERSONALITY_TEST],
1738			      [have_personality=true],
1739			      [have_personality=false])])
1740if $have_personality
1741then
1742    AC_DEFINE([HAVE_PERSONALITY], 1,
1743	      [Define if you support the personality syscall.])
1744fi
1745
1746dnl Handle optional features that can be enabled.
1747
1748target_sysroot_reloc=0
1749AC_ARG_WITH(sysroot,
1750AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@], [search for usr/lib et al within DIR]),
1751[
1752 case ${with_sysroot} in
1753 yes) TARGET_SYSTEM_ROOT='${exec_prefix}/${target_alias}/sys-root' ;;
1754 *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
1755 esac
1756
1757 TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
1758
1759 if test "x$prefix" = xNONE; then
1760  test_prefix=/usr/local
1761 else
1762  test_prefix=$prefix
1763 fi
1764 if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
1765  test_exec_prefix=$test_prefix
1766 else
1767  test_exec_prefix=$exec_prefix
1768 fi
1769 case ${TARGET_SYSTEM_ROOT} in
1770 "${test_prefix}"|"${test_prefix}/"*|\
1771 "${test_exec_prefix}"|"${test_exec_prefix}/"*|\
1772 '${prefix}'|'${prefix}/'*|\
1773 '${exec_prefix}'|'${exec_prefix}/'*)
1774   target_sysroot_reloc=1
1775   ;;
1776 esac
1777], [
1778 TARGET_SYSTEM_ROOT=
1779 TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"\"'
1780])
1781TARGET_SYSTEM_ROOT_DEFINE="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE=$target_sysroot_reloc"
1782AC_SUBST(TARGET_SYSTEM_ROOT)
1783AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
1784
1785GDB_AC_WITH_DIR(SYSTEM_GDBINIT, system-gdbinit,
1786    [automatically load a system-wide gdbinit file],
1787    [])
1788
1789AC_ARG_ENABLE(werror,
1790  AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
1791  [case "${enableval}" in
1792     yes | y) ERROR_ON_WARNING="yes" ;;
1793     no | n)  ERROR_ON_WARNING="no" ;;
1794     *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
1795   esac])
1796
1797WERROR_CFLAGS=""
1798if test "${ERROR_ON_WARNING}" = yes ; then
1799    WERROR_CFLAGS="-Werror"
1800fi
1801
1802# The entries after -Wno-pointer-sign are disabled warnings which may
1803# be enabled in the future, which can not currently be used to build
1804# GDB.
1805# NOTE: If you change this list, remember to update
1806# gdb/doc/gdbint.texinfo.
1807build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
1808-Wformat-nonliteral -Wno-pointer-sign \
1809-Wno-unused -Wunused-value -Wunused-function \
1810-Wno-switch -Wno-char-subscripts"
1811
1812# Enable -Wno-format by default when using gcc on mingw since many
1813# GCC versions complain about %I64.
1814case "${host}" in
1815  *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;;
1816esac
1817
1818AC_ARG_ENABLE(build-warnings,
1819AS_HELP_STRING([--enable-build-warnings], [enable build-time compiler warnings if gcc is used]),
1820[case "${enableval}" in
1821  yes)	;;
1822  no)	build_warnings="-w";;
1823  ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
1824        build_warnings="${build_warnings} ${t}";;
1825  *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
1826        build_warnings="${t} ${build_warnings}";;
1827  *)    build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
1828esac
1829if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
1830  echo "Setting compiler warning flags = $build_warnings" 6>&1
1831fi])dnl
1832AC_ARG_ENABLE(gdb-build-warnings,
1833AS_HELP_STRING([--enable-gdb-build-warnings], [enable GDB specific build-time compiler warnings if gcc is used]),
1834[case "${enableval}" in
1835  yes)	;;
1836  no)	build_warnings="-w";;
1837  ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
1838        build_warnings="${build_warnings} ${t}";;
1839  *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
1840        build_warnings="${t} ${build_warnings}";;
1841  *)    build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
1842esac
1843if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
1844  echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
1845fi])dnl
1846WARN_CFLAGS=""
1847if test "x${build_warnings}" != x -a "x$GCC" = xyes
1848then
1849    AC_MSG_CHECKING(compiler warning flags)
1850    # Separate out the -Werror flag as some files just cannot be
1851    # compiled with it enabled.
1852    for w in ${build_warnings}; do
1853	case $w in
1854	-Werr*) WERROR_CFLAGS=-Werror ;;
1855	*) # Check that GCC accepts it
1856	    saved_CFLAGS="$CFLAGS"
1857	    CFLAGS="$CFLAGS $w"
1858	    AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
1859	    CFLAGS="$saved_CFLAGS"
1860	esac
1861    done
1862    AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
1863fi
1864AC_SUBST(WARN_CFLAGS)
1865AC_SUBST(WERROR_CFLAGS)
1866
1867# In the Cygwin environment, we need some additional flags.
1868AC_CACHE_CHECK([for cygwin], gdb_cv_os_cygwin,
1869[AC_EGREP_CPP(lose, [
1870#if defined (__CYGWIN__) || defined (__CYGWIN32__)
1871lose
1872#endif],[gdb_cv_os_cygwin=yes],[gdb_cv_os_cygwin=no])])
1873
1874
1875dnl Figure out which of the many generic ser-*.c files the _host_ supports.
1876SER_HARDWIRE="ser-base.o ser-unix.o ser-pipe.o ser-tcp.o"
1877case ${host} in
1878  *go32* ) SER_HARDWIRE=ser-go32.o ;;
1879  *djgpp* ) SER_HARDWIRE=ser-go32.o ;;
1880  *mingw32*) SER_HARDWIRE="ser-base.o ser-tcp.o ser-mingw.o" ;;
1881esac
1882AC_SUBST(SER_HARDWIRE)
1883
1884# libreadline needs libuser32.a in a cygwin environment
1885WIN32LIBS=
1886if test x$gdb_cv_os_cygwin = xyes; then
1887    WIN32LIBS="-luser32"
1888    case "${target}" in
1889	*cygwin*) WIN32LIBS="$WIN32LIBS -limagehlp"
1890	;;
1891    esac
1892fi
1893
1894# The ser-tcp.c module requires sockets.
1895case ${host} in
1896  *mingw32*)
1897    AC_DEFINE(USE_WIN32API, 1,
1898              [Define if we should use the Windows API, instead of the
1899	       POSIX API.  On Windows, we use the Windows API when
1900	       building for MinGW, but the POSIX API when building
1901	       for Cygwin.])
1902    WIN32LIBS="$WIN32LIBS -lws2_32"
1903    ;;
1904esac
1905AC_SUBST(WIN32LIBS)
1906
1907# Add ELF support to GDB, but only if BFD includes ELF support.
1908OLD_CFLAGS=$CFLAGS
1909OLD_LDFLAGS=$LDFLAGS
1910OLD_LIBS=$LIBS
1911CFLAGS="$CFLAGS -I${srcdir}/../include -I../bfd -I${srcdir}/../bfd"
1912LDFLAGS="$LDFLAGS -L../bfd -L../libiberty"
1913intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
1914# -ldl is provided by bfd/Makfile.am (LIBDL) <PLUGINS>.
1915if test "$plugins" = "yes"; then
1916  LIBS="-ldl $LIBS"
1917fi
1918LIBS="-lbfd -liberty $intl $LIBS"
1919AC_CACHE_CHECK([for ELF support in BFD], gdb_cv_var_elf,
1920[AC_TRY_LINK(
1921[#include <stdlib.h>
1922#include "bfd.h"
1923#include "elf-bfd.h"
1924],
1925[bfd *abfd = NULL; bfd_get_elf_phdr_upper_bound (abfd); ],
1926gdb_cv_var_elf=yes, gdb_cv_var_elf=no)])
1927if test $gdb_cv_var_elf = yes; then
1928  CONFIG_OBS="$CONFIG_OBS elfread.o"
1929  AC_DEFINE(HAVE_ELF, 1,
1930	    [Define if ELF support should be included.])
1931  # -ldl is provided by bfd/Makfile.am (LIBDL) <PLUGINS>.
1932  if test "$plugins" = "yes"; then
1933    OLD_LIBS="-ldl $OLD_LIBS"
1934  fi
1935fi
1936CFLAGS=$OLD_CFLAGS
1937LDFLAGS=$OLD_LDFLAGS
1938LIBS=$OLD_LIBS
1939
1940# Add any host-specific objects to GDB.
1941CONFIG_OBS="${CONFIG_OBS} ${gdb_host_obs}"
1942
1943LIBGUI="../libgui/src/libgui.a"
1944GUI_CFLAGS_X="-I${srcdir}/../libgui/src"
1945AC_SUBST(LIBGUI)
1946AC_SUBST(GUI_CFLAGS_X)
1947
1948WIN32LDAPP=
1949AC_SUBST(WIN32LIBS)
1950AC_SUBST(WIN32LDAPP)
1951
1952case "${host}" in
1953*-*-cygwin* | *-*-mingw* )
1954    configdir="win"
1955    ;;
1956*)
1957    configdir="unix"
1958    ;;
1959esac
1960
1961GDBTKLIBS=
1962if test "${enable_gdbtk}" = "yes"; then
1963
1964    # Gdbtk must have an absolute path to srcdir in order to run
1965    # properly when not installed.
1966    here=`pwd`
1967    cd ${srcdir}
1968    GDBTK_SRC_DIR=`pwd`
1969    cd $here
1970
1971    SC_PATH_TCLCONFIG
1972
1973    # If $no_tk is nonempty, then we can't do Tk, and there is no
1974    # point to doing Tcl.
1975    SC_PATH_TKCONFIG
1976
1977    if test -z "${no_tcl}" -a -z "${no_tk}"; then
1978	SC_LOAD_TCLCONFIG
1979
1980        # Check for in-tree tcl
1981        here=`pwd`
1982        cd ${srcdir}/..
1983        topdir=`pwd`
1984        cd ${here}
1985
1986        intree="no"
1987        if test "${TCL_SRC_DIR}" = "${topdir}/tcl"; then
1988          intree="yes"
1989        fi
1990
1991        # Find Tcl private headers
1992        if test x"${intree}" = xno; then
1993          CY_AC_TCL_PRIVATE_HEADERS
1994	  TCL_INCLUDE="${TCL_INCLUDE_SPEC} ${TCL_PRIVATE_INCLUDE}"
1995          TCL_LIBRARY="${TCL_LIB_SPEC}"
1996          TCL_DEPS=""
1997        else
1998          # If building tcl in the same src tree, private headers
1999          # are not needed, but we need to be sure to use the right
2000          # headers library
2001	  TCL_INCLUDE="-I${TCL_SRC_DIR}/generic"
2002          TCL_LIBRARY="${TCL_BUILD_LIB_SPEC}"
2003          TCL_DEPS="../tcl/${configdir}${TCL_LIB_FILE}"
2004        fi
2005	AC_SUBST(TCL_INCLUDE)
2006	AC_SUBST(TCL_LIBRARY)
2007        AC_SUBST(TCL_DEPS)
2008
2009	SC_LOAD_TKCONFIG
2010
2011        # Check for in-tree Tk
2012        intree="no"
2013        if test "${TK_SRC_DIR}" = "${topdir}/tk"; then
2014          intree="yes"
2015        fi
2016
2017        # Find Tk private headers
2018        if test x"${intree}" = xno; then
2019          CY_AC_TK_PRIVATE_HEADERS
2020	  TK_INCLUDE="${TK_INCLUDE_SPEC} ${TK_PRIVATE_INCLUDE}"
2021	  TK_LIBRARY=${TK_LIB_SPEC}
2022          TK_DEPS=""
2023        else
2024          TK_INCLUDE="-I${TK_SRC_DIR}/generic"
2025          TK_LIBRARY="${TK_BUILD_LIB_SPEC}"
2026          TK_DEPS="../tk/${configdir}/${TK_LIB_FILE}"
2027        fi
2028	AC_SUBST(TK_INCLUDE)
2029	AC_SUBST(TK_LIBRARY)
2030	AC_SUBST(TK_DEPS)
2031	AC_SUBST(TK_XINCLUDES)
2032
2033        ENABLE_CFLAGS="${ENABLE_CFLAGS} \$(SUBDIR_GDBTK_CFLAGS)"
2034
2035	# Include some libraries that Tcl and Tk want.
2036	TCL_LIBS='$(LIBGUI) $(TK) $(TCL) $(X11_LDFLAGS) $(X11_LIBS)'
2037	# Yes, the ordering seems wrong here.  But it isn't.
2038	# TK_LIBS is the list of libraries that need to be linked
2039	# after Tcl/Tk.  Note that this isn't put into LIBS.  If it
2040	# were in LIBS then any link tests after this point would
2041	# try to include things like `$(LIBGUI)', which wouldn't work.
2042	GDBTKLIBS="${TCL_LIBS} ${TK_LIBS}"
2043
2044        CONFIG_OBS="${CONFIG_OBS} \$(SUBDIR_GDBTK_OBS)"
2045        CONFIG_DEPS="${CONFIG_DEPS} \$(SUBDIR_GDBTK_DEPS)"
2046        CONFIG_SRCS="${CONFIG_SRCS} \$(SUBDIR_GDBTK_SRCS)"
2047	CONFIG_ALL="${CONFIG_ALL} all-gdbtk"
2048	CONFIG_CLEAN="${CONFIG_CLEAN} clean-gdbtk"
2049	CONFIG_INSTALL="${CONFIG_INSTALL} install-gdbtk"
2050	CONFIG_UNINSTALL="${CONFIG_UNINSTALL} uninstall-gdbtk"
2051
2052	if test x$gdb_cv_os_cygwin = xyes; then
2053	  WIN32LIBS="${WIN32LIBS} -lshell32 -lgdi32 -lcomdlg32 -ladvapi32"
2054	  WIN32LDAPP="-Wl,--subsystem,console"
2055	  CONFIG_OBS="${CONFIG_OBS} gdbres.o"
2056	fi
2057
2058        AC_CONFIG_SUBDIRS(gdbtk)
2059    fi
2060fi
2061
2062AC_SUBST(X_CFLAGS)
2063AC_SUBST(X_LDFLAGS)
2064AC_SUBST(X_LIBS)
2065AC_SUBST(GDBTKLIBS)
2066AC_SUBST(GDBTK_CFLAGS)
2067AC_SUBST(GDBTK_SRC_DIR)
2068
2069AC_PATH_X
2070
2071# Unlike the sim directory, whether a simulator is linked is controlled by
2072# presence of a gdb_sim definition in the target configure.tgt entry.
2073# This code just checks for a few cases where we'd like to ignore those
2074# definitions, even when they're present in the '.mt' file.  These cases
2075# are when --disable-sim is specified, or if the simulator directory is
2076# not part of the source tree.
2077#
2078AC_ARG_ENABLE(sim,
2079AS_HELP_STRING([--enable-sim], [link gdb with simulator]),
2080[echo "enable_sim = $enable_sim";
2081 echo "enableval = ${enableval}";
2082 case "${enableval}" in
2083  yes) ignore_sim=false ;;
2084  no)  ignore_sim=true ;;
2085  *)   ignore_sim=false ;;
2086 esac],
2087[ignore_sim=false])
2088
2089if test ! -d "${srcdir}/../sim"; then
2090  ignore_sim=true
2091fi
2092
2093SIM=
2094SIM_OBS=
2095if test "${ignore_sim}" = "false"; then
2096  if test x"${gdb_sim}" != x ; then
2097    SIM="${gdb_sim}"
2098    SIM_OBS="remote-sim.o"
2099    AC_DEFINE(WITH_SIM, 1, [Define if the simulator is being linked in.])
2100  fi
2101fi
2102AC_SUBST(SIM)
2103AC_SUBST(SIM_OBS)
2104
2105AC_SUBST(ENABLE_CFLAGS)
2106AC_SUBST(PROFILE_CFLAGS)
2107
2108AC_SUBST(CONFIG_OBS)
2109AC_SUBST(CONFIG_DEPS)
2110AC_SUBST(CONFIG_SRCS)
2111AC_SUBST(CONFIG_ALL)
2112AC_SUBST(CONFIG_CLEAN)
2113AC_SUBST(CONFIG_INSTALL)
2114AC_SUBST(CONFIG_UNINSTALL)
2115
2116# List of host floatformats.
2117AC_DEFINE_UNQUOTED(GDB_HOST_FLOAT_FORMAT,$gdb_host_float_format,[Host float floatformat])
2118AC_DEFINE_UNQUOTED(GDB_HOST_DOUBLE_FORMAT,$gdb_host_double_format,[Host double floatformat])
2119AC_DEFINE_UNQUOTED(GDB_HOST_LONG_DOUBLE_FORMAT,$gdb_host_long_double_format,[Host long double floatformat])
2120
2121# target_subdir is used by the testsuite to find the target libraries.
2122target_subdir=
2123if test "${host}" != "${target}"; then
2124    target_subdir="${target_alias}/"
2125fi
2126AC_SUBST(target_subdir)
2127
2128frags=
2129if test "${gdb_native}" = "yes"; then
2130  host_makefile_frag=${srcdir}/config/${gdb_host_cpu}/${gdb_host}.mh
2131  if test ! -f ${host_makefile_frag}; then
2132    AC_MSG_ERROR("*** Gdb does not support native target ${host}")
2133  fi
2134  frags="$frags $host_makefile_frag"
2135else
2136  host_makefile_frag=/dev/null
2137fi
2138
2139AC_SUBST_FILE(host_makefile_frag)
2140AC_SUBST(frags)
2141
2142changequote(,)dnl
2143if test "${gdb_native}" = "yes"; then
2144# We pick this up from the host configuration file (.mh) because we
2145# do not have a native configuration Makefile fragment.
2146nativefile=`sed -n '
2147s/NAT_FILE[ 	]*=[ 	]*\([^ 	]*\)/\1/p
2148' ${host_makefile_frag}`
2149fi
2150changequote([,])
2151
2152if test x"${gdb_osabi}" != x ; then
2153    AC_DEFINE_UNQUOTED(GDB_OSABI_DEFAULT, $gdb_osabi,
2154		       [Define to the default OS ABI for this configuration.])
2155fi
2156
2157# Enable multi-ice-gdb-server.
2158AC_ARG_ENABLE(multi-ice,
2159AS_HELP_STRING([--enable-multi-ice], [build the multi-ice-gdb-server]),
2160  [case $enableval in
2161    yes | no)
2162      ;;
2163    *) AC_MSG_ERROR([bad value $enableval for --enable-multi-ice]) ;;
2164  esac])
2165if test "x$enable_multi_ice" = xyes; then
2166   AC_CONFIG_SUBDIRS(multi-ice)
2167fi
2168
2169AC_ARG_ENABLE(gdbserver,
2170AS_HELP_STRING([--enable-gdbserver],
2171               [automatically build gdbserver (yes/no/auto, default is auto)]),
2172[case "${enableval}" in
2173  yes| no|auto) ;;
2174  *) AC_MSG_ERROR(bad value ${enableval} for --enable-gdbserver option) ;;
2175esac],[enable_gdbserver=auto])
2176
2177# We only build gdbserver automatically in a native configuration, and
2178# only if the user did not explicitly disable its build.
2179if test "$gdb_native" = "yes" -a "$enable_gdbserver" != "no"; then
2180  AC_MSG_CHECKING(whether gdbserver is supported on this host)
2181  if test "x$build_gdbserver" = xyes; then
2182    AC_MSG_RESULT(yes)
2183    AC_CONFIG_SUBDIRS(gdbserver)
2184    gdbserver_build_enabled=yes
2185  else
2186    AC_MSG_RESULT(no)
2187  fi
2188fi
2189
2190# If the user explicitly request the gdbserver to be built, verify that
2191# we were in fact able to enable it.
2192if test "$enable_gdbserver" = "yes" -a "$gdbserver_build_enabled" != "yes"; then
2193  AC_MSG_ERROR(Automatic gdbserver build is not supported for this configuration)
2194fi
2195
2196# If nativefile (NAT_FILE) is not set in config/*/*.m[ht] files, we link
2197# to an empty version.
2198
2199files=
2200links=
2201
2202rm -f nm.h
2203if test "${nativefile}" != ""; then
2204    case "${nativefile}" in
2205      nm-*.h ) GDB_NM_FILE="config/${gdb_host_cpu}/${nativefile}" ;;
2206      * ) GDB_NM_FILE="${nativefile}"
2207    esac
2208    files="${files} ${GDB_NM_FILE}"
2209    links="${links} nm.h"
2210    AC_DEFINE_UNQUOTED(GDB_NM_FILE, "${GDB_NM_FILE}", [nativefile])
2211fi
2212AC_SUBST(GDB_NM_FILE)
2213
2214AC_LINK_FILES($files, $links)
2215
2216dnl Check for exe extension set on certain hosts (e.g. Win32)
2217AC_EXEEXT
2218
2219dnl  Detect the character set used by this host.
2220dnl  At the moment, we just assume it's UTF-8.
2221AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8",
2222          [Define to be a string naming the default host character set.])
2223
2224AC_OUTPUT(Makefile .gdbinit:gdbinit.in doc/Makefile gnulib/Makefile data-directory/Makefile,
2225[
2226case x$CONFIG_HEADERS in
2227xconfig.h:config.in)
2228echo > stamp-h ;;
2229esac
2230])
2231
2232exit 0
2233