gdb/gdbserver/
[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
c9a1864a 29gl_EARLY
fd462a61 30AC_GNU_SOURCE
d6e9fb05
JK
31
32AC_CANONICAL_SYSTEM
84563040 33
d6e9fb05 34AC_PROG_INSTALL
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
0d62e5e8 46AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
94e10508 47 proc_service.h sys/procfs.h thread_db.h linux/elf.h dnl
b80864fb 48 stdlib.h unistd.h dnl
1b3f6016 49 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
61ff6e04 50 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
2fa291ac 51 netinet/tcp.h arpa/inet.h sys/wait.h sys/un.h)
f8255c2a 52AC_CHECK_FUNCS(pread pwrite pread64 readlink)
c9a1864a 53AC_REPLACE_FUNCS(vasprintf vsnprintf)
84563040 54
0fb4aa4b
PA
55# Check for UST
56ustlibs=""
57ustinc=""
58
59AC_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])
62AC_ARG_WITH(ust_include, [ --with-ust-include=PATH Specify directory for installed UST include files])
63AC_ARG_WITH(ust_lib, [ --with-ust-lib=PATH Specify the directory for the installed UST library])
64
65case $with_ust in
66 no)
67 ustlibs=
68 ustinc=
69 ;;
70 "" | yes)
71 ustlibs=" -lust "
72 ustinc=""
73 ;;
74 *)
75 ustlibs="-L$with_ust/lib -lust"
76 ustinc="-I$with_ust/include "
77 ;;
78esac
79if test "x$with_ust_include" != x; then
80 ustinc="-I$with_ust_include "
81fi
82if test "x$with_ust_lib" != x; then
83 ustlibs="-L$with_ust_lib -lust"
84fi
85
86if test "x$with_ust" != "xno"; then
87 saved_CFLAGS="$CFLAGS"
88 CFLAGS="$CFLAGS $ustinc"
89 AC_MSG_CHECKING([for ust])
90 AC_TRY_COMPILE([
91#define CONFIG_UST_GDB_INTEGRATION
92#include <ust/ust.h>
93 ],[],
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"
97fi
98
99# Flags needed for UST
100AC_SUBST(ustlibs)
101AC_SUBST(ustinc)
102
d4596a3d
PA
103AC_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) ;;
109 esac])
110
111# Enable -Werror by default when using gcc
112if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
113 ERROR_ON_WARNING=yes
114fi
115
116WERROR_CFLAGS=""
117if test "${ERROR_ON_WARNING}" = yes ; then
118 WERROR_CFLAGS="-Werror"
119fi
120
121build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
854d88f0 122-Wformat-nonliteral -Wno-char-subscripts"
d4596a3d
PA
123
124WARN_CFLAGS=""
125if test "x$GCC" = xyes
126then
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
131 case $w in
132 -Werr*) WERROR_CFLAGS=-Werror ;;
133 *) # Check that GCC accepts it
134 saved_CFLAGS="$CFLAGS"
135 CFLAGS="$CFLAGS $w"
136 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
137 CFLAGS="$saved_CFLAGS"
138 esac
139 done
140 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
141fi
142AC_SUBST(WARN_CFLAGS)
143AC_SUBST(WERROR_CFLAGS)
144
10e86dd7
DE
145dnl dladdr is glibc-specific. It is used by thread-db.c but only for
146dnl debugging messages. It lives in -ldl which is handled below so we don't
147dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily
148dnl augment LIBS.
149old_LIBS="$LIBS"
150LIBS="$LIBS -ldl"
151AC_CHECK_FUNCS(dladdr)
152LIBS="$old_LIBS"
153
68070c10
PA
154have_errno=no
155AC_MSG_CHECKING(for errno)
156AC_TRY_LINK([
157#if HAVE_ERRNO_H
158#include <errno.h>
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])
161if test $have_errno = no; then
162AC_TRY_LINK([
163#if HAVE_ERRNO_H
164#include <errno.h>
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])],
167 [AC_MSG_RESULT(no)])
168fi
169
bb0116a4 170AC_CHECK_DECLS([strerror, perror, memmem, vasprintf, vsnprintf])
43d5792c 171
ccbd4912
MK
172AC_CHECK_TYPES(socklen_t, [], [],
173[#include <sys/types.h>
174#include <sys/socket.h>
175])
fb1e4ffc 176
8365dcf5
TJB
177AC_CHECK_TYPES([Elf32_auxv_t, Elf64_auxv_t], [], [],
178#include <elf.h>
179)
180
c16158bc
JM
181ACX_PKGVERSION([GDB])
182ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
183AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
184AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
185
8838b45e
NS
186# Check for various supplementary target information (beyond the
187# triplet) which might affect the choices in configure.srv.
188case "${target}" in
189changequote(,)dnl
190 i[34567]86-*-linux*)
191changequote([,])dnl
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], [
196#if __x86_64__
197got it
198#endif
199 ], [gdb_cv_i386_is_x86_64=yes],
200 [gdb_cv_i386_is_x86_64=no])
201 CPPFLAGS="$save_CPPFLAGS"])
202 ;;
9ac544ce
MK
203 m68k-*-*)
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], [
208#ifdef __mcoldfire__
209got it
210#endif
211 ], [gdb_cv_m68k_is_coldfire=yes],
212 [gdb_cv_m68k_is_coldfire=no])
213 CPPFLAGS="$save_CPPFLAGS"])
214 ;;
8838b45e
NS
215esac
216
7ea81414 217. ${srcdir}/configure.srv
c906108c 218
68070c10
PA
219if test "${srv_mingwce}" = "yes"; then
220 LIBS="$LIBS -lws2"
221elif test "${srv_mingw}" = "yes"; then
12ea4b69 222 LIBS="$LIBS -lws2_32"
ac8c974e
AR
223elif test "${srv_qnx}" = "yes"; then
224 LIBS="$LIBS -lsocket"
8ed54b31
JB
225elif test "${srv_lynxos}" = "yes"; then
226 LIBS="$LIBS -lnetinet"
68070c10
PA
227fi
228
229if test "${srv_mingw}" = "yes"; then
b80864fb
DJ
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
234 for Cygwin.])
235fi
236
58caa3dc 237if test "${srv_linux_usrregs}" = "yes"; then
f450004a
DJ
238 AC_DEFINE(HAVE_LINUX_USRREGS, 1,
239 [Define if the target supports PTRACE_PEEKUSR for register ]
240 [access.])
58caa3dc
DJ
241fi
242
243if test "${srv_linux_regsets}" = "yes"; then
e9d25b98
DJ
244 AC_DEFINE(HAVE_LINUX_REGSETS, 1,
245 [Define if the target supports register sets.])
246
58caa3dc
DJ
247 AC_MSG_CHECKING(for PTRACE_GETREGS)
248 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
249 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
250 [PTRACE_GETREGS;],
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
e9d25b98 255 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
f450004a
DJ
256 [Define if the target supports PTRACE_GETREGS for register ]
257 [access.])
58caa3dc
DJ
258 fi
259
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
f450004a
DJ
268 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
269 [Define if the target supports PTRACE_GETFPXREGS for extended ]
270 [register access.])
58caa3dc
DJ
271 fi
272fi
273
0d62e5e8
DJ
274if 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)
0d62e5e8
DJ
278 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
279fi
280
193f13e6
MK
281dnl Check for libdl, but do not add it to LIBS as only gdbserver
282dnl needs it (and gdbreplay doesn't).
283old_LIBS="$LIBS"
284AC_CHECK_LIB(dl, dlopen)
285LIBS="$old_LIBS"
286
0d62e5e8
DJ
287srv_thread_depfiles=
288srv_libs=
289USE_THREAD_DB=
290
291if test "$srv_linux_thread_db" = "yes"; then
193f13e6
MK
292 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
293 srv_libs="-ldl"
f6528abd 294 AC_MSG_CHECKING(for the dynamic export flag)
193f13e6 295 old_LDFLAGS="$LDFLAGS"
f6528abd
JK
296 # Older GNU ld supports --export-dynamic but --dynamic-list may not be
297 # supported there.
298 RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
299 LDFLAGS="$LDFLAGS $RDYNAMIC"
300 AC_TRY_LINK([], [],
301 [found="-Wl,--dynamic-list"
302 RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
303 [RDYNAMIC="-rdynamic"
304 LDFLAGS="$old_LDFLAGS $RDYNAMIC"
305 AC_TRY_LINK([], [],
306 [found="-rdynamic"],
307 [found="no"
308 RDYNAMIC=""])])
193f13e6
MK
309 AC_SUBST(RDYNAMIC)
310 LDFLAGS="$old_LDFLAGS"
f6528abd 311 AC_MSG_RESULT($found)
193f13e6
MK
312 else
313 srv_libs="-lthread_db"
314 fi
0d62e5e8 315
0d62e5e8
DJ
316 srv_thread_depfiles="thread-db.o proc-service.o"
317 USE_THREAD_DB="-DUSE_THREAD_DB"
3db0444b
DJ
318 AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
319 [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
1b3f6016
PA
320 [gdbsrv_cv_have_td_version=yes],
321 [gdbsrv_cv_have_td_version=no])])
3db0444b
DJ
322 if test $gdbsrv_cv_have_td_version = yes; then
323 AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
324 fi
0d62e5e8
DJ
325fi
326
96f15937
PP
327AC_ARG_WITH(libthread-db,
328AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
329[srv_libthread_db_path="${withval}"
96f15937
PP
330 srv_libs="$srv_libthread_db_path"
331])
332
193f13e6
MK
333if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
334 AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
335fi
336
9b4b61c8 337if test "$srv_xmlfiles" != ""; then
fb1e4ffc
DJ
338 srv_xmlbuiltin="xml-builtin.o"
339 AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
340
341 tmp_xmlfiles=$srv_xmlfiles
9b4b61c8 342 srv_xmlfiles=""
fb1e4ffc
DJ
343 for f in $tmp_xmlfiles; do
344 srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
345 done
346fi
347
59a016f0 348GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles"
0d62e5e8 349GDBSERVER_LIBS="$srv_libs"
c906108c 350
fa593d66
PA
351dnl Check whether the target supports __sync_*_compare_and_swap.
352AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
353 gdbsrv_cv_have_sync_builtins, [
354AC_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)])
357if 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])
360fi
361
362dnl Check for -fvisibility=hidden support in the compiler.
363saved_cflags="$CFLAGS"
364CFLAGS="$CFLAGS -fvisibility=hidden"
365AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
366 [gdbsrv_cv_have_visibility_hidden=yes],
367 [gdbsrv_cv_have_visibility_hidden=no])
368CFLAGS="$saved_cflags"
369
03583c20
UW
370dnl Check if we can disable the virtual address space randomization.
371dnl The functionality of setarch -R.
372AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
373define([PERSONALITY_TEST], [AC_LANG_PROGRAM([#include <sys/personality.h>], [
374# if !HAVE_DECL_ADDR_NO_RANDOMIZE
375# define ADDR_NO_RANDOMIZE 0x0040000
376# endif
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))
380 return 1])])
381AC_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])])
387if $gdbsrv_cv_have_personality
388then
389 AC_DEFINE([HAVE_PERSONALITY], 1,
390 [Define if you support the personality syscall.])
391fi
392
c2a66c29 393
fa593d66 394IPA_DEPFILES=""
c2a66c29 395extra_libraries=""
fa593d66 396
c2a66c29 397# check whether to enable the inprocess agent
fa593d66
PA
398if test "$ipa_obj" != "" \
399 -a "$gdbsrv_cv_have_sync_builtins" = yes \
400 -a "$gdbsrv_cv_have_visibility_hidden" = yes; then
c2a66c29
NS
401 have_ipa=true
402else
403 have_ipa=false
404fi
405
406AC_ARG_ENABLE(inprocess-agent,
407AS_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]) ;;
412esac],
413[want_ipa=$have_ipa])
414
415if $want_ipa ; then
416 if $have_ipa ; then
417 IPA_DEPFILES="$ipa_obj"
418 extra_libraries="$extra_libraries libinproctrace.so"
419 else
420 AC_MSG_ERROR([inprocess agent not supported for this target])
421 fi
fa593d66
PA
422fi
423
7ea81414 424AC_SUBST(GDBSERVER_DEPFILES)
0d62e5e8
DJ
425AC_SUBST(GDBSERVER_LIBS)
426AC_SUBST(USE_THREAD_DB)
fb1e4ffc
DJ
427AC_SUBST(srv_xmlbuiltin)
428AC_SUBST(srv_xmlfiles)
fa593d66
PA
429AC_SUBST(IPA_DEPFILES)
430AC_SUBST(extra_libraries)
c906108c 431
c9a1864a
YQ
432gl_INIT
433# GDBserver does not use automake, but gnulib does. This line lets
434# us generate its Makefile.in.
435AM_INIT_AUTOMAKE(gdbserver, UNUSED-VERSION, [no-define])
436
437GNULIB_STDINT_H=
438if test x"$STDINT_H" != x; then
439 GNULIB_STDINT_H=gnulib/$STDINT_H
440fi
441AC_SUBST(GNULIB_STDINT_H)
442
443AC_OUTPUT(Makefile gnulib/Makefile:${srcdir}/../gnulib/Makefile.in,
c3a3ccc7
DJ
444[case x$CONFIG_HEADERS in
445xconfig.h:config.in)
446echo > stamp-h ;;
447esac
448])
This page took 1.031821 seconds and 4 git commands to generate.