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