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 wait.h sys/un.h dnl
60 AC_CHECK_FUNCS(pread pwrite pread64 readlink)
61 AC_REPLACE_FUNCS(vasprintf vsnprintf)
67 AC_ARG_WITH(ust, [ --with-ust=PATH Specify prefix directory for the installed UST package
68 Equivalent to --with-ust-include=PATH/include
69 plus --with-ust-lib=PATH/lib])
70 AC_ARG_WITH(ust_include, [ --with-ust-include=PATH Specify directory for installed UST include files])
71 AC_ARG_WITH(ust_lib, [ --with-ust-lib=PATH Specify the directory for the installed UST library])
83 ustlibs="-L$with_ust/lib -lust"
84 ustinc="-I$with_ust/include "
87 if test "x$with_ust_include" != x; then
88 ustinc="-I$with_ust_include "
90 if test "x$with_ust_lib" != x; then
91 ustlibs="-L$with_ust_lib -lust"
94 if test "x$with_ust" != "xno"; then
95 saved_CFLAGS="$CFLAGS"
96 CFLAGS="$CFLAGS $ustinc"
97 AC_MSG_CHECKING([for ust])
99 #define CONFIG_UST_GDB_INTEGRATION
102 [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_UST, 1, [Define if UST is available])],
103 [AC_MSG_RESULT([no]); ustlibs= ; ustinc= ])
104 CFLAGS="$saved_CFLAGS"
107 # Flags needed for UST
111 AC_ARG_ENABLE(werror,
112 AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
113 [case "${enableval}" in
114 yes | y) ERROR_ON_WARNING="yes" ;;
115 no | n) ERROR_ON_WARNING="no" ;;
116 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
119 # Enable -Werror by default when using gcc
120 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
125 if test "${ERROR_ON_WARNING}" = yes ; then
126 WERROR_CFLAGS="-Werror"
129 build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
130 -Wformat-nonliteral -Wno-char-subscripts -Wempty-body"
133 if test "x$GCC" = xyes
135 AC_MSG_CHECKING(compiler warning flags)
136 # Separate out the -Werror flag as some files just cannot be
137 # compiled with it enabled.
138 for w in ${build_warnings}; do
140 -Werr*) WERROR_CFLAGS=-Werror ;;
141 *) # Check that GCC accepts it
142 saved_CFLAGS="$CFLAGS"
144 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
145 CFLAGS="$saved_CFLAGS"
148 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
150 AC_SUBST(WARN_CFLAGS)
151 AC_SUBST(WERROR_CFLAGS)
153 dnl dladdr is glibc-specific. It is used by thread-db.c but only for
154 dnl debugging messages. It lives in -ldl which is handled below so we don't
155 dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily
159 AC_CHECK_FUNCS(dladdr)
163 AC_MSG_CHECKING(for errno)
167 #endif], [static int x; x = errno;],
168 [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO, 1, [Define if errno is available]) have_errno=yes])
169 if test $have_errno = no; then
173 #endif], [extern int errno; static int x; x = errno;],
174 [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])],
178 AC_CHECK_DECLS([strerror, strstr, perror, vasprintf, vsnprintf])
180 AC_CHECK_TYPES(socklen_t, [], [],
181 [#include <sys/types.h>
182 #include <sys/socket.h>
185 AC_CHECK_TYPES([Elf32_auxv_t, Elf64_auxv_t], [], [],
189 ACX_PKGVERSION([GDB])
190 ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
191 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
192 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
194 # Check for various supplementary target information (beyond the
195 # triplet) which might affect the choices in configure.srv.
200 AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64],
201 [save_CPPFLAGS="$CPPFLAGS"
202 CPPFLAGS="$CPPFLAGS $CFLAGS"
203 AC_EGREP_CPP([got it], [
207 ], [gdb_cv_i386_is_x86_64=yes],
208 [gdb_cv_i386_is_x86_64=no])
209 CPPFLAGS="$save_CPPFLAGS"])
212 AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire],
213 [save_CPPFLAGS="$CPPFLAGS"
214 CPPFLAGS="$CPPFLAGS $CFLAGS"
215 AC_EGREP_CPP([got it], [
219 ], [gdb_cv_m68k_is_coldfire=yes],
220 [gdb_cv_m68k_is_coldfire=no])
221 CPPFLAGS="$save_CPPFLAGS"])
225 . ${srcdir}/configure.srv
227 if test "${srv_mingwce}" = "yes"; then
229 elif test "${srv_mingw}" = "yes"; then
230 LIBS="$LIBS -lws2_32"
231 elif test "${srv_qnx}" = "yes"; then
232 LIBS="$LIBS -lsocket"
233 elif test "${srv_lynxos}" = "yes"; then
234 LIBS="$LIBS -lnetinet"
237 if test "${srv_mingw}" = "yes"; then
238 AC_DEFINE(USE_WIN32API, 1,
239 [Define if we should use the Windows API, instead of the
240 POSIX API. On Windows, we use the Windows API when
241 building for MinGW, but the POSIX API when building
245 if test "${srv_linux_usrregs}" = "yes"; then
246 AC_DEFINE(HAVE_LINUX_USRREGS, 1,
247 [Define if the target supports PTRACE_PEEKUSR for register ]
251 if test "${srv_linux_regsets}" = "yes"; then
252 AC_DEFINE(HAVE_LINUX_REGSETS, 1,
253 [Define if the target supports register sets.])
255 AC_MSG_CHECKING(for PTRACE_GETREGS)
256 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
257 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
259 [gdbsrv_cv_have_ptrace_getregs=yes],
260 [gdbsrv_cv_have_ptrace_getregs=no])])
261 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
262 if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
263 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
264 [Define if the target supports PTRACE_GETREGS for register ]
268 AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
269 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
270 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
271 [PTRACE_GETFPXREGS;],
272 [gdbsrv_cv_have_ptrace_getfpxregs=yes],
273 [gdbsrv_cv_have_ptrace_getfpxregs=no])])
274 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
275 if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
276 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
277 [Define if the target supports PTRACE_GETFPXREGS for extended ]
282 if test "$ac_cv_header_sys_procfs_h" = yes; then
283 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
284 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
285 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
286 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
289 dnl Some systems (e.g., Android) have lwpid_t defined in libthread_db.h.
290 if test "$bfd_cv_have_sys_procfs_type_lwpid_t" != yes; then
291 GDBSERVER_HAVE_THREAD_DB_TYPE(lwpid_t)
294 dnl Some systems (e.g., Android) have psaddr_t defined in libthread_db.h.
295 if test "$bfd_cv_have_sys_procfs_type_psaddr_t" != yes; then
296 GDBSERVER_HAVE_THREAD_DB_TYPE(psaddr_t)
299 dnl Check for libdl, but do not add it to LIBS as only gdbserver
300 dnl needs it (and gdbreplay doesn't).
302 AC_CHECK_LIB(dl, dlopen)
309 if test "$srv_linux_thread_db" = "yes"; then
310 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
312 AC_MSG_CHECKING(for the dynamic export flag)
313 old_LDFLAGS="$LDFLAGS"
314 # Older GNU ld supports --export-dynamic but --dynamic-list may not be
316 RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
317 LDFLAGS="$LDFLAGS $RDYNAMIC"
319 [found="-Wl,--dynamic-list"
320 RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
321 [RDYNAMIC="-rdynamic"
322 LDFLAGS="$old_LDFLAGS $RDYNAMIC"
328 LDFLAGS="$old_LDFLAGS"
329 AC_MSG_RESULT($found)
331 srv_libs="-lthread_db"
334 srv_thread_depfiles="thread-db.o proc-service.o"
335 USE_THREAD_DB="-DUSE_THREAD_DB"
336 AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
337 [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
338 [gdbsrv_cv_have_td_version=yes],
339 [gdbsrv_cv_have_td_version=no])])
340 if test $gdbsrv_cv_have_td_version = yes; then
341 AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
345 AC_ARG_WITH(libthread-db,
346 AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
347 [srv_libthread_db_path="${withval}"
348 srv_libs="$srv_libthread_db_path"
351 if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
352 AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
355 if test "$srv_xmlfiles" != ""; then
356 srv_xmlbuiltin="xml-builtin.o"
357 AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
359 tmp_xmlfiles=$srv_xmlfiles
361 for f in $tmp_xmlfiles; do
362 srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
366 GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles"
367 GDBSERVER_LIBS="$srv_libs"
369 dnl Check whether the target supports __sync_*_compare_and_swap.
370 AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
371 gdbsrv_cv_have_sync_builtins, [
372 AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
373 gdbsrv_cv_have_sync_builtins=yes,
374 gdbsrv_cv_have_sync_builtins=no)])
375 if test $gdbsrv_cv_have_sync_builtins = yes; then
376 AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
377 [Define to 1 if the target supports __sync_*_compare_and_swap])
380 dnl Check for -fvisibility=hidden support in the compiler.
381 saved_cflags="$CFLAGS"
382 CFLAGS="$CFLAGS -fvisibility=hidden"
383 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
384 [gdbsrv_cv_have_visibility_hidden=yes],
385 [gdbsrv_cv_have_visibility_hidden=no])
386 CFLAGS="$saved_cflags"
388 dnl Check if we can disable the virtual address space randomization.
389 dnl The functionality of setarch -R.
390 AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
391 define([PERSONALITY_TEST], [AC_LANG_PROGRAM([#include <sys/personality.h>], [
392 # if !HAVE_DECL_ADDR_NO_RANDOMIZE
393 # define ADDR_NO_RANDOMIZE 0x0040000
395 /* Test the flag could be set and stays set. */
396 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
397 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
399 AC_RUN_IFELSE([PERSONALITY_TEST],
400 [gdbsrv_cv_have_personality=true],
401 [gdbsrv_cv_have_personality=false],
402 [AC_LINK_IFELSE([PERSONALITY_TEST],
403 [gdbsrv_cv_have_personality=true],
404 [gdbsrv_cv_have_personality=false])])
405 if $gdbsrv_cv_have_personality
407 AC_DEFINE([HAVE_PERSONALITY], 1,
408 [Define if you support the personality syscall.])
415 # check whether to enable the inprocess agent
416 if test "$ipa_obj" != "" \
417 -a "$gdbsrv_cv_have_sync_builtins" = yes \
418 -a "$gdbsrv_cv_have_visibility_hidden" = yes; then
424 AC_ARG_ENABLE(inprocess-agent,
425 AS_HELP_STRING([--enable-inprocess-agent], [inprocess agent]),
426 [case "$enableval" in
427 yes) want_ipa=true ;;
428 no) want_ipa=false ;;
429 *) AC_MSG_ERROR([bad value $enableval for inprocess-agent]) ;;
431 [want_ipa=$have_ipa])
435 IPA_DEPFILES="$ipa_obj"
436 extra_libraries="$extra_libraries libinproctrace.so"
438 AC_MSG_ERROR([inprocess agent not supported for this target])
442 AC_SUBST(GDBSERVER_DEPFILES)
443 AC_SUBST(GDBSERVER_LIBS)
444 AC_SUBST(USE_THREAD_DB)
445 AC_SUBST(srv_xmlbuiltin)
446 AC_SUBST(srv_xmlfiles)
447 AC_SUBST(IPA_DEPFILES)
448 AC_SUBST(extra_libraries)
450 GNULIB=build-gnulib-gdbserver/import
453 if test x"$STDINT_H" != x; then
454 GNULIB_STDINT_H=$GNULIB/$STDINT_H
456 AC_SUBST(GNULIB_STDINT_H)
459 [case x$CONFIG_HEADERS in