1 dnl Autoconf configure script for GDB, the GNU debugger.
2 dnl Copyright 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
4 dnl This file is part of GDB.
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.
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.
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.
20 dnl Process this file with autoconf to produce a configure script.
24 AC_CONFIG_HEADER(config.h:config.in)
31 AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/..)
34 dnl gdb doesn't use gettext, but bfd does. We call this to ensure we
35 dnl link with the correct libraries.
39 dnl List of object files added by configure.
45 configdirs="doc testsuite"
47 AC_ARG_ENABLE(multi-ice,
48 [ --enable-multi-ice Build the multi-ice-gdb-server],
49 [case "${enableval}" in
50 yes ) enable_multi_ice="yes" ;;
51 no) enable_multi_ice="no" ;;
52 *) AC_MSG_ERROR(Bad value for --enable-multi-ice: ${enableval}) ;;
56 if test "${enable_multi_ice}" = "yes"; then
57 configdirs="${configdirs} multi-ice"
63 . ${srcdir}/configure.host
65 . ${srcdir}/configure.tgt
73 AC_CHECK_TOOL(RANLIB, ranlib, :)
82 AC_CHECK_HEADERS(ctype.h curses.h endian.h link.h \
83 memory.h objlist.h ptrace.h sgtty.h stddef.h stdlib.h \
84 string.h sys/procfs.h sys/ptrace.h sys/reg.h \
85 term.h termio.h termios.h unistd.h wait.h sys/wait.h \
86 wchar.h wctype.h asm/debugreg.h sys/debugreg.h sys/select.h)
91 AC_CHECK_FUNCS(setpgid sbrk sigaction isascii bzero bcopy btowc poll)
94 AC_CHECK_LIB(socket, socketpair)
95 AC_CHECK_FUNCS(socketpair)
98 BFD_NEED_DECLARATION(malloc)
99 BFD_NEED_DECLARATION(realloc)
100 BFD_NEED_DECLARATION(free)
101 BFD_NEED_DECLARATION(strerror)
102 BFD_NEED_DECLARATION(strdup)
103 BFD_NEED_DECLARATION(strstr)
106 # The following save_state_t checkery is only necessary for HPUX
107 # versions earlier than 10.20. When those fade from memory, this
108 # could be expunged. --jsm 1999-03-22
110 AC_MSG_CHECKING(for HPUX save_state structure)
111 AC_EGREP_HEADER(save_state_t, machine/save_state.h,
112 gdb_cv_hpux_savestate=yes, gdb_cv_hpux_savestate=no)
113 AC_EGREP_HEADER(ss_wide, machine/save_state.h, gdb_cv_hpux_sswide=yes,
114 gdb_cv_hpux_sswide=no)
115 if test $gdb_cv_hpux_savestate = yes
117 AC_DEFINE(HAVE_STRUCT_SAVE_STATE_T, 1)
119 if test $gdb_cv_hpux_sswide = yes
121 AC_DEFINE(HAVE_STRUCT_MEMBER_SS_WIDE, 1)
123 AC_MSG_RESULT($gdb_cv_hpux_sswide)
126 # If we are configured native on GNU/Linux, work around problems with
128 # Also detect which type of /proc is in use, such as for Unixware.
130 if test "${target}" = "${host}"; then
131 gdb_cv_hostos_is_solaris=no
133 i[[3456]]86-*-linux*)
134 AC_DEFINE(START_INFERIOR_TRAPS_EXPECTED,2)
135 AC_DEFINE(sys_quotactl)
138 gdb_cv_hostos_is_solaris=yes ;;
140 AC_MSG_CHECKING(for directory proc entries)
141 # The [gdb_host != sun4sol2] hack is because Solaris does provide the
142 # multiple procfs files as of Solaris 2.6, but GDB can't use it right now.
143 if test "$ac_cv_header_sys_procfs_h" = yes -a \
144 "$gdb_cv_hostos_is_solaris" = no \
149 -a -f /proc/$$/status; then
151 AC_DEFINE(HAVE_MULTIPLE_PROC_FDS)
157 if test "$ac_cv_header_sys_procfs_h" = yes; then
158 BFD_HAVE_SYS_PROCFS_TYPE(pstatus_t)
159 BFD_HAVE_SYS_PROCFS_TYPE(prrun_t)
160 BFD_HAVE_SYS_PROCFS_TYPE(gregset_t)
161 BFD_HAVE_SYS_PROCFS_TYPE(fpregset_t)
163 dnl Check for PIOCSET ioctl entry
165 AC_MSG_CHECKING(for PIOCSET ioctl entry in sys/procfs.h)
166 AC_CACHE_VAL(gdb_cv_have_procfs_piocset,
167 [AC_TRY_COMPILE([#include <unistd.h>
168 #include <sys/types.h>
169 #include <sys/procfs.h>
172 dummy = ioctl(0, PIOCSET, &dummy);
174 gdb_cv_have_procfs_piocset=yes, gdb_cv_have_procfs_piocset=no)])
175 AC_MSG_RESULT($gdb_cv_have_procfs_piocset)
176 if test $gdb_cv_have_procfs_piocset = yes; then
177 AC_DEFINE(HAVE_PROCFS_PIOCSET)
181 dnl See if host has libm. This is usually needed by simulators.
182 AC_CHECK_LIB(m, main)
184 dnl Solaris puts wctype in /usr/lib/libw.a before Solaris 2.6.
186 dnl A bug in GNU ld 2.9.1 causes a problem if we link in -lw
187 dnl under Solaris 2.6 because it is some funky empty library.
188 dnl So only link in libw if we have to.
189 AC_CHECK_LIB(c, wctype,: ,AC_CHECK_LIB(w, wctype))
191 dnl See if compiler supports "long long" type.
193 AC_MSG_CHECKING(for long long support in compiler)
194 AC_CACHE_VAL(gdb_cv_c_long_long,
196 extern long long foo;
197 switch (foo & 2) { case 0: return 1; }
199 gdb_cv_c_long_long=yes, gdb_cv_c_long_long=no)])
200 AC_MSG_RESULT($gdb_cv_c_long_long)
201 if test $gdb_cv_c_long_long = yes; then
202 AC_DEFINE(CC_HAS_LONG_LONG)
205 dnl See if the compiler and runtime support printing long long
207 AC_MSG_CHECKING(for long long support in printf)
208 AC_CACHE_VAL(gdb_cv_printf_has_long_long,
213 l = (l << 16) + 0x0123;
214 l = (l << 16) + 0x4567;
215 l = (l << 16) + 0x89ab;
216 l = (l << 16) + 0xcdef;
217 sprintf (buf, "0x%016llx", l);
218 return (strcmp ("0x0123456789abcdef", buf));
220 gdb_cv_printf_has_long_long=yes,
221 gdb_cv_printf_has_long_long=no,
222 gdb_cv_printf_has_long_long=no)])
223 if test $gdb_cv_printf_has_long_long = yes; then
224 AC_DEFINE(PRINTF_HAS_LONG_LONG)
226 AC_MSG_RESULT($gdb_cv_printf_has_long_long)
228 dnl See if compiler supports "long double" type. Can't use AC_C_LONG_DOUBLE
229 dnl because autoconf complains about cross-compilation issues. However, this
230 dnl code uses the same variables as the macro for compatibility.
232 AC_MSG_CHECKING(for long double support in compiler)
233 AC_CACHE_VAL(ac_cv_c_long_double,
234 [AC_TRY_COMPILE(, [long double foo;],
235 ac_cv_c_long_double=yes, ac_cv_c_long_double=no)])
236 AC_MSG_RESULT($ac_cv_c_long_double)
237 if test $ac_cv_c_long_double = yes; then
238 AC_DEFINE(HAVE_LONG_DOUBLE)
241 dnl See if the compiler and runtime support printing long doubles
243 AC_MSG_CHECKING(for long double support in printf)
244 AC_CACHE_VAL(gdb_cv_printf_has_long_double,
248 long double f = 3.141592653;
249 sprintf (buf, "%Lg", f);
250 return (strncmp ("3.14159", buf, 7));
252 gdb_cv_printf_has_long_double=yes,
253 gdb_cv_printf_has_long_double=no,
254 gdb_cv_printf_has_long_double=no)])
255 if test $gdb_cv_printf_has_long_double = yes; then
256 AC_DEFINE(PRINTF_HAS_LONG_DOUBLE)
258 AC_MSG_RESULT($gdb_cv_printf_has_long_double)
260 dnl See if the compiler and runtime support scanning long doubles
262 AC_MSG_CHECKING(for long double support in scanf)
263 AC_CACHE_VAL(gdb_cv_scanf_has_long_double,
266 char *buf = "3.141592653";
268 sscanf (buf, "%Lg", &f);
269 return !(f > 3.14159 && f < 3.14160);
271 gdb_cv_scanf_has_long_double=yes,
272 gdb_cv_scanf_has_long_double=no,
273 gdb_cv_scanf_has_long_double=no)])
274 if test $gdb_cv_scanf_has_long_double = yes; then
275 AC_DEFINE(SCANF_HAS_LONG_DOUBLE)
277 AC_MSG_RESULT($gdb_cv_scanf_has_long_double)
281 dnl See if thread_db library is around for Solaris thread debugging. Note that
282 dnl we must explicitly test for version 1 of the library because version 0
283 dnl (present on Solaris 2.4 or earlier) doesn't have the same API.
285 dnl Note that we only want this if we are both native (host == target), and
286 dnl not doing a canadian cross build (build == host).
288 if test ${build} = ${host} -a ${host} = ${target} ; then
291 AC_MSG_CHECKING(for HPUX/OSF thread support)
292 if test -f /usr/include/dce/cma_config.h ; then
293 if test "$GCC" = "yes" ; then
295 AC_DEFINE(HAVE_HPUX_THREAD_SUPPORT)
296 CONFIG_OBS="${CONFIG_OJS} hpux-thread.o"
297 CONFIG_SRCS="${CONFIG_SRCS} hpux-thread.c"
299 AC_MSG_RESULT(no (suppressed because you are not using GCC))
306 AC_MSG_CHECKING(for Solaris thread debugging library)
307 if test -f /usr/lib/libthread_db.so.1 ; then
309 AC_DEFINE(HAVE_THREAD_DB_LIB)
310 CONFIG_OBS="${CONFIG_OBS} sol-thread.o"
311 CONFIG_SRCS="${CONFIG_SRCS} sol-thread.c"
312 AC_CHECK_LIB(dl, dlopen)
313 if test "$GCC" = "yes" ; then
314 # The GNU linker requires the -export-dynamic option to make
315 # all symbols visible in the dynamic symbol table.
316 hold_ldflags=$LDFLAGS
317 AC_MSG_CHECKING(for the ld -export-dynamic flag)
318 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
319 AC_TRY_LINK(, [int i;], found=yes, found=no)
320 LDFLAGS=$hold_ldflags
321 AC_MSG_RESULT($found)
322 if test $found = yes; then
323 CONFIG_LDFLAGS="${CONFIG_LDFLAGS} -Wl,-export-dynamic"
326 # Sun randomly tweaked the prototypes in <proc_service.h>
328 AC_MSG_CHECKING(if <proc_service.h> is old)
329 AC_CACHE_VAL(gdb_cv_proc_service_is_old,[
331 #include <proc_service.h>
333 (struct ps_prochandle*, psaddr_t, const void*, size_t);
334 ],, gdb_cv_proc_service_is_old=no,
335 gdb_cv_proc_service_is_old=yes)
337 AC_MSG_RESULT($gdb_cv_proc_service_is_old)
338 if test $gdb_cv_proc_service_is_old = yes; then
339 AC_DEFINE(PROC_SERVICE_IS_OLD)
346 AC_SUBST(CONFIG_LDFLAGS)
349 dnl Handle optional features that can be enabled.
353 [ --enable-tui Enable full-screen terminal user interface],
355 case "${enable_tui}" in
357 "") enable_tui=yes ;;
359 AC_MSG_ERROR(Bad value for --enable-tui: ${enableval})
363 case ${enable_tui} in
367 TUI_LIBRARY=tui/libtui.a
375 AC_SUBST(TUI_LIBRARY)
377 AC_ARG_ENABLE(netrom,
378 [ --enable-netrom Enable NetROM support],
379 [case "${enableval}" in
380 yes) enable_netrom=yes ;;
381 no) enable_netrom=no ;;
382 *) AC_MSG_ERROR(bad value ${enableval} given for netrom option) ;;
385 if test "${enable_netrom}" = "yes"; then
386 CONFIG_OBS="${CONFIG_OBS} remote-nrom.o"
387 CONFIG_SRCS="${CONFIG_SRCS} remote-nrom.c"
390 AC_ARG_ENABLE(build-warnings,
391 [ --enable-build-warnings Enable build-time compiler warnings if gcc is used],
392 [build_warnings="-Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations"
393 case "${enableval}" in
395 no) build_warnings="-w";;
396 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
397 build_warnings="${build_warnings} ${t}";;
398 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
399 build_warnings="${t} ${build_warnings}";;
400 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
401 esac],[build_warnings=""])dnl
403 if test "x${build_warnings}" != x -a "x$GCC" = xyes
405 WARN_CFLAGS="${build_warnings}"
409 AC_SUBST(WARN_CFLAGS)
413 AC_SUBST(MMALLOC_CFLAGS)
417 [ --with-mmalloc Use memory mapped malloc package],
418 [case "${withval}" in
419 yes) want_mmalloc=true ;;
420 no) want_mmalloc=false;;
421 *) AC_MSG_ERROR(bad value ${withval} for GDB with-mmalloc option) ;;
422 esac],[want_mmalloc=false])dnl
424 if test x$want_mmalloc = xtrue; then
425 AC_DEFINE(USE_MMALLOC)
426 AC_DEFINE(MMCHECK_FORCE)
427 MMALLOC_CFLAGS="-I$srcdir/../mmalloc"
428 MMALLOC='../mmalloc/libmmalloc.a'
432 # In the Cygwin environment, we need some additional flags.
433 AC_CACHE_CHECK([for cygwin], gdb_cv_os_cygwin,
434 [AC_EGREP_CPP(lose, [
435 #if defined (__CYGWIN__) || defined (__CYGWIN32__)
437 #endif],[gdb_cv_os_cygwin=yes],[gdb_cv_os_cygwin=no])])
439 DLLTOOL=${DLLTOOL-dlltool}
440 WINDRES=${WINDRES-windres}
444 dnl Figure out which term library to use.
445 if test x$gdb_host = xgo32; then
448 if test x$gdb_cv_os_cygwin = xyes; then
449 TERM_LIB='`if test -r ../libtermcap/libtermcap.a; then echo ../libtermcap/libtermcap.a; else echo -ltermcap; fi`'
452 AC_CHECK_LIB(ncurses, tgetent, TERM_LIB=-lncurses,
453 AC_CHECK_LIB(Hcurses, tgetent, TERM_LIB=-lHcurses,
454 AC_CHECK_LIB(termlib, tgetent, TERM_LIB=-ltermlib,
455 AC_CHECK_LIB(termcap, tgetent, TERM_LIB=-ltermcap,
456 AC_CHECK_LIB(curses, tgetent, TERM_LIB=-lcurses,
457 AC_CHECK_LIB(terminfo, tgetent, TERM_LIB=-lterminfo))))))
459 if test "x$TERM_LIB" = x
461 AC_MSG_ERROR(Could not find a term library, e.g. termcap or termlib!)
467 # libreadline needs libuser32.a in a cygwin environment
469 if test x$gdb_cv_os_cygwin = xyes; then
478 # Unlike the sim directory, whether a simulator is linked is controlled by
479 # presence of a SIM= and a SIM_OBS= definition in the target '.mt' file.
480 # This code just checks for a few cases where we'd like to ignore those
481 # definitions, even when they're present in the '.mt' file. These cases
482 # are when --disable-sim is specified, or if the simulator directory is
483 # not part of the soruce tree.
486 [ --enable-sim Link gdb with simulator],
487 [echo "enable_sim = $enable_sim";
488 echo "enableval = ${enableval}";
489 case "${enableval}" in
490 yes) ignore_sim=false ;;
491 no) ignore_sim=true ;;
492 *) ignore_sim=false ;;
496 if test ! -d "${srcdir}/../sim"; then
500 if test "${ignore_sim}" = "true"; then
502 IGNORE_SIM_OBS="SIM_OBS="
509 AC_SUBST(IGNORE_SIM_OBS)
511 AC_SUBST(ENABLE_CFLAGS)
514 AC_SUBST(CONFIG_DEPS)
515 AC_SUBST(CONFIG_SRCS)
517 # Begin stuff to support --enable-shared
518 AC_ARG_ENABLE(shared,
519 [ --enable-shared Use shared libraries],
520 [case "${enableval}" in
528 # If we have shared libraries, try to set rpath reasonably.
529 if test "${shared}" = "true"; then
532 HLDFLAGS='-Wl,+s,+b,$(libdir)'
534 *-*-irix5* | *-*-irix6*)
535 HLDFLAGS='-Wl,-rpath,$(libdir)'
539 *-*-linux* | *-pc-linux-gnu)
540 HLDFLAGS='-Wl,-rpath,$(libdir)'
543 HLDFLAGS='-R $(libdir)'
546 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;'
551 # On SunOS, if the linker supports the -rpath option, use it to
552 # prevent ../bfd and ../opcodes from being included in the run time
556 echo 'main () { }' > conftest.c
557 ${CC} -o conftest -Wl,-rpath= conftest.c >/dev/null 2>conftest.t
558 if grep 'unrecognized' conftest.t >/dev/null 2>&1; then
560 elif grep 'No such file' conftest.t >/dev/null 2>&1; then
562 elif grep 'do not mix' conftest.t >/dev/null 2>&1; then
564 elif grep 'some text already loaded' conftest.t >/dev/null 2>&1; then
566 elif test "${shared}" = "true"; then
567 HLDFLAGS='-Wl,-rpath=$(libdir)'
569 HLDFLAGS='-Wl,-rpath='
571 rm -f conftest.t conftest.c conftest
576 # End stuff to support --enable-shared
578 # target_subdir is used by the testsuite to find the target libraries.
580 if test "${host}" != "${target}"; then
581 target_subdir="${target_alias}/"
583 AC_SUBST(target_subdir)
586 host_makefile_frag=${srcdir}/config/${gdb_host_cpu}/${gdb_host}.mh
587 if test ! -f ${host_makefile_frag}; then
588 AC_MSG_ERROR("*** Gdb does not support host ${host}")
590 frags="$frags $host_makefile_frag"
592 target_makefile_frag=${srcdir}/config/${gdb_target_cpu}/${gdb_target}.mt
593 if test ! -f ${target_makefile_frag}; then
594 AC_MSG_ERROR("*** Gdb does not support target ${target}")
596 frags="$frags $target_makefile_frag"
598 AC_SUBST_FILE(host_makefile_frag)
599 AC_SUBST_FILE(target_makefile_frag)
604 s/XM_FILE[ ]*=[ ]*\([^ ]*\)/\1/p
605 ' ${host_makefile_frag}`
608 s/TM_FILE[ ]*=[ ]*\([^ ]*\)/\1/p
609 ' ${target_makefile_frag}`
611 # these really aren't orthogonal true/false values of the same condition,
612 # but shells are slow enough that I like to reuse the test conditions
614 if test "${target}" = "${host}"; then
616 s/NAT_FILE[ ]*=[ ]*\([^ ]*\)/\1/p
617 ' ${host_makefile_frag}`
619 # GDBserver is only useful in a "native" enviroment
620 # configdirs=`echo $configdirs | sed 's/gdbserver//'`
624 SUBDIRS="doc testsuite nlm"
625 if test "${enable_multi_ice}" = "yes"; then
626 SUBDIRS="${SUBDIRS} multi-ice"
631 # If hostfile (XM_FILE) and/or targetfile (TM_FILE) and/or nativefile
632 # (NAT_FILE) is not set in config/*/*.m[ht] files, we don't make the
633 # corresponding links. But we have to remove the xm.h files and tm.h
634 # files anyway, e.g. when switching from "configure host" to
640 if test "${hostfile}" != ""; then
641 files="${files} config/${gdb_host_cpu}/${hostfile}"
642 links="${links} xm.h"
645 if test "${targetfile}" != ""; then
646 files="${files} config/${gdb_target_cpu}/${targetfile}"
647 links="${links} tm.h"
650 if test "${nativefile}" != ""; then
651 files="${files} config/${gdb_host_cpu}/${nativefile}"
652 links="${links} nm.h"
654 # A cross-only configuration.
655 files="${files} config/nm-empty.h"
656 links="${links} nm.h"
659 AC_LINK_FILES($files, $links)
661 dnl Check for exe extension set on certain hosts (e.g. Win32)
664 AC_CONFIG_SUBDIRS($configdirs)
665 AC_OUTPUT(Makefile tui/Makefile .gdbinit:gdbinit.in,
667 dnl Autoconf doesn't provide a mechanism for modifying definitions
668 dnl provided by makefile fragments.
670 if test "${nativefile}" = ""; then
671 sed -e '/^NATDEPFILES[[ ]]*=[[ ]]*/s//# NATDEPFILES=/' \
672 < Makefile > Makefile.tem
673 mv -f Makefile.tem Makefile
677 sed -e '/^TM_FILE[ ]*=/s,^TM_FILE[ ]*=[ ]*,&config/'"${gdb_target_cpu}"'/,
678 /^XM_FILE[ ]*=/s,^XM_FILE[ ]*=[ ]*,&config/'"${gdb_host_cpu}"'/,
679 /^NAT_FILE[ ]*=/s,^NAT_FILE[ ]*=[ ]*,&config/'"${gdb_host_cpu}"'/,' <Makefile >Makefile.tmp
680 mv -f Makefile.tmp Makefile
683 case x$CONFIG_HEADERS in
689 gdb_host_cpu=$gdb_host_cpu
690 gdb_target_cpu=$gdb_target_cpu
691 nativefile=$nativefile