1 dnl Autoconf configure script for GDB server.
2 dnl Copyright (C) 2000-2014 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 # Set the 'development' global.
44 . $srcdir/../development.sh
46 # Enable -lmcheck by default (it provides cheap-enough memory
47 # mangling), but turn it off for releases.
53 GDB_AC_LIBMCHECK(${libmcheck_default})
55 ACX_NONCANONICAL_TARGET
58 # Dependency checking.
60 ZW_PROG_COMPILER_DEPENDENCIES([CC])
62 # Check for the 'make' the user wants to use.
63 AC_CHECK_PROGS(MAKE, make)
65 case "`$MAKE --version 2>&1 | sed 1q`" in
70 AM_CONDITIONAL(GMAKE, test "$MAKE_IS_GNU" = yes)
73 # Configure gnulib. We can't use AC_CONFIG_SUBDIRS as that'd expect
74 # to find the the source subdir to be configured directly under
75 # gdbserver/. We need to build gnulib under some other directory not
76 # "gnulib", to avoid the problem of both GDB and GDBserver wanting to
77 # build it in the same directory, when building in the source dir.
78 ACX_CONFIGURE_DIR(["../gnulib"], ["build-gnulib-gdbserver"])
80 AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
81 proc_service.h sys/procfs.h linux/elf.h dnl
82 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
83 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
84 netinet/tcp.h arpa/inet.h)
85 AC_CHECK_FUNCS(gettimeofday pread pwrite pread64 readlink)
86 AC_REPLACE_FUNCS(vasprintf vsnprintf)
94 AC_ARG_WITH(ust, [ --with-ust=PATH Specify prefix directory for the installed UST package
95 Equivalent to --with-ust-include=PATH/include
96 plus --with-ust-lib=PATH/lib])
97 AC_ARG_WITH(ust_include, [ --with-ust-include=PATH Specify directory for installed UST include files])
98 AC_ARG_WITH(ust_lib, [ --with-ust-lib=PATH Specify the directory for the installed UST library])
110 ustlibs="-L$with_ust/lib -lust"
111 ustinc="-I$with_ust/include "
114 if test "x$with_ust_include" != x; then
115 ustinc="-I$with_ust_include "
117 if test "x$with_ust_lib" != x; then
118 ustlibs="-L$with_ust_lib -lust"
121 if test "x$with_ust" != "xno"; then
122 saved_CFLAGS="$CFLAGS"
123 CFLAGS="$CFLAGS $ustinc"
124 AC_MSG_CHECKING([for ust])
126 #define CONFIG_UST_GDB_INTEGRATION
129 [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_UST, 1, [Define if UST is available])],
130 [AC_MSG_RESULT([no]); ustlibs= ; ustinc= ])
131 CFLAGS="$saved_CFLAGS"
134 # Flags needed for UST
138 AC_ARG_ENABLE(werror,
139 AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
140 [case "${enableval}" in
141 yes | y) ERROR_ON_WARNING="yes" ;;
142 no | n) ERROR_ON_WARNING="no" ;;
143 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
146 # Enable -Werror by default when using gcc
147 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
152 if test "${ERROR_ON_WARNING}" = yes ; then
153 WERROR_CFLAGS="-Werror"
156 build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
157 -Wformat-nonliteral -Wno-char-subscripts -Wempty-body"
160 if test "x$GCC" = xyes
162 AC_MSG_CHECKING(compiler warning flags)
163 # Separate out the -Werror flag as some files just cannot be
164 # compiled with it enabled.
165 for w in ${build_warnings}; do
167 -Werr*) WERROR_CFLAGS=-Werror ;;
168 *) # Check that GCC accepts it
169 saved_CFLAGS="$CFLAGS"
171 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
172 CFLAGS="$saved_CFLAGS"
175 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
177 AC_SUBST(WARN_CFLAGS)
178 AC_SUBST(WERROR_CFLAGS)
180 dnl dladdr is glibc-specific. It is used by thread-db.c but only for
181 dnl debugging messages. It lives in -ldl which is handled below so we don't
182 dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily
186 AC_CHECK_FUNCS(dladdr)
189 AC_CHECK_DECLS([strerror, perror, vasprintf, vsnprintf])
191 AC_CHECK_TYPES(socklen_t, [], [],
192 [#include <sys/types.h>
193 #include <sys/socket.h>
196 AC_CHECK_TYPES([Elf32_auxv_t, Elf64_auxv_t], [], [],
200 ACX_PKGVERSION([GDB])
201 ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
202 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
203 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
205 # Check for various supplementary target information (beyond the
206 # triplet) which might affect the choices in configure.srv.
211 AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64],
212 [save_CPPFLAGS="$CPPFLAGS"
213 CPPFLAGS="$CPPFLAGS $CFLAGS"
214 AC_EGREP_CPP([got it], [
218 ], [gdb_cv_i386_is_x86_64=yes],
219 [gdb_cv_i386_is_x86_64=no])
220 CPPFLAGS="$save_CPPFLAGS"])
223 AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire],
224 [save_CPPFLAGS="$CPPFLAGS"
225 CPPFLAGS="$CPPFLAGS $CFLAGS"
226 AC_EGREP_CPP([got it], [
230 ], [gdb_cv_m68k_is_coldfire=yes],
231 [gdb_cv_m68k_is_coldfire=no])
232 CPPFLAGS="$save_CPPFLAGS"])
236 . ${srcdir}/configure.srv
238 if test "${srv_mingwce}" = "yes"; then
240 elif test "${srv_mingw}" = "yes"; then
241 LIBS="$LIBS -lws2_32"
242 elif test "${srv_qnx}" = "yes"; then
243 LIBS="$LIBS -lsocket"
244 elif test "${srv_lynxos}" = "yes"; then
245 LIBS="$LIBS -lnetinet"
248 if test "${srv_mingw}" = "yes"; then
249 AC_DEFINE(USE_WIN32API, 1,
250 [Define if we should use the Windows API, instead of the
251 POSIX API. On Windows, we use the Windows API when
252 building for MinGW, but the POSIX API when building
256 if test "${srv_linux_usrregs}" = "yes"; then
257 AC_DEFINE(HAVE_LINUX_USRREGS, 1,
258 [Define if the target supports PTRACE_PEEKUSR for register ]
262 if test "${srv_linux_regsets}" = "yes"; then
263 AC_DEFINE(HAVE_LINUX_REGSETS, 1,
264 [Define if the target supports register sets.])
266 AC_MSG_CHECKING(for PTRACE_GETREGS)
267 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
268 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
270 [gdbsrv_cv_have_ptrace_getregs=yes],
271 [gdbsrv_cv_have_ptrace_getregs=no])])
272 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
273 if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
274 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
275 [Define if the target supports PTRACE_GETREGS for register ]
279 AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
280 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
281 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
282 [PTRACE_GETFPXREGS;],
283 [gdbsrv_cv_have_ptrace_getfpxregs=yes],
284 [gdbsrv_cv_have_ptrace_getfpxregs=no])])
285 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
286 if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
287 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
288 [Define if the target supports PTRACE_GETFPXREGS for extended ]
293 if test "${srv_linux_btrace}" = "yes"; then
294 AC_DEFINE(HAVE_LINUX_BTRACE, 1,
295 [Define if the target supports branch tracing.])
298 if test "$ac_cv_header_sys_procfs_h" = yes; then
299 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
300 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
301 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
302 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
305 dnl Some systems (e.g., Android) have lwpid_t defined in libthread_db.h.
306 if test "$bfd_cv_have_sys_procfs_type_lwpid_t" != yes; then
307 GDBSERVER_HAVE_THREAD_DB_TYPE(lwpid_t)
310 dnl Some systems (e.g., Android) have psaddr_t defined in libthread_db.h.
311 if test "$bfd_cv_have_sys_procfs_type_psaddr_t" != yes; then
312 GDBSERVER_HAVE_THREAD_DB_TYPE(psaddr_t)
315 dnl Check for libdl, but do not add it to LIBS as only gdbserver
316 dnl needs it (and gdbreplay doesn't).
318 AC_CHECK_LIB(dl, dlopen)
324 if test "$srv_linux_thread_db" = "yes"; then
325 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
327 AC_MSG_CHECKING(for the dynamic export flag)
328 old_LDFLAGS="$LDFLAGS"
329 # Older GNU ld supports --export-dynamic but --dynamic-list may not be
331 RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
332 LDFLAGS="$LDFLAGS $RDYNAMIC"
334 [found="-Wl,--dynamic-list"
335 RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
336 [RDYNAMIC="-rdynamic"
337 LDFLAGS="$old_LDFLAGS $RDYNAMIC"
343 LDFLAGS="$old_LDFLAGS"
344 AC_MSG_RESULT($found)
346 srv_libs="-lthread_db"
349 srv_thread_depfiles="thread-db.o proc-service.o"
350 AC_DEFINE(USE_THREAD_DB, 1, [Define if we should use libthread_db.])
351 AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
352 [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
353 [gdbsrv_cv_have_td_version=yes],
354 [gdbsrv_cv_have_td_version=no])])
355 if test $gdbsrv_cv_have_td_version = yes; then
356 AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
360 AC_ARG_WITH(libthread-db,
361 AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
362 [srv_libthread_db_path="${withval}"
363 srv_libs="$srv_libthread_db_path"
366 if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
367 AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
370 if test "$srv_xmlfiles" != ""; then
371 srv_xmlbuiltin="xml-builtin.o"
372 AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
374 tmp_xmlfiles=$srv_xmlfiles
376 for f in $tmp_xmlfiles; do
377 srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
381 GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles"
382 GDBSERVER_LIBS="$srv_libs"
384 dnl Check whether the target supports __sync_*_compare_and_swap.
385 AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
386 gdbsrv_cv_have_sync_builtins, [
387 AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
388 gdbsrv_cv_have_sync_builtins=yes,
389 gdbsrv_cv_have_sync_builtins=no)])
390 if test $gdbsrv_cv_have_sync_builtins = yes; then
391 AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
392 [Define to 1 if the target supports __sync_*_compare_and_swap])
395 dnl Check for -fvisibility=hidden support in the compiler.
396 saved_cflags="$CFLAGS"
397 CFLAGS="$CFLAGS -fvisibility=hidden"
398 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
399 [gdbsrv_cv_have_visibility_hidden=yes],
400 [gdbsrv_cv_have_visibility_hidden=no])
401 CFLAGS="$saved_cflags"
403 dnl Check if we can disable the virtual address space randomization.
404 dnl The functionality of setarch -R.
405 AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
406 define([PERSONALITY_TEST], [AC_LANG_PROGRAM([#include <sys/personality.h>], [
407 # if !HAVE_DECL_ADDR_NO_RANDOMIZE
408 # define ADDR_NO_RANDOMIZE 0x0040000
410 /* Test the flag could be set and stays set. */
411 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
412 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
414 AC_RUN_IFELSE([PERSONALITY_TEST],
415 [gdbsrv_cv_have_personality=true],
416 [gdbsrv_cv_have_personality=false],
417 [AC_LINK_IFELSE([PERSONALITY_TEST],
418 [gdbsrv_cv_have_personality=true],
419 [gdbsrv_cv_have_personality=false])])
420 if $gdbsrv_cv_have_personality
422 AC_DEFINE([HAVE_PERSONALITY], 1,
423 [Define if you support the personality syscall.])
430 # check whether to enable the inprocess agent
431 if test "$ipa_obj" != "" \
432 -a "$gdbsrv_cv_have_sync_builtins" = yes \
433 -a "$gdbsrv_cv_have_visibility_hidden" = yes; then
439 AC_ARG_ENABLE(inprocess-agent,
440 AS_HELP_STRING([--enable-inprocess-agent], [inprocess agent]),
441 [case "$enableval" in
442 yes) want_ipa=true ;;
443 no) want_ipa=false ;;
444 *) AC_MSG_ERROR([bad value $enableval for inprocess-agent]) ;;
446 [want_ipa=$have_ipa])
450 IPA_DEPFILES="$ipa_obj"
451 extra_libraries="$extra_libraries libinproctrace.so"
453 AC_MSG_ERROR([inprocess agent not supported for this target])
457 AC_SUBST(GDBSERVER_DEPFILES)
458 AC_SUBST(GDBSERVER_LIBS)
459 AC_SUBST(srv_xmlbuiltin)
460 AC_SUBST(srv_xmlfiles)
461 AC_SUBST(IPA_DEPFILES)
462 AC_SUBST(extra_libraries)
464 GNULIB=build-gnulib-gdbserver/import
467 if test x"$STDINT_H" != x; then
468 GNULIB_STDINT_H=$GNULIB/$STDINT_H
470 AC_SUBST(GNULIB_STDINT_H)
473 [case x$CONFIG_HEADERS in