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