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