1 dnl Autoconf configure script for GDB server.
2 dnl Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
3 dnl 2010 Free Software Foundation, Inc.
5 dnl This file is part of GDB.
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 3 of the License, or
10 dnl (at your option) any later version.
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.
17 dnl You should have received a copy of the GNU General Public License
18 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
20 dnl Process this file with autoconf to produce a configure script.
25 AC_CONFIG_HEADER(config.h:config.in)
26 AC_CONFIG_LIBOBJ_DIR(../gnulib)
39 AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
40 proc_service.h sys/procfs.h thread_db.h linux/elf.h dnl
42 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
43 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
44 netinet/tcp.h arpa/inet.h sys/wait.h)
45 AC_CHECK_FUNCS(pread pwrite pread64)
46 AC_REPLACE_FUNCS(memmem)
48 dnl dladdr is glibc-specific. It is used by thread-db.c but only for
49 dnl debugging messages. It lives in -ldl which is handled below so we don't
50 dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily
54 AC_CHECK_FUNCS(dladdr)
58 AC_MSG_CHECKING(for errno)
62 #endif], [static int x; x = errno;],
63 [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO, 1, [Define if errno is available]) have_errno=yes])
64 if test $have_errno = no; then
68 #endif], [extern int errno; static int x; x = errno;],
69 [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_ERRNO, 1, [Define if errno is available]) AC_DEFINE(MUST_DEFINE_ERRNO, 1, [Checking if errno must be defined])],
73 AC_CHECK_DECLS([strerror, perror, memmem])
75 AC_CHECK_TYPES(socklen_t, [], [],
76 [#include <sys/types.h>
77 #include <sys/socket.h>
81 ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
82 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
83 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
85 # Check for various supplementary target information (beyond the
86 # triplet) which might affect the choices in configure.srv.
91 AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64],
92 [save_CPPFLAGS="$CPPFLAGS"
93 CPPFLAGS="$CPPFLAGS $CFLAGS"
94 AC_EGREP_CPP([got it], [
98 ], [gdb_cv_i386_is_x86_64=yes],
99 [gdb_cv_i386_is_x86_64=no])
100 CPPFLAGS="$save_CPPFLAGS"])
103 AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire],
104 [save_CPPFLAGS="$CPPFLAGS"
105 CPPFLAGS="$CPPFLAGS $CFLAGS"
106 AC_EGREP_CPP([got it], [
110 ], [gdb_cv_m68k_is_coldfire=yes],
111 [gdb_cv_m68k_is_coldfire=no])
112 CPPFLAGS="$save_CPPFLAGS"])
116 . ${srcdir}/configure.srv
118 if test "${srv_mingwce}" = "yes"; then
120 elif test "${srv_mingw}" = "yes"; then
121 LIBS="$LIBS -lwsock32"
122 elif test "${srv_qnx}" = "yes"; then
123 LIBS="$LIBS -lsocket"
126 if test "${srv_mingw}" = "yes"; then
127 AC_DEFINE(USE_WIN32API, 1,
128 [Define if we should use the Windows API, instead of the
129 POSIX API. On Windows, we use the Windows API when
130 building for MinGW, but the POSIX API when building
134 if test "${srv_linux_usrregs}" = "yes"; then
135 AC_DEFINE(HAVE_LINUX_USRREGS, 1,
136 [Define if the target supports PTRACE_PEEKUSR for register ]
140 if test "${srv_linux_regsets}" = "yes"; then
141 AC_DEFINE(HAVE_LINUX_REGSETS, 1,
142 [Define if the target supports register sets.])
144 AC_MSG_CHECKING(for PTRACE_GETREGS)
145 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
146 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
148 [gdbsrv_cv_have_ptrace_getregs=yes],
149 [gdbsrv_cv_have_ptrace_getregs=no])])
150 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
151 if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
152 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
153 [Define if the target supports PTRACE_GETREGS for register ]
157 AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
158 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
159 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
160 [PTRACE_GETFPXREGS;],
161 [gdbsrv_cv_have_ptrace_getfpxregs=yes],
162 [gdbsrv_cv_have_ptrace_getfpxregs=no])])
163 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
164 if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
165 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
166 [Define if the target supports PTRACE_GETFPXREGS for extended ]
171 if test "$ac_cv_header_sys_procfs_h" = yes; then
172 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
173 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
174 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
175 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
182 if test "$srv_linux_thread_db" = "yes"; then
184 old_LDFLAGS="$LDFLAGS"
185 LDFLAGS="$LDFLAGS -rdynamic"
186 AC_TRY_LINK([], [], [RDYNAMIC=-rdynamic], [RDYNAMIC=])
188 LDFLAGS="$old_LDFLAGS"
190 srv_thread_depfiles="thread-db.o proc-service.o"
191 USE_THREAD_DB="-DUSE_THREAD_DB"
192 AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
193 [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
194 [gdbsrv_cv_have_td_version=yes],
195 [gdbsrv_cv_have_td_version=no])])
196 if test $gdbsrv_cv_have_td_version = yes; then
197 AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
201 AC_ARG_WITH(libthread-db,
202 AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
203 [srv_libthread_db_path="${withval}"
204 AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
205 srv_libs="$srv_libthread_db_path"
208 if test "$srv_xmlfiles" != ""; then
209 srv_xmlbuiltin="xml-builtin.o"
210 AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
212 tmp_xmlfiles=$srv_xmlfiles
214 for f in $tmp_xmlfiles; do
215 srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
219 GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles"
220 GDBSERVER_LIBS="$srv_libs"
222 AC_SUBST(GDBSERVER_DEPFILES)
223 AC_SUBST(GDBSERVER_LIBS)
224 AC_SUBST(USE_THREAD_DB)
225 AC_SUBST(srv_xmlbuiltin)
226 AC_SUBST(srv_xmlfiles)
229 [case x$CONFIG_HEADERS in