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