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