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 AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
47 proc_service.h sys/procfs.h thread_db.h linux/elf.h dnl
49 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
50 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
51 netinet/tcp.h arpa/inet.h sys/wait.h sys/un.h)
52 AC_CHECK_FUNCS(pread pwrite pread64 readlink)
53 AC_REPLACE_FUNCS(vasprintf vsnprintf)
59 AC_ARG_WITH(ust, [ --with-ust=PATH Specify prefix directory for the installed UST package
60 Equivalent to --with-ust-include=PATH/include
61 plus --with-ust-lib=PATH/lib])
62 AC_ARG_WITH(ust_include, [ --with-ust-include=PATH Specify directory for installed UST include files])
63 AC_ARG_WITH(ust_lib, [ --with-ust-lib=PATH Specify the directory for the installed UST library])
75 ustlibs="-L$with_ust/lib -lust"
76 ustinc="-I$with_ust/include "
79 if test "x$with_ust_include" != x; then
80 ustinc="-I$with_ust_include "
82 if test "x$with_ust_lib" != x; then
83 ustlibs="-L$with_ust_lib -lust"
86 if test "x$with_ust" != "xno"; then
87 saved_CFLAGS="$CFLAGS"
88 CFLAGS="$CFLAGS $ustinc"
89 AC_MSG_CHECKING([for ust])
91 #define CONFIG_UST_GDB_INTEGRATION
94 [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_UST, 1, [Define if UST is available])],
95 [AC_MSG_RESULT([no]); ustlibs= ; ustinc= ])
96 CFLAGS="$saved_CFLAGS"
99 # Flags needed for UST
103 AC_ARG_ENABLE(werror,
104 AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
105 [case "${enableval}" in
106 yes | y) ERROR_ON_WARNING="yes" ;;
107 no | n) ERROR_ON_WARNING="no" ;;
108 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
111 # Enable -Werror by default when using gcc
112 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
117 if test "${ERROR_ON_WARNING}" = yes ; then
118 WERROR_CFLAGS="-Werror"
121 build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
122 -Wformat-nonliteral -Wno-char-subscripts"
125 if test "x$GCC" = xyes
127 AC_MSG_CHECKING(compiler warning flags)
128 # Separate out the -Werror flag as some files just cannot be
129 # compiled with it enabled.
130 for w in ${build_warnings}; do
132 -Werr*) WERROR_CFLAGS=-Werror ;;
133 *) # Check that GCC accepts it
134 saved_CFLAGS="$CFLAGS"
136 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
137 CFLAGS="$saved_CFLAGS"
140 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
142 AC_SUBST(WARN_CFLAGS)
143 AC_SUBST(WERROR_CFLAGS)
145 dnl dladdr is glibc-specific. It is used by thread-db.c but only for
146 dnl debugging messages. It lives in -ldl which is handled below so we don't
147 dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily
151 AC_CHECK_FUNCS(dladdr)
155 AC_MSG_CHECKING(for errno)
159 #endif], [static int x; x = errno;],
160 [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO, 1, [Define if errno is available]) have_errno=yes])
161 if test $have_errno = no; then
165 #endif], [extern int errno; static int x; x = errno;],
166 [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])],
170 AC_CHECK_DECLS([strerror, perror, memmem, vasprintf, vsnprintf])
172 AC_CHECK_TYPES(socklen_t, [], [],
173 [#include <sys/types.h>
174 #include <sys/socket.h>
177 AC_CHECK_TYPES([Elf32_auxv_t, Elf64_auxv_t], [], [],
181 ACX_PKGVERSION([GDB])
182 ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
183 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
184 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
186 # Check for various supplementary target information (beyond the
187 # triplet) which might affect the choices in configure.srv.
192 AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64],
193 [save_CPPFLAGS="$CPPFLAGS"
194 CPPFLAGS="$CPPFLAGS $CFLAGS"
195 AC_EGREP_CPP([got it], [
199 ], [gdb_cv_i386_is_x86_64=yes],
200 [gdb_cv_i386_is_x86_64=no])
201 CPPFLAGS="$save_CPPFLAGS"])
204 AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire],
205 [save_CPPFLAGS="$CPPFLAGS"
206 CPPFLAGS="$CPPFLAGS $CFLAGS"
207 AC_EGREP_CPP([got it], [
211 ], [gdb_cv_m68k_is_coldfire=yes],
212 [gdb_cv_m68k_is_coldfire=no])
213 CPPFLAGS="$save_CPPFLAGS"])
217 . ${srcdir}/configure.srv
219 if test "${srv_mingwce}" = "yes"; then
221 elif test "${srv_mingw}" = "yes"; then
222 LIBS="$LIBS -lws2_32"
223 elif test "${srv_qnx}" = "yes"; then
224 LIBS="$LIBS -lsocket"
225 elif test "${srv_lynxos}" = "yes"; then
226 LIBS="$LIBS -lnetinet"
229 if test "${srv_mingw}" = "yes"; then
230 AC_DEFINE(USE_WIN32API, 1,
231 [Define if we should use the Windows API, instead of the
232 POSIX API. On Windows, we use the Windows API when
233 building for MinGW, but the POSIX API when building
237 if test "${srv_linux_usrregs}" = "yes"; then
238 AC_DEFINE(HAVE_LINUX_USRREGS, 1,
239 [Define if the target supports PTRACE_PEEKUSR for register ]
243 if test "${srv_linux_regsets}" = "yes"; then
244 AC_DEFINE(HAVE_LINUX_REGSETS, 1,
245 [Define if the target supports register sets.])
247 AC_MSG_CHECKING(for PTRACE_GETREGS)
248 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
249 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
251 [gdbsrv_cv_have_ptrace_getregs=yes],
252 [gdbsrv_cv_have_ptrace_getregs=no])])
253 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
254 if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
255 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
256 [Define if the target supports PTRACE_GETREGS for register ]
260 AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
261 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
262 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
263 [PTRACE_GETFPXREGS;],
264 [gdbsrv_cv_have_ptrace_getfpxregs=yes],
265 [gdbsrv_cv_have_ptrace_getfpxregs=no])])
266 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
267 if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
268 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
269 [Define if the target supports PTRACE_GETFPXREGS for extended ]
274 if test "$ac_cv_header_sys_procfs_h" = yes; then
275 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
276 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
277 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
278 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
281 dnl Check for libdl, but do not add it to LIBS as only gdbserver
282 dnl needs it (and gdbreplay doesn't).
284 AC_CHECK_LIB(dl, dlopen)
291 if test "$srv_linux_thread_db" = "yes"; then
292 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
294 AC_MSG_CHECKING(for the dynamic export flag)
295 old_LDFLAGS="$LDFLAGS"
296 # Older GNU ld supports --export-dynamic but --dynamic-list may not be
298 RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
299 LDFLAGS="$LDFLAGS $RDYNAMIC"
301 [found="-Wl,--dynamic-list"
302 RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
303 [RDYNAMIC="-rdynamic"
304 LDFLAGS="$old_LDFLAGS $RDYNAMIC"
310 LDFLAGS="$old_LDFLAGS"
311 AC_MSG_RESULT($found)
313 srv_libs="-lthread_db"
316 srv_thread_depfiles="thread-db.o proc-service.o"
317 USE_THREAD_DB="-DUSE_THREAD_DB"
318 AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
319 [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
320 [gdbsrv_cv_have_td_version=yes],
321 [gdbsrv_cv_have_td_version=no])])
322 if test $gdbsrv_cv_have_td_version = yes; then
323 AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
327 AC_ARG_WITH(libthread-db,
328 AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
329 [srv_libthread_db_path="${withval}"
330 srv_libs="$srv_libthread_db_path"
333 if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
334 AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
337 if test "$srv_xmlfiles" != ""; then
338 srv_xmlbuiltin="xml-builtin.o"
339 AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
341 tmp_xmlfiles=$srv_xmlfiles
343 for f in $tmp_xmlfiles; do
344 srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
348 GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles"
349 GDBSERVER_LIBS="$srv_libs"
351 dnl Check whether the target supports __sync_*_compare_and_swap.
352 AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
353 gdbsrv_cv_have_sync_builtins, [
354 AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
355 gdbsrv_cv_have_sync_builtins=yes,
356 gdbsrv_cv_have_sync_builtins=no)])
357 if test $gdbsrv_cv_have_sync_builtins = yes; then
358 AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
359 [Define to 1 if the target supports __sync_*_compare_and_swap])
362 dnl Check for -fvisibility=hidden support in the compiler.
363 saved_cflags="$CFLAGS"
364 CFLAGS="$CFLAGS -fvisibility=hidden"
365 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
366 [gdbsrv_cv_have_visibility_hidden=yes],
367 [gdbsrv_cv_have_visibility_hidden=no])
368 CFLAGS="$saved_cflags"
370 dnl Check if we can disable the virtual address space randomization.
371 dnl The functionality of setarch -R.
372 AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
373 define([PERSONALITY_TEST], [AC_LANG_PROGRAM([#include <sys/personality.h>], [
374 # if !HAVE_DECL_ADDR_NO_RANDOMIZE
375 # define ADDR_NO_RANDOMIZE 0x0040000
377 /* Test the flag could be set and stays set. */
378 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
379 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
381 AC_RUN_IFELSE([PERSONALITY_TEST],
382 [gdbsrv_cv_have_personality=true],
383 [gdbsrv_cv_have_personality=false],
384 [AC_LINK_IFELSE([PERSONALITY_TEST],
385 [gdbsrv_cv_have_personality=true],
386 [gdbsrv_cv_have_personality=false])])
387 if $gdbsrv_cv_have_personality
389 AC_DEFINE([HAVE_PERSONALITY], 1,
390 [Define if you support the personality syscall.])
397 # check whether to enable the inprocess agent
398 if test "$ipa_obj" != "" \
399 -a "$gdbsrv_cv_have_sync_builtins" = yes \
400 -a "$gdbsrv_cv_have_visibility_hidden" = yes; then
406 AC_ARG_ENABLE(inprocess-agent,
407 AS_HELP_STRING([--enable-inprocess-agent], [inprocess agent]),
408 [case "$enableval" in
409 yes) want_ipa=true ;;
410 no) want_ipa=false ;;
411 *) AC_MSG_ERROR([bad value $enableval for inprocess-agent]) ;;
413 [want_ipa=$have_ipa])
417 IPA_DEPFILES="$ipa_obj"
418 extra_libraries="$extra_libraries libinproctrace.so"
420 AC_MSG_ERROR([inprocess agent not supported for this target])
424 AC_SUBST(GDBSERVER_DEPFILES)
425 AC_SUBST(GDBSERVER_LIBS)
426 AC_SUBST(USE_THREAD_DB)
427 AC_SUBST(srv_xmlbuiltin)
428 AC_SUBST(srv_xmlfiles)
429 AC_SUBST(IPA_DEPFILES)
430 AC_SUBST(extra_libraries)
433 # GDBserver does not use automake, but gnulib does. This line lets
434 # us generate its Makefile.in.
435 AM_INIT_AUTOMAKE(gdbserver, UNUSED-VERSION, [no-define])
438 if test x"$STDINT_H" != x; then
439 GNULIB_STDINT_H=gnulib/$STDINT_H
441 AC_SUBST(GNULIB_STDINT_H)
443 AC_OUTPUT(Makefile gnulib/Makefile:${srcdir}/../gnulib/Makefile.in,
444 [case x$CONFIG_HEADERS in