1 dnl Autoconf configure script for GDB server.
2 dnl Copyright (C) 2000, 2002-2012 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 3 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, see <http://www.gnu.org/licenses/>.
19 dnl Process this file with autoconf to produce a configure script.
24 AC_CONFIG_HEADER(config.h:config.in)
43 # Check for the 'make' the user wants to use.
44 AC_CHECK_PROGS(MAKE, make)
46 # Configure gnulib. We can't use AC_CONFIG_SUBDIRS as that'd expect
47 # to find the the source subdir to be configured directly under
48 # gdbserver/. We need to build gnulib under some other directory not
49 # "gnulib", to avoid the problem of both GDB and GDBserver wanting to
50 # build it in the same directory, when building in the source dir.
51 ACX_CONFIGURE_DIR(["../gnulib"], ["build-gnulib-gdbserver"])
53 AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
54 proc_service.h sys/procfs.h thread_db.h linux/elf.h dnl
56 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
57 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
58 netinet/tcp.h arpa/inet.h sys/wait.h sys/un.h)
59 AC_CHECK_FUNCS(pread pwrite pread64 readlink)
60 AC_REPLACE_FUNCS(vasprintf vsnprintf)
66 AC_ARG_WITH(ust, [ --with-ust=PATH Specify prefix directory for the installed UST package
67 Equivalent to --with-ust-include=PATH/include
68 plus --with-ust-lib=PATH/lib])
69 AC_ARG_WITH(ust_include, [ --with-ust-include=PATH Specify directory for installed UST include files])
70 AC_ARG_WITH(ust_lib, [ --with-ust-lib=PATH Specify the directory for the installed UST library])
82 ustlibs="-L$with_ust/lib -lust"
83 ustinc="-I$with_ust/include "
86 if test "x$with_ust_include" != x; then
87 ustinc="-I$with_ust_include "
89 if test "x$with_ust_lib" != x; then
90 ustlibs="-L$with_ust_lib -lust"
93 if test "x$with_ust" != "xno"; then
94 saved_CFLAGS="$CFLAGS"
95 CFLAGS="$CFLAGS $ustinc"
96 AC_MSG_CHECKING([for ust])
98 #define CONFIG_UST_GDB_INTEGRATION
101 [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_UST, 1, [Define if UST is available])],
102 [AC_MSG_RESULT([no]); ustlibs= ; ustinc= ])
103 CFLAGS="$saved_CFLAGS"
106 # Flags needed for UST
110 AC_ARG_ENABLE(werror,
111 AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
112 [case "${enableval}" in
113 yes | y) ERROR_ON_WARNING="yes" ;;
114 no | n) ERROR_ON_WARNING="no" ;;
115 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
118 # Enable -Werror by default when using gcc
119 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
124 if test "${ERROR_ON_WARNING}" = yes ; then
125 WERROR_CFLAGS="-Werror"
128 build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
129 -Wformat-nonliteral -Wno-char-subscripts"
132 if test "x$GCC" = xyes
134 AC_MSG_CHECKING(compiler warning flags)
135 # Separate out the -Werror flag as some files just cannot be
136 # compiled with it enabled.
137 for w in ${build_warnings}; do
139 -Werr*) WERROR_CFLAGS=-Werror ;;
140 *) # Check that GCC accepts it
141 saved_CFLAGS="$CFLAGS"
143 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
144 CFLAGS="$saved_CFLAGS"
147 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
149 AC_SUBST(WARN_CFLAGS)
150 AC_SUBST(WERROR_CFLAGS)
152 dnl dladdr is glibc-specific. It is used by thread-db.c but only for
153 dnl debugging messages. It lives in -ldl which is handled below so we don't
154 dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily
158 AC_CHECK_FUNCS(dladdr)
162 AC_MSG_CHECKING(for errno)
166 #endif], [static int x; x = errno;],
167 [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO, 1, [Define if errno is available]) have_errno=yes])
168 if test $have_errno = no; then
172 #endif], [extern int errno; static int x; x = errno;],
173 [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])],
177 AC_CHECK_DECLS([strerror, strstr, perror, vasprintf, vsnprintf])
179 AC_CHECK_TYPES(socklen_t, [], [],
180 [#include <sys/types.h>
181 #include <sys/socket.h>
184 AC_CHECK_TYPES([Elf32_auxv_t, Elf64_auxv_t], [], [],
188 ACX_PKGVERSION([GDB])
189 ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
190 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
191 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
193 # Check for various supplementary target information (beyond the
194 # triplet) which might affect the choices in configure.srv.
199 AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64],
200 [save_CPPFLAGS="$CPPFLAGS"
201 CPPFLAGS="$CPPFLAGS $CFLAGS"
202 AC_EGREP_CPP([got it], [
206 ], [gdb_cv_i386_is_x86_64=yes],
207 [gdb_cv_i386_is_x86_64=no])
208 CPPFLAGS="$save_CPPFLAGS"])
211 AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire],
212 [save_CPPFLAGS="$CPPFLAGS"
213 CPPFLAGS="$CPPFLAGS $CFLAGS"
214 AC_EGREP_CPP([got it], [
218 ], [gdb_cv_m68k_is_coldfire=yes],
219 [gdb_cv_m68k_is_coldfire=no])
220 CPPFLAGS="$save_CPPFLAGS"])
224 . ${srcdir}/configure.srv
226 if test "${srv_mingwce}" = "yes"; then
228 elif test "${srv_mingw}" = "yes"; then
229 LIBS="$LIBS -lws2_32"
230 elif test "${srv_qnx}" = "yes"; then
231 LIBS="$LIBS -lsocket"
232 elif test "${srv_lynxos}" = "yes"; then
233 LIBS="$LIBS -lnetinet"
236 if test "${srv_mingw}" = "yes"; then
237 AC_DEFINE(USE_WIN32API, 1,
238 [Define if we should use the Windows API, instead of the
239 POSIX API. On Windows, we use the Windows API when
240 building for MinGW, but the POSIX API when building
244 if test "${srv_linux_usrregs}" = "yes"; then
245 AC_DEFINE(HAVE_LINUX_USRREGS, 1,
246 [Define if the target supports PTRACE_PEEKUSR for register ]
250 if test "${srv_linux_regsets}" = "yes"; then
251 AC_DEFINE(HAVE_LINUX_REGSETS, 1,
252 [Define if the target supports register sets.])
254 AC_MSG_CHECKING(for PTRACE_GETREGS)
255 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
256 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
258 [gdbsrv_cv_have_ptrace_getregs=yes],
259 [gdbsrv_cv_have_ptrace_getregs=no])])
260 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
261 if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
262 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
263 [Define if the target supports PTRACE_GETREGS for register ]
267 AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
268 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
269 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
270 [PTRACE_GETFPXREGS;],
271 [gdbsrv_cv_have_ptrace_getfpxregs=yes],
272 [gdbsrv_cv_have_ptrace_getfpxregs=no])])
273 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
274 if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
275 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
276 [Define if the target supports PTRACE_GETFPXREGS for extended ]
281 if test "$ac_cv_header_sys_procfs_h" = yes; then
282 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
283 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
284 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
285 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
288 dnl Some systems (e.g., Android) have lwpid_t defined in libthread_db.h.
289 if test "$bfd_cv_have_sys_procfs_type_lwpid_t" != yes; then
290 GDBSERVER_HAVE_THREAD_DB_TYPE(lwpid_t)
293 dnl Some systems (e.g., Android) have psaddr_t defined in libthread_db.h.
294 if test "$bfd_cv_have_sys_procfs_type_psaddr_t" != yes; then
295 GDBSERVER_HAVE_THREAD_DB_TYPE(psaddr_t)
298 dnl Check for libdl, but do not add it to LIBS as only gdbserver
299 dnl needs it (and gdbreplay doesn't).
301 AC_CHECK_LIB(dl, dlopen)
308 if test "$srv_linux_thread_db" = "yes"; then
309 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
311 AC_MSG_CHECKING(for the dynamic export flag)
312 old_LDFLAGS="$LDFLAGS"
313 # Older GNU ld supports --export-dynamic but --dynamic-list may not be
315 RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
316 LDFLAGS="$LDFLAGS $RDYNAMIC"
318 [found="-Wl,--dynamic-list"
319 RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
320 [RDYNAMIC="-rdynamic"
321 LDFLAGS="$old_LDFLAGS $RDYNAMIC"
327 LDFLAGS="$old_LDFLAGS"
328 AC_MSG_RESULT($found)
330 srv_libs="-lthread_db"
333 srv_thread_depfiles="thread-db.o proc-service.o"
334 USE_THREAD_DB="-DUSE_THREAD_DB"
335 AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
336 [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
337 [gdbsrv_cv_have_td_version=yes],
338 [gdbsrv_cv_have_td_version=no])])
339 if test $gdbsrv_cv_have_td_version = yes; then
340 AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
344 AC_ARG_WITH(libthread-db,
345 AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
346 [srv_libthread_db_path="${withval}"
347 srv_libs="$srv_libthread_db_path"
350 if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
351 AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
354 if test "$srv_xmlfiles" != ""; then
355 srv_xmlbuiltin="xml-builtin.o"
356 AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
358 tmp_xmlfiles=$srv_xmlfiles
360 for f in $tmp_xmlfiles; do
361 srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
365 GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles"
366 GDBSERVER_LIBS="$srv_libs"
368 dnl Check whether the target supports __sync_*_compare_and_swap.
369 AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
370 gdbsrv_cv_have_sync_builtins, [
371 AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
372 gdbsrv_cv_have_sync_builtins=yes,
373 gdbsrv_cv_have_sync_builtins=no)])
374 if test $gdbsrv_cv_have_sync_builtins = yes; then
375 AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
376 [Define to 1 if the target supports __sync_*_compare_and_swap])
379 dnl Check for -fvisibility=hidden support in the compiler.
380 saved_cflags="$CFLAGS"
381 CFLAGS="$CFLAGS -fvisibility=hidden"
382 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
383 [gdbsrv_cv_have_visibility_hidden=yes],
384 [gdbsrv_cv_have_visibility_hidden=no])
385 CFLAGS="$saved_cflags"
387 dnl Check if we can disable the virtual address space randomization.
388 dnl The functionality of setarch -R.
389 AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
390 define([PERSONALITY_TEST], [AC_LANG_PROGRAM([#include <sys/personality.h>], [
391 # if !HAVE_DECL_ADDR_NO_RANDOMIZE
392 # define ADDR_NO_RANDOMIZE 0x0040000
394 /* Test the flag could be set and stays set. */
395 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
396 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
398 AC_RUN_IFELSE([PERSONALITY_TEST],
399 [gdbsrv_cv_have_personality=true],
400 [gdbsrv_cv_have_personality=false],
401 [AC_LINK_IFELSE([PERSONALITY_TEST],
402 [gdbsrv_cv_have_personality=true],
403 [gdbsrv_cv_have_personality=false])])
404 if $gdbsrv_cv_have_personality
406 AC_DEFINE([HAVE_PERSONALITY], 1,
407 [Define if you support the personality syscall.])
414 # check whether to enable the inprocess agent
415 if test "$ipa_obj" != "" \
416 -a "$gdbsrv_cv_have_sync_builtins" = yes \
417 -a "$gdbsrv_cv_have_visibility_hidden" = yes; then
423 AC_ARG_ENABLE(inprocess-agent,
424 AS_HELP_STRING([--enable-inprocess-agent], [inprocess agent]),
425 [case "$enableval" in
426 yes) want_ipa=true ;;
427 no) want_ipa=false ;;
428 *) AC_MSG_ERROR([bad value $enableval for inprocess-agent]) ;;
430 [want_ipa=$have_ipa])
434 IPA_DEPFILES="$ipa_obj"
435 extra_libraries="$extra_libraries libinproctrace.so"
437 AC_MSG_ERROR([inprocess agent not supported for this target])
441 AC_SUBST(GDBSERVER_DEPFILES)
442 AC_SUBST(GDBSERVER_LIBS)
443 AC_SUBST(USE_THREAD_DB)
444 AC_SUBST(srv_xmlbuiltin)
445 AC_SUBST(srv_xmlfiles)
446 AC_SUBST(IPA_DEPFILES)
447 AC_SUBST(extra_libraries)
449 GNULIB=build-gnulib-gdbserver/import
452 if test x"$STDINT_H" != x; then
453 GNULIB_STDINT_H=$GNULIB/$STDINT_H
455 AC_SUBST(GNULIB_STDINT_H)
458 [case x$CONFIG_HEADERS in