include alloca.h if available.
[deliverable/binutils-gdb.git] / gdb / gdbserver / configure.ac
1 dnl Autoconf configure script for GDB server.
2 dnl Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
3 dnl 2010 Free Software Foundation, Inc.
4 dnl
5 dnl This file is part of GDB.
6 dnl
7 dnl This program is free software; you can redistribute it and/or modify
8 dnl it under the terms of the GNU General Public License as published by
9 dnl the Free Software Foundation; either version 3 of the License, or
10 dnl (at your option) any later version.
11 dnl
12 dnl This program is distributed in the hope that it will be useful,
13 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 dnl GNU General Public License for more details.
16 dnl
17 dnl You should have received a copy of the GNU General Public License
18 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 dnl Process this file with autoconf to produce a configure script.
21
22 AC_PREREQ(2.59)dnl
23
24 AC_INIT(server.c)
25 AC_CONFIG_HEADER(config.h:config.in)
26 AC_CONFIG_LIBOBJ_DIR(../gnulib)
27
28 AC_PROG_CC
29 AC_GNU_SOURCE
30
31 AC_CANONICAL_SYSTEM
32
33 AC_PROG_INSTALL
34
35 AC_ARG_PROGRAM
36
37 AC_HEADER_STDC
38
39 AC_FUNC_ALLOCA
40 AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
41 proc_service.h sys/procfs.h thread_db.h linux/elf.h dnl
42 stdlib.h unistd.h dnl
43 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
44 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
45 netinet/tcp.h arpa/inet.h sys/wait.h)
46 AC_CHECK_FUNCS(pread pwrite pread64)
47 AC_REPLACE_FUNCS(memmem)
48
49 # Check for UST
50 ustlibs=""
51 ustinc=""
52
53 AC_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])
56 AC_ARG_WITH(ust_include, [ --with-ust-include=PATH Specify directory for installed UST include files])
57 AC_ARG_WITH(ust_lib, [ --with-ust-lib=PATH Specify the directory for the installed UST library])
58
59 case $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 ;;
72 esac
73 if test "x$with_ust_include" != x; then
74 ustinc="-I$with_ust_include "
75 fi
76 if test "x$with_ust_lib" != x; then
77 ustlibs="-L$with_ust_lib -lust"
78 fi
79
80 if 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"
91 fi
92
93 # Flags needed for UST
94 AC_SUBST(ustlibs)
95 AC_SUBST(ustinc)
96
97 AC_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
106 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
107 ERROR_ON_WARNING=yes
108 fi
109
110 WERROR_CFLAGS=""
111 if test "${ERROR_ON_WARNING}" = yes ; then
112 WERROR_CFLAGS="-Werror"
113 fi
114
115 build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
116 -Wformat-nonliteral -Wno-char-subscripts"
117
118 WARN_CFLAGS=""
119 if test "x$GCC" = xyes
120 then
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})
135 fi
136 AC_SUBST(WARN_CFLAGS)
137 AC_SUBST(WERROR_CFLAGS)
138
139 dnl dladdr is glibc-specific. It is used by thread-db.c but only for
140 dnl debugging messages. It lives in -ldl which is handled below so we don't
141 dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily
142 dnl augment LIBS.
143 old_LIBS="$LIBS"
144 LIBS="$LIBS -ldl"
145 AC_CHECK_FUNCS(dladdr)
146 LIBS="$old_LIBS"
147
148 have_errno=no
149 AC_MSG_CHECKING(for errno)
150 AC_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])
155 if test $have_errno = no; then
156 AC_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)])
162 fi
163
164 AC_CHECK_DECLS([strerror, perror, memmem])
165
166 AC_CHECK_TYPES(socklen_t, [], [],
167 [#include <sys/types.h>
168 #include <sys/socket.h>
169 ])
170
171 ACX_PKGVERSION([GDB])
172 ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
173 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
174 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
175
176 # Check for various supplementary target information (beyond the
177 # triplet) which might affect the choices in configure.srv.
178 case "${target}" in
179 changequote(,)dnl
180 i[34567]86-*-linux*)
181 changequote([,])dnl
182 AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64],
183 [save_CPPFLAGS="$CPPFLAGS"
184 CPPFLAGS="$CPPFLAGS $CFLAGS"
185 AC_EGREP_CPP([got it], [
186 #if __x86_64__
187 got it
188 #endif
189 ], [gdb_cv_i386_is_x86_64=yes],
190 [gdb_cv_i386_is_x86_64=no])
191 CPPFLAGS="$save_CPPFLAGS"])
192 ;;
193 m68k-*-*)
194 AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire],
195 [save_CPPFLAGS="$CPPFLAGS"
196 CPPFLAGS="$CPPFLAGS $CFLAGS"
197 AC_EGREP_CPP([got it], [
198 #ifdef __mcoldfire__
199 got it
200 #endif
201 ], [gdb_cv_m68k_is_coldfire=yes],
202 [gdb_cv_m68k_is_coldfire=no])
203 CPPFLAGS="$save_CPPFLAGS"])
204 ;;
205 esac
206
207 . ${srcdir}/configure.srv
208
209 if test "${srv_mingwce}" = "yes"; then
210 LIBS="$LIBS -lws2"
211 elif test "${srv_mingw}" = "yes"; then
212 LIBS="$LIBS -lws2_32"
213 elif test "${srv_qnx}" = "yes"; then
214 LIBS="$LIBS -lsocket"
215 fi
216
217 if test "${srv_mingw}" = "yes"; then
218 AC_DEFINE(USE_WIN32API, 1,
219 [Define if we should use the Windows API, instead of the
220 POSIX API. On Windows, we use the Windows API when
221 building for MinGW, but the POSIX API when building
222 for Cygwin.])
223 fi
224
225 if test "${srv_linux_usrregs}" = "yes"; then
226 AC_DEFINE(HAVE_LINUX_USRREGS, 1,
227 [Define if the target supports PTRACE_PEEKUSR for register ]
228 [access.])
229 fi
230
231 if test "${srv_linux_regsets}" = "yes"; then
232 AC_DEFINE(HAVE_LINUX_REGSETS, 1,
233 [Define if the target supports register sets.])
234
235 AC_MSG_CHECKING(for PTRACE_GETREGS)
236 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
237 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
238 [PTRACE_GETREGS;],
239 [gdbsrv_cv_have_ptrace_getregs=yes],
240 [gdbsrv_cv_have_ptrace_getregs=no])])
241 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
242 if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
243 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
244 [Define if the target supports PTRACE_GETREGS for register ]
245 [access.])
246 fi
247
248 AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
249 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
250 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
251 [PTRACE_GETFPXREGS;],
252 [gdbsrv_cv_have_ptrace_getfpxregs=yes],
253 [gdbsrv_cv_have_ptrace_getfpxregs=no])])
254 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
255 if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
256 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
257 [Define if the target supports PTRACE_GETFPXREGS for extended ]
258 [register access.])
259 fi
260 fi
261
262 if test "$ac_cv_header_sys_procfs_h" = yes; then
263 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
264 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
265 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
266 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
267 fi
268
269 dnl Check for libdl, but do not add it to LIBS as only gdbserver
270 dnl needs it (and gdbreplay doesn't).
271 old_LIBS="$LIBS"
272 AC_CHECK_LIB(dl, dlopen)
273 LIBS="$old_LIBS"
274
275 srv_thread_depfiles=
276 srv_libs=
277 USE_THREAD_DB=
278
279 if test "$srv_linux_thread_db" = "yes"; then
280 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
281 srv_libs="-ldl"
282 AC_MSG_CHECKING(for the dynamic export flag)
283 old_LDFLAGS="$LDFLAGS"
284 # Older GNU ld supports --export-dynamic but --dynamic-list may not be
285 # supported there.
286 RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
287 LDFLAGS="$LDFLAGS $RDYNAMIC"
288 AC_TRY_LINK([], [],
289 [found="-Wl,--dynamic-list"
290 RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
291 [RDYNAMIC="-rdynamic"
292 LDFLAGS="$old_LDFLAGS $RDYNAMIC"
293 AC_TRY_LINK([], [],
294 [found="-rdynamic"],
295 [found="no"
296 RDYNAMIC=""])])
297 AC_SUBST(RDYNAMIC)
298 LDFLAGS="$old_LDFLAGS"
299 AC_MSG_RESULT($found)
300 else
301 srv_libs="-lthread_db"
302 fi
303
304 srv_thread_depfiles="thread-db.o proc-service.o"
305 USE_THREAD_DB="-DUSE_THREAD_DB"
306 AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
307 [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
308 [gdbsrv_cv_have_td_version=yes],
309 [gdbsrv_cv_have_td_version=no])])
310 if test $gdbsrv_cv_have_td_version = yes; then
311 AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
312 fi
313 fi
314
315 AC_ARG_WITH(libthread-db,
316 AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
317 [srv_libthread_db_path="${withval}"
318 srv_libs="$srv_libthread_db_path"
319 ])
320
321 if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
322 AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
323 fi
324
325 if test "$srv_xmlfiles" != ""; then
326 srv_xmlbuiltin="xml-builtin.o"
327 AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
328
329 tmp_xmlfiles=$srv_xmlfiles
330 srv_xmlfiles=""
331 for f in $tmp_xmlfiles; do
332 srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
333 done
334 fi
335
336 GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles"
337 GDBSERVER_LIBS="$srv_libs"
338
339 dnl Check whether the target supports __sync_*_compare_and_swap.
340 AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
341 gdbsrv_cv_have_sync_builtins, [
342 AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
343 gdbsrv_cv_have_sync_builtins=yes,
344 gdbsrv_cv_have_sync_builtins=no)])
345 if test $gdbsrv_cv_have_sync_builtins = yes; then
346 AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
347 [Define to 1 if the target supports __sync_*_compare_and_swap])
348 fi
349
350 dnl Check for -fvisibility=hidden support in the compiler.
351 saved_cflags="$CFLAGS"
352 CFLAGS="$CFLAGS -fvisibility=hidden"
353 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
354 [gdbsrv_cv_have_visibility_hidden=yes],
355 [gdbsrv_cv_have_visibility_hidden=no])
356 CFLAGS="$saved_cflags"
357
358 IPA_DEPFILES=""
359
360 # Rather than allowing to build a broken IPA, we simply disable it if
361 # we don't find a compiler supporting all the features we need.
362 if test "$ipa_obj" != "" \
363 -a "$gdbsrv_cv_have_sync_builtins" = yes \
364 -a "$gdbsrv_cv_have_visibility_hidden" = yes; then
365 IPA_DEPFILES="$ipa_obj"
366 extra_libraries="libinproctrace.so"
367 fi
368
369 AC_SUBST(GDBSERVER_DEPFILES)
370 AC_SUBST(GDBSERVER_LIBS)
371 AC_SUBST(USE_THREAD_DB)
372 AC_SUBST(srv_xmlbuiltin)
373 AC_SUBST(srv_xmlfiles)
374 AC_SUBST(IPA_DEPFILES)
375 AC_SUBST(extra_libraries)
376
377 AC_OUTPUT(Makefile,
378 [case x$CONFIG_HEADERS in
379 xconfig.h:config.in)
380 echo > stamp-h ;;
381 esac
382 ])
This page took 0.036938 seconds and 4 git commands to generate.