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)
52 AC_ARG_WITH(ust, [ --with-ust=PATH Specify prefix directory for the installed UST package
53 Equivalent to --with-ust-include=PATH/include
54 plus --with-ust-lib=PATH/lib])
55 AC_ARG_WITH(ust_include, [ --with-ust-include=PATH Specify directory for installed UST include files])
56 AC_ARG_WITH(ust_lib, [ --with-ust-lib=PATH Specify the directory for the installed UST library])
68 ustlibs="-L$with_ust/lib -lust"
69 ustinc="-I$with_ust/include "
72 if test "x$with_ust_include" != x; then
73 ustinc="-I$with_ust_include "
75 if test "x$with_ust_lib" != x; then
76 ustlibs="-L$with_ust_lib -lust"
79 if test "x$with_ust" != "xno"; then
80 saved_CFLAGS="$CFLAGS"
81 CFLAGS="$CFLAGS $ustinc"
82 AC_MSG_CHECKING([for ust])
84 #define CONFIG_UST_GDB_INTEGRATION
87 [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_UST, 1, [Define if UST is available])],
88 [AC_MSG_RESULT([no]); ustlibs= ; ustinc= ])
89 CFLAGS="$saved_CFLAGS"
92 # Flags needed for UST
96 dnl dladdr is glibc-specific. It is used by thread-db.c but only for
97 dnl debugging messages. It lives in -ldl which is handled below so we don't
98 dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily
102 AC_CHECK_FUNCS(dladdr)
106 AC_MSG_CHECKING(for errno)
110 #endif], [static int x; x = errno;],
111 [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO, 1, [Define if errno is available]) have_errno=yes])
112 if test $have_errno = no; then
116 #endif], [extern int errno; static int x; x = errno;],
117 [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])],
121 AC_CHECK_DECLS([strerror, perror, memmem])
123 AC_CHECK_TYPES(socklen_t, [], [],
124 [#include <sys/types.h>
125 #include <sys/socket.h>
128 ACX_PKGVERSION([GDB])
129 ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
130 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
131 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
133 # Check for various supplementary target information (beyond the
134 # triplet) which might affect the choices in configure.srv.
139 AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64],
140 [save_CPPFLAGS="$CPPFLAGS"
141 CPPFLAGS="$CPPFLAGS $CFLAGS"
142 AC_EGREP_CPP([got it], [
146 ], [gdb_cv_i386_is_x86_64=yes],
147 [gdb_cv_i386_is_x86_64=no])
148 CPPFLAGS="$save_CPPFLAGS"])
151 AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire],
152 [save_CPPFLAGS="$CPPFLAGS"
153 CPPFLAGS="$CPPFLAGS $CFLAGS"
154 AC_EGREP_CPP([got it], [
158 ], [gdb_cv_m68k_is_coldfire=yes],
159 [gdb_cv_m68k_is_coldfire=no])
160 CPPFLAGS="$save_CPPFLAGS"])
164 . ${srcdir}/configure.srv
166 if test "${srv_mingwce}" = "yes"; then
168 elif test "${srv_mingw}" = "yes"; then
169 LIBS="$LIBS -lws2_32"
170 elif test "${srv_qnx}" = "yes"; then
171 LIBS="$LIBS -lsocket"
174 if test "${srv_mingw}" = "yes"; then
175 AC_DEFINE(USE_WIN32API, 1,
176 [Define if we should use the Windows API, instead of the
177 POSIX API. On Windows, we use the Windows API when
178 building for MinGW, but the POSIX API when building
182 if test "${srv_linux_usrregs}" = "yes"; then
183 AC_DEFINE(HAVE_LINUX_USRREGS, 1,
184 [Define if the target supports PTRACE_PEEKUSR for register ]
188 if test "${srv_linux_regsets}" = "yes"; then
189 AC_DEFINE(HAVE_LINUX_REGSETS, 1,
190 [Define if the target supports register sets.])
192 AC_MSG_CHECKING(for PTRACE_GETREGS)
193 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
194 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
196 [gdbsrv_cv_have_ptrace_getregs=yes],
197 [gdbsrv_cv_have_ptrace_getregs=no])])
198 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
199 if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
200 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
201 [Define if the target supports PTRACE_GETREGS for register ]
205 AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
206 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
207 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
208 [PTRACE_GETFPXREGS;],
209 [gdbsrv_cv_have_ptrace_getfpxregs=yes],
210 [gdbsrv_cv_have_ptrace_getfpxregs=no])])
211 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
212 if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
213 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
214 [Define if the target supports PTRACE_GETFPXREGS for extended ]
219 if test "$ac_cv_header_sys_procfs_h" = yes; then
220 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
221 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
222 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
223 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
226 dnl Check for libdl, but do not add it to LIBS as only gdbserver
227 dnl needs it (and gdbreplay doesn't).
229 AC_CHECK_LIB(dl, dlopen)
236 if test "$srv_linux_thread_db" = "yes"; then
237 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
239 AC_MSG_CHECKING(for the dynamic export flag)
240 old_LDFLAGS="$LDFLAGS"
241 # Older GNU ld supports --export-dynamic but --dynamic-list may not be
243 RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
244 LDFLAGS="$LDFLAGS $RDYNAMIC"
246 [found="-Wl,--dynamic-list"
247 RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
248 [RDYNAMIC="-rdynamic"
249 LDFLAGS="$old_LDFLAGS $RDYNAMIC"
255 LDFLAGS="$old_LDFLAGS"
256 AC_MSG_RESULT($found)
258 srv_libs="-lthread_db"
261 srv_thread_depfiles="thread-db.o proc-service.o"
262 USE_THREAD_DB="-DUSE_THREAD_DB"
263 AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
264 [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
265 [gdbsrv_cv_have_td_version=yes],
266 [gdbsrv_cv_have_td_version=no])])
267 if test $gdbsrv_cv_have_td_version = yes; then
268 AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
272 AC_ARG_WITH(libthread-db,
273 AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
274 [srv_libthread_db_path="${withval}"
275 srv_libs="$srv_libthread_db_path"
278 if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
279 AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
282 if test "$srv_xmlfiles" != ""; then
283 srv_xmlbuiltin="xml-builtin.o"
284 AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
286 tmp_xmlfiles=$srv_xmlfiles
288 for f in $tmp_xmlfiles; do
289 srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
293 GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles"
294 GDBSERVER_LIBS="$srv_libs"
296 dnl Check whether the target supports __sync_*_compare_and_swap.
297 AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
298 gdbsrv_cv_have_sync_builtins, [
299 AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
300 gdbsrv_cv_have_sync_builtins=yes,
301 gdbsrv_cv_have_sync_builtins=no)])
302 if test $gdbsrv_cv_have_sync_builtins = yes; then
303 AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
304 [Define to 1 if the target supports __sync_*_compare_and_swap])
307 dnl Check for -fvisibility=hidden support in the compiler.
308 saved_cflags="$CFLAGS"
309 CFLAGS="$CFLAGS -fvisibility=hidden"
310 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
311 [gdbsrv_cv_have_visibility_hidden=yes],
312 [gdbsrv_cv_have_visibility_hidden=no])
313 CFLAGS="$saved_cflags"
317 # Rather than allowing to build a broken IPA, we simply disable it if
318 # we don't find a compiler supporting all the features we need.
319 if test "$ipa_obj" != "" \
320 -a "$gdbsrv_cv_have_sync_builtins" = yes \
321 -a "$gdbsrv_cv_have_visibility_hidden" = yes; then
322 IPA_DEPFILES="$ipa_obj"
323 extra_libraries="libinproctrace.so"
326 AC_SUBST(GDBSERVER_DEPFILES)
327 AC_SUBST(GDBSERVER_LIBS)
328 AC_SUBST(USE_THREAD_DB)
329 AC_SUBST(srv_xmlbuiltin)
330 AC_SUBST(srv_xmlfiles)
331 AC_SUBST(IPA_DEPFILES)
332 AC_SUBST(extra_libraries)
335 [case x$CONFIG_HEADERS in