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