1 dnl Autoconf configure script for GDB server.
2 dnl Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
3 dnl 2010, 2011 Free Software Foundation, Inc.
5 dnl This file is part of GDB.
7 dnl This program is free software; you can redistribute it and/or modify
8 dnl it under the terms of the GNU General Public License as published by
9 dnl the Free Software Foundation; either version 3 of the License, or
10 dnl (at your option) any later version.
12 dnl This program is distributed in the hope that it will be useful,
13 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 dnl GNU General Public License for more details.
17 dnl You should have received a copy of the GNU General Public License
18 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
20 dnl Process this file with autoconf to produce a configure script.
25 AC_CONFIG_HEADER(config.h:config.in)
26 AC_CONFIG_LIBOBJ_DIR(../gnulib)
41 AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
42 proc_service.h sys/procfs.h thread_db.h linux/elf.h dnl
44 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
45 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
46 netinet/tcp.h arpa/inet.h sys/wait.h)
47 AC_CHECK_FUNCS(pread pwrite pread64)
48 AC_REPLACE_FUNCS(memmem vasprintf vsnprintf)
54 AC_ARG_WITH(ust, [ --with-ust=PATH Specify prefix directory for the installed UST package
55 Equivalent to --with-ust-include=PATH/include
56 plus --with-ust-lib=PATH/lib])
57 AC_ARG_WITH(ust_include, [ --with-ust-include=PATH Specify directory for installed UST include files])
58 AC_ARG_WITH(ust_lib, [ --with-ust-lib=PATH Specify the directory for the installed UST library])
70 ustlibs="-L$with_ust/lib -lust"
71 ustinc="-I$with_ust/include "
74 if test "x$with_ust_include" != x; then
75 ustinc="-I$with_ust_include "
77 if test "x$with_ust_lib" != x; then
78 ustlibs="-L$with_ust_lib -lust"
81 if test "x$with_ust" != "xno"; then
82 saved_CFLAGS="$CFLAGS"
83 CFLAGS="$CFLAGS $ustinc"
84 AC_MSG_CHECKING([for ust])
86 #define CONFIG_UST_GDB_INTEGRATION
89 [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_UST, 1, [Define if UST is available])],
90 [AC_MSG_RESULT([no]); ustlibs= ; ustinc= ])
91 CFLAGS="$saved_CFLAGS"
94 # Flags needed for UST
99 AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
100 [case "${enableval}" in
101 yes | y) ERROR_ON_WARNING="yes" ;;
102 no | n) ERROR_ON_WARNING="no" ;;
103 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
106 # Enable -Werror by default when using gcc
107 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
112 if test "${ERROR_ON_WARNING}" = yes ; then
113 WERROR_CFLAGS="-Werror"
116 build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
117 -Wformat-nonliteral -Wno-char-subscripts"
120 if test "x$GCC" = xyes
122 AC_MSG_CHECKING(compiler warning flags)
123 # Separate out the -Werror flag as some files just cannot be
124 # compiled with it enabled.
125 for w in ${build_warnings}; do
127 -Werr*) WERROR_CFLAGS=-Werror ;;
128 *) # Check that GCC accepts it
129 saved_CFLAGS="$CFLAGS"
131 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
132 CFLAGS="$saved_CFLAGS"
135 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
137 AC_SUBST(WARN_CFLAGS)
138 AC_SUBST(WERROR_CFLAGS)
140 dnl dladdr is glibc-specific. It is used by thread-db.c but only for
141 dnl debugging messages. It lives in -ldl which is handled below so we don't
142 dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily
146 AC_CHECK_FUNCS(dladdr)
150 AC_MSG_CHECKING(for errno)
154 #endif], [static int x; x = errno;],
155 [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO, 1, [Define if errno is available]) have_errno=yes])
156 if test $have_errno = no; then
160 #endif], [extern int errno; static int x; x = errno;],
161 [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])],
165 AC_CHECK_DECLS([strerror, perror, memmem, vasprintf, vsnprintf])
167 AC_CHECK_TYPES(socklen_t, [], [],
168 [#include <sys/types.h>
169 #include <sys/socket.h>
172 ACX_PKGVERSION([GDB])
173 ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
174 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
175 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
177 # Check for various supplementary target information (beyond the
178 # triplet) which might affect the choices in configure.srv.
183 AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64],
184 [save_CPPFLAGS="$CPPFLAGS"
185 CPPFLAGS="$CPPFLAGS $CFLAGS"
186 AC_EGREP_CPP([got it], [
190 ], [gdb_cv_i386_is_x86_64=yes],
191 [gdb_cv_i386_is_x86_64=no])
192 CPPFLAGS="$save_CPPFLAGS"])
195 AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire],
196 [save_CPPFLAGS="$CPPFLAGS"
197 CPPFLAGS="$CPPFLAGS $CFLAGS"
198 AC_EGREP_CPP([got it], [
202 ], [gdb_cv_m68k_is_coldfire=yes],
203 [gdb_cv_m68k_is_coldfire=no])
204 CPPFLAGS="$save_CPPFLAGS"])
208 . ${srcdir}/configure.srv
210 if test "${srv_mingwce}" = "yes"; then
212 elif test "${srv_mingw}" = "yes"; then
213 LIBS="$LIBS -lws2_32"
214 elif test "${srv_qnx}" = "yes"; then
215 LIBS="$LIBS -lsocket"
216 elif test "${srv_lynxos}" = "yes"; then
217 LIBS="$LIBS -lnetinet"
220 if test "${srv_mingw}" = "yes"; then
221 AC_DEFINE(USE_WIN32API, 1,
222 [Define if we should use the Windows API, instead of the
223 POSIX API. On Windows, we use the Windows API when
224 building for MinGW, but the POSIX API when building
228 if test "${srv_linux_usrregs}" = "yes"; then
229 AC_DEFINE(HAVE_LINUX_USRREGS, 1,
230 [Define if the target supports PTRACE_PEEKUSR for register ]
234 if test "${srv_linux_regsets}" = "yes"; then
235 AC_DEFINE(HAVE_LINUX_REGSETS, 1,
236 [Define if the target supports register sets.])
238 AC_MSG_CHECKING(for PTRACE_GETREGS)
239 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
240 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
242 [gdbsrv_cv_have_ptrace_getregs=yes],
243 [gdbsrv_cv_have_ptrace_getregs=no])])
244 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
245 if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
246 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
247 [Define if the target supports PTRACE_GETREGS for register ]
251 AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
252 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
253 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
254 [PTRACE_GETFPXREGS;],
255 [gdbsrv_cv_have_ptrace_getfpxregs=yes],
256 [gdbsrv_cv_have_ptrace_getfpxregs=no])])
257 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
258 if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
259 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
260 [Define if the target supports PTRACE_GETFPXREGS for extended ]
265 if test "$ac_cv_header_sys_procfs_h" = yes; then
266 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
267 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
268 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
269 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
272 dnl Check for libdl, but do not add it to LIBS as only gdbserver
273 dnl needs it (and gdbreplay doesn't).
275 AC_CHECK_LIB(dl, dlopen)
282 if test "$srv_linux_thread_db" = "yes"; then
283 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
285 AC_MSG_CHECKING(for the dynamic export flag)
286 old_LDFLAGS="$LDFLAGS"
287 # Older GNU ld supports --export-dynamic but --dynamic-list may not be
289 RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
290 LDFLAGS="$LDFLAGS $RDYNAMIC"
292 [found="-Wl,--dynamic-list"
293 RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
294 [RDYNAMIC="-rdynamic"
295 LDFLAGS="$old_LDFLAGS $RDYNAMIC"
301 LDFLAGS="$old_LDFLAGS"
302 AC_MSG_RESULT($found)
304 srv_libs="-lthread_db"
307 srv_thread_depfiles="thread-db.o proc-service.o"
308 USE_THREAD_DB="-DUSE_THREAD_DB"
309 AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
310 [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
311 [gdbsrv_cv_have_td_version=yes],
312 [gdbsrv_cv_have_td_version=no])])
313 if test $gdbsrv_cv_have_td_version = yes; then
314 AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
318 AC_ARG_WITH(libthread-db,
319 AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
320 [srv_libthread_db_path="${withval}"
321 srv_libs="$srv_libthread_db_path"
324 if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
325 AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
328 if test "$srv_xmlfiles" != ""; then
329 srv_xmlbuiltin="xml-builtin.o"
330 AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
332 tmp_xmlfiles=$srv_xmlfiles
334 for f in $tmp_xmlfiles; do
335 srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
339 GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles"
340 GDBSERVER_LIBS="$srv_libs"
342 dnl Check whether the target supports __sync_*_compare_and_swap.
343 AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
344 gdbsrv_cv_have_sync_builtins, [
345 AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
346 gdbsrv_cv_have_sync_builtins=yes,
347 gdbsrv_cv_have_sync_builtins=no)])
348 if test $gdbsrv_cv_have_sync_builtins = yes; then
349 AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
350 [Define to 1 if the target supports __sync_*_compare_and_swap])
353 dnl Check for -fvisibility=hidden support in the compiler.
354 saved_cflags="$CFLAGS"
355 CFLAGS="$CFLAGS -fvisibility=hidden"
356 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
357 [gdbsrv_cv_have_visibility_hidden=yes],
358 [gdbsrv_cv_have_visibility_hidden=no])
359 CFLAGS="$saved_cflags"
365 # check whether to enable the inprocess agent
366 if test "$ipa_obj" != "" \
367 -a "$gdbsrv_cv_have_sync_builtins" = yes \
368 -a "$gdbsrv_cv_have_visibility_hidden" = yes; then
374 AC_ARG_ENABLE(inprocess-agent,
375 AS_HELP_STRING([--enable-inprocess-agent], [inprocess agent]),
376 [case "$enableval" in
377 yes) want_ipa=true ;;
378 no) want_ipa=false ;;
379 *) AC_MSG_ERROR([bad value $enableval for inprocess-agent]) ;;
381 [want_ipa=$have_ipa])
385 IPA_DEPFILES="$ipa_obj"
386 extra_libraries="$extra_libraries libinproctrace.so"
388 AC_MSG_ERROR([inprocess agent not supported for this target])
392 AC_SUBST(GDBSERVER_DEPFILES)
393 AC_SUBST(GDBSERVER_LIBS)
394 AC_SUBST(USE_THREAD_DB)
395 AC_SUBST(srv_xmlbuiltin)
396 AC_SUBST(srv_xmlfiles)
397 AC_SUBST(IPA_DEPFILES)
398 AC_SUBST(extra_libraries)
401 [case x$CONFIG_HEADERS in