2012-11-15 Pierre Muller <muller@sourceware.org>
[deliverable/binutils-gdb.git] / gdb / gdbserver / configure.ac
CommitLineData
d6e9fb05 1dnl Autoconf configure script for GDB server.
0b302171 2dnl Copyright (C) 2000, 2002-2012 Free Software Foundation, Inc.
d6e9fb05
JK
3dnl
4dnl This file is part of GDB.
5dnl
6dnl This program is free software; you can redistribute it and/or modify
7dnl it under the terms of the GNU General Public License as published by
5a0e3bd0 8dnl the Free Software Foundation; either version 3 of the License, or
d6e9fb05
JK
9dnl (at your option) any later version.
10dnl
11dnl This program is distributed in the hope that it will be useful,
12dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14dnl GNU General Public License for more details.
15dnl
16dnl You should have received a copy of the GNU General Public License
5a0e3bd0 17dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
d6e9fb05
JK
18
19dnl Process this file with autoconf to produce a configure script.
20
bec39cab
AC
21AC_PREREQ(2.59)dnl
22
d6e9fb05 23AC_INIT(server.c)
84563040 24AC_CONFIG_HEADER(config.h:config.in)
c9a1864a
YQ
25
26AM_MAINTAINER_MODE
84563040
DJ
27
28AC_PROG_CC
fd462a61 29AC_GNU_SOURCE
d6e9fb05
JK
30
31AC_CANONICAL_SYSTEM
84563040 32
d6e9fb05 33AC_PROG_INSTALL
c971b7fa 34AC_PROG_RANLIB
c906108c 35
dcdb98d2
DJ
36AC_ARG_PROGRAM
37
ee6e2b82 38AC_HEADER_STDC
d26e3629 39AC_HEADER_DIRENT
84563040 40
a1723c35 41AC_FUNC_ALLOCA
c9a1864a
YQ
42
43# Check for the 'make' the user wants to use.
44AC_CHECK_PROGS(MAKE, make)
45
c971b7fa
PA
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.
51ACX_CONFIGURE_DIR(["../gnulib"], ["build-gnulib-gdbserver"])
52
0d62e5e8 53AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
94e10508 54 proc_service.h sys/procfs.h thread_db.h linux/elf.h dnl
b80864fb 55 stdlib.h unistd.h dnl
1b3f6016 56 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
61ff6e04 57 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
8bdce1ff 58 netinet/tcp.h arpa/inet.h sys/wait.h wait.h sys/un.h)
f8255c2a 59AC_CHECK_FUNCS(pread pwrite pread64 readlink)
c9a1864a 60AC_REPLACE_FUNCS(vasprintf vsnprintf)
84563040 61
0fb4aa4b
PA
62# Check for UST
63ustlibs=""
64ustinc=""
65
66AC_ARG_WITH(ust, [ --with-ust=PATH Specify prefix directory for the installed UST package
67 Equivalent to --with-ust-include=PATH/include
68 plus --with-ust-lib=PATH/lib])
69AC_ARG_WITH(ust_include, [ --with-ust-include=PATH Specify directory for installed UST include files])
70AC_ARG_WITH(ust_lib, [ --with-ust-lib=PATH Specify the directory for the installed UST library])
71
72case $with_ust in
73 no)
74 ustlibs=
75 ustinc=
76 ;;
77 "" | yes)
78 ustlibs=" -lust "
79 ustinc=""
80 ;;
81 *)
82 ustlibs="-L$with_ust/lib -lust"
83 ustinc="-I$with_ust/include "
84 ;;
85esac
86if test "x$with_ust_include" != x; then
87 ustinc="-I$with_ust_include "
88fi
89if test "x$with_ust_lib" != x; then
90 ustlibs="-L$with_ust_lib -lust"
91fi
92
93if test "x$with_ust" != "xno"; then
94 saved_CFLAGS="$CFLAGS"
95 CFLAGS="$CFLAGS $ustinc"
96 AC_MSG_CHECKING([for ust])
97 AC_TRY_COMPILE([
98#define CONFIG_UST_GDB_INTEGRATION
99#include <ust/ust.h>
100 ],[],
101 [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_UST, 1, [Define if UST is available])],
102 [AC_MSG_RESULT([no]); ustlibs= ; ustinc= ])
103 CFLAGS="$saved_CFLAGS"
104fi
105
106# Flags needed for UST
107AC_SUBST(ustlibs)
108AC_SUBST(ustinc)
109
d4596a3d
PA
110AC_ARG_ENABLE(werror,
111 AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
112 [case "${enableval}" in
113 yes | y) ERROR_ON_WARNING="yes" ;;
114 no | n) ERROR_ON_WARNING="no" ;;
115 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
116 esac])
117
118# Enable -Werror by default when using gcc
119if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
120 ERROR_ON_WARNING=yes
121fi
122
123WERROR_CFLAGS=""
124if test "${ERROR_ON_WARNING}" = yes ; then
125 WERROR_CFLAGS="-Werror"
126fi
127
128build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
854d88f0 129-Wformat-nonliteral -Wno-char-subscripts"
d4596a3d
PA
130
131WARN_CFLAGS=""
132if test "x$GCC" = xyes
133then
134 AC_MSG_CHECKING(compiler warning flags)
135 # Separate out the -Werror flag as some files just cannot be
136 # compiled with it enabled.
137 for w in ${build_warnings}; do
138 case $w in
139 -Werr*) WERROR_CFLAGS=-Werror ;;
140 *) # Check that GCC accepts it
141 saved_CFLAGS="$CFLAGS"
142 CFLAGS="$CFLAGS $w"
143 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
144 CFLAGS="$saved_CFLAGS"
145 esac
146 done
147 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
148fi
149AC_SUBST(WARN_CFLAGS)
150AC_SUBST(WERROR_CFLAGS)
151
10e86dd7
DE
152dnl dladdr is glibc-specific. It is used by thread-db.c but only for
153dnl debugging messages. It lives in -ldl which is handled below so we don't
154dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily
155dnl augment LIBS.
156old_LIBS="$LIBS"
157LIBS="$LIBS -ldl"
158AC_CHECK_FUNCS(dladdr)
159LIBS="$old_LIBS"
160
68070c10
PA
161have_errno=no
162AC_MSG_CHECKING(for errno)
163AC_TRY_LINK([
164#if HAVE_ERRNO_H
165#include <errno.h>
166#endif], [static int x; x = errno;],
167 [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO, 1, [Define if errno is available]) have_errno=yes])
168if test $have_errno = no; then
169AC_TRY_LINK([
170#if HAVE_ERRNO_H
171#include <errno.h>
172#endif], [extern int errno; static int x; x = errno;],
173 [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])],
174 [AC_MSG_RESULT(no)])
175fi
176
e6712ff1 177AC_CHECK_DECLS([strerror, strstr, perror, vasprintf, vsnprintf])
43d5792c 178
ccbd4912
MK
179AC_CHECK_TYPES(socklen_t, [], [],
180[#include <sys/types.h>
181#include <sys/socket.h>
182])
fb1e4ffc 183
8365dcf5
TJB
184AC_CHECK_TYPES([Elf32_auxv_t, Elf64_auxv_t], [], [],
185#include <elf.h>
186)
187
c16158bc
JM
188ACX_PKGVERSION([GDB])
189ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
190AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
191AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
192
8838b45e
NS
193# Check for various supplementary target information (beyond the
194# triplet) which might affect the choices in configure.srv.
195case "${target}" in
196changequote(,)dnl
197 i[34567]86-*-linux*)
198changequote([,])dnl
199 AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64],
200 [save_CPPFLAGS="$CPPFLAGS"
201 CPPFLAGS="$CPPFLAGS $CFLAGS"
202 AC_EGREP_CPP([got it], [
203#if __x86_64__
204got it
205#endif
206 ], [gdb_cv_i386_is_x86_64=yes],
207 [gdb_cv_i386_is_x86_64=no])
208 CPPFLAGS="$save_CPPFLAGS"])
209 ;;
9ac544ce
MK
210 m68k-*-*)
211 AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire],
212 [save_CPPFLAGS="$CPPFLAGS"
213 CPPFLAGS="$CPPFLAGS $CFLAGS"
214 AC_EGREP_CPP([got it], [
215#ifdef __mcoldfire__
216got it
217#endif
218 ], [gdb_cv_m68k_is_coldfire=yes],
219 [gdb_cv_m68k_is_coldfire=no])
220 CPPFLAGS="$save_CPPFLAGS"])
221 ;;
8838b45e
NS
222esac
223
7ea81414 224. ${srcdir}/configure.srv
c906108c 225
68070c10
PA
226if test "${srv_mingwce}" = "yes"; then
227 LIBS="$LIBS -lws2"
228elif test "${srv_mingw}" = "yes"; then
12ea4b69 229 LIBS="$LIBS -lws2_32"
ac8c974e
AR
230elif test "${srv_qnx}" = "yes"; then
231 LIBS="$LIBS -lsocket"
8ed54b31
JB
232elif test "${srv_lynxos}" = "yes"; then
233 LIBS="$LIBS -lnetinet"
68070c10
PA
234fi
235
236if test "${srv_mingw}" = "yes"; then
b80864fb
DJ
237 AC_DEFINE(USE_WIN32API, 1,
238 [Define if we should use the Windows API, instead of the
239 POSIX API. On Windows, we use the Windows API when
240 building for MinGW, but the POSIX API when building
241 for Cygwin.])
242fi
243
58caa3dc 244if test "${srv_linux_usrregs}" = "yes"; then
f450004a
DJ
245 AC_DEFINE(HAVE_LINUX_USRREGS, 1,
246 [Define if the target supports PTRACE_PEEKUSR for register ]
247 [access.])
58caa3dc
DJ
248fi
249
250if test "${srv_linux_regsets}" = "yes"; then
e9d25b98
DJ
251 AC_DEFINE(HAVE_LINUX_REGSETS, 1,
252 [Define if the target supports register sets.])
253
58caa3dc
DJ
254 AC_MSG_CHECKING(for PTRACE_GETREGS)
255 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
256 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
257 [PTRACE_GETREGS;],
258 [gdbsrv_cv_have_ptrace_getregs=yes],
259 [gdbsrv_cv_have_ptrace_getregs=no])])
260 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
261 if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
e9d25b98 262 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
f450004a
DJ
263 [Define if the target supports PTRACE_GETREGS for register ]
264 [access.])
58caa3dc
DJ
265 fi
266
267 AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
268 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
269 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
270 [PTRACE_GETFPXREGS;],
271 [gdbsrv_cv_have_ptrace_getfpxregs=yes],
272 [gdbsrv_cv_have_ptrace_getfpxregs=no])])
273 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
274 if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
f450004a
DJ
275 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
276 [Define if the target supports PTRACE_GETFPXREGS for extended ]
277 [register access.])
58caa3dc
DJ
278 fi
279fi
280
0d62e5e8
DJ
281if test "$ac_cv_header_sys_procfs_h" = yes; then
282 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
283 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
284 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
0d62e5e8
DJ
285 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
286fi
287
18f5fd81
TJB
288dnl Some systems (e.g., Android) have lwpid_t defined in libthread_db.h.
289if test "$bfd_cv_have_sys_procfs_type_lwpid_t" != yes; then
290 GDBSERVER_HAVE_THREAD_DB_TYPE(lwpid_t)
291fi
292
293dnl Some systems (e.g., Android) have psaddr_t defined in libthread_db.h.
294if test "$bfd_cv_have_sys_procfs_type_psaddr_t" != yes; then
295 GDBSERVER_HAVE_THREAD_DB_TYPE(psaddr_t)
296fi
297
193f13e6
MK
298dnl Check for libdl, but do not add it to LIBS as only gdbserver
299dnl needs it (and gdbreplay doesn't).
300old_LIBS="$LIBS"
301AC_CHECK_LIB(dl, dlopen)
302LIBS="$old_LIBS"
303
0d62e5e8
DJ
304srv_thread_depfiles=
305srv_libs=
306USE_THREAD_DB=
307
308if test "$srv_linux_thread_db" = "yes"; then
193f13e6
MK
309 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
310 srv_libs="-ldl"
f6528abd 311 AC_MSG_CHECKING(for the dynamic export flag)
193f13e6 312 old_LDFLAGS="$LDFLAGS"
f6528abd
JK
313 # Older GNU ld supports --export-dynamic but --dynamic-list may not be
314 # supported there.
315 RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
316 LDFLAGS="$LDFLAGS $RDYNAMIC"
317 AC_TRY_LINK([], [],
318 [found="-Wl,--dynamic-list"
319 RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
320 [RDYNAMIC="-rdynamic"
321 LDFLAGS="$old_LDFLAGS $RDYNAMIC"
322 AC_TRY_LINK([], [],
323 [found="-rdynamic"],
324 [found="no"
325 RDYNAMIC=""])])
193f13e6
MK
326 AC_SUBST(RDYNAMIC)
327 LDFLAGS="$old_LDFLAGS"
f6528abd 328 AC_MSG_RESULT($found)
193f13e6
MK
329 else
330 srv_libs="-lthread_db"
331 fi
0d62e5e8 332
0d62e5e8
DJ
333 srv_thread_depfiles="thread-db.o proc-service.o"
334 USE_THREAD_DB="-DUSE_THREAD_DB"
3db0444b
DJ
335 AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
336 [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
1b3f6016
PA
337 [gdbsrv_cv_have_td_version=yes],
338 [gdbsrv_cv_have_td_version=no])])
3db0444b
DJ
339 if test $gdbsrv_cv_have_td_version = yes; then
340 AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
341 fi
0d62e5e8
DJ
342fi
343
96f15937
PP
344AC_ARG_WITH(libthread-db,
345AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
346[srv_libthread_db_path="${withval}"
96f15937
PP
347 srv_libs="$srv_libthread_db_path"
348])
349
193f13e6
MK
350if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
351 AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
352fi
353
9b4b61c8 354if test "$srv_xmlfiles" != ""; then
fb1e4ffc
DJ
355 srv_xmlbuiltin="xml-builtin.o"
356 AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
357
358 tmp_xmlfiles=$srv_xmlfiles
9b4b61c8 359 srv_xmlfiles=""
fb1e4ffc
DJ
360 for f in $tmp_xmlfiles; do
361 srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
362 done
363fi
364
59a016f0 365GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles"
0d62e5e8 366GDBSERVER_LIBS="$srv_libs"
c906108c 367
fa593d66
PA
368dnl Check whether the target supports __sync_*_compare_and_swap.
369AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
370 gdbsrv_cv_have_sync_builtins, [
371AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
372 gdbsrv_cv_have_sync_builtins=yes,
373 gdbsrv_cv_have_sync_builtins=no)])
374if test $gdbsrv_cv_have_sync_builtins = yes; then
375 AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
376 [Define to 1 if the target supports __sync_*_compare_and_swap])
377fi
378
379dnl Check for -fvisibility=hidden support in the compiler.
380saved_cflags="$CFLAGS"
381CFLAGS="$CFLAGS -fvisibility=hidden"
382AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
383 [gdbsrv_cv_have_visibility_hidden=yes],
384 [gdbsrv_cv_have_visibility_hidden=no])
385CFLAGS="$saved_cflags"
386
03583c20
UW
387dnl Check if we can disable the virtual address space randomization.
388dnl The functionality of setarch -R.
389AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
390define([PERSONALITY_TEST], [AC_LANG_PROGRAM([#include <sys/personality.h>], [
391# if !HAVE_DECL_ADDR_NO_RANDOMIZE
392# define ADDR_NO_RANDOMIZE 0x0040000
393# endif
394 /* Test the flag could be set and stays set. */
395 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
396 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
397 return 1])])
398AC_RUN_IFELSE([PERSONALITY_TEST],
399 [gdbsrv_cv_have_personality=true],
400 [gdbsrv_cv_have_personality=false],
401 [AC_LINK_IFELSE([PERSONALITY_TEST],
402 [gdbsrv_cv_have_personality=true],
403 [gdbsrv_cv_have_personality=false])])
404if $gdbsrv_cv_have_personality
405then
406 AC_DEFINE([HAVE_PERSONALITY], 1,
407 [Define if you support the personality syscall.])
408fi
409
c2a66c29 410
fa593d66 411IPA_DEPFILES=""
c2a66c29 412extra_libraries=""
fa593d66 413
c2a66c29 414# check whether to enable the inprocess agent
fa593d66
PA
415if test "$ipa_obj" != "" \
416 -a "$gdbsrv_cv_have_sync_builtins" = yes \
417 -a "$gdbsrv_cv_have_visibility_hidden" = yes; then
c2a66c29
NS
418 have_ipa=true
419else
420 have_ipa=false
421fi
422
423AC_ARG_ENABLE(inprocess-agent,
424AS_HELP_STRING([--enable-inprocess-agent], [inprocess agent]),
425[case "$enableval" in
426 yes) want_ipa=true ;;
427 no) want_ipa=false ;;
428 *) AC_MSG_ERROR([bad value $enableval for inprocess-agent]) ;;
429esac],
430[want_ipa=$have_ipa])
431
432if $want_ipa ; then
433 if $have_ipa ; then
434 IPA_DEPFILES="$ipa_obj"
435 extra_libraries="$extra_libraries libinproctrace.so"
436 else
437 AC_MSG_ERROR([inprocess agent not supported for this target])
438 fi
fa593d66
PA
439fi
440
7ea81414 441AC_SUBST(GDBSERVER_DEPFILES)
0d62e5e8
DJ
442AC_SUBST(GDBSERVER_LIBS)
443AC_SUBST(USE_THREAD_DB)
fb1e4ffc
DJ
444AC_SUBST(srv_xmlbuiltin)
445AC_SUBST(srv_xmlfiles)
fa593d66
PA
446AC_SUBST(IPA_DEPFILES)
447AC_SUBST(extra_libraries)
c906108c 448
c971b7fa 449GNULIB=build-gnulib-gdbserver/import
c9a1864a
YQ
450
451GNULIB_STDINT_H=
452if test x"$STDINT_H" != x; then
c971b7fa 453 GNULIB_STDINT_H=$GNULIB/$STDINT_H
c9a1864a
YQ
454fi
455AC_SUBST(GNULIB_STDINT_H)
456
c971b7fa 457AC_OUTPUT(Makefile,
c3a3ccc7
DJ
458[case x$CONFIG_HEADERS in
459xconfig.h:config.in)
460echo > stamp-h ;;
461esac
462])
This page took 1.57258 seconds and 4 git commands to generate.