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)
25 AC_CONFIG_LIBOBJ_DIR(../gnulib)
40 AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
41 proc_service.h sys/procfs.h thread_db.h linux/elf.h dnl
43 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
44 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
45 netinet/tcp.h arpa/inet.h sys/wait.h sys/un.h)
46 AC_CHECK_FUNCS(pread pwrite pread64 readlink)
47 AC_REPLACE_FUNCS(memmem vasprintf vsnprintf)
53 AC_ARG_WITH(ust, [ --with-ust=PATH Specify prefix directory for the installed UST package
54 Equivalent to --with-ust-include=PATH/include
55 plus --with-ust-lib=PATH/lib])
56 AC_ARG_WITH(ust_include, [ --with-ust-include=PATH Specify directory for installed UST include files])
57 AC_ARG_WITH(ust_lib, [ --with-ust-lib=PATH Specify the directory for the installed UST library])
69 ustlibs="-L$with_ust/lib -lust"
70 ustinc="-I$with_ust/include "
73 if test "x$with_ust_include" != x; then
74 ustinc="-I$with_ust_include "
76 if test "x$with_ust_lib" != x; then
77 ustlibs="-L$with_ust_lib -lust"
80 if test "x$with_ust" != "xno"; then
81 saved_CFLAGS="$CFLAGS"
82 CFLAGS="$CFLAGS $ustinc"
83 AC_MSG_CHECKING([for ust])
85 #define CONFIG_UST_GDB_INTEGRATION
88 [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_UST, 1, [Define if UST is available])],
89 [AC_MSG_RESULT([no]); ustlibs= ; ustinc= ])
90 CFLAGS="$saved_CFLAGS"
93 # Flags needed for UST
98 AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
99 [case "${enableval}" in
100 yes | y) ERROR_ON_WARNING="yes" ;;
101 no | n) ERROR_ON_WARNING="no" ;;
102 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
105 # Enable -Werror by default when using gcc
106 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
111 if test "${ERROR_ON_WARNING}" = yes ; then
112 WERROR_CFLAGS="-Werror"
115 build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
116 -Wformat-nonliteral -Wno-char-subscripts"
119 if test "x$GCC" = xyes
121 AC_MSG_CHECKING(compiler warning flags)
122 # Separate out the -Werror flag as some files just cannot be
123 # compiled with it enabled.
124 for w in ${build_warnings}; do
126 -Werr*) WERROR_CFLAGS=-Werror ;;
127 *) # Check that GCC accepts it
128 saved_CFLAGS="$CFLAGS"
130 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
131 CFLAGS="$saved_CFLAGS"
134 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
136 AC_SUBST(WARN_CFLAGS)
137 AC_SUBST(WERROR_CFLAGS)
139 dnl dladdr is glibc-specific. It is used by thread-db.c but only for
140 dnl debugging messages. It lives in -ldl which is handled below so we don't
141 dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily
145 AC_CHECK_FUNCS(dladdr)
149 AC_MSG_CHECKING(for errno)
153 #endif], [static int x; x = errno;],
154 [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO, 1, [Define if errno is available]) have_errno=yes])
155 if test $have_errno = no; then
159 #endif], [extern int errno; static int x; x = errno;],
160 [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])],
164 AC_CHECK_DECLS([strerror, perror, memmem, vasprintf, vsnprintf])
166 AC_CHECK_TYPES(socklen_t, [], [],
167 [#include <sys/types.h>
168 #include <sys/socket.h>
171 AC_CHECK_TYPES([Elf32_auxv_t, Elf64_auxv_t], [], [],
175 ACX_PKGVERSION([GDB])
176 ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
177 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
178 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
180 # Check for various supplementary target information (beyond the
181 # triplet) which might affect the choices in configure.srv.
186 AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64],
187 [save_CPPFLAGS="$CPPFLAGS"
188 CPPFLAGS="$CPPFLAGS $CFLAGS"
189 AC_EGREP_CPP([got it], [
193 ], [gdb_cv_i386_is_x86_64=yes],
194 [gdb_cv_i386_is_x86_64=no])
195 CPPFLAGS="$save_CPPFLAGS"])
198 AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire],
199 [save_CPPFLAGS="$CPPFLAGS"
200 CPPFLAGS="$CPPFLAGS $CFLAGS"
201 AC_EGREP_CPP([got it], [
205 ], [gdb_cv_m68k_is_coldfire=yes],
206 [gdb_cv_m68k_is_coldfire=no])
207 CPPFLAGS="$save_CPPFLAGS"])
211 . ${srcdir}/configure.srv
213 if test "${srv_mingwce}" = "yes"; then
215 elif test "${srv_mingw}" = "yes"; then
216 LIBS="$LIBS -lws2_32"
217 elif test "${srv_qnx}" = "yes"; then
218 LIBS="$LIBS -lsocket"
219 elif test "${srv_lynxos}" = "yes"; then
220 LIBS="$LIBS -lnetinet"
223 if test "${srv_mingw}" = "yes"; then
224 AC_DEFINE(USE_WIN32API, 1,
225 [Define if we should use the Windows API, instead of the
226 POSIX API. On Windows, we use the Windows API when
227 building for MinGW, but the POSIX API when building
231 if test "${srv_linux_usrregs}" = "yes"; then
232 AC_DEFINE(HAVE_LINUX_USRREGS, 1,
233 [Define if the target supports PTRACE_PEEKUSR for register ]
237 if test "${srv_linux_regsets}" = "yes"; then
238 AC_DEFINE(HAVE_LINUX_REGSETS, 1,
239 [Define if the target supports register sets.])
241 AC_MSG_CHECKING(for PTRACE_GETREGS)
242 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
243 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
245 [gdbsrv_cv_have_ptrace_getregs=yes],
246 [gdbsrv_cv_have_ptrace_getregs=no])])
247 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
248 if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
249 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
250 [Define if the target supports PTRACE_GETREGS for register ]
254 AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
255 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
256 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
257 [PTRACE_GETFPXREGS;],
258 [gdbsrv_cv_have_ptrace_getfpxregs=yes],
259 [gdbsrv_cv_have_ptrace_getfpxregs=no])])
260 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
261 if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
262 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
263 [Define if the target supports PTRACE_GETFPXREGS for extended ]
268 if test "$ac_cv_header_sys_procfs_h" = yes; then
269 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
270 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
271 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
272 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
275 dnl Check for libdl, but do not add it to LIBS as only gdbserver
276 dnl needs it (and gdbreplay doesn't).
278 AC_CHECK_LIB(dl, dlopen)
285 if test "$srv_linux_thread_db" = "yes"; then
286 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
288 AC_MSG_CHECKING(for the dynamic export flag)
289 old_LDFLAGS="$LDFLAGS"
290 # Older GNU ld supports --export-dynamic but --dynamic-list may not be
292 RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
293 LDFLAGS="$LDFLAGS $RDYNAMIC"
295 [found="-Wl,--dynamic-list"
296 RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
297 [RDYNAMIC="-rdynamic"
298 LDFLAGS="$old_LDFLAGS $RDYNAMIC"
304 LDFLAGS="$old_LDFLAGS"
305 AC_MSG_RESULT($found)
307 srv_libs="-lthread_db"
310 srv_thread_depfiles="thread-db.o proc-service.o"
311 USE_THREAD_DB="-DUSE_THREAD_DB"
312 AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
313 [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
314 [gdbsrv_cv_have_td_version=yes],
315 [gdbsrv_cv_have_td_version=no])])
316 if test $gdbsrv_cv_have_td_version = yes; then
317 AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
321 AC_ARG_WITH(libthread-db,
322 AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
323 [srv_libthread_db_path="${withval}"
324 srv_libs="$srv_libthread_db_path"
327 if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
328 AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
331 if test "$srv_xmlfiles" != ""; then
332 srv_xmlbuiltin="xml-builtin.o"
333 AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
335 tmp_xmlfiles=$srv_xmlfiles
337 for f in $tmp_xmlfiles; do
338 srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
342 GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles"
343 GDBSERVER_LIBS="$srv_libs"
345 dnl Check whether the target supports __sync_*_compare_and_swap.
346 AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
347 gdbsrv_cv_have_sync_builtins, [
348 AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
349 gdbsrv_cv_have_sync_builtins=yes,
350 gdbsrv_cv_have_sync_builtins=no)])
351 if test $gdbsrv_cv_have_sync_builtins = yes; then
352 AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
353 [Define to 1 if the target supports __sync_*_compare_and_swap])
356 dnl Check for -fvisibility=hidden support in the compiler.
357 saved_cflags="$CFLAGS"
358 CFLAGS="$CFLAGS -fvisibility=hidden"
359 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
360 [gdbsrv_cv_have_visibility_hidden=yes],
361 [gdbsrv_cv_have_visibility_hidden=no])
362 CFLAGS="$saved_cflags"
364 dnl Check if we can disable the virtual address space randomization.
365 dnl The functionality of setarch -R.
366 AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
367 define([PERSONALITY_TEST], [AC_LANG_PROGRAM([#include <sys/personality.h>], [
368 # if !HAVE_DECL_ADDR_NO_RANDOMIZE
369 # define ADDR_NO_RANDOMIZE 0x0040000
371 /* Test the flag could be set and stays set. */
372 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
373 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
375 AC_RUN_IFELSE([PERSONALITY_TEST],
376 [gdbsrv_cv_have_personality=true],
377 [gdbsrv_cv_have_personality=false],
378 [AC_LINK_IFELSE([PERSONALITY_TEST],
379 [gdbsrv_cv_have_personality=true],
380 [gdbsrv_cv_have_personality=false])])
381 if $gdbsrv_cv_have_personality
383 AC_DEFINE([HAVE_PERSONALITY], 1,
384 [Define if you support the personality syscall.])
391 # check whether to enable the inprocess agent
392 if test "$ipa_obj" != "" \
393 -a "$gdbsrv_cv_have_sync_builtins" = yes \
394 -a "$gdbsrv_cv_have_visibility_hidden" = yes; then
400 AC_ARG_ENABLE(inprocess-agent,
401 AS_HELP_STRING([--enable-inprocess-agent], [inprocess agent]),
402 [case "$enableval" in
403 yes) want_ipa=true ;;
404 no) want_ipa=false ;;
405 *) AC_MSG_ERROR([bad value $enableval for inprocess-agent]) ;;
407 [want_ipa=$have_ipa])
411 IPA_DEPFILES="$ipa_obj"
412 extra_libraries="$extra_libraries libinproctrace.so"
414 AC_MSG_ERROR([inprocess agent not supported for this target])
418 AC_SUBST(GDBSERVER_DEPFILES)
419 AC_SUBST(GDBSERVER_LIBS)
420 AC_SUBST(USE_THREAD_DB)
421 AC_SUBST(srv_xmlbuiltin)
422 AC_SUBST(srv_xmlfiles)
423 AC_SUBST(IPA_DEPFILES)
424 AC_SUBST(extra_libraries)
427 [case x$CONFIG_HEADERS in