Tue Jul 22 19:45:37 1997 Martin M. Hunt <hunt@cygnus.com>
[external/binutils.git] / gdb / configure.in
1 dnl Autoconf configure script for GDB, the GNU debugger.
2 dnl Copyright 1995, 1996 Free Software Foundation, Inc.
3 dnl
4 dnl This file is part of GDB.
5 dnl 
6 dnl This program is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 2 of the License, or
9 dnl (at your option) any later version.
10 dnl 
11 dnl This program is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 dnl GNU General Public License for more details.
15 dnl 
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with this program; if not, write to the Free Software
18 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 dnl Process this file with autoconf to produce a configure script.
21
22 AC_PREREQ(2.5)dnl
23 AC_INIT(main.c)
24 AC_CONFIG_HEADER(config.h:config.in)
25
26 AC_PROG_CC
27 AC_AIX
28 AC_MINIX
29 AC_ISC_POSIX
30
31 AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/..)
32 AC_CANONICAL_SYSTEM
33
34 dnl List of object files added by configure.
35
36 CONFIG_OBS=
37
38 configdirs="doc testsuite"
39
40 dnl
41 changequote(,)dnl
42
43 . ${srcdir}/configure.host
44
45 . ${srcdir}/configure.tgt
46
47 dnl
48 changequote([,])dnl
49
50 AC_PROG_INSTALL
51 AC_CHECK_TOOL(AR, ar)
52 AC_CHECK_TOOL(RANLIB, ranlib, :)
53 AC_PROG_YACC
54 AC_PROG_AWK
55
56 AC_ARG_PROGRAM
57
58 AC_TYPE_SIGNAL
59
60 AC_HEADER_STDC
61 AC_CHECK_HEADERS(limits.h memory.h string.h strings.h unistd.h termios.h termio.h sgtty.h stddef.h stdlib.h sys/procfs.h link.h endian.h objlist.h)
62 AC_HEADER_STAT
63
64 AC_C_CONST
65
66 AC_CHECK_FUNCS(setpgid sbrk select poll)
67
68 # If we are configured native on Linux, work around problems with sys/procfs.h
69 if test "${target}" = "${host}"; then
70   case "${host}" in
71   i[3456]86-*-linux*)
72         AC_DEFINE(START_INFERIOR_TRAPS_EXPECTED,"2")
73         AC_DEFINE(sys_quotactl)
74         ;;
75   esac
76 fi
77
78 AC_MSG_CHECKING([for gregset_t type])
79 AC_CACHE_VAL(gdb_cv_have_gregset_t,
80 [AC_TRY_LINK([#include <sys/procfs.h>],[gregset_t *gregsetp = 0],
81 gdb_cv_have_gregset_t=yes, gdb_cv_have_gregset_t=no)])
82 AC_MSG_RESULT($gdb_cv_have_gregset_t)
83 if test $gdb_cv_have_gregset_t = yes; then
84   AC_DEFINE(HAVE_GREGSET_T)
85 fi
86
87 AC_MSG_CHECKING([for fpregset_t type])
88 AC_CACHE_VAL(gdb_cv_have_fpregset_t,
89 [AC_TRY_LINK([#include <sys/procfs.h>],[fpregset_t *fpregsetp = 0],
90 gdb_cv_have_fpregset_t=yes, gdb_cv_have_fpregset_t=no)])
91 AC_MSG_RESULT($gdb_cv_have_fpregset_t)
92 if test $gdb_cv_have_fpregset_t = yes; then
93   AC_DEFINE(HAVE_FPREGSET_T)
94 fi
95
96 dnl See if host has libm.  This is usually needed by simulators.
97 AC_CHECK_LIB(m, main)
98
99 dnl See if compiler supports "long long" type.
100
101 AC_MSG_CHECKING(for long long support in compiler)
102 AC_CACHE_VAL(gdb_cv_c_long_long,
103 [AC_TRY_COMPILE(, [
104   extern long long foo;
105   switch (foo & 2) { case 0: return 1; }
106 ],
107 gdb_cv_c_long_long=yes, gdb_cv_c_long_long=no)])
108 AC_MSG_RESULT($gdb_cv_c_long_long)
109 if test $gdb_cv_c_long_long = yes; then
110   AC_DEFINE(CC_HAS_LONG_LONG)
111 fi
112
113 dnl See if the compiler and runtime support printing long long
114
115 AC_MSG_CHECKING(for long long support in printf)
116 AC_CACHE_VAL(gdb_cv_printf_has_long_long,
117 [AC_TRY_RUN([
118 int main () {
119   char buf[16];
120   long long l = 0x12345;
121   sprintf (buf, "%llx", l);
122   return (strcmp ("12345", buf));
123 }],
124 gdb_cv_printf_has_long_long=yes,
125 gdb_cv_printf_has_long_long=no,
126 gdb_cv_printf_has_long_long=no)])
127 if test $gdb_cv_printf_has_long_long = yes; then
128   AC_DEFINE(PRINTF_HAS_LONG_LONG)
129 fi
130 AC_MSG_RESULT($gdb_cv_printf_has_long_long)
131
132 dnl See if compiler supports "long double" type.  Can't use AC_C_LONG_DOUBLE
133 dnl because autoconf complains about cross-compilation issues.  However, this
134 dnl code uses the same variables as the macro for compatibility.
135
136 AC_MSG_CHECKING(for long double support in compiler)
137 AC_CACHE_VAL(ac_cv_c_long_double,
138 [AC_TRY_COMPILE(, [long double foo;],
139 ac_cv_c_long_double=yes, ac_cv_c_long_double=no)])
140 AC_MSG_RESULT($ac_cv_c_long_double)
141 if test $ac_cv_c_long_double = yes; then
142   AC_DEFINE(HAVE_LONG_DOUBLE)
143 fi
144
145 dnl See if the compiler and runtime support printing long doubles
146
147 AC_MSG_CHECKING(for long double support in printf)
148 AC_CACHE_VAL(gdb_cv_printf_has_long_double,
149 [AC_TRY_RUN([
150 int main () {
151   char buf[16];
152   long double f = 3.141592653;
153   sprintf (buf, "%Lg", f);
154   return (strncmp ("3.14159", buf, 7));
155 }],
156 gdb_cv_printf_has_long_double=yes,
157 gdb_cv_printf_has_long_double=no,
158 gdb_cv_printf_has_long_double=no)])
159 if test $gdb_cv_printf_has_long_double = yes; then
160   AC_DEFINE(PRINTF_HAS_LONG_DOUBLE)
161 fi
162 AC_MSG_RESULT($gdb_cv_printf_has_long_double)
163
164 AC_FUNC_MMAP
165
166 BFD_NEED_DECLARATION(malloc)
167 BFD_NEED_DECLARATION(realloc)
168 BFD_NEED_DECLARATION(free)
169
170 dnl See if thread_db library is around for Solaris thread debugging.  Note that
171 dnl we must explicitly test for version 1 of the library because version 0
172 dnl (present on Solaris 2.4 or earlier) doesn't have the same API.
173
174 dnl Note that we only want this if we are both native (host == target), and
175 dnl not doing a canadian cross build (build == host).
176
177 if test ${build} = ${host} -a ${host} = ${target} ; then
178         case ${host_os} in
179         hpux*)
180                 AC_MSG_CHECKING(for HPUX/OSF thread support)
181                 if test -f /usr/include/dce/cma_config.h ; then
182                         if test "$GCC" = "yes" ; then
183                                 AC_MSG_RESULT(yes)
184                                 AC_DEFINE(HAVE_HPUX_THREAD_SUPPORT)
185                                 CONFIG_OBS="${CONFIG_OJS} hpux-thread.o"
186                         else
187                                 AC_MSG_RESULT(no (suppressed because you are not using GCC))
188                         fi
189                 else
190                         AC_MSG_RESULT(no)
191                 fi
192                 ;;
193         solaris*)
194                 AC_MSG_CHECKING(for Solaris thread debugging library)
195                 if test -f /usr/lib/libthread_db.so.1 ; then
196                         AC_MSG_RESULT(yes)
197                         AC_DEFINE(HAVE_THREAD_DB_LIB)
198                         CONFIG_OBS="${CONFIG_OBS} sol-thread.o"
199                         AC_CHECK_LIB(dl, dlopen)
200                         if test "$GCC" = "yes" ; then
201                                 CONFIG_LDFLAGS="${CONFIG_LDFLAGS} -Xlinker -export-dynamic"
202                         fi
203                 else
204                         AC_MSG_RESULT(no)
205                 fi
206                 ;;
207         esac
208         AC_SUBST(CONFIG_LDFLAGS)
209 fi
210
211 dnl Handle optional features that can be enabled.
212 ENABLE_CFLAGS=
213
214 AC_ARG_ENABLE(netrom,
215 [  --enable-netrom ],
216 [case "${enableval}" in
217 yes)    enable_netrom=yes ;;
218 no)     enable_netrom=no ;;
219 *)      AC_MSG_ERROR(bad value ${enableval} given for netrom option) ;;
220 esac])
221
222 if test "${enable_netrom}" = "yes"; then
223         CONFIG_OBS="${CONFIG_OBS} remote-nrom.o" 
224 fi
225
226 # start-sanitize-gm
227 ENABLE_GM=
228
229 AC_ARG_ENABLE(gm,
230 [  --enable-gm ],
231 [case "${enableval}" in
232 yes)    CONFIG_OBS="${CONFIG_OBS} gmagic.o"
233         ENABLE_CFLAGS=-DGENERAL_MAGIC
234         ;;
235 no)     ;;
236 *)      AC_MSG_ERROR(bad value ${enableval} given for gm option) ;;
237 esac])
238
239 # end-sanitize-gm
240
241 # start-sanitize-gdbtk
242 ENABLE_IDE=
243 AC_ARG_ENABLE(ide, [  --enable-ide            Enable IDE support])
244 if test "$enable_ide" = yes; then
245    enable_ide=yes
246    ENABLE_IDE=1
247 else
248    enable_ide=no
249 fi
250 AC_SUBST(ENABLE_IDE)
251
252 ENABLE_GDBTK=
253
254 AC_ARG_ENABLE(gdbtk,
255 [  --enable-gdbtk ],
256 [case "${enableval}" in
257     yes)
258         case "$host" in
259         *go32*)
260             AC_MSG_WARN([GDB does not support GDBtk on host ${host}.  GDBtk will be disabled.])
261             enable_gdbtk=no ;;
262         *windows*)
263             AC_MSG_WARN([GDB does not support GDBtk on host ${host}.  GDBtk will be disabled.])
264             enable_gdbtk=no ;;
265         *)
266             enable_gdbtk=yes ;;
267         esac ;;
268     no)
269         enable_gdbtk=no  ;;
270     *)
271         AC_MSG_ERROR(bad value ${enableval} given for gdbtk option) ;;
272 esac],
273 [
274 # Default is on for everything but go32 and cygwin32
275 case "$host" in
276     *go32* | *windows*)
277         ;;
278     *)
279         enable_gdbtk=yes ;;
280     esac
281 ])
282
283 case "${target}" in
284 *-cygwin32)
285         configdir="win"
286         ;;
287 *)
288         configdir="unix"
289         ;;
290 esac
291
292 if test "${enable_gdbtk}" = "yes"; then
293
294     CY_AC_PATH_TCLCONFIG
295     if test -z "${no_tcl}"; then
296         CY_AC_LOAD_TCLCONFIG
297         CY_AC_PATH_TKCONFIG
298
299         # If $no_tk is nonempty, then we can't do Tk, and there is no
300         # point to doing Tcl.
301         if test -z "${no_tk}"; then
302            CY_AC_LOAD_TKCONFIG
303            CY_AC_PATH_TCLH
304            CY_AC_PATH_TKH
305            CY_AC_PATH_ITCLH
306            CY_AC_PATH_TIX
307
308            # now look for tix library stuff
309            TIXVERSION=4.1.7.6
310            . ${ac_cv_c_tclconfig}/tclConfig.sh
311            case "${host}" in
312            *-*-cygwin32*)
313                 tixdir=../tix/win/tcl7.6
314                 ;;
315            *)
316                 tixdir=../tix/unix/tk4.2
317                 ;;
318            esac 
319            if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
320                 TIXLIB="-L${tixdir} -ltix${TIXVERSION}"
321            else
322                 TIXLIB="-L${tixdir} -ltix`echo ${TIXVERSION} | tr -d .`"
323            fi
324
325            ENABLE_GDBTK=1
326
327            # Include some libraries that Tcl and Tk want.
328            if test "${enable_ide}" = "yes"; then        
329               TCL_LIBS='$(IDE) $(ITCL) $(TIX) $(TK) $(TCL) $(X11_LDFLAGS) $(X11_LIBS)'
330            else
331               TCL_LIBS='$(ITCL) $(TIX) $(TK) $(TCL) $(X11_LDFLAGS) $(X11_LIBS)'
332            fi
333            # Yes, the ordering seems wrong here.  But it isn't.
334            # TK_LIBS is the list of libraries that need to be linked
335            # after Tcl/Tk.
336            LIBS="${LIBS} ${TCL_LIBS} ${TK_LIBS}"
337            CONFIG_OBS="${CONFIG_OBS} gdbtk.o"
338         fi
339     fi
340 fi
341
342 AC_SUBST(ENABLE_GDBTK)
343 AC_SUBST(X_CFLAGS)
344 AC_SUBST(X_LDFLAGS)
345 AC_SUBST(X_LIBS)
346 AC_SUBST(TIXLIB)
347 # end-sanitize-gdbtk
348
349 AC_SUBST(ENABLE_CFLAGS)
350
351 AC_SUBST(CONFIG_OBS)
352
353 # Begin stuff to support --enable-shared
354 AC_ARG_ENABLE(shared,
355 [  --enable-shared         use shared libraries],
356 [case "${enableval}" in
357   yes) shared=true ;;
358   no)  shared=false ;;
359   *) shared=true ;;
360 esac])dnl
361
362 HLDFLAGS=
363 HLDENV=
364 # If we have shared libraries, try to set rpath reasonably.
365 if test "${shared}" = "true"; then
366   case "${host}" in
367   *-*-hpux*)
368     HLDFLAGS='-Wl,+s,+b,$(libdir)'
369     ;;
370   *-*-irix5* | *-*-irix6*)
371     HLDFLAGS='-Wl,-rpath,$(libdir)'
372     ;;
373   *-*-linux*aout*)
374     ;;
375   *-*-linux* | *-pc-linux-gnu)
376     HLDFLAGS='-Wl,-rpath,$(libdir)'
377     ;;
378   *-*-solaris*)
379     HLDFLAGS='-R $(libdir)'
380     ;;
381   *-*-sysv4*)
382     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;'
383     ;;
384   esac
385 fi
386
387 # On SunOS, if the linker supports the -rpath option, use it to
388 # prevent ../bfd and ../opcodes from being included in the run time
389 # search path.
390 case "${host}" in
391   *-*-sunos*)
392     echo 'main () { }' > conftest.c
393     ${CC} -o conftest -Wl,-rpath= conftest.c >/dev/null 2>conftest.t
394     if grep 'unrecognized' conftest.t >/dev/null 2>&1; then
395       :
396     elif grep 'No such file' conftest.t >/dev/null 2>&1; then
397       :
398     elif grep 'do not mix' conftest.t >/dev/null 2>&1; then
399       :
400     elif grep 'some text already loaded' conftest.t >/dev/null 2>&1; then
401       :
402     elif test "${shared}" = "true"; then
403       HLDFLAGS='-Wl,-rpath=$(libdir)'
404     else
405       HLDFLAGS='-Wl,-rpath='
406     fi
407     rm -f conftest.t conftest.c conftest
408     ;;
409 esac
410 AC_SUBST(HLDFLAGS)
411 AC_SUBST(HLDENV)
412 # End stuff to support --enable-shared
413
414 # target_subdir is used by the testsuite to find the target libraries.
415 target_subdir=
416 if test "${host}" != "${target}"; then
417     target_subdir="${target_alias}/"
418 fi
419 AC_SUBST(target_subdir)
420
421 frags=
422 host_makefile_frag=${srcdir}/config/${gdb_host_cpu}/${gdb_host}.mh
423 if test ! -f ${host_makefile_frag}; then
424 AC_MSG_ERROR("*** Gdb does not support host ${host}")
425 fi
426 frags="$frags $host_makefile_frag"
427
428 target_makefile_frag=${srcdir}/config/${gdb_target_cpu}/${gdb_target}.mt
429 if test ! -f ${target_makefile_frag}; then
430 AC_MSG_ERROR("*** Gdb does not support target ${target}")
431 fi
432 frags="$frags $target_makefile_frag"
433
434 AC_SUBST_FILE(host_makefile_frag)
435 AC_SUBST_FILE(target_makefile_frag)
436 AC_SUBST(frags)
437
438 changequote(,)dnl
439 hostfile=`sed -n '
440 s/XM_FILE[      ]*=[    ]*\([^  ]*\)/\1/p
441 ' ${host_makefile_frag}`
442
443 targetfile=`sed -n '
444 s/TM_FILE[      ]*=[    ]*\([^  ]*\)/\1/p
445 ' ${target_makefile_frag}`
446
447 # these really aren't orthogonal true/false values of the same condition,
448 # but shells are slow enough that I like to reuse the test conditions
449 # whenever possible
450 if test "${target}" = "${host}"; then
451 nativefile=`sed -n '
452 s/NAT_FILE[     ]*=[    ]*\([^  ]*\)/\1/p
453 ' ${host_makefile_frag}`
454 # else
455 # GDBserver is only useful in a "native" enviroment
456 # configdirs=`echo $configdirs | sed 's/gdbserver//'`
457 fi
458 changequote([,])
459
460 # If hostfile (XM_FILE) and/or targetfile (TM_FILE) and/or nativefile
461 # (NAT_FILE) is not set in config/*/*.m[ht] files, we don't make the
462 # corresponding links.  But we have to remove the xm.h files and tm.h
463 # files anyway, e.g. when switching from "configure host" to
464 # "configure none".
465
466 files=
467 links=
468 rm -f xm.h
469 if test "${hostfile}" != ""; then
470 files="${files} config/${gdb_host_cpu}/${hostfile}"
471 links="${links} xm.h"
472 fi
473 rm -f tm.h
474 if test "${targetfile}" != ""; then
475 files="${files} config/${gdb_target_cpu}/${targetfile}"
476 links="${links} tm.h"
477 fi
478 rm -f nm.h
479 if test "${nativefile}" != ""; then
480 files="${files} config/${gdb_host_cpu}/${nativefile}"
481 links="${links} nm.h"
482 else
483 # A cross-only configuration.
484 files="${files} config/nm-empty.h"
485 links="${links} nm.h"
486 fi
487 # start-sanitize-gdbtk
488 AC_PROG_LN_S
489 # Make it possible to use the GUI without doing a full install
490 if test "${enable_gdbtk}" = "yes" -a ! -d gdbtcl ; then
491   if test "$LN_S" = "ln -s" -a ! -f gdbtcl ; then
492   echo linking $srcdir/gdbtcl to gdbtcl
493   $LN_S $srcdir/gdbtcl gdbtcl
494   else
495   echo Warning: Unable to link $srcdir/gdbtcl to gdbtcl.  You will need to do a
496   echo "         " make install before you are able to run the GUI.
497   fi
498 fi
499 # end-sanitize-gdbtk
500
501 AC_LINK_FILES($files, $links)
502
503 AC_CONFIG_SUBDIRS($configdirs)
504 AC_OUTPUT(Makefile .gdbinit:gdbinit.in,
505 [
506 dnl Autoconf doesn't provide a mechanism for modifying definitions 
507 dnl provided by makefile fragments.
508 dnl
509 if test "${nativefile}" = ""; then
510 sed -e '/^NATDEPFILES[[         ]]*=[[  ]]*/s//# NATDEPFILES=/' \
511         < Makefile > Makefile.tem
512 mv -f Makefile.tem Makefile
513 fi
514
515 changequote(,)dnl
516 sed -e '/^TM_FILE[      ]*=/s,^TM_FILE[         ]*=[    ]*,&config/'"${gdb_target_cpu}"'/,
517 /^XM_FILE[      ]*=/s,^XM_FILE[         ]*=[    ]*,&config/'"${gdb_host_cpu}"'/,
518 /^NAT_FILE[     ]*=/s,^NAT_FILE[        ]*=[    ]*,&config/'"${gdb_host_cpu}"'/,' <Makefile >Makefile.tmp
519 mv -f Makefile.tmp Makefile
520 changequote([,])dnl
521
522 case x$CONFIG_HEADERS in
523 xconfig.h:config.in)
524 echo > stamp-h ;;
525 esac
526 ],
527 [
528 gdb_host_cpu=$gdb_host_cpu
529 gdb_target_cpu=$gdb_target_cpu
530 nativefile=$nativefile
531 ])
532
533 exit 0
534