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