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