1dnl $MirOS: src/gnu/usr.bin/binutils/gdb/configure.ac,v 1.4 2005/07/07 16:22:56 tg Exp $
2dnl
3dnl Autoconf configure script for GDB, the GNU debugger.
4dnl Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
5dnl Free Software Foundation, Inc.
6dnl
7dnl This file is part of GDB.
8dnl
9dnl This program is free software; you can redistribute it and/or modify
10dnl it under the terms of the GNU General Public License as published by
11dnl the Free Software Foundation; either version 2 of the License, or
12dnl (at your option) any later version.
13dnl
14dnl This program is distributed in the hope that it will be useful,
15dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
16dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17dnl GNU General Public License for more details.
18dnl
19dnl You should have received a copy of the GNU General Public License
20dnl along with this program; if not, write to the Free Software
21dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23dnl Process this file with autoconf to produce a configure script.
24
25AC_PREREQ(2.59)dnl
26AC_INIT(main.c)
27AC_CONFIG_HEADER(config.h:config.in)
28AM_MAINTAINER_MODE
29
30AC_PROG_CC
31AC_GNU_SOURCE
32AC_AIX
33AC_ISC_POSIX
34AM_PROG_CC_STDC
35
36AC_CANONICAL_SYSTEM
37
38dnl List of object files and targets accumulated by configure.
39
40CONFIG_OBS=
41CONFIG_DEPS=
42CONFIG_SRCS=
43ENABLE_CFLAGS=
44
45CONFIG_ALL=
46CONFIG_CLEAN=
47CONFIG_INSTALL=
48CONFIG_UNINSTALL=
49
50PACKAGE=gdb
51AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package. ])
52AC_SUBST(PACKAGE)
53
54debugdir=${libdir}/debug
55
56AC_ARG_WITH(separate-debug-dir,
57[  --with-separate-debug-dir=path   Look for global separate debug info in this path [LIBDIR/debug]],
58[debugdir="${withval}"])
59
60AC_DEFINE_DIR(DEBUGDIR, debugdir,
61              [Global directory for separate debug files. ])
62#AC_DEFINE_UNQUOTED(DEBUGDIR, "$debugdir"),
63
64AC_CONFIG_SUBDIRS(doc)
65
66. $srcdir/configure.host
67
68. $srcdir/configure.tgt
69
70# Fetch the default architecture and default target vector from BFD.
71targ=$target; . $srcdir/../bfd/config.bfd
72
73# We only want the first architecture, so strip off the others if
74# there is more than one.
75targ_archs=`echo $targ_archs | sed 's/ .*//'`
76
77if test "x$targ_archs" != x; then
78  AC_DEFINE_UNQUOTED(DEFAULT_BFD_ARCH, $targ_archs,
79    [Define to BFD's default architecture. ])
80fi
81if test "x$targ_defvec" != x; then
82  AC_DEFINE_UNQUOTED(DEFAULT_BFD_VEC, $targ_defvec,
83    [Define to BFD's default target vector. ])
84fi
85
86AC_ARG_PROGRAM
87
88# The CLI cannot be disabled yet, but may be in the future.
89
90# Enable CLI.
91AC_ARG_ENABLE(gdbcli,
92[  --disable-gdbcli        disable command-line interface (CLI)],
93  [case $enableval in
94    yes)
95      ;;
96    no)
97      AC_MSG_ERROR([the command-line interface cannot be disabled yet]) ;;
98    *)
99      AC_MSG_ERROR([bad value $enableval for --enable-gdbcli]) ;;
100  esac],
101  [enable_gdbcli=yes])
102if test x"$enable_gdbcli" = xyes; then
103  if test -d $srcdir/cli; then
104    CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_CLI_OBS)"
105    CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_CLI_DEPS)"
106    CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_CLI_SRCS)"
107    ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_CLI_CFLAGS)"
108  fi
109fi
110
111# Enable MI.
112AC_ARG_ENABLE(gdbmi,
113[  --disable-gdbmi         disable machine-interface (MI)],
114  [case $enableval in
115    yes | no)
116      ;;
117    *)
118      AC_MSG_ERROR([bad value $enableval for --enable-gdbmi]) ;;
119  esac],
120  [enable_gdbmi=yes])
121if test x"$enable_gdbmi" = xyes; then
122  if test -d $srcdir/mi; then
123    CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_MI_OBS)"
124    CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_MI_DEPS)"
125    CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_MI_SRCS)"
126    ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_MI_CFLAGS)"
127  fi
128fi
129
130# Enable TUI.
131AC_ARG_ENABLE(tui,
132[  --enable-tui            enable full-screen terminal user interface (TUI)],
133  [case $enableval in
134    yes | no)
135      ;;
136    *)
137      AC_MSG_ERROR([bad value $enableval for --enable-tui]) ;;
138  esac],enable_tui=yes)
139
140# Enable gdbtk.
141AC_ARG_ENABLE(gdbtk,
142[  --enable-gdbtk          enable gdbtk graphical user interface (GUI)],
143  [case $enableval in
144    yes | no)
145      ;;
146    *)
147      AC_MSG_ERROR([bad value $enableval for --enable-gdbtk]) ;;
148  esac],
149  [if test -d $srcdir/gdbtk -a -d $srcdir/../itcl; then
150    enable_gdbtk=yes
151  else
152    enable_gdbtk=no
153  fi])
154# We unconditionally disable gdbtk tests on selected platforms.
155case $host_os in
156  go32* | windows*)
157    AC_MSG_WARN([gdbtk isn't supported on $host; disabling])
158    enable_gdbtk=no ;;
159esac
160
161# Libunwind support.
162AC_ARG_WITH(libunwind,
163[  --with-libunwind            Use libunwind frame unwinding support],
164[case "${withval}" in
165  yes)  enable_libunwind=yes ;;
166  no)   enable_libunwind=no ;;
167  *)    AC_MSG_ERROR(bad value ${withval} for GDB with-libunwind option) ;;
168esac],[
169  AC_CHECK_HEADERS(libunwind.h)
170  AC_CHECK_HEADERS(libunwind-ia64.h)
171  if test x"$ac_cv_header_libunwind_h" = xyes -a x"$ac_cv_header_libunwind_ia64_h" = xyes; then
172    enable_libunwind=yes;
173  fi
174])
175
176if test x"$enable_libunwind" = xyes; then
177  AC_CHECK_HEADERS(libunwind.h)
178  AC_CHECK_HEADERS(libunwind-ia64.h)
179  AC_DEFINE(HAVE_LIBUNWIND, 1, [Define if libunwind library is being used.])
180  CONFIG_OBS="$CONFIG_OBS libunwind-frame.o"
181  CONFIG_DEPS="$CONFIG_DEPS libunwind-frame.o"
182  CONFIG_SRCS="$CONFIG_SRCS libunwind-frame.c"
183fi
184
185# Profiling support.
186AC_ARG_ENABLE(profiling,
187[  --enable-profiling      enable profiling of GDB],
188  [case $enableval in
189    yes | no)
190      ;;
191    *)
192      AC_MSG_ERROR([bad value $enableval for --enable-profile]) ;;
193  esac],
194 [enable_profiling=no])
195
196AC_CHECK_FUNCS(monstartup _mcleanup)
197AC_CACHE_CHECK([for _etext], ac_cv_var__etext,
198[AC_TRY_LINK(
199[#include <stdlib.h>
200extern char _etext;
201],
202[free (&_etext);], ac_cv_var__etext=yes, ac_cv_var__etext=no)])
203if test $ac_cv_var__etext = yes; then
204  AC_DEFINE(HAVE__ETEXT, 1,
205            [Define to 1 if your system has the _etext variable. ])
206fi
207if test "$enable_profiling" = yes ; then
208  if test $ac_cv_func_monstartup = no || test $ac_cv_func__mcleanup = no; then
209    AC_MSG_ERROR(--enable-profiling requires monstartup and _mcleanup)
210  fi
211  PROFILE_CFLAGS=-pg
212  OLD_CFLAGS="$CFLAGS"
213  CFLAGS="$CFLAGS $PROFILE_CFLAGS"
214
215  AC_CACHE_CHECK([whether $CC supports -pg], ac_cv_cc_supports_pg,
216    [AC_TRY_COMPILE([], [int x;], ac_cv_cc_supports_pg=yes,
217     ac_cv_cc_supports_pg=no)])
218
219  if test $ac_cv_cc_supports_pg = no; then
220    AC_MSG_ERROR(--enable-profiling requires a compiler which supports -pg)
221  fi
222
223  CFLAGS="$OLD_CFLAGS"
224fi
225
226# --------------------- #
227# Checks for programs.  #
228# --------------------- #
229
230AC_PROG_AWK
231AC_PROG_INSTALL
232AC_PROG_LN_S
233AC_PROG_RANLIB
234AC_PROG_YACC
235
236AC_CHECK_TOOL(AR, ar)
237AC_CHECK_TOOL(DLLTOOL, dlltool)
238AC_CHECK_TOOL(WINDRES, windres)
239
240# Needed for GNU/Hurd.
241AC_CHECK_TOOL(MIG, mig)
242
243# ---------------------- #
244# Checks for libraries.  #
245# ---------------------- #
246
247# We might need to link with -lm; most simulators need it.
248AC_CHECK_LIB(m, main)
249
250# We need to link with -lw to get `wctype' on Solaris before Solaris
251# 2.6.  Solaris 2.6 and beyond have this function in libc, and have a
252# libw that some versions of the GNU linker cannot hanle (GNU ld 2.9.1
253# is known to have this problem).  Therefore we avoid libw if we can.
254AC_CHECK_FUNC(wctype, [],
255  [AC_CHECK_LIB(w, wctype)])
256
257# Some systems (e.g. Solaris) have `gethostbyname' in libnsl.
258AC_SEARCH_LIBS(gethostbyname, nsl)
259
260# Some systems (e.g. Solaris) have `socketpair' in libsocket.
261AC_SEARCH_LIBS(socketpair, socket)
262
263# For the TUI, we need enhanced curses functionality.
264#
265# FIXME: kettenis/20040905: We prefer ncurses over the vendor-supplied
266# curses library because the latter might not provide all the
267# functionality we need.  However, this leads to problems on systems
268# where the linker searches /usr/local/lib, but the compiler doesn't
269# search /usr/local/include, if ncurses is installed in /usr/local.  A
270# default installation of ncurses on alpha*-dec-osf* will lead to such
271# a situation.
272AC_SEARCH_LIBS(waddstr, [ncurses cursesX curses])
273
274# Since GDB uses Readline, we need termcap functionality.  In many
275# cases this will be provided by the curses library, but some systems
276# have a seperate termcap library, or no curses library at all.
277
278case $host_os in
279  cygwin*)
280    if test -d $srcdir/libtermcap; then
281      LIBS="../libtermcap/libtermcap.a $LIBS"
282      ac_cv_search_tgetent="../libtermcap/libtermcap.a"
283    fi ;;
284  go32* | *djgpp*)
285    ac_cv_search_tgetent="none required"
286    ;;
287esac
288
289# These are the libraries checked by Readline.
290AC_SEARCH_LIBS(tgetent, [termcap tinfo curses ncurses])
291
292if test "$ac_cv_search_tgetent" = no; then
293  AC_MSG_ERROR([no termcap library found])
294fi
295
296# ------------------------- #
297# Checks for header files.  #
298# ------------------------- #
299
300AC_HEADER_DIRENT
301AC_HEADER_STAT
302AC_HEADER_STDC
303AC_CHECK_HEADERS(nlist.h)
304AC_CHECK_HEADERS(link.h, [], [],
305[#if HAVE_SYS_TYPES_H
306# include <sys/types.h>
307#endif
308#if HAVE_NLIST_H
309# include <nlist.h>
310#endif
311])
312AC_CHECK_HEADERS(machine/reg.h)
313AC_CHECK_HEADERS(poll.h sys/poll.h)
314AC_CHECK_HEADERS(proc_service.h thread_db.h gnu/libc-version.h)
315AC_CHECK_HEADERS(stddef.h)
316AC_CHECK_HEADERS(stdlib.h)
317AC_CHECK_HEADERS(stdint.h)
318AC_CHECK_HEADERS(string.h memory.h strings.h)
319AC_CHECK_HEADERS(sys/fault.h)
320AC_CHECK_HEADERS(sys/file.h)
321AC_CHECK_HEADERS(sys/filio.h)
322AC_CHECK_HEADERS(sys/ioctl.h)
323AC_CHECK_HEADERS(sys/param.h)
324AC_CHECK_HEADERS(sys/proc.h, [], [],
325[#if HAVE_SYS_PARAM_H
326# include <sys/param.h>
327#endif
328])
329AC_CHECK_HEADERS(sys/procfs.h)
330AC_CHECK_HEADERS(sys/ptrace.h ptrace.h)
331AC_CHECK_HEADERS(sys/reg.h sys/debugreg.h)
332AC_CHECK_HEADERS(sys/select.h)
333AC_CHECK_HEADERS(sys/syscall.h)
334AC_CHECK_HEADERS(sys/types.h)
335AC_CHECK_HEADERS(sys/user.h, [], [],
336[#if HAVE_SYS_PARAM_H
337# include <sys/param.h>
338#endif
339])
340AC_CHECK_HEADERS(sys/wait.h wait.h)
341AC_CHECK_HEADERS(termios.h termio.h sgtty.h)
342AC_CHECK_HEADERS(unistd.h)
343
344# On Solaris 2.[789], we need to define _MSE_INT_H to avoid a clash
345# between <widec.h> and <wchar.h> that would cause AC_CHECK_HEADERS to
346# think that we don't have <curses.h> if we're using GCC.
347case $host_os in
348  solaris2.[[789]])
349    if test "$GCC" = yes; then
350      AC_DEFINE(_MSE_INT_H, 1,
351        [Define to 1 to avoid a clash between <widec.h> and <wchar.h> on
352   Solaris 2.[789] when using GCC. ])
353    fi ;;
354esac
355AC_CHECK_HEADERS(curses.h cursesX.h ncurses.h ncurses/ncurses.h)
356AC_CHECK_HEADERS(ncurses/term.h)
357AC_CHECK_HEADERS(term.h, [], [],
358[#if HAVE_CURSES_H
359# include <curses.h>
360#endif
361])
362
363# FIXME: kettenis/20030102: In most cases we include these
364# unconditionally, so what's the point in checking these?
365AC_CHECK_HEADERS(ctype.h time.h)
366
367# ------------------------- #
368# Checks for declarations.  #
369# ------------------------- #
370
371AC_CHECK_DECLS([free, malloc, realloc])
372AC_CHECK_DECLS([strerror, strstr])
373AC_CHECK_DECLS([getopt, snprintf, vsnprintf])
374
375# ----------------------- #
376# Checks for structures.  #
377# ----------------------- #
378
379AC_CHECK_MEMBERS([struct stat.st_blocks])
380AC_CHECK_MEMBERS([struct stat.st_blksize])
381
382# ------------------ #
383# Checks for types.  #
384# ------------------ #
385
386AC_TYPE_SIGNAL
387AC_CHECK_TYPES(socklen_t, [], [],
388[#include <sys/types.h>
389#include <sys/socket.h>
390])
391AC_CHECK_TYPES(uintptr_t, [], [], [#include <stdint.h>])
392
393# ------------------------------------- #
394# Checks for compiler characteristics.  #
395# ------------------------------------- #
396
397AC_C_CONST
398AC_C_INLINE
399
400# ------------------------------ #
401# Checks for library functions.  #
402# ------------------------------ #
403
404AC_FUNC_ALLOCA
405AC_FUNC_MMAP
406AC_FUNC_VFORK
407AC_CHECK_FUNCS(canonicalize_file_name realpath)
408AC_CHECK_FUNCS(getuid getgid)
409AC_CHECK_FUNCS(poll)
410AC_CHECK_FUNCS(pread64)
411AC_CHECK_FUNCS(sbrk)
412AC_CHECK_FUNCS(setpgid setpgrp)
413AC_CHECK_FUNCS(sigaction sigprocmask sigsetmask)
414AC_CHECK_FUNCS(socketpair)
415AC_CHECK_FUNCS(syscall)
416AC_CHECK_FUNCS(ttrace)
417AC_CHECK_FUNCS(wborder)
418
419# Check the return and argument types of ptrace.  No canned test for
420# this, so roll our own.
421gdb_ptrace_headers='
422#if HAVE_SYS_TYPES_H
423# include <sys/types.h>
424#endif
425#if HAVE_SYS_PTRACE_H
426# include <sys/ptrace.h>
427#endif
428#if HAVE_UNISTD_H
429# include <unistd.h>
430#endif
431'
432# There is no point in checking if we don't have a prototype.
433AC_CHECK_DECLS(ptrace, [], [
434  : ${gdb_cv_func_ptrace_ret='int'}
435  : ${gdb_cv_func_ptrace_args='int,int,long,long'}
436], $gdb_ptrace_headers)
437# Check return type.
438AC_CACHE_CHECK([return type of ptrace], gdb_cv_func_ptrace_ret,
439  AC_TRY_COMPILE($gdb_ptrace_headers,
440    [extern int ptrace ();],
441    gdb_cv_func_ptrace_ret='int',
442    gdb_cv_func_ptrace_ret='long'))
443AC_DEFINE_UNQUOTED(PTRACE_TYPE_RET, $gdb_cv_func_ptrace_ret,
444  [Define as the return type of ptrace.])
445# Check argument types.
446AC_CACHE_CHECK([types of arguments for ptrace], gdb_cv_func_ptrace_args, [
447for gdb_arg1 in 'int' 'long'; do
448 for gdb_arg2 in 'pid_t' 'int' 'long'; do
449  for gdb_arg3 in 'int *' 'caddr_t' 'int' 'long'; do
450   for gdb_arg4 in 'int' 'long'; do
451     AC_TRY_COMPILE($gdb_ptrace_headers, [
452extern $gdb_cv_func_ptrace_ret
453  ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4);
454], [gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4";
455    break 4;])
456    for gdb_arg5 in 'int *' 'int' 'long'; do
457     AC_TRY_COMPILE($gdb_ptrace_headers, [
458extern $gdb_cv_func_ptrace_ret
459  ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4, $gdb_arg5);
460], [
461gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4,$gdb_arg5";
462    break 5;])
463    done
464   done
465  done
466 done
467done
468# Provide a safe default value.
469: ${gdb_cv_func_ptrace_args='int,int,long,long'}
470])
471ac_save_IFS=$IFS; IFS=','
472set dummy `echo "$gdb_cv_func_ptrace_args" | sed 's/\*/\*/g'`
473IFS=$ac_save_IFS
474shift
475AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG3, $[3],
476  [Define to the type of arg 3 for ptrace.])
477if test -n "$[5]"; then
478  AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG5, $[5],
479    [Define to the type of arg 5 for ptrace.])
480fi
481
482dnl AC_FUNC_SETPGRP does not work when cross compiling
483dnl Instead, assume we will have a prototype for setpgrp if cross compiling.
484if test "$cross_compiling" = no; then
485  AC_FUNC_SETPGRP
486else
487  AC_CACHE_CHECK([whether setpgrp takes no argument], ac_cv_func_setpgrp_void,
488    [AC_TRY_COMPILE([
489#include <unistd.h>
490], [
491  if (setpgrp(1,1) == -1)
492    exit (0);
493  else
494    exit (1);
495], ac_cv_func_setpgrp_void=no, ac_cv_func_setpgrp_void=yes)])
496if test $ac_cv_func_setpgrp_void = yes; then
497  AC_DEFINE(SETPGRP_VOID, 1)
498fi
499fi
500
501# Check if sigsetjmp is available.  Using AC_CHECK_FUNCS won't do
502# since sigsetjmp might only be defined as a macro.
503AC_CACHE_CHECK([for sigsetjmp], gdb_cv_func_sigsetjmp,
504[AC_TRY_COMPILE([
505#include <setjmp.h>
506], [sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);],
507gdb_cv_func_sigsetjmp=yes, gdb_cv_func_sigsetjmp=no)])
508if test $gdb_cv_func_sigsetjmp = yes; then
509  AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ])
510fi
511
512# Assume we'll default to using the included libiberty regex.
513gdb_use_included_regex=yes
514
515# However, if the system regex is GNU regex, then default to *not*
516# using the included regex.
517AC_CACHE_CHECK(
518  [for GNU regex],
519  [gdb_cv_have_gnu_regex],
520  [AC_TRY_COMPILE(
521    [#include <gnu-versions.h>],
522    [#define REGEX_INTERFACE_VERSION 1
523#if _GNU_REGEX_INTERFACE_VERSION != REGEX_INTERFACE_VERSION
524# error "Version mismatch"
525#endif],
526    gdb_cv_have_gnu_regex=yes,
527    gdb_cv_have_gnu_regex=no)])
528if test $gdb_cv_have_gnu_regex = yes; then
529  gdb_use_included_regex=no
530fi
531
532AC_ARG_WITH(included-regex,
533  [  --without-included-regex don't use included regex; this is the default
534                          on systems with version 2 of the GNU C library
535                          (use with caution on other system)],
536  gdb_with_regex=$withval,
537  gdb_with_regex=$gdb_use_included_regex)
538if test "$gdb_with_regex" = yes; then
539  AC_DEFINE(USE_INCLUDED_REGEX, 1,
540    [Define to 1 if the regex included in libiberty should be used.])
541fi
542
543# Check if <sys/proc.h> defines `struct thread' with a td_pcb member.
544AC_CHECK_MEMBERS([struct thread.td_pcb], [], [],
545[#include <sys/param.h>
546#include <sys/proc.h>
547])
548
549# See if <sys/lwp.h> defines `struct lwp`.
550AC_CACHE_CHECK([for struct lwp], gdb_cv_struct_lwp,
551[AC_TRY_COMPILE([#include <sys/param.h>
552#include <sys/lwp.h>], [struct lwp l;],
553gdb_cv_struct_lwp=yes, gdb_cv_struct_lwp=no)])
554if test $gdb_cv_struct_lwp = yes; then
555  AC_DEFINE(HAVE_STRUCT_LWP, 1,
556            [Define to 1 if your system has struct lwp.])
557fi
558
559# See if <machine/reg.h> degines `struct reg'.
560AC_CACHE_CHECK([for struct reg in machine/reg.h], gdb_cv_struct_reg,
561[AC_TRY_COMPILE([#include <sys/types.h>
562#include <machine/reg.h>], [struct reg r;],
563gdb_cv_struct_reg=yes, gdb_cv_struct_reg=no)])
564if test $gdb_cv_struct_reg = yes; then
565  AC_DEFINE(HAVE_STRUCT_REG, 1,
566            [Define to 1 if your system has struct reg in <machine/reg.h>.])
567fi
568
569# See if <machine/reg.h> supports the %fs and %gs i386 segment registers.
570# Older i386 BSD's don't have the r_fs and r_gs members of `struct reg'.
571AC_CHECK_MEMBERS([struct reg.r_fs, struct reg.r_gs], [], [],
572                 [#include <machine/reg.h>])
573
574# See if <sys/ptrace.h> provides the PTRACE_GETREGS request.
575AC_MSG_CHECKING(for PTRACE_GETREGS)
576AC_CACHE_VAL(gdb_cv_have_ptrace_getregs,
577[AC_TRY_COMPILE([#include <sys/ptrace.h>],
578		[PTRACE_GETREGS;],
579		[gdb_cv_have_ptrace_getregs=yes],
580		[gdb_cv_have_ptrace_getregs=no])])
581AC_MSG_RESULT($gdb_cv_have_ptrace_getregs)
582if test $gdb_cv_have_ptrace_getregs = yes; then
583  AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
584  [Define if sys/ptrace.h defines the PTRACE_GETREGS request.])
585fi
586
587# See if <sys/ptrace.h> provides the PTRACE_GETFPXREGS request.
588AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
589AC_CACHE_VAL(gdb_cv_have_ptrace_getfpxregs,
590[AC_TRY_COMPILE([#include <sys/ptrace.h>],
591		[PTRACE_GETFPXREGS;],
592		[gdb_cv_have_ptrace_getfpxregs=yes],
593		[gdb_cv_have_ptrace_getfpxregs=no])])
594AC_MSG_RESULT($gdb_cv_have_ptrace_getfpxregs)
595if test $gdb_cv_have_ptrace_getfpxregs = yes; then
596  AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
597  [Define if sys/ptrace.h defines the PTRACE_GETFPXREGS request.])
598fi
599
600# See if <sys/ptrace.h> provides the PT_GETDBREGS request.
601AC_MSG_CHECKING(for PT_GETDBREGS)
602AC_CACHE_VAL(gdb_cv_have_pt_getdbregs,
603[AC_TRY_COMPILE([#include <sys/types.h>
604#include <sys/ptrace.h>],
605		[PT_GETDBREGS;],
606		[gdb_cv_have_pt_getdbregs=yes],
607		[gdb_cv_have_pt_getdbregs=no])])
608AC_MSG_RESULT($gdb_cv_have_pt_getdbregs)
609if test $gdb_cv_have_pt_getdbregs = yes; then
610  AC_DEFINE(HAVE_PT_GETDBREGS, 1,
611  [Define if sys/ptrace.h defines the PT_GETDBREGS request.])
612fi
613
614# See if <sys/ptrace.h> provides the PT_GETXMMREGS request.
615AC_MSG_CHECKING(for PT_GETXMMREGS)
616AC_CACHE_VAL(gdb_cv_have_pt_getxmmregs,
617[AC_TRY_COMPILE([#include <sys/types.h>
618#include <sys/ptrace.h>],
619		[PT_GETXMMREGS;],
620		[gdb_cv_have_pt_getxmmregs=yes],
621		[gdb_cv_have_pt_getxmmregs=no])])
622AC_MSG_RESULT($gdb_cv_have_pt_getxmmregs)
623if test $gdb_cv_have_pt_getxmmregs = yes; then
624  AC_DEFINE(HAVE_PT_GETXMMREGS, 1,
625  [Define if sys/ptrace.h defines the PT_GETXMMREGS request.])
626fi
627
628# If we are configured native on GNU/Linux, work around problems with
629# sys/procfs.h
630# Also detect which type of /proc is in use, such as for Unixware or Solaris.
631
632if test "${target}" = "${host}"; then
633  case "${host}" in
634  i[[3456]]86-*-linux*)
635	AC_DEFINE(START_INFERIOR_TRAPS_EXPECTED, 2,
636        [Define on a GNU/Linux system to work around problems in sys/procfs.h.])
637	AC_DEFINE(sys_quotactl, 1,
638        [Define on a GNU/Linux system to work around problems in sys/procfs.h.])
639	;;
640  *-*-unixware* | *-*-sysv4.2* | *-*-sysv5* | *-*-interix* )
641      AC_DEFINE(NEW_PROC_API, 1,
642      [Define if you want to use new multi-fd /proc interface
643       (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros).])
644      ;;
645  *-*-solaris2.[[6789]] | *-*-solaris2.1[[0-9]])
646      AC_DEFINE(NEW_PROC_API, 1,
647      [Define if you want to use new multi-fd /proc interface
648       (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros).])
649      ;;
650  mips-sgi-irix5*)
651      # Work around <sys/proc.h> needing _KMEMUSER problem on IRIX 5.
652      AC_DEFINE([_KMEMUSER], 1,
653      [Define to 1 so <sys/proc.h> gets a definition of anon_hdl.  Works
654       around a <sys/proc.h> problem on IRIX 5.])
655      ;;
656  esac
657fi
658
659if test "$ac_cv_header_sys_procfs_h" = yes; then
660  BFD_HAVE_SYS_PROCFS_TYPE(pstatus_t)
661  BFD_HAVE_SYS_PROCFS_TYPE(prrun_t)
662  BFD_HAVE_SYS_PROCFS_TYPE(gregset_t)
663  BFD_HAVE_SYS_PROCFS_TYPE(fpregset_t)
664  BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
665  BFD_HAVE_SYS_PROCFS_TYPE(prfpregset_t)
666  BFD_HAVE_SYS_PROCFS_TYPE(prgregset32_t)
667  BFD_HAVE_SYS_PROCFS_TYPE(prfpregset32_t)
668  BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
669  BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
670  BFD_HAVE_SYS_PROCFS_TYPE(prsysent_t)
671  BFD_HAVE_SYS_PROCFS_TYPE(pr_sigset_t)
672  BFD_HAVE_SYS_PROCFS_TYPE(pr_sigaction64_t)
673  BFD_HAVE_SYS_PROCFS_TYPE(pr_siginfo64_t)
674
675
676  dnl Check for broken prfpregset_t type
677
678  dnl For Linux/i386, glibc 2.1.3 was released with a bogus
679  dnl prfpregset_t type (it's a typedef for the pointer to a struct
680  dnl instead of the struct itself).  We detect this here, and work
681  dnl around it in gdb_proc_service.h.
682
683  if test $bfd_cv_have_sys_procfs_type_prfpregset_t = yes; then
684    AC_MSG_CHECKING(whether prfpregset_t type is broken)
685    AC_CACHE_VAL(gdb_cv_prfpregset_t_broken,
686      [AC_TRY_RUN([#include <sys/procfs.h>
687       int main ()
688       {
689         if (sizeof (prfpregset_t) == sizeof (void *))
690           return 1;
691         return 0;
692       }],
693       gdb_cv_prfpregset_t_broken=no,
694       gdb_cv_prfpregset_t_broken=yes,
695       gdb_cv_prfpregset_t_broken=yes)])
696    AC_MSG_RESULT($gdb_cv_prfpregset_t_broken)
697    if test $gdb_cv_prfpregset_t_broken = yes; then
698      AC_DEFINE(PRFPREGSET_T_BROKEN, 1,
699      [Define if the prfpregset_t type is broken.])
700    fi
701  fi
702
703  dnl Check for PIOCSET ioctl entry
704
705  AC_MSG_CHECKING(for PIOCSET ioctl entry in sys/procfs.h)
706  AC_CACHE_VAL(gdb_cv_have_procfs_piocset,
707  [AC_TRY_COMPILE([#include <unistd.h>
708#include <sys/types.h>
709#include <sys/procfs.h>
710], [
711    int dummy;;
712    dummy = ioctl(0, PIOCSET, &dummy);
713  ],
714  gdb_cv_have_procfs_piocset=yes, gdb_cv_have_procfs_piocset=no)])
715  AC_MSG_RESULT($gdb_cv_have_procfs_piocset)
716  if test $gdb_cv_have_procfs_piocset = yes; then
717    AC_DEFINE(HAVE_PROCFS_PIOCSET, 1,
718    [Define if ioctl argument PIOCSET is available.])
719  fi
720fi
721
722dnl For native ports (host == target), check to see what kind of
723dnl legacy link.h support is needed.  (See solib-legacy.c.)
724if test ${host} = ${target} ; then
725  dnl Check for struct link_map with l_ members which are indicative
726  dnl of SVR4-like shared libraries
727
728  AC_MSG_CHECKING(for member l_addr in struct link_map)
729  AC_CACHE_VAL(gdb_cv_have_struct_link_map_with_l_members,
730    [AC_TRY_COMPILE([#include <link.h>],
731                    [struct link_map lm; (void) lm.l_addr;],
732                    gdb_cv_have_struct_link_map_with_l_members=yes,
733                    gdb_cv_have_struct_link_map_with_l_members=no)])
734  AC_MSG_RESULT($gdb_cv_have_struct_link_map_with_l_members)
735  if test $gdb_cv_have_struct_link_map_with_l_members = yes; then
736    AC_DEFINE(HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS,1,
737    [Define if <link.h> exists and defines struct link_map which has
738     members with an ``l_'' prefix.  (For Solaris, SVR4, and
739     SVR4-like systems.)])
740  fi
741
742  dnl Check for struct link_map with lm_ members which are indicative
743  dnl of SunOS-like shared libraries
744
745  AC_MSG_CHECKING(for member lm_addr in struct link_map)
746  AC_CACHE_VAL(gdb_cv_have_struct_link_map_with_lm_members,
747    [AC_TRY_COMPILE([#include <sys/types.h>
748#include <link.h>],
749                    [struct link_map lm; (void) lm.lm_addr;],
750                    gdb_cv_have_struct_link_map_with_lm_members=yes,
751                    gdb_cv_have_struct_link_map_with_lm_members=no)])
752  AC_MSG_RESULT($gdb_cv_have_struct_link_map_with_lm_members)
753  if test $gdb_cv_have_struct_link_map_with_lm_members = yes; then
754    AC_DEFINE(HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS, 1,
755    [Define if <link.h> exists and defines struct link_map which has
756     members with an ``lm_'' prefix.  (For SunOS.)])
757  fi
758
759  dnl Check for struct so_map with som_ members which are found on
760  dnl some *BSD systems.
761
762  AC_MSG_CHECKING(for member som_addr in struct so_map)
763  AC_CACHE_VAL(gdb_cv_have_struct_so_map_with_som_members,
764    [AC_TRY_COMPILE([#include <sys/types.h>
765#ifdef HAVE_NLIST_H
766#include <nlist.h>
767#endif
768#include <link.h>],
769                    [struct so_map lm; (void) lm.som_addr;],
770                    gdb_cv_have_struct_so_map_with_som_members=yes,
771                    gdb_cv_have_struct_so_map_with_som_members=no)])
772  AC_MSG_RESULT($gdb_cv_have_struct_so_map_with_som_members)
773  if test $gdb_cv_have_struct_so_map_with_som_members = yes; then
774    AC_DEFINE(HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS, 1,
775    [Define if <link.h> exists and defines a struct so_map which has
776     members with an ``som_'' prefix.  (Found on older *BSD systems.)])
777  fi
778
779  dnl Check for struct link_map32 type, which allows a 64-bit Solaris
780  dnl debugger to debug a 32-bit Solaris app with 32-bit shared libraries.
781
782  AC_MSG_CHECKING(for struct link_map32 in sys/link.h)
783  AC_CACHE_VAL(gdb_cv_have_struct_link_map32,
784    [AC_TRY_COMPILE([#define _SYSCALL32
785#include <sys/link.h>], [struct link_map32 l;],
786     gdb_cv_have_struct_link_map32=yes,
787     gdb_cv_have_struct_link_map32=no)])
788  AC_MSG_RESULT($gdb_cv_have_struct_link_map32)
789  if test $gdb_cv_have_struct_link_map32 = yes; then
790    AC_DEFINE(HAVE_STRUCT_LINK_MAP32, 1,
791    [Define if <sys/link.h> has struct link_map32])
792    AC_DEFINE(_SYSCALL32, 1,
793    [Define if <sys/link.h> has link_map32 (solaris sparc-64 target)])
794  fi
795fi
796
797# Check if the compiler supports the `long long' type.
798
799AC_CACHE_CHECK([for long long support in compiler], gdb_cv_c_long_long,
800               [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
801[[extern long long foo;]],
802[[switch (foo & 2) { case 0: return 1; }]])],
803                                  gdb_cv_c_long_long=yes,
804                                  gdb_cv_c_long_long=no)])
805if test $gdb_cv_c_long_long = yes; then
806  AC_DEFINE(CC_HAS_LONG_LONG, 1,
807            [Define to 1 if the compiler supports long long.])
808fi
809
810# Check if the compiler and runtime support printing long longs.
811
812AC_CACHE_CHECK([for long long support in printf],
813               gdb_cv_printf_has_long_long,
814               [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
815[[char buf[32];
816  long long l = 0;
817  l = (l << 16) + 0x0123;
818  l = (l << 16) + 0x4567;
819  l = (l << 16) + 0x89ab;
820  l = (l << 16) + 0xcdef;
821  sprintf (buf, "0x%016llx", l);
822  return (strcmp ("0x0123456789abcdef", buf));]])],
823                              gdb_cv_printf_has_long_long=yes,
824                              gdb_cv_printf_has_long_long=no,
825                              gdb_cv_printf_has_long_long=no)])
826if test $gdb_cv_printf_has_long_long = yes; then
827  AC_DEFINE(PRINTF_HAS_LONG_LONG, 1,
828            [Define to 1 if the "%ll" format works to print long longs.])
829fi
830
831# Check if the compiler supports the `long double' type.  We can't use
832# AC_C_LONG_DOUBLE because that one does additional checks on the
833# constants defined in <float.h> that fail on some systems,
834# e.g. FreeBSD/i386 4.7 and OpenBSD/i386 3.6.
835
836AC_CACHE_CHECK([for long double support in compiler], gdb_cv_c_long_double,
837               [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[long double foo;]])],
838                                  gdb_cv_c_long_double=yes,
839                                  gdb_cv_c_long_double=no)])
840if test $gdb_cv_c_long_double = yes; then
841  AC_DEFINE(HAVE_LONG_DOUBLE, 1,
842           [Define to 1 if the compiler supports long double.])
843fi
844
845# Check if the compiler and runtime support printing long doubles.
846
847AC_CACHE_CHECK([for long double support in printf],
848               gdb_cv_printf_has_long_double,
849               [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
850[[char buf[16];
851  long double f = 3.141592653;
852  sprintf (buf, "%Lg", f);
853  return (strncmp ("3.14159", buf, 7));]])],
854                              gdb_cv_printf_has_long_double=yes,
855                              gdb_cv_printf_has_long_double=no,
856                              gdb_cv_printf_has_long_double=no)])
857if test $gdb_cv_printf_has_long_double = yes; then
858  AC_DEFINE(PRINTF_HAS_LONG_DOUBLE, 1,
859            [Define to 1 if the "%Lg" format works to print long doubles.])
860fi
861
862# Check if the compiler and runtime support scanning long doubles.
863
864AC_CACHE_CHECK([for long double support in scanf],
865               gdb_cv_scanf_has_long_double,
866               [AC_RUN_IFELSE([AC_LANG_PROGRAM(
867[[#include <stdio.h>]],
868[[char *buf = "3.141592653";
869  long double f = 0;
870  sscanf (buf, "%Lg", &f);
871  return !(f > 3.14159 && f < 3.14160);]])],
872                              gdb_cv_scanf_has_long_double=yes,
873                              gdb_cv_scanf_has_long_double=no,
874                              gdb_cv_scanf_has_long_double=no)])
875if test $gdb_cv_scanf_has_long_double = yes; then
876  AC_DEFINE(SCANF_HAS_LONG_DOUBLE, 1,
877            [Define to 1 if the "%Lg" format works to scan long doubles.])
878fi
879
880case ${host_os} in
881aix*)
882  AC_CACHE_CHECK([for -bbigtoc option], [gdb_cv_bigtoc], [
883    SAVE_LDFLAGS=$LDFLAGS
884
885    case $GCC in
886    yes) gdb_cv_bigtoc=-Wl,-bbigtoc ;;
887    *) gdb_cv_bigtoc=-bbigtoc ;;
888    esac
889
890    LDFLAGS=$LDFLAGS\ $gdb_cv_bigtoc
891    AC_TRY_LINK([], [int i;], [], [gdb_cv_bigtoc=])
892    LDFLAGS="${SAVE_LDFLAGS}"
893  ])
894  CONFIG_LDFLAGS="${CONFIG_LDFLAGS} ${gdb_cv_bigtoc}"
895  ;;
896esac
897
898
899dnl For certain native configurations, we need to check whether thread
900dnl support can be built in or not.
901dnl
902dnl Note that we only want this if we are both native (host == target),
903dnl and not doing a canadian cross build (build == host).
904
905if test ${build} = ${host} -a ${host} = ${target} ; then
906   case ${host_os} in
907   hpux*)
908      AC_MSG_CHECKING(for HPUX/OSF thread support)
909      if test -f /usr/include/dce/cma_config.h ; then
910         if test "$GCC" = "yes" ; then
911            AC_MSG_RESULT(yes)
912            AC_DEFINE(HAVE_HPUX_THREAD_SUPPORT, 1,
913	    [Define if you have HPUX threads])
914            CONFIG_OBS="${CONFIG_OBS} hpux-thread.o"
915            CONFIG_SRCS="${CONFIG_SRCS} hpux-thread.c"
916         else
917            AC_MSG_RESULT(no (suppressed because you are not using GCC))
918         fi
919      else
920         AC_MSG_RESULT(no)
921      fi
922      ;;
923   solaris*)
924      # See if thread_db library is around for Solaris thread debugging.
925      # Note that we must explicitly test for version 1 of the library
926      # because version 0 (present on Solaris 2.4 or earlier) doesn't have
927      # the same API.
928      AC_MSG_CHECKING(for Solaris thread debugging library)
929      if test -f /usr/lib/libthread_db.so.1 ; then
930         AC_MSG_RESULT(yes)
931         AC_DEFINE(HAVE_THREAD_DB_LIB, 1,
932         [Define if using Solaris thread debugging.])
933         CONFIG_OBS="${CONFIG_OBS} sol-thread.o"
934         CONFIG_SRCS="${CONFIG_SRCS} sol-thread.c"
935         AC_CHECK_LIB(dl, dlopen)
936         if test "$GCC" = "yes" ; then
937            # The GNU linker requires the -export-dynamic option to make
938            # all symbols visible in the dynamic symbol table.
939            hold_ldflags=$LDFLAGS
940            AC_MSG_CHECKING(for the ld -export-dynamic flag)
941            LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
942            AC_TRY_LINK(, [int i;], found=yes, found=no)
943            LDFLAGS=$hold_ldflags
944            AC_MSG_RESULT($found)
945            if test $found = yes; then
946               CONFIG_LDFLAGS="${CONFIG_LDFLAGS} -Wl,-export-dynamic"
947            fi
948         fi
949	 # Sun randomly tweaked the prototypes in <proc_service.h>
950	 # at one point.
951	 AC_MSG_CHECKING(if <proc_service.h> is old)
952	 AC_CACHE_VAL(gdb_cv_proc_service_is_old,[
953	    AC_TRY_COMPILE([
954		#include <proc_service.h>
955		ps_err_e ps_pdwrite
956		    (struct ps_prochandle*, psaddr_t, const void*, size_t);
957	    ],, gdb_cv_proc_service_is_old=no,
958	        gdb_cv_proc_service_is_old=yes)
959	 ])
960	 AC_MSG_RESULT($gdb_cv_proc_service_is_old)
961	 if test $gdb_cv_proc_service_is_old = yes; then
962	    AC_DEFINE(PROC_SERVICE_IS_OLD, 1,
963            [Define if <proc_service.h> on solaris uses int instead of
964             size_t, and assorted other type changes.])
965	 fi
966      else
967         AC_MSG_RESULT(no)
968      fi
969      ;;
970   aix*)
971      AC_MSG_CHECKING(for AiX thread debugging library)
972      AC_CACHE_VAL(gdb_cv_have_aix_thread_debug,
973                   [AC_TRY_COMPILE([#include <sys/pthdebug.h>],
974                                   [#ifndef PTHDB_VERSION_3
975                                    #error
976                                    #endif],
977                                   gdb_cv_have_aix_thread_debug=yes,
978                                   gdb_cv_have_aix_thread_debug=no)])
979      AC_MSG_RESULT($gdb_cv_have_aix_thread_debug)
980      if test $gdb_cv_have_aix_thread_debug = yes; then
981         CONFIG_SRCS="${CONFIG_SRCS} aix-thread.c"
982         CONFIG_OBS="${CONFIG_OBS} aix-thread.o"
983         CONFIG_LDFLAGS="${CONFIG_LDFLAGS} -lpthdebug"
984      fi
985      ;;
986   esac
987   AC_SUBST(CONFIG_LDFLAGS)
988fi
989
990dnl See if we have a thread_db header file that has TD_NOTALLOC.
991if test "x$ac_cv_header_thread_db_h" = "xyes"; then
992   AC_CACHE_CHECK([whether <thread_db.h> has TD_NOTALLOC],
993                  gdb_cv_thread_db_h_has_td_notalloc,
994     AC_TRY_COMPILE(
995       [#include <thread_db.h>],
996       [int i = TD_NOTALLOC;],
997       gdb_cv_thread_db_h_has_td_notalloc=yes,
998       gdb_cv_thread_db_h_has_td_notalloc=no
999     )
1000   )
1001fi
1002if test "x$gdb_cv_thread_db_h_has_td_notalloc" = "xyes"; then
1003  AC_DEFINE(THREAD_DB_HAS_TD_NOTALLOC, 1,
1004            [Define if <thread_db.h> has the TD_NOTALLOC error code.])
1005fi
1006
1007dnl See if we have a sys/syscall header file that has __NR_tkill.
1008if test "x$ac_cv_header_sys_syscall_h" = "xyes"; then
1009   AC_CACHE_CHECK([whether <sys/syscall.h> has __NR_tkill],
1010                  gdb_cv_sys_syscall_h_has_tkill,
1011     AC_TRY_COMPILE(
1012       [#include <sys/syscall.h>],
1013       [int i = __NR_tkill;],
1014       gdb_cv_sys_syscall_h_has_tkill=yes,
1015       gdb_cv_sys_syscall_h_has_tkill=no
1016     )
1017   )
1018fi
1019dnl See if we can issue tkill syscall.
1020if test "x$gdb_cv_sys_syscall_h_has_tkill" = "xyes" && test "x$ac_cv_func_syscall" = "xyes"; then
1021  AC_DEFINE(HAVE_TKILL_SYSCALL, 1, [Define if you support the tkill syscall.])
1022fi
1023
1024dnl Handle optional features that can be enabled.
1025
1026AC_ARG_WITH(sysroot,
1027[  --with-sysroot[=DIR] Search for usr/lib et al within DIR.],
1028[
1029 case ${with_sysroot} in
1030 yes) TARGET_SYSTEM_ROOT='${exec_prefix}/${target_alias}/sys-root' ;;
1031 *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
1032 esac
1033
1034 TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
1035
1036 if test "x$exec_prefix" = xNONE; then
1037  if test "x$prefix" = xNONE; then
1038   test_prefix=/usr/local
1039  else
1040   test_prefix=$prefix
1041  fi
1042 else
1043  test_prefix=$exec_prefix
1044 fi
1045 case ${TARGET_SYSTEM_ROOT} in
1046 "${test_prefix}"|"${test_prefix}/"*|\
1047 '${exec_prefix}'|'${exec_prefix}/'*)
1048   t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE"
1049   TARGET_SYSTEM_ROOT_DEFINE="$t"
1050   ;;
1051 esac
1052], [
1053 TARGET_SYSTEM_ROOT=
1054 TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"\"'
1055])
1056AC_SUBST(TARGET_SYSTEM_ROOT)
1057AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
1058
1059# NOTE: Don't add -Wall or -Wunused, they both include
1060# -Wunused-parameter which reports bogus warnings.
1061# NOTE: If you add to this list, remember to update
1062# gdb/doc/gdbint.texinfo.
1063build_warnings="-Wimplicit -Wreturn-type -Wcomment -Wtrigraphs \
1064-Wformat -Wparentheses -Wpointer-arith -Wformat-nonliteral \
1065-Wunused-label -Wunused-function"
1066
1067# GCC supports -Wuninitialized only with -O or -On, n != 0.
1068if test x${CFLAGS+set} = xset; then
1069  case "${CFLAGS}" in
1070    *"-O0"* ) ;;
1071    *"-O"* )
1072      build_warnings="${build_warnings} -Wuninitialized"
1073    ;;
1074  esac
1075else
1076  build_warnings="${build_warnings} -Wuninitialized"
1077fi
1078
1079# Up for debate: -Wswitch -Wcomment -trigraphs -Wtrigraphs
1080# -Wunused-function -Wunused-variable -Wunused-value
1081# -Wchar-subscripts -Wtraditional -Wshadow -Wcast-qual
1082# -Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes
1083# -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls
1084# -Woverloaded-virtual -Winline -Werror"
1085AC_ARG_ENABLE(build-warnings,
1086[  --enable-build-warnings Enable build-time compiler warnings if gcc is used],
1087[case "${enableval}" in
1088  yes)	;;
1089  no)	build_warnings="-w";;
1090  ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
1091        build_warnings="${build_warnings} ${t}";;
1092  *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
1093        build_warnings="${t} ${build_warnings}";;
1094  *)    build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
1095esac
1096if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
1097  echo "Setting compiler warning flags = $build_warnings" 6>&1
1098fi])dnl
1099AC_ARG_ENABLE(gdb-build-warnings,
1100[  --enable-gdb-build-warnings Enable GDB specific build-time compiler warnings if gcc is used],
1101[case "${enableval}" in
1102  yes)	;;
1103  no)	build_warnings="-w";;
1104  ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
1105        build_warnings="${build_warnings} ${t}";;
1106  *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
1107        build_warnings="${t} ${build_warnings}";;
1108  *)    build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
1109esac
1110if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
1111  echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
1112fi])dnl
1113WARN_CFLAGS=""
1114WERROR_CFLAGS=""
1115if test "x${build_warnings}" != x -a "x$GCC" = xyes
1116then
1117    AC_MSG_CHECKING(compiler warning flags)
1118    # Separate out the -Werror flag as some files just cannot be
1119    # compiled with it enabled.
1120    for w in ${build_warnings}; do
1121	case $w in
1122	-Werr*) WERROR_CFLAGS=-Werror ;;
1123	*) # Check that GCC accepts it
1124	    saved_CFLAGS="$CFLAGS"
1125	    CFLAGS="$CFLAGS $w"
1126	    AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
1127	    CFLAGS="$saved_CFLAGS"
1128	esac
1129    done
1130    AC_MSG_RESULT(${WARN_CFLAGS}${WERROR_CFLAGS})
1131fi
1132AC_SUBST(WARN_CFLAGS)
1133AC_SUBST(WERROR_CFLAGS)
1134
1135# In the Cygwin environment, we need some additional flags.
1136AC_CACHE_CHECK([for cygwin], gdb_cv_os_cygwin,
1137[AC_EGREP_CPP(lose, [
1138#if defined (__CYGWIN__) || defined (__CYGWIN32__)
1139lose
1140#endif],[gdb_cv_os_cygwin=yes],[gdb_cv_os_cygwin=no])])
1141
1142
1143dnl Figure out which of the many generic ser-*.c files the _host_ supports.
1144SER_HARDWIRE="ser-base.o ser-unix.o ser-pipe.o ser-tcp.o"
1145case ${host} in
1146  *go32* ) SER_HARDWIRE=ser-go32.o ;;
1147  *djgpp* ) SER_HARDWIRE=ser-go32.o ;;
1148  *mingw32*) SER_HARDWIRE="ser-base.o ser-tcp.o" ;;
1149esac
1150AC_SUBST(SER_HARDWIRE)
1151
1152# libreadline needs libuser32.a in a cygwin environment
1153WIN32LIBS=
1154if test x$gdb_cv_os_cygwin = xyes; then
1155    WIN32LIBS="-luser32"
1156    case "${target}" in
1157	*cygwin*) WIN32LIBS="$WIN32LIBS -limagehlp"
1158	;;
1159    esac
1160fi
1161
1162# The ser-tcp.c module requires sockets.
1163case ${host} in
1164  *mingw32*)
1165    AC_DEFINE(USE_WIN32API, 1,
1166              [Define if we should use the Windows API, instead of the
1167	       POSIX API.  On Windows, we use the Windows API when
1168	       building for MinGW, but the POSIX API when building
1169	       for Cygwin.])
1170    WIN32LIBS="$WIN32LIBS -lws2_32"
1171    ;;
1172esac
1173AC_SUBST(WIN32LIBS)
1174
1175LIBGUI="../libgui/src/libgui.a"
1176GUI_CFLAGS_X="-I${srcdir}/../libgui/src"
1177AC_SUBST(LIBGUI)
1178AC_SUBST(GUI_CFLAGS_X)
1179
1180WIN32LDAPP=
1181AC_SUBST(WIN32LIBS)
1182AC_SUBST(WIN32LDAPP)
1183
1184case "${host}" in
1185*-*-cygwin*)
1186    configdir="win"
1187    ;;
1188*)
1189    configdir="unix"
1190    ;;
1191esac
1192
1193GDBTKLIBS=
1194if test "${enable_gdbtk}" = "yes"; then
1195
1196    # Gdbtk must have an absolute path to srcdir in order to run
1197    # properly when not installed.
1198    here=`pwd`
1199    cd ${srcdir}
1200    GDBTK_SRC_DIR=`pwd`
1201    cd $here
1202
1203    CY_AC_PATH_TCLCONFIG
1204    if test -z "${no_tcl}"; then
1205	CY_AC_LOAD_TCLCONFIG
1206	CY_AC_PATH_TKCONFIG
1207
1208	# now look for Tcl library stuff
1209
1210	tcldir="../tcl/${configdir}/"
1211
1212	TCL_DEPS="${tcldir}${TCL_LIB_FILE}"
1213
1214	# If $no_tk is nonempty, then we can't do Tk, and there is no
1215	# point to doing Tcl.
1216	if test -z "${no_tk}"; then
1217	   CY_AC_LOAD_TKCONFIG
1218	   CY_AC_PATH_TCLH
1219	   CY_AC_PATH_TKH
1220	   CY_AC_PATH_ITCLH
1221	   CY_AC_PATH_ITKH
1222
1223
1224	   # now look for Tk library stuff
1225
1226	   tkdir="../tk/${configdir}/"
1227
1228	   TK_DEPS="${tkdir}${TK_LIB_FILE}"
1229
1230	   # now look for Itcl library stuff
1231
1232	   CY_AC_PATH_ITCLCONFIG
1233           if test -z "${no_itcl}"; then
1234             CY_AC_LOAD_ITCLCONFIG
1235
1236	     ITCLLIB="${ITCL_BUILD_LIB_SPEC}"
1237	     ITCL_DEPS="${ITCL_LIB_FULL_PATH}"
1238           fi
1239
1240
1241	   # now look for Itk library stuff
1242	   CY_AC_PATH_ITKCONFIG
1243           if test -z "${no_itcl}"; then
1244             CY_AC_LOAD_ITKCONFIG
1245
1246	     ITKLIB="${ITK_BUILD_LIB_SPEC}"
1247	     ITK_DEPS="${ITK_LIB_FULL_PATH}"
1248           fi
1249
1250           ENABLE_CFLAGS="${ENABLE_CFLAGS} \$(SUBDIR_GDBTK_CFLAGS)"
1251
1252	   # Include some libraries that Tcl and Tk want.
1253	   TCL_LIBS='$(LIBGUI) $(ITCL) $(ITK) $(TK) $(TCL) $(X11_LDFLAGS) $(X11_LIBS)'
1254	   # Yes, the ordering seems wrong here.  But it isn't.
1255	   # TK_LIBS is the list of libraries that need to be linked
1256	   # after Tcl/Tk.  Note that this isn't put into LIBS.  If it
1257	   # were in LIBS then any link tests after this point would
1258	   # try to include things like `$(LIBGUI)', which wouldn't work.
1259	   GDBTKLIBS="${TCL_LIBS} ${TK_LIBS}"
1260
1261           CONFIG_OBS="${CONFIG_OBS} \$(SUBDIR_GDBTK_OBS)"
1262           CONFIG_DEPS="${CONFIG_DEPS} \$(SUBDIR_GDBTK_DEPS)"
1263           CONFIG_SRCS="${CONFIG_SRCS} \$(SUBDIR_GDBTK_SRCS)"
1264	   CONFIG_ALL="${CONFIG_ALL} all-gdbtk"
1265	   CONFIG_CLEAN="${CONFIG_CLEAN} clean-gdbtk"
1266	   CONFIG_INSTALL="${CONFIG_INSTALL} install-gdbtk"
1267	   CONFIG_UNINSTALL="${CONFIG_UNINSTALL} uninstall-gdbtk"
1268
1269	   if test x$gdb_cv_os_cygwin = xyes; then
1270	      WIN32LIBS="${WIN32LIBS} -lshell32 -lgdi32 -lcomdlg32 -ladvapi32"
1271	      WIN32LDAPP="-Wl,--subsystem,console"
1272	      CONFIG_OBS="${CONFIG_OBS} gdbres.o"
1273	   fi
1274	fi
1275    fi
1276
1277    AC_CONFIG_SUBDIRS(gdbtk)
1278fi
1279
1280AC_SUBST(X_CFLAGS)
1281AC_SUBST(X_LDFLAGS)
1282AC_SUBST(X_LIBS)
1283AC_SUBST(TCL_DEPS)
1284AC_SUBST(TK_DEPS)
1285AC_SUBST(ITCLLIB)
1286AC_SUBST(ITCL_DEPS)
1287AC_SUBST(ITKLIB)
1288AC_SUBST(ITK_DEPS)
1289AC_SUBST(GDBTKLIBS)
1290AC_SUBST(GDBTK_CFLAGS)
1291AC_SUBST(GDBTK_SRC_DIR)
1292
1293AC_PATH_X
1294
1295# Check whether we should enable the TUI, but only do so if we really
1296# can.
1297if test x"$enable_tui" = xyes; then
1298  if test -d $srcdir/tui; then
1299    if test "$ac_cv_search_waddstr" != no; then
1300      CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_TUI_OBS)"
1301      CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_TUI_DEPS)"
1302      CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_TUI_SRCS)"
1303      CONFIG_INITS="$CONFIG_INITS \$(SUBDIR_TUI_INITS)"
1304      ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_TUI_CFLAGS)"
1305      CONFIG_ALL="${CONFIG_ALL} all-tui"
1306      CONFIG_CLEAN="${CONFIG_CLEAN} clean-tui"
1307      CONFIG_INSTALL="${CONFIG_INSTALL} install-tui"
1308      CONFIG_UNINSTALL="${CONFIG_UNINSTALL} uninstall-tui"
1309    else
1310      AC_MSG_WARN([no enhanced curses library found; disabling TUI])
1311    fi
1312  fi
1313fi
1314
1315# Unlike the sim directory, whether a simulator is linked is controlled by
1316# presence of a SIM= and a SIM_OBS= definition in the target '.mt' file.
1317# This code just checks for a few cases where we'd like to ignore those
1318# definitions, even when they're present in the '.mt' file.  These cases
1319# are when --disable-sim is specified, or if the simulator directory is
1320# not part of the source tree.
1321#
1322AC_ARG_ENABLE(sim,
1323[  --enable-sim            Link gdb with simulator],
1324[echo "enable_sim = $enable_sim";
1325 echo "enableval = ${enableval}";
1326 case "${enableval}" in
1327  yes) ignore_sim=false ;;
1328  no)  ignore_sim=true ;;
1329  *)   ignore_sim=false ;;
1330 esac],
1331[ignore_sim=false])
1332
1333if test ! -d "${srcdir}/../sim"; then
1334  ignore_sim=true
1335fi
1336
1337if test "${ignore_sim}" = "true"; then
1338    IGNORE_SIM="SIM="
1339    IGNORE_SIM_OBS="SIM_OBS="
1340else
1341    IGNORE_SIM=""
1342    IGNORE_SIM_OBS=""
1343    AC_DEFINE(WITH_SIM, 1, [Define if the simulator is being linked in.])
1344fi
1345AC_SUBST(IGNORE_SIM)
1346AC_SUBST(IGNORE_SIM_OBS)
1347
1348AC_SUBST(ENABLE_CFLAGS)
1349AC_SUBST(PROFILE_CFLAGS)
1350
1351AC_SUBST(CONFIG_OBS)
1352AC_SUBST(CONFIG_DEPS)
1353AC_SUBST(CONFIG_SRCS)
1354AC_SUBST(CONFIG_ALL)
1355AC_SUBST(CONFIG_CLEAN)
1356AC_SUBST(CONFIG_INSTALL)
1357AC_SUBST(CONFIG_UNINSTALL)
1358
1359# List of host floatformats.
1360AC_DEFINE_UNQUOTED(GDB_HOST_FLOAT_FORMAT,$gdb_host_float_format,[Host float floatformat])
1361AC_DEFINE_UNQUOTED(GDB_HOST_DOUBLE_FORMAT,$gdb_host_double_format,[Host double floatformat])
1362AC_DEFINE_UNQUOTED(GDB_HOST_LONG_DOUBLE_FORMAT,$gdb_host_long_double_format,[Host long double floatformat])
1363
1364# target_subdir is used by the testsuite to find the target libraries.
1365target_subdir=
1366if test "${host}" != "${target}"; then
1367    target_subdir="${target_alias}/"
1368fi
1369AC_SUBST(target_subdir)
1370
1371frags=
1372if test "${target}" = "${host}"; then
1373  host_makefile_frag=${srcdir}/config/${gdb_host_cpu}/${gdb_host}.mh
1374  if test ! -f ${host_makefile_frag}; then
1375    AC_MSG_ERROR("*** Gdb does not support native target ${host}")
1376  fi
1377  frags="$frags $host_makefile_frag"
1378else
1379  host_makefile_frag=/dev/null
1380fi
1381
1382target_makefile_frag=${srcdir}/config/${gdb_target_cpu}/${gdb_target}.mt
1383if test ! -f ${target_makefile_frag}; then
1384  AC_MSG_ERROR("*** Gdb does not support target ${target}")
1385fi
1386frags="$frags $target_makefile_frag"
1387
1388AC_SUBST_FILE(host_makefile_frag)
1389AC_SUBST_FILE(target_makefile_frag)
1390AC_SUBST(frags)
1391
1392changequote(,)dnl
1393hostfile=`sed -n '
1394s/XM_FILE[ 	]*=[ 	]*\([^ 	]*\)/\1/p
1395' ${host_makefile_frag}`
1396
1397targetfile=`sed -n '
1398s/DEPRECATED_TM_FILE[ 	]*=[ 	]*\([^ 	]*\)/\1/p
1399' ${target_makefile_frag}`
1400
1401if test "${target}" = "${host}"; then
1402# We pick this up from the host configuration file (.mh) because we
1403# do not have a native configuration Makefile fragment.
1404nativefile=`sed -n '
1405s/NAT_FILE[ 	]*=[ 	]*\([^ 	]*\)/\1/p
1406' ${host_makefile_frag}`
1407fi
1408changequote([,])
1409
1410if test x"${gdb_osabi}" != x ; then
1411    AC_DEFINE_UNQUOTED(GDB_OSABI_DEFAULT, $gdb_osabi,
1412		       [Define to the default OS ABI for this configuration.])
1413fi
1414
1415# Enable multi-ice-gdb-server.
1416AC_ARG_ENABLE(multi-ice,
1417[  --enable-multi-ice      build the multi-ice-gdb-server],
1418  [case $enableval in
1419    yes | no)
1420      ;;
1421    *) AC_MSG_ERROR([bad value $enableval for --enable-multi-ice]) ;;
1422  esac])
1423if test "x$enable_multi_ice" = xyes; then
1424   AC_CONFIG_SUBDIRS(multi-ice)
1425fi
1426
1427# We only build gdbserver automatically if host and target are the same.
1428if test "x$target" = "x$host"; then
1429  AC_MSG_CHECKING(whether gdbserver is supported on this host)
1430  if test "x$build_gdbserver" = xyes; then
1431    AC_MSG_RESULT(yes)
1432    AC_CONFIG_SUBDIRS(gdbserver)
1433  else
1434    AC_MSG_RESULT(no)
1435  fi
1436fi
1437
1438# We build rdi-share on ARM-based targets, as instructed by configure.tgt.
1439if test "x$build_rdi_share" = xyes; then
1440   AC_CONFIG_SUBDIRS(rdi-share)
1441fi
1442
1443# We configure the nlm subdirectory on netware targets, as instructed
1444# by configure.tgt.
1445if test "x$build_nlm" = xyes; then
1446   AC_CONFIG_SUBDIRS(nlm)
1447fi
1448
1449# If hostfile (XM_FILE) and/or targetfile (DEPRECATED_TM_FILE) and/or
1450# nativefile (NAT_FILE) is not set in config/*/*.m[ht] files, we link
1451# to an empty version.
1452
1453files=
1454links=
1455
1456rm -f xm.h
1457xm_h=""
1458if test "${hostfile}" != ""; then
1459    xm_h=xm.h
1460    case "${hostfile}" in
1461      xm-*.h ) GDB_XM_FILE="config/${gdb_host_cpu}/${hostfile}" ;;
1462      * ) GDB_XM_FILE="${hostfile}"
1463    esac
1464    files="${files} ${GDB_XM_FILE}"
1465    links="${links} xm.h"
1466    AC_DEFINE_UNQUOTED(GDB_XM_FILE, "${GDB_XM_FILE}", [hostfile])
1467fi
1468AC_SUBST(xm_h)
1469
1470rm -f tm.h
1471tm_h=""
1472if test "${targetfile}" != ""; then
1473    tm_h=tm.h
1474    case "${targetfile}" in
1475      tm-*.h ) GDB_TM_FILE="config/${gdb_target_cpu}/${targetfile}" ;;
1476      * ) GDB_TM_FILE="${targetfile}"
1477    esac
1478    files="${files} ${GDB_TM_FILE}"
1479    links="${links} tm.h"
1480    AC_DEFINE_UNQUOTED(GDB_TM_FILE, "${GDB_TM_FILE}", [targetfile])
1481fi
1482AC_SUBST(tm_h)
1483
1484rm -f nm.h
1485nm_h=""
1486if test "${nativefile}" != ""; then
1487    nm_h=nm.h
1488    case "${nativefile}" in
1489      nm-*.h ) GDB_NM_FILE="config/${gdb_host_cpu}/${nativefile}" ;;
1490      * ) GDB_NM_FILE="${nativefile}"
1491    esac
1492    files="${files} ${GDB_NM_FILE}"
1493    links="${links} nm.h"
1494    AC_DEFINE_UNQUOTED(GDB_NM_FILE, "${GDB_NM_FILE}", [nativefile])
1495fi
1496AC_SUBST(nm_h)
1497
1498AC_LINK_FILES($files, $links)
1499
1500dnl Check for exe extension set on certain hosts (e.g. Win32)
1501AC_EXEEXT
1502
1503dnl  Detect the character set used by this host.
1504
1505dnl  At the moment, we just assume it's ISO-8859-1 (which is a
1506dnl  superset of ASCII containing the characters needed for French,
1507dnl  German, Spanish, Italian, and possibly others), but if were
1508dnl  *were* to support any host character sets other than ISO-8859-1,
1509dnl  here's where we'd detect it.
1510AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "ISO-8859-1",
1511          [Define to be a string naming the default host character set.])
1512
1513AM_ICONV
1514
1515AC_OUTPUT(Makefile .gdbinit:gdbinit.in,
1516[
1517dnl Autoconf doesn't provide a mechanism for modifying definitions
1518dnl provided by makefile fragments.
1519dnl
1520
1521changequote(,)dnl
1522sed -e '/^DEPRECATED_TM_FILE[ 	]*=/s,^DEPRECATED_TM_FILE[ 	]*=[ 	]*,&config/'"${gdb_target_cpu}"'/,
1523/^XM_FILE[ 	]*=/s,^XM_FILE[ 	]*=[ 	]*,&config/'"${gdb_host_cpu}"'/,
1524/^NAT_FILE[ 	]*=/s,^NAT_FILE[ 	]*=[ 	]*,&config/'"${gdb_host_cpu}"'/,' <Makefile >Makefile.tmp
1525mv -f Makefile.tmp Makefile
1526changequote([,])dnl
1527
1528
1529case x$CONFIG_HEADERS in
1530xconfig.h:config.in)
1531echo > stamp-h ;;
1532esac
1533],
1534[
1535gdb_host_cpu=$gdb_host_cpu
1536gdb_target_cpu=$gdb_target_cpu
1537nativefile=$nativefile
1538])
1539
1540exit 0
1541