db9d45715efb2dd765b5cd5728e87adf838f81d1
[deliverable/binutils-gdb.git] / gdbserver / configure.ac
1 dnl Autoconf configure script for GDB server.
2 dnl Copyright (C) 2000-2020 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_INIT(server.cc)
22 AC_CONFIG_HEADERS(config.h:config.in, [echo > stamp-h])
23
24 AM_MAINTAINER_MODE
25
26 AC_PROG_CC
27 AC_PROG_CXX
28 AC_GNU_SOURCE
29 AC_SYS_LARGEFILE
30 AM_PROG_INSTALL_STRIP
31
32 AC_CANONICAL_SYSTEM
33
34 AC_PROG_INSTALL
35 AC_CHECK_TOOL(AR, ar)
36 AC_PROG_RANLIB
37
38 AC_ARG_PROGRAM
39
40 # We require a C++11 compiler. Check if one is available, and if
41 # necessary, set CXX_DIALECT to some -std=xxx switch.
42 AX_CXX_COMPILE_STDCXX(11, , mandatory)
43
44 AC_HEADER_STDC
45
46 GDB_AC_COMMON
47
48 GDB_AC_SELFTEST([
49 srv_selftest_objs="gdbsupport/selftest.o"
50 ])
51
52 ACX_NONCANONICAL_TARGET
53 ACX_NONCANONICAL_HOST
54
55 # Dependency checking.
56 ZW_CREATE_DEPDIR
57
58 # Create sub-directories for objects and dependencies.
59 CONFIG_SRC_SUBDIR="arch gdbsupport nat target"
60 AC_SUBST(CONFIG_SRC_SUBDIR)
61
62 AC_CONFIG_COMMANDS([gdbdepdir],[
63 for subdir in ${CONFIG_SRC_SUBDIR}
64 do
65 $SHELL $ac_aux_dir/mkinstalldirs $subdir/$DEPDIR
66 done],
67 [ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR CONFIG_SRC_SUBDIR="$CONFIG_SRC_SUBDIR"])
68
69 ZW_PROG_COMPILER_DEPENDENCIES([CC])
70
71 AC_CHECK_HEADERS(termios.h sys/reg.h string.h dnl
72 sys/procfs.h linux/elf.h dnl
73 fcntl.h signal.h sys/file.h dnl
74 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
75 netinet/tcp.h arpa/inet.h)
76 AC_FUNC_FORK
77 AC_CHECK_FUNCS(pread pwrite pread64)
78
79 # Check the return and argument types of ptrace.
80 GDB_AC_PTRACE
81
82 # Check for UST
83 ustlibs=""
84 ustinc=""
85
86 AC_ARG_WITH(ust, [ --with-ust=PATH Specify prefix directory for the installed UST package
87 Equivalent to --with-ust-include=PATH/include
88 plus --with-ust-lib=PATH/lib])
89 AC_ARG_WITH(ust_include, [ --with-ust-include=PATH Specify directory for installed UST include files])
90 AC_ARG_WITH(ust_lib, [ --with-ust-lib=PATH Specify the directory for the installed UST library])
91
92 case $with_ust in
93 no)
94 ustlibs=
95 ustinc=
96 ;;
97 "" | yes)
98 ustlibs=" -lust "
99 ustinc=""
100 ;;
101 *)
102 ustlibs="-L$with_ust/lib -lust"
103 ustinc="-I$with_ust/include "
104 ;;
105 esac
106 if test "x$with_ust_include" != x; then
107 ustinc="-I$with_ust_include "
108 fi
109 if test "x$with_ust_lib" != x; then
110 ustlibs="-L$with_ust_lib -lust"
111 fi
112
113 if test "x$with_ust" != "xno"; then
114 saved_CFLAGS="$CFLAGS"
115 CFLAGS="$CFLAGS $ustinc"
116 AC_MSG_CHECKING([for ust])
117 AC_TRY_COMPILE([
118 #define CONFIG_UST_GDB_INTEGRATION
119 #include <ust/ust.h>
120 ],[],
121 [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_UST, 1, [Define if UST is available])],
122 [AC_MSG_RESULT([no]); ustlibs= ; ustinc= ])
123 CFLAGS="$saved_CFLAGS"
124 fi
125
126 # Flags needed for UST
127 AC_SUBST(ustlibs)
128 AC_SUBST(ustinc)
129
130 AM_GDB_WARNINGS
131
132 dnl dladdr is glibc-specific. It is used by thread-db.c but only for
133 dnl debugging messages. It lives in -ldl which is handled below so we don't
134 dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily
135 dnl augment LIBS.
136 old_LIBS="$LIBS"
137 LIBS="$LIBS -ldl"
138 AC_CHECK_FUNCS(dladdr)
139 LIBS="$old_LIBS"
140
141 libiberty_INIT
142
143 AC_CHECK_DECLS([perror, vasprintf, vsnprintf])
144
145 # See if <sys/user.h> supports the %fs_base and %gs_bas amd64 segment registers.
146 # Older amd64 Linux's don't have the fs_base and gs_base members of
147 # `struct user_regs_struct'.
148 AC_CHECK_MEMBERS([struct user_regs_struct.fs_base, struct user_regs_struct.gs_base],
149 [], [], [#include <sys/types.h>
150 #include <sys/user.h>])
151
152
153 AC_CHECK_TYPES(socklen_t, [], [],
154 [#include <sys/types.h>
155 #include <sys/socket.h>
156 ])
157
158 case "${target}" in
159 *-android*)
160 # Starting with NDK version 9, <elf.h> actually includes definitions
161 # of Elf32_auxv_t and Elf64_auxv_t. But sadly, <elf.h> includes
162 # <sys/exec_elf.h> which defines some of the ELF types incorrectly,
163 # leading to conflicts with the defintions from <linux/elf.h>.
164 # This makes it impossible for us to include both <elf.h> and
165 # <linux/elf.h>, which means that, in practice, we do not have
166 # access to Elf32_auxv_t and Elf64_auxv_t on this platform.
167 # Therefore, do not try to auto-detect availability, as it would
168 # get it wrong on this platform.
169 ;;
170 *)
171 AC_CHECK_TYPES([Elf32_auxv_t, Elf64_auxv_t], [], [],
172 #include <elf.h>
173 )
174 esac
175
176 ACX_PKGVERSION([GDB])
177 ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
178 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
179 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
180
181 # Check for various supplementary target information (beyond the
182 # triplet) which might affect the choices in configure.srv.
183 case "${target}" in
184 changequote(,)dnl
185 i[34567]86-*-linux*)
186 changequote([,])dnl
187 AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64],
188 [save_CPPFLAGS="$CPPFLAGS"
189 CPPFLAGS="$CPPFLAGS $CFLAGS"
190 AC_EGREP_CPP([got it], [
191 #if __x86_64__
192 got it
193 #endif
194 ], [gdb_cv_i386_is_x86_64=yes],
195 [gdb_cv_i386_is_x86_64=no])
196 CPPFLAGS="$save_CPPFLAGS"])
197 ;;
198
199 x86_64-*-linux*)
200 AC_CACHE_CHECK([if building for x32], [gdb_cv_x86_is_x32],
201 [save_CPPFLAGS="$CPPFLAGS"
202 CPPFLAGS="$CPPFLAGS $CFLAGS"
203 AC_EGREP_CPP([got it], [
204 #if __x86_64__ && __ILP32__
205 got it
206 #endif
207 ], [gdb_cv_x86_is_x32=yes],
208 [gdb_cv_x86_is_x32=no])
209 CPPFLAGS="$save_CPPFLAGS"])
210 ;;
211
212 m68k-*-*)
213 AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire],
214 [save_CPPFLAGS="$CPPFLAGS"
215 CPPFLAGS="$CPPFLAGS $CFLAGS"
216 AC_EGREP_CPP([got it], [
217 #ifdef __mcoldfire__
218 got it
219 #endif
220 ], [gdb_cv_m68k_is_coldfire=yes],
221 [gdb_cv_m68k_is_coldfire=no])
222 CPPFLAGS="$save_CPPFLAGS"])
223 ;;
224 esac
225
226 . ${srcdir}/configure.srv
227
228 if test "${srv_mingwce}" = "yes"; then
229 LIBS="$LIBS -lws2"
230 elif test "${srv_mingw}" = "yes"; then
231 # WIN32APILIBS is set by GDB_AC_COMMON.
232 LIBS="$LIBS $WIN32APILIBS"
233 elif test "${srv_qnx}" = "yes"; then
234 LIBS="$LIBS -lsocket"
235 elif test "${srv_lynxos}" = "yes"; then
236 LIBS="$LIBS -lnetinet"
237 fi
238
239 if test "${srv_linux_usrregs}" = "yes"; then
240 AC_DEFINE(HAVE_LINUX_USRREGS, 1,
241 [Define if the target supports PTRACE_PEEKUSR for register ]
242 [access.])
243 fi
244
245 if test "${srv_linux_regsets}" = "yes"; then
246 AC_DEFINE(HAVE_LINUX_REGSETS, 1,
247 [Define if the target supports register sets.])
248
249 AC_MSG_CHECKING(for PTRACE_GETREGS)
250 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
251 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
252 [PTRACE_GETREGS;],
253 [gdbsrv_cv_have_ptrace_getregs=yes],
254 [gdbsrv_cv_have_ptrace_getregs=no])])
255 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
256 if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
257 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
258 [Define if the target supports PTRACE_GETREGS for register ]
259 [access.])
260 fi
261
262 AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
263 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
264 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
265 [PTRACE_GETFPXREGS;],
266 [gdbsrv_cv_have_ptrace_getfpxregs=yes],
267 [gdbsrv_cv_have_ptrace_getfpxregs=no])])
268 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
269 if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
270 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
271 [Define if the target supports PTRACE_GETFPXREGS for extended ]
272 [register access.])
273 fi
274 fi
275
276 if test "${srv_linux_btrace}" = "yes"; then
277 AC_DEFINE(HAVE_LINUX_BTRACE, 1,
278 [Define if the target supports branch tracing.])
279 fi
280
281 dnl Some systems (e.g., Android) have lwpid_t defined in libthread_db.h.
282 if test "$bfd_cv_have_sys_procfs_type_lwpid_t" != yes; then
283 GDBSERVER_HAVE_THREAD_DB_TYPE(lwpid_t)
284 fi
285
286 dnl Some systems (e.g., Android) have psaddr_t defined in libthread_db.h.
287 if test "$bfd_cv_have_sys_procfs_type_psaddr_t" != yes; then
288 GDBSERVER_HAVE_THREAD_DB_TYPE(psaddr_t)
289 fi
290
291 dnl Check for libdl, but do not add it to LIBS as only gdbserver
292 dnl needs it (and gdbreplay doesn't).
293 old_LIBS="$LIBS"
294 AC_CHECK_LIB(dl, dlopen)
295 LIBS="$old_LIBS"
296
297 srv_thread_depfiles=
298 srv_libs=
299
300 if test "$srv_linux_thread_db" = "yes"; then
301 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
302 srv_libs="-ldl"
303 AC_MSG_CHECKING(for the dynamic export flag)
304 old_LDFLAGS="$LDFLAGS"
305 # Older GNU ld supports --export-dynamic but --dynamic-list may not be
306 # supported there.
307 RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
308 LDFLAGS="$LDFLAGS $RDYNAMIC"
309 AC_TRY_LINK([], [],
310 [found="-Wl,--dynamic-list"
311 RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
312 [RDYNAMIC="-rdynamic"
313 LDFLAGS="$old_LDFLAGS $RDYNAMIC"
314 AC_TRY_LINK([], [],
315 [found="-rdynamic"],
316 [found="no"
317 RDYNAMIC=""])])
318 AC_SUBST(RDYNAMIC)
319 LDFLAGS="$old_LDFLAGS"
320 AC_MSG_RESULT($found)
321 else
322 srv_libs="-lthread_db"
323 fi
324
325 srv_thread_depfiles="thread-db.o proc-service.o"
326 AC_DEFINE(USE_THREAD_DB, 1, [Define if we should use libthread_db.])
327 AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
328 [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
329 [gdbsrv_cv_have_td_version=yes],
330 [gdbsrv_cv_have_td_version=no])])
331 if test "$gdbsrv_cv_have_td_version" = yes; then
332 AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
333 fi
334 fi
335
336 AC_ARG_WITH(libthread-db,
337 AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
338 [srv_libthread_db_path="${withval}"
339 srv_libs="$srv_libthread_db_path"
340 ])
341
342 if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
343 AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
344 fi
345
346 if test "$srv_xmlfiles" != ""; then
347 srv_xmlbuiltin="xml-builtin.o"
348 AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
349
350 tmp_xmlfiles=$srv_xmlfiles
351 srv_xmlfiles=""
352 for f in $tmp_xmlfiles; do
353 srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
354 done
355 fi
356
357 GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles $srv_selftest_objs"
358 GDBSERVER_LIBS="$srv_libs"
359
360 dnl Check whether the target supports __sync_*_compare_and_swap.
361 AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
362 gdbsrv_cv_have_sync_builtins, [
363 AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
364 gdbsrv_cv_have_sync_builtins=yes,
365 gdbsrv_cv_have_sync_builtins=no)])
366 if test "$gdbsrv_cv_have_sync_builtins" = yes; then
367 AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
368 [Define to 1 if the target supports __sync_*_compare_and_swap])
369 fi
370
371 dnl Check for -fvisibility=hidden support in the compiler.
372 saved_cflags="$CFLAGS"
373 CFLAGS="$CFLAGS -fvisibility=hidden"
374 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
375 [gdbsrv_cv_have_visibility_hidden=yes],
376 [gdbsrv_cv_have_visibility_hidden=no])
377 CFLAGS="$saved_cflags"
378
379 IPA_DEPFILES=""
380 extra_libraries=""
381
382 # check whether to enable the inprocess agent
383 if test "$ipa_obj" != "" \
384 -a "$gdbsrv_cv_have_sync_builtins" = yes \
385 -a "$gdbsrv_cv_have_visibility_hidden" = yes; then
386 have_ipa=true
387 else
388 have_ipa=false
389 fi
390
391 AC_ARG_ENABLE(inprocess-agent,
392 AS_HELP_STRING([--enable-inprocess-agent], [inprocess agent]),
393 [case "$enableval" in
394 yes) want_ipa=true ;;
395 no) want_ipa=false ;;
396 *) AC_MSG_ERROR([bad value $enableval for inprocess-agent]) ;;
397 esac],
398 [want_ipa=$have_ipa])
399
400 if $want_ipa ; then
401 if $have_ipa ; then
402 IPA_DEPFILES="$ipa_obj"
403 extra_libraries="$extra_libraries libinproctrace.so"
404 else
405 AC_MSG_ERROR([inprocess agent not supported for this target])
406 fi
407 fi
408
409 AC_SUBST(GDBSERVER_DEPFILES)
410 AC_SUBST(GDBSERVER_LIBS)
411 AC_SUBST(srv_xmlbuiltin)
412 AC_SUBST(srv_xmlfiles)
413 AC_SUBST(IPA_DEPFILES)
414 AC_SUBST(extra_libraries)
415
416 GNULIB=../gnulib/import
417
418 GNULIB_STDINT_H=
419 if test x"$STDINT_H" != x; then
420 GNULIB_STDINT_H=$GNULIB/$STDINT_H
421 fi
422 AC_SUBST(GNULIB_STDINT_H)
423
424 AC_CONFIG_FILES([Makefile])
425
426 AC_OUTPUT
This page took 0.049704 seconds and 4 git commands to generate.