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