* NEWS: Mention some additional changes.
[deliverable/binutils-gdb.git] / gdb / gdbserver / configure.ac
CommitLineData
d6e9fb05 1dnl Autoconf configure script for GDB server.
abd775ce
JB
2dnl Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
3dnl 2010 Free Software Foundation, Inc.
d6e9fb05
JK
4dnl
5dnl This file is part of GDB.
6dnl
7dnl This program is free software; you can redistribute it and/or modify
8dnl it under the terms of the GNU General Public License as published by
5a0e3bd0 9dnl the Free Software Foundation; either version 3 of the License, or
d6e9fb05
JK
10dnl (at your option) any later version.
11dnl
12dnl This program is distributed in the hope that it will be useful,
13dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15dnl GNU General Public License for more details.
16dnl
17dnl You should have received a copy of the GNU General Public License
5a0e3bd0 18dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
d6e9fb05
JK
19
20dnl Process this file with autoconf to produce a configure script.
21
bec39cab
AC
22AC_PREREQ(2.59)dnl
23
d6e9fb05 24AC_INIT(server.c)
84563040 25AC_CONFIG_HEADER(config.h:config.in)
e28b3332 26AC_CONFIG_LIBOBJ_DIR(../gnulib)
84563040
DJ
27
28AC_PROG_CC
fd462a61 29AC_GNU_SOURCE
d6e9fb05
JK
30
31AC_CANONICAL_SYSTEM
84563040 32
d6e9fb05 33AC_PROG_INSTALL
c906108c 34
dcdb98d2
DJ
35AC_ARG_PROGRAM
36
ee6e2b82 37AC_HEADER_STDC
84563040 38
0d62e5e8 39AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
94e10508 40 proc_service.h sys/procfs.h thread_db.h linux/elf.h dnl
b80864fb 41 stdlib.h unistd.h dnl
1b3f6016 42 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
61ff6e04 43 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
b80864fb 44 netinet/tcp.h arpa/inet.h sys/wait.h)
4e799345 45AC_CHECK_FUNCS(pread pwrite pread64)
e28b3332 46AC_REPLACE_FUNCS(memmem)
84563040 47
0fb4aa4b
PA
48# Check for UST
49ustlibs=""
50ustinc=""
51
52AC_ARG_WITH(ust, [ --with-ust=PATH Specify prefix directory for the installed UST package
53 Equivalent to --with-ust-include=PATH/include
54 plus --with-ust-lib=PATH/lib])
55AC_ARG_WITH(ust_include, [ --with-ust-include=PATH Specify directory for installed UST include files])
56AC_ARG_WITH(ust_lib, [ --with-ust-lib=PATH Specify the directory for the installed UST library])
57
58case $with_ust in
59 no)
60 ustlibs=
61 ustinc=
62 ;;
63 "" | yes)
64 ustlibs=" -lust "
65 ustinc=""
66 ;;
67 *)
68 ustlibs="-L$with_ust/lib -lust"
69 ustinc="-I$with_ust/include "
70 ;;
71esac
72if test "x$with_ust_include" != x; then
73 ustinc="-I$with_ust_include "
74fi
75if test "x$with_ust_lib" != x; then
76 ustlibs="-L$with_ust_lib -lust"
77fi
78
79if test "x$with_ust" != "xno"; then
80 saved_CFLAGS="$CFLAGS"
81 CFLAGS="$CFLAGS $ustinc"
82 AC_MSG_CHECKING([for ust])
83 AC_TRY_COMPILE([
84#define CONFIG_UST_GDB_INTEGRATION
85#include <ust/ust.h>
86 ],[],
87 [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_UST, 1, [Define if UST is available])],
88 [AC_MSG_RESULT([no]); ustlibs= ; ustinc= ])
89 CFLAGS="$saved_CFLAGS"
90fi
91
92# Flags needed for UST
93AC_SUBST(ustlibs)
94AC_SUBST(ustinc)
95
10e86dd7
DE
96dnl dladdr is glibc-specific. It is used by thread-db.c but only for
97dnl debugging messages. It lives in -ldl which is handled below so we don't
98dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily
99dnl augment LIBS.
100old_LIBS="$LIBS"
101LIBS="$LIBS -ldl"
102AC_CHECK_FUNCS(dladdr)
103LIBS="$old_LIBS"
104
68070c10
PA
105have_errno=no
106AC_MSG_CHECKING(for errno)
107AC_TRY_LINK([
108#if HAVE_ERRNO_H
109#include <errno.h>
110#endif], [static int x; x = errno;],
111 [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO, 1, [Define if errno is available]) have_errno=yes])
112if test $have_errno = no; then
113AC_TRY_LINK([
114#if HAVE_ERRNO_H
115#include <errno.h>
116#endif], [extern int errno; static int x; x = errno;],
117 [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])],
118 [AC_MSG_RESULT(no)])
119fi
120
ec56be1b 121AC_CHECK_DECLS([strerror, perror, memmem])
43d5792c 122
ccbd4912
MK
123AC_CHECK_TYPES(socklen_t, [], [],
124[#include <sys/types.h>
125#include <sys/socket.h>
126])
fb1e4ffc 127
c16158bc
JM
128ACX_PKGVERSION([GDB])
129ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
130AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
131AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
132
8838b45e
NS
133# Check for various supplementary target information (beyond the
134# triplet) which might affect the choices in configure.srv.
135case "${target}" in
136changequote(,)dnl
137 i[34567]86-*-linux*)
138changequote([,])dnl
139 AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64],
140 [save_CPPFLAGS="$CPPFLAGS"
141 CPPFLAGS="$CPPFLAGS $CFLAGS"
142 AC_EGREP_CPP([got it], [
143#if __x86_64__
144got it
145#endif
146 ], [gdb_cv_i386_is_x86_64=yes],
147 [gdb_cv_i386_is_x86_64=no])
148 CPPFLAGS="$save_CPPFLAGS"])
149 ;;
9ac544ce
MK
150 m68k-*-*)
151 AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire],
152 [save_CPPFLAGS="$CPPFLAGS"
153 CPPFLAGS="$CPPFLAGS $CFLAGS"
154 AC_EGREP_CPP([got it], [
155#ifdef __mcoldfire__
156got it
157#endif
158 ], [gdb_cv_m68k_is_coldfire=yes],
159 [gdb_cv_m68k_is_coldfire=no])
160 CPPFLAGS="$save_CPPFLAGS"])
161 ;;
8838b45e
NS
162esac
163
7ea81414 164. ${srcdir}/configure.srv
c906108c 165
68070c10
PA
166if test "${srv_mingwce}" = "yes"; then
167 LIBS="$LIBS -lws2"
168elif test "${srv_mingw}" = "yes"; then
12ea4b69 169 LIBS="$LIBS -lws2_32"
ac8c974e
AR
170elif test "${srv_qnx}" = "yes"; then
171 LIBS="$LIBS -lsocket"
68070c10
PA
172fi
173
174if test "${srv_mingw}" = "yes"; then
b80864fb
DJ
175 AC_DEFINE(USE_WIN32API, 1,
176 [Define if we should use the Windows API, instead of the
177 POSIX API. On Windows, we use the Windows API when
178 building for MinGW, but the POSIX API when building
179 for Cygwin.])
180fi
181
58caa3dc 182if test "${srv_linux_usrregs}" = "yes"; then
f450004a
DJ
183 AC_DEFINE(HAVE_LINUX_USRREGS, 1,
184 [Define if the target supports PTRACE_PEEKUSR for register ]
185 [access.])
58caa3dc
DJ
186fi
187
188if test "${srv_linux_regsets}" = "yes"; then
e9d25b98
DJ
189 AC_DEFINE(HAVE_LINUX_REGSETS, 1,
190 [Define if the target supports register sets.])
191
58caa3dc
DJ
192 AC_MSG_CHECKING(for PTRACE_GETREGS)
193 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
194 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
195 [PTRACE_GETREGS;],
196 [gdbsrv_cv_have_ptrace_getregs=yes],
197 [gdbsrv_cv_have_ptrace_getregs=no])])
198 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
199 if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
e9d25b98 200 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
f450004a
DJ
201 [Define if the target supports PTRACE_GETREGS for register ]
202 [access.])
58caa3dc
DJ
203 fi
204
205 AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
206 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
207 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
208 [PTRACE_GETFPXREGS;],
209 [gdbsrv_cv_have_ptrace_getfpxregs=yes],
210 [gdbsrv_cv_have_ptrace_getfpxregs=no])])
211 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
212 if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
f450004a
DJ
213 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
214 [Define if the target supports PTRACE_GETFPXREGS for extended ]
215 [register access.])
58caa3dc
DJ
216 fi
217fi
218
0d62e5e8
DJ
219if test "$ac_cv_header_sys_procfs_h" = yes; then
220 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
221 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
222 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
0d62e5e8
DJ
223 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
224fi
225
193f13e6
MK
226dnl Check for libdl, but do not add it to LIBS as only gdbserver
227dnl needs it (and gdbreplay doesn't).
228old_LIBS="$LIBS"
229AC_CHECK_LIB(dl, dlopen)
230LIBS="$old_LIBS"
231
0d62e5e8
DJ
232srv_thread_depfiles=
233srv_libs=
234USE_THREAD_DB=
235
236if test "$srv_linux_thread_db" = "yes"; then
193f13e6
MK
237 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
238 srv_libs="-ldl"
f6528abd 239 AC_MSG_CHECKING(for the dynamic export flag)
193f13e6 240 old_LDFLAGS="$LDFLAGS"
f6528abd
JK
241 # Older GNU ld supports --export-dynamic but --dynamic-list may not be
242 # supported there.
243 RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
244 LDFLAGS="$LDFLAGS $RDYNAMIC"
245 AC_TRY_LINK([], [],
246 [found="-Wl,--dynamic-list"
247 RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
248 [RDYNAMIC="-rdynamic"
249 LDFLAGS="$old_LDFLAGS $RDYNAMIC"
250 AC_TRY_LINK([], [],
251 [found="-rdynamic"],
252 [found="no"
253 RDYNAMIC=""])])
193f13e6
MK
254 AC_SUBST(RDYNAMIC)
255 LDFLAGS="$old_LDFLAGS"
f6528abd 256 AC_MSG_RESULT($found)
193f13e6
MK
257 else
258 srv_libs="-lthread_db"
259 fi
0d62e5e8 260
0d62e5e8
DJ
261 srv_thread_depfiles="thread-db.o proc-service.o"
262 USE_THREAD_DB="-DUSE_THREAD_DB"
3db0444b
DJ
263 AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
264 [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
1b3f6016
PA
265 [gdbsrv_cv_have_td_version=yes],
266 [gdbsrv_cv_have_td_version=no])])
3db0444b
DJ
267 if test $gdbsrv_cv_have_td_version = yes; then
268 AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
269 fi
0d62e5e8
DJ
270fi
271
96f15937
PP
272AC_ARG_WITH(libthread-db,
273AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
274[srv_libthread_db_path="${withval}"
96f15937
PP
275 srv_libs="$srv_libthread_db_path"
276])
277
193f13e6
MK
278if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
279 AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
280fi
281
9b4b61c8 282if test "$srv_xmlfiles" != ""; then
fb1e4ffc
DJ
283 srv_xmlbuiltin="xml-builtin.o"
284 AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
285
286 tmp_xmlfiles=$srv_xmlfiles
9b4b61c8 287 srv_xmlfiles=""
fb1e4ffc
DJ
288 for f in $tmp_xmlfiles; do
289 srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
290 done
291fi
292
59a016f0 293GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles"
0d62e5e8 294GDBSERVER_LIBS="$srv_libs"
c906108c 295
fa593d66
PA
296dnl Check whether the target supports __sync_*_compare_and_swap.
297AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
298 gdbsrv_cv_have_sync_builtins, [
299AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
300 gdbsrv_cv_have_sync_builtins=yes,
301 gdbsrv_cv_have_sync_builtins=no)])
302if test $gdbsrv_cv_have_sync_builtins = yes; then
303 AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
304 [Define to 1 if the target supports __sync_*_compare_and_swap])
305fi
306
307dnl Check for -fvisibility=hidden support in the compiler.
308saved_cflags="$CFLAGS"
309CFLAGS="$CFLAGS -fvisibility=hidden"
310AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
311 [gdbsrv_cv_have_visibility_hidden=yes],
312 [gdbsrv_cv_have_visibility_hidden=no])
313CFLAGS="$saved_cflags"
314
315IPA_DEPFILES=""
316
317# Rather than allowing to build a broken IPA, we simply disable it if
318# we don't find a compiler supporting all the features we need.
319if test "$ipa_obj" != "" \
320 -a "$gdbsrv_cv_have_sync_builtins" = yes \
321 -a "$gdbsrv_cv_have_visibility_hidden" = yes; then
322 IPA_DEPFILES="$ipa_obj"
323 extra_libraries="libinproctrace.so"
324fi
325
7ea81414 326AC_SUBST(GDBSERVER_DEPFILES)
0d62e5e8
DJ
327AC_SUBST(GDBSERVER_LIBS)
328AC_SUBST(USE_THREAD_DB)
fb1e4ffc
DJ
329AC_SUBST(srv_xmlbuiltin)
330AC_SUBST(srv_xmlfiles)
fa593d66
PA
331AC_SUBST(IPA_DEPFILES)
332AC_SUBST(extra_libraries)
c906108c 333
c3a3ccc7
DJ
334AC_OUTPUT(Makefile,
335[case x$CONFIG_HEADERS in
336xconfig.h:config.in)
337echo > stamp-h ;;
338esac
339])
This page took 0.942943 seconds and 4 git commands to generate.