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