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"
50 . ${srcdir}/configure.host
52 . ${srcdir}/configure.tgt
60 AC_CHECK_TOOL(RANLIB, ranlib, :)
69 AC_CHECK_HEADERS(ctype.h curses.h endian.h link.h \
70 memory.h objlist.h ptrace.h sgtty.h stddef.h stdlib.h \
71 string.h sys/procfs.h sys/ptrace.h sys/reg.h \
72 term.h termio.h termios.h unistd.h wait.h sys/wait.h \
73 wchar.h wctype.h asm/debugreg.h sys/debugreg.h sys/select.h)
78 AC_CHECK_FUNCS(setpgid sbrk sigaction isascii bzero bcopy btowc poll)
81 BFD_NEED_DECLARATION(malloc)
82 BFD_NEED_DECLARATION(realloc)
83 BFD_NEED_DECLARATION(free)
84 BFD_NEED_DECLARATION(strerror)
85 BFD_NEED_DECLARATION(strdup)
86 BFD_NEED_DECLARATION(strstr)
89 # The following save_state_t checkery is only necessary for HPUX
90 # versions earlier than 10.20. When those fade from memory, this
91 # could be expunged. --jsm 1999-03-22
93 AC_MSG_CHECKING(for HPUX save_state structure)
94 AC_EGREP_HEADER(save_state_t, machine/save_state.h,
95 gdb_cv_hpux_savestate=yes, gdb_cv_hpux_savestate=no)
96 AC_EGREP_HEADER(ss_wide, machine/save_state.h, gdb_cv_hpux_sswide=yes,
97 gdb_cv_hpux_sswide=no)
98 if test $gdb_cv_hpux_savestate = yes
100 AC_DEFINE(HAVE_STRUCT_SAVE_STATE_T, 1)
102 if test $gdb_cv_hpux_sswide = yes
104 AC_DEFINE(HAVE_STRUCT_MEMBER_SS_WIDE, 1)
106 AC_MSG_RESULT($gdb_cv_hpux_sswide)
109 # If we are configured native on GNU/Linux, work around problems with
111 # Also detect which type of /proc is in use, such as for Unixware.
113 if test "${target}" = "${host}"; then
114 gdb_cv_hostos_is_solaris=no
116 i[[3456]]86-*-linux*)
117 AC_DEFINE(START_INFERIOR_TRAPS_EXPECTED,2)
118 AC_DEFINE(sys_quotactl)
121 gdb_cv_hostos_is_solaris=yes ;;
123 AC_MSG_CHECKING(for directory proc entries)
124 # The [gdb_host != sun4sol2] hack is because Solaris does provide the
125 # multiple procfs files as of Solaris 2.6, but GDB can't use it right now.
126 if test "$ac_cv_header_sys_procfs_h" = yes -a \
127 "$gdb_cv_hostos_is_solaris" = no \
132 -a -f /proc/$$/status; then
134 AC_DEFINE(HAVE_MULTIPLE_PROC_FDS)
140 if test "$ac_cv_header_sys_procfs_h" = yes; then
141 BFD_HAVE_SYS_PROCFS_TYPE(pstatus_t)
142 BFD_HAVE_SYS_PROCFS_TYPE(prrun_t)
143 BFD_HAVE_SYS_PROCFS_TYPE(gregset_t)
144 BFD_HAVE_SYS_PROCFS_TYPE(fpregset_t)
146 dnl Check for PIOCSET ioctl entry
148 AC_MSG_CHECKING(for PIOCSET ioctl entry in sys/procfs.h)
149 AC_CACHE_VAL(gdb_cv_have_procfs_piocset,
150 [AC_TRY_COMPILE([#include <unistd.h>
151 #include <sys/types.h>
152 #include <sys/procfs.h>
155 dummy = ioctl(0, PIOCSET, &dummy);
157 gdb_cv_have_procfs_piocset=yes, gdb_cv_have_procfs_piocset=no)])
158 AC_MSG_RESULT($gdb_cv_have_procfs_piocset)
159 if test $gdb_cv_have_procfs_piocset = yes; then
160 AC_DEFINE(HAVE_PROCFS_PIOCSET)
164 dnl See if host has libm. This is usually needed by simulators.
165 AC_CHECK_LIB(m, main)
167 dnl Solaris puts wctype in /usr/lib/libw.a before Solaris 2.6.
169 dnl A bug in GNU ld 2.9.1 causes a problem if we link in -lw
170 dnl under Solaris 2.6 because it is some funky empty library.
171 dnl So only link in libw if we have to.
172 AC_CHECK_LIB(c, wctype,: ,AC_CHECK_LIB(w, wctype))
174 dnl See if compiler supports "long long" type.
176 AC_MSG_CHECKING(for long long support in compiler)
177 AC_CACHE_VAL(gdb_cv_c_long_long,
179 extern long long foo;
180 switch (foo & 2) { case 0: return 1; }
182 gdb_cv_c_long_long=yes, gdb_cv_c_long_long=no)])
183 AC_MSG_RESULT($gdb_cv_c_long_long)
184 if test $gdb_cv_c_long_long = yes; then
185 AC_DEFINE(CC_HAS_LONG_LONG)
188 dnl See if the compiler and runtime support printing long long
190 AC_MSG_CHECKING(for long long support in printf)
191 AC_CACHE_VAL(gdb_cv_printf_has_long_long,
196 l = (l << 16) + 0x0123;
197 l = (l << 16) + 0x4567;
198 l = (l << 16) + 0x89ab;
199 l = (l << 16) + 0xcdef;
200 sprintf (buf, "0x%016llx", l);
201 return (strcmp ("0x0123456789abcdef", buf));
203 gdb_cv_printf_has_long_long=yes,
204 gdb_cv_printf_has_long_long=no,
205 gdb_cv_printf_has_long_long=no)])
206 if test $gdb_cv_printf_has_long_long = yes; then
207 AC_DEFINE(PRINTF_HAS_LONG_LONG)
209 AC_MSG_RESULT($gdb_cv_printf_has_long_long)
211 dnl See if compiler supports "long double" type. Can't use AC_C_LONG_DOUBLE
212 dnl because autoconf complains about cross-compilation issues. However, this
213 dnl code uses the same variables as the macro for compatibility.
215 AC_MSG_CHECKING(for long double support in compiler)
216 AC_CACHE_VAL(ac_cv_c_long_double,
217 [AC_TRY_COMPILE(, [long double foo;],
218 ac_cv_c_long_double=yes, ac_cv_c_long_double=no)])
219 AC_MSG_RESULT($ac_cv_c_long_double)
220 if test $ac_cv_c_long_double = yes; then
221 AC_DEFINE(HAVE_LONG_DOUBLE)
224 dnl See if the compiler and runtime support printing long doubles
226 AC_MSG_CHECKING(for long double support in printf)
227 AC_CACHE_VAL(gdb_cv_printf_has_long_double,
231 long double f = 3.141592653;
232 sprintf (buf, "%Lg", f);
233 return (strncmp ("3.14159", buf, 7));
235 gdb_cv_printf_has_long_double=yes,
236 gdb_cv_printf_has_long_double=no,
237 gdb_cv_printf_has_long_double=no)])
238 if test $gdb_cv_printf_has_long_double = yes; then
239 AC_DEFINE(PRINTF_HAS_LONG_DOUBLE)
241 AC_MSG_RESULT($gdb_cv_printf_has_long_double)
243 dnl See if the compiler and runtime support scanning long doubles
245 AC_MSG_CHECKING(for long double support in scanf)
246 AC_CACHE_VAL(gdb_cv_scanf_has_long_double,
249 char *buf = "3.141592653";
251 sscanf (buf, "%Lg", &f);
252 return !(f > 3.14159 && f < 3.14160);
254 gdb_cv_scanf_has_long_double=yes,
255 gdb_cv_scanf_has_long_double=no,
256 gdb_cv_scanf_has_long_double=no)])
257 if test $gdb_cv_scanf_has_long_double = yes; then
258 AC_DEFINE(SCANF_HAS_LONG_DOUBLE)
260 AC_MSG_RESULT($gdb_cv_scanf_has_long_double)
264 dnl See if thread_db library is around for Solaris thread debugging. Note that
265 dnl we must explicitly test for version 1 of the library because version 0
266 dnl (present on Solaris 2.4 or earlier) doesn't have the same API.
268 dnl Note that we only want this if we are both native (host == target), and
269 dnl not doing a canadian cross build (build == host).
271 if test ${build} = ${host} -a ${host} = ${target} ; then
274 AC_MSG_CHECKING(for HPUX/OSF thread support)
275 if test -f /usr/include/dce/cma_config.h ; then
276 if test "$GCC" = "yes" ; then
278 AC_DEFINE(HAVE_HPUX_THREAD_SUPPORT)
279 CONFIG_OBS="${CONFIG_OJS} hpux-thread.o"
280 CONFIG_SRCS="${CONFIG_SRCS} hpux-thread.c"
282 AC_MSG_RESULT(no (suppressed because you are not using GCC))
289 AC_MSG_CHECKING(for Solaris thread debugging library)
290 if test -f /usr/lib/libthread_db.so.1 ; then
292 AC_DEFINE(HAVE_THREAD_DB_LIB)
293 CONFIG_OBS="${CONFIG_OBS} sol-thread.o"
294 CONFIG_SRCS="${CONFIG_SRCS} sol-thread.c"
295 AC_CHECK_LIB(dl, dlopen)
296 if test "$GCC" = "yes" ; then
297 # The GNU linker requires the -export-dynamic option to make
298 # all symbols visible in the dynamic symbol table.
299 hold_ldflags=$LDFLAGS
300 AC_MSG_CHECKING(for the ld -export-dynamic flag)
301 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
302 AC_TRY_LINK(, [int i;], found=yes, found=no)
303 LDFLAGS=$hold_ldflags
304 AC_MSG_RESULT($found)
305 if test $found = yes; then
306 CONFIG_LDFLAGS="${CONFIG_LDFLAGS} -Wl,-export-dynamic"
309 # Sun randomly tweaked the prototypes in <proc_service.h>
311 AC_MSG_CHECKING(if <proc_service.h> is old)
312 AC_CACHE_VAL(gdb_cv_proc_service_is_old,[
314 #include <proc_service.h>
316 (struct ps_prochandle*, psaddr_t, const void*, size_t);
317 ],, gdb_cv_proc_service_is_old=no,
318 gdb_cv_proc_service_is_old=yes)
320 AC_MSG_RESULT($gdb_cv_proc_service_is_old)
321 if test $gdb_cv_proc_service_is_old = yes; then
322 AC_DEFINE(PROC_SERVICE_IS_OLD)
329 AC_SUBST(CONFIG_LDFLAGS)
332 dnl Handle optional features that can be enabled.
336 [ --enable-tui Enable full-screen terminal user interface],
338 case "${enable_tui}" in
340 "") enable_tui=yes ;;
342 AC_MSG_ERROR(Bad value for --enable-tui: ${enableval})
346 case ${enable_tui} in
350 TUI_LIBRARY=tui/libtui.a
358 AC_SUBST(TUI_LIBRARY)
360 AC_ARG_ENABLE(netrom,
361 [ --enable-netrom Enable NetROM support],
362 [case "${enableval}" in
363 yes) enable_netrom=yes ;;
364 no) enable_netrom=no ;;
365 *) AC_MSG_ERROR(bad value ${enableval} given for netrom option) ;;
368 if test "${enable_netrom}" = "yes"; then
369 CONFIG_OBS="${CONFIG_OBS} remote-nrom.o"
370 CONFIG_SRCS="${CONFIG_SRCS} remote-nrom.c"
373 AC_ARG_ENABLE(build-warnings,
374 [ --enable-build-warnings Enable build-time compiler warnings if gcc is used],
375 [build_warnings="-Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations"
376 case "${enableval}" in
378 no) build_warnings="-w";;
379 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
380 build_warnings="${build_warnings} ${t}";;
381 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
382 build_warnings="${t} ${build_warnings}";;
383 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
384 esac],[build_warnings=""])dnl
386 if test "x${build_warnings}" != x -a "x$GCC" = xyes
388 WARN_CFLAGS="${build_warnings}"
392 AC_SUBST(WARN_CFLAGS)
396 AC_SUBST(MMALLOC_CFLAGS)
400 [ --with-mmalloc Use memory mapped malloc package],
401 [case "${withval}" in
402 yes) want_mmalloc=true ;;
403 no) want_mmalloc=false;;
404 *) AC_MSG_ERROR(bad value ${withval} for GDB with-mmalloc option) ;;
405 esac],[want_mmalloc=false])dnl
407 if test x$want_mmalloc = xtrue; then
408 AC_DEFINE(USE_MMALLOC)
409 AC_DEFINE(MMCHECK_FORCE)
410 MMALLOC_CFLAGS="-I$srcdir/../mmalloc"
411 MMALLOC='../mmalloc/libmmalloc.a'
415 # In the Cygwin environment, we need some additional flags.
416 AC_CACHE_CHECK([for cygwin], gdb_cv_os_cygwin,
417 [AC_EGREP_CPP(lose, [
418 #if defined (__CYGWIN__) || defined (__CYGWIN32__)
420 #endif],[gdb_cv_os_cygwin=yes],[gdb_cv_os_cygwin=no])])
422 DLLTOOL=${DLLTOOL-dlltool}
423 WINDRES=${WINDRES-windres}
427 dnl Figure out which term library to use.
428 if test x$gdb_host = xgo32; then
431 if test x$gdb_cv_os_cygwin = xyes; then
432 TERM_LIB='`if test -r ../libtermcap/libtermcap.a; then echo ../libtermcap/libtermcap.a; else echo -ltermcap; fi`'
435 AC_CHECK_LIB(ncurses, tgetent, TERM_LIB=-lncurses,
436 AC_CHECK_LIB(Hcurses, tgetent, TERM_LIB=-lHcurses,
437 AC_CHECK_LIB(termlib, tgetent, TERM_LIB=-ltermlib,
438 AC_CHECK_LIB(termcap, tgetent, TERM_LIB=-ltermcap,
439 AC_CHECK_LIB(curses, tgetent, TERM_LIB=-lcurses,
440 AC_CHECK_LIB(terminfo, tgetent, TERM_LIB=-lterminfo))))))
442 if test "x$TERM_LIB" = x
444 AC_MSG_ERROR(Could not find a term library, e.g. termcap or termlib!)
450 # libreadline needs libuser32.a in a cygwin environment
452 if test x$gdb_cv_os_cygwin = xyes; then
461 # Unlike the sim directory, whether a simulator is linked is controlled by
462 # presence of a SIM= and a SIM_OBS= definition in the target '.mt' file.
463 # This code just checks for a few cases where we'd like to ignore those
464 # definitions, even when they're present in the '.mt' file. These cases
465 # are when --disable-sim is specified, or if the simulator directory is
466 # not part of the soruce tree.
469 [ --enable-sim Link gdb with simulator],
470 [echo "enable_sim = $enable_sim";
471 echo "enableval = ${enableval}";
472 case "${enableval}" in
473 yes) ignore_sim=false ;;
474 no) ignore_sim=true ;;
475 *) ignore_sim=false ;;
479 if test ! -d "${srcdir}/../sim"; then
483 if test "${ignore_sim}" = "true"; then
485 IGNORE_SIM_OBS="SIM_OBS="
492 AC_SUBST(IGNORE_SIM_OBS)
494 AC_SUBST(ENABLE_CFLAGS)
497 AC_SUBST(CONFIG_DEPS)
498 AC_SUBST(CONFIG_SRCS)
500 # Begin stuff to support --enable-shared
501 AC_ARG_ENABLE(shared,
502 [ --enable-shared Use shared libraries],
503 [case "${enableval}" in
511 # If we have shared libraries, try to set rpath reasonably.
512 if test "${shared}" = "true"; then
515 HLDFLAGS='-Wl,+s,+b,$(libdir)'
517 *-*-irix5* | *-*-irix6*)
518 HLDFLAGS='-Wl,-rpath,$(libdir)'
522 *-*-linux* | *-pc-linux-gnu)
523 HLDFLAGS='-Wl,-rpath,$(libdir)'
526 HLDFLAGS='-R $(libdir)'
529 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;'
534 # On SunOS, if the linker supports the -rpath option, use it to
535 # prevent ../bfd and ../opcodes from being included in the run time
539 echo 'main () { }' > conftest.c
540 ${CC} -o conftest -Wl,-rpath= conftest.c >/dev/null 2>conftest.t
541 if grep 'unrecognized' conftest.t >/dev/null 2>&1; then
543 elif grep 'No such file' conftest.t >/dev/null 2>&1; then
545 elif grep 'do not mix' conftest.t >/dev/null 2>&1; then
547 elif grep 'some text already loaded' conftest.t >/dev/null 2>&1; then
549 elif test "${shared}" = "true"; then
550 HLDFLAGS='-Wl,-rpath=$(libdir)'
552 HLDFLAGS='-Wl,-rpath='
554 rm -f conftest.t conftest.c conftest
559 # End stuff to support --enable-shared
561 # target_subdir is used by the testsuite to find the target libraries.
563 if test "${host}" != "${target}"; then
564 target_subdir="${target_alias}/"
566 AC_SUBST(target_subdir)
569 host_makefile_frag=${srcdir}/config/${gdb_host_cpu}/${gdb_host}.mh
570 if test ! -f ${host_makefile_frag}; then
571 AC_MSG_ERROR("*** Gdb does not support host ${host}")
573 frags="$frags $host_makefile_frag"
575 target_makefile_frag=${srcdir}/config/${gdb_target_cpu}/${gdb_target}.mt
576 if test ! -f ${target_makefile_frag}; then
577 AC_MSG_ERROR("*** Gdb does not support target ${target}")
579 frags="$frags $target_makefile_frag"
581 AC_SUBST_FILE(host_makefile_frag)
582 AC_SUBST_FILE(target_makefile_frag)
587 s/XM_FILE[ ]*=[ ]*\([^ ]*\)/\1/p
588 ' ${host_makefile_frag}`
591 s/TM_FILE[ ]*=[ ]*\([^ ]*\)/\1/p
592 ' ${target_makefile_frag}`
594 # these really aren't orthogonal true/false values of the same condition,
595 # but shells are slow enough that I like to reuse the test conditions
597 if test "${target}" = "${host}"; then
599 s/NAT_FILE[ ]*=[ ]*\([^ ]*\)/\1/p
600 ' ${host_makefile_frag}`
602 # GDBserver is only useful in a "native" enviroment
603 # configdirs=`echo $configdirs | sed 's/gdbserver//'`
607 # If hostfile (XM_FILE) and/or targetfile (TM_FILE) and/or nativefile
608 # (NAT_FILE) is not set in config/*/*.m[ht] files, we don't make the
609 # corresponding links. But we have to remove the xm.h files and tm.h
610 # files anyway, e.g. when switching from "configure host" to
616 if test "${hostfile}" != ""; then
617 files="${files} config/${gdb_host_cpu}/${hostfile}"
618 links="${links} xm.h"
621 if test "${targetfile}" != ""; then
622 files="${files} config/${gdb_target_cpu}/${targetfile}"
623 links="${links} tm.h"
626 if test "${nativefile}" != ""; then
627 files="${files} config/${gdb_host_cpu}/${nativefile}"
628 links="${links} nm.h"
630 # A cross-only configuration.
631 files="${files} config/nm-empty.h"
632 links="${links} nm.h"
635 AC_LINK_FILES($files, $links)
637 dnl Check for exe extension set on certain hosts (e.g. Win32)
640 AC_CONFIG_SUBDIRS($configdirs)
641 AC_OUTPUT(Makefile tui/Makefile .gdbinit:gdbinit.in,
643 dnl Autoconf doesn't provide a mechanism for modifying definitions
644 dnl provided by makefile fragments.
646 if test "${nativefile}" = ""; then
647 sed -e '/^NATDEPFILES[[ ]]*=[[ ]]*/s//# NATDEPFILES=/' \
648 < Makefile > Makefile.tem
649 mv -f Makefile.tem Makefile
653 sed -e '/^TM_FILE[ ]*=/s,^TM_FILE[ ]*=[ ]*,&config/'"${gdb_target_cpu}"'/,
654 /^XM_FILE[ ]*=/s,^XM_FILE[ ]*=[ ]*,&config/'"${gdb_host_cpu}"'/,
655 /^NAT_FILE[ ]*=/s,^NAT_FILE[ ]*=[ ]*,&config/'"${gdb_host_cpu}"'/,' <Makefile >Makefile.tmp
656 mv -f Makefile.tmp Makefile
659 case x$CONFIG_HEADERS in
665 gdb_host_cpu=$gdb_host_cpu
666 gdb_target_cpu=$gdb_target_cpu
667 nativefile=$nativefile