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