]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/gdbserver/configure.ac
gdbserver: Make `make TAGS' actually work
[thirdparty/binutils-gdb.git] / gdb / gdbserver / configure.ac
CommitLineData
d6e9fb05 1dnl Autoconf configure script for GDB server.
b811d2c2 2dnl Copyright (C) 2000-2020 Free Software Foundation, Inc.
d6e9fb05
JK
3dnl
4dnl This file is part of GDB.
5dnl
6dnl This program is free software; you can redistribute it and/or modify
7dnl it under the terms of the GNU General Public License as published by
5a0e3bd0 8dnl the Free Software Foundation; either version 3 of the License, or
d6e9fb05
JK
9dnl (at your option) any later version.
10dnl
11dnl This program is distributed in the hope that it will be useful,
12dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14dnl GNU General Public License for more details.
15dnl
16dnl You should have received a copy of the GNU General Public License
5a0e3bd0 17dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
d6e9fb05
JK
18
19dnl Process this file with autoconf to produce a configure script.
20
21AC_INIT(server.c)
c5adaa19 22AC_CONFIG_HEADERS(config.h:config.in, [echo > stamp-h])
c9a1864a
YQ
23
24AM_MAINTAINER_MODE
84563040
DJ
25
26AC_PROG_CC
3bc3d82a 27AC_PROG_CXX
fd462a61 28AC_GNU_SOURCE
589bc927 29AC_SYS_LARGEFILE
d6e9fb05
JK
30
31AC_CANONICAL_SYSTEM
84563040 32
d6e9fb05 33AC_PROG_INSTALL
e1d2394b 34AC_CHECK_TOOL(AR, ar)
c971b7fa 35AC_PROG_RANLIB
c906108c 36
dcdb98d2
DJ
37AC_ARG_PROGRAM
38
0bcda685
PA
39# We require a C++11 compiler. Check if one is available, and if
40# necessary, set CXX_DIALECT to some -std=xxx switch.
41AX_CXX_COMPILE_STDCXX(11, , mandatory)
42
ee6e2b82 43AC_HEADER_STDC
84563040 44
17ef446e 45# Set the 'development' global.
270c9937 46. $srcdir/../../bfd/development.sh
17ef446e 47
8ecfd7bd 48GDB_AC_SELFTEST([
268a13a5 49 srv_selftest_objs="gdbsupport/selftest.o"
8ecfd7bd 50])
6d580b63 51
bd885420
YQ
52ACX_NONCANONICAL_TARGET
53ACX_NONCANONICAL_HOST
54
61c125b9
TT
55# Dependency checking.
56ZW_CREATE_DEPDIR
60d6cfc9
YQ
57
58# Create sub-directories for objects and dependencies.
42cd72aa 59CONFIG_SRC_SUBDIR="arch gdbsupport nat target"
60d6cfc9
YQ
60AC_SUBST(CONFIG_SRC_SUBDIR)
61
62AC_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
61c125b9
TT
69ZW_PROG_COMPILER_DEPENDENCIES([CC])
70
648d586d
JB
71gnulib_extra_configure_args=
72# If large-file support is disabled, make sure gnulib does the same.
73if test "$enable_largefile" = no; then
74gnulib_extra_configure_args="$gnulib_extra_configure_args --disable-largefile"
75fi
76
c971b7fa
PA
77# Configure gnulib. We can't use AC_CONFIG_SUBDIRS as that'd expect
78# to find the the source subdir to be configured directly under
79# gdbserver/. We need to build gnulib under some other directory not
80# "gnulib", to avoid the problem of both GDB and GDBserver wanting to
81# build it in the same directory, when building in the source dir.
73cc7272 82ACX_CONFIGURE_DIR(["../../gnulib"], ["build-gnulib-gdbserver"],
648d586d 83 ["$gnulib_extra_configure_args"])
c971b7fa 84
0b04e523
TT
85ACX_CONFIGURE_DIR(["../../libiberty"], ["build-libiberty-gdbserver"])
86
726e1356 87AC_CHECK_HEADERS(termios.h sys/reg.h string.h dnl
05ea2a05 88 sys/procfs.h linux/elf.h dnl
9c232dda 89 fcntl.h signal.h sys/file.h dnl
80e24d09 90 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
1bd2f0ba 91 netinet/tcp.h arpa/inet.h)
eb0edac8 92AC_FUNC_FORK
05ea2a05 93AC_CHECK_FUNCS(pread pwrite pread64)
84563040 94
3266f10b
TT
95GDB_AC_COMMON
96
eb7aa561
PA
97# Check the return and argument types of ptrace.
98GDB_AC_PTRACE
99
0fb4aa4b
PA
100# Check for UST
101ustlibs=""
102ustinc=""
103
104AC_ARG_WITH(ust, [ --with-ust=PATH Specify prefix directory for the installed UST package
105 Equivalent to --with-ust-include=PATH/include
106 plus --with-ust-lib=PATH/lib])
107AC_ARG_WITH(ust_include, [ --with-ust-include=PATH Specify directory for installed UST include files])
108AC_ARG_WITH(ust_lib, [ --with-ust-lib=PATH Specify the directory for the installed UST library])
109
110case $with_ust in
111 no)
112 ustlibs=
113 ustinc=
114 ;;
115 "" | yes)
116 ustlibs=" -lust "
117 ustinc=""
118 ;;
119 *)
120 ustlibs="-L$with_ust/lib -lust"
121 ustinc="-I$with_ust/include "
122 ;;
123esac
124if test "x$with_ust_include" != x; then
125 ustinc="-I$with_ust_include "
126fi
127if test "x$with_ust_lib" != x; then
128 ustlibs="-L$with_ust_lib -lust"
129fi
130
131if test "x$with_ust" != "xno"; then
132 saved_CFLAGS="$CFLAGS"
133 CFLAGS="$CFLAGS $ustinc"
134 AC_MSG_CHECKING([for ust])
135 AC_TRY_COMPILE([
136#define CONFIG_UST_GDB_INTEGRATION
137#include <ust/ust.h>
138 ],[],
139 [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_UST, 1, [Define if UST is available])],
140 [AC_MSG_RESULT([no]); ustlibs= ; ustinc= ])
141 CFLAGS="$saved_CFLAGS"
142fi
143
144# Flags needed for UST
145AC_SUBST(ustlibs)
146AC_SUBST(ustinc)
147
8f13a3ce 148AM_GDB_WARNINGS
3bc3d82a 149
10e86dd7
DE
150dnl dladdr is glibc-specific. It is used by thread-db.c but only for
151dnl debugging messages. It lives in -ldl which is handled below so we don't
152dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily
153dnl augment LIBS.
154old_LIBS="$LIBS"
155LIBS="$LIBS -ldl"
156AC_CHECK_FUNCS(dladdr)
157LIBS="$old_LIBS"
158
07697489
PA
159libiberty_INIT
160
ab7d13f0 161AC_CHECK_DECLS([perror, vasprintf, vsnprintf])
43d5792c 162
239b6d10
WT
163# See if <sys/user.h> supports the %fs_base and %gs_bas amd64 segment registers.
164# Older amd64 Linux's don't have the fs_base and gs_base members of
165# `struct user_regs_struct'.
166AC_CHECK_MEMBERS([struct user_regs_struct.fs_base, struct user_regs_struct.gs_base],
f517c180
EA
167 [], [], [#include <sys/types.h>
168#include <sys/user.h>])
239b6d10
WT
169
170
ccbd4912
MK
171AC_CHECK_TYPES(socklen_t, [], [],
172[#include <sys/types.h>
173#include <sys/socket.h>
174])
fb1e4ffc 175
64da5dd5
JB
176case "${target}" in
177 *-android*)
178 # Starting with NDK version 9, <elf.h> actually includes definitions
179 # of Elf32_auxv_t and Elf64_auxv_t. But sadly, <elf.h> includes
180 # <sys/exec_elf.h> which defines some of the ELF types incorrectly,
181 # leading to conflicts with the defintions from <linux/elf.h>.
182 # This makes it impossible for us to include both <elf.h> and
183 # <linux/elf.h>, which means that, in practice, we do not have
184 # access to Elf32_auxv_t and Elf64_auxv_t on this platform.
185 # Therefore, do not try to auto-detect availability, as it would
186 # get it wrong on this platform.
187 ;;
188 *)
189 AC_CHECK_TYPES([Elf32_auxv_t, Elf64_auxv_t], [], [],
190 #include <elf.h>
191 )
192esac
8365dcf5 193
c16158bc
JM
194ACX_PKGVERSION([GDB])
195ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
196AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
197AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
198
8838b45e
NS
199# Check for various supplementary target information (beyond the
200# triplet) which might affect the choices in configure.srv.
201case "${target}" in
202changequote(,)dnl
203 i[34567]86-*-linux*)
204changequote([,])dnl
205 AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64],
206 [save_CPPFLAGS="$CPPFLAGS"
207 CPPFLAGS="$CPPFLAGS $CFLAGS"
208 AC_EGREP_CPP([got it], [
209#if __x86_64__
210got it
211#endif
212 ], [gdb_cv_i386_is_x86_64=yes],
213 [gdb_cv_i386_is_x86_64=no])
214 CPPFLAGS="$save_CPPFLAGS"])
215 ;;
201506da
PA
216
217 x86_64-*-linux*)
218 AC_CACHE_CHECK([if building for x32], [gdb_cv_x86_is_x32],
219 [save_CPPFLAGS="$CPPFLAGS"
220 CPPFLAGS="$CPPFLAGS $CFLAGS"
221 AC_EGREP_CPP([got it], [
222#if __x86_64__ && __ILP32__
223got it
224#endif
225 ], [gdb_cv_x86_is_x32=yes],
226 [gdb_cv_x86_is_x32=no])
227 CPPFLAGS="$save_CPPFLAGS"])
228 ;;
229
9ac544ce
MK
230 m68k-*-*)
231 AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire],
232 [save_CPPFLAGS="$CPPFLAGS"
233 CPPFLAGS="$CPPFLAGS $CFLAGS"
234 AC_EGREP_CPP([got it], [
235#ifdef __mcoldfire__
236got it
237#endif
238 ], [gdb_cv_m68k_is_coldfire=yes],
239 [gdb_cv_m68k_is_coldfire=no])
240 CPPFLAGS="$save_CPPFLAGS"])
241 ;;
8838b45e
NS
242esac
243
7ea81414 244. ${srcdir}/configure.srv
c906108c 245
68070c10
PA
246if test "${srv_mingwce}" = "yes"; then
247 LIBS="$LIBS -lws2"
248elif test "${srv_mingw}" = "yes"; then
b2ceabe8
TT
249 # WIN32APILIBS is set by GDB_AC_COMMON.
250 LIBS="$LIBS $WIN32APILIBS"
ac8c974e
AR
251elif test "${srv_qnx}" = "yes"; then
252 LIBS="$LIBS -lsocket"
8ed54b31
JB
253elif test "${srv_lynxos}" = "yes"; then
254 LIBS="$LIBS -lnetinet"
68070c10
PA
255fi
256
58caa3dc 257if test "${srv_linux_usrregs}" = "yes"; then
f450004a
DJ
258 AC_DEFINE(HAVE_LINUX_USRREGS, 1,
259 [Define if the target supports PTRACE_PEEKUSR for register ]
260 [access.])
58caa3dc
DJ
261fi
262
263if test "${srv_linux_regsets}" = "yes"; then
e9d25b98
DJ
264 AC_DEFINE(HAVE_LINUX_REGSETS, 1,
265 [Define if the target supports register sets.])
266
58caa3dc
DJ
267 AC_MSG_CHECKING(for PTRACE_GETREGS)
268 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
269 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
270 [PTRACE_GETREGS;],
271 [gdbsrv_cv_have_ptrace_getregs=yes],
272 [gdbsrv_cv_have_ptrace_getregs=no])])
273 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
274 if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
e9d25b98 275 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
f450004a
DJ
276 [Define if the target supports PTRACE_GETREGS for register ]
277 [access.])
58caa3dc
DJ
278 fi
279
280 AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
281 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
282 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
283 [PTRACE_GETFPXREGS;],
284 [gdbsrv_cv_have_ptrace_getfpxregs=yes],
285 [gdbsrv_cv_have_ptrace_getfpxregs=no])])
286 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
287 if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
f450004a
DJ
288 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
289 [Define if the target supports PTRACE_GETFPXREGS for extended ]
290 [register access.])
58caa3dc
DJ
291 fi
292fi
293
9accd112
MM
294if test "${srv_linux_btrace}" = "yes"; then
295 AC_DEFINE(HAVE_LINUX_BTRACE, 1,
296 [Define if the target supports branch tracing.])
297fi
298
18f5fd81
TJB
299dnl Some systems (e.g., Android) have lwpid_t defined in libthread_db.h.
300if test "$bfd_cv_have_sys_procfs_type_lwpid_t" != yes; then
301 GDBSERVER_HAVE_THREAD_DB_TYPE(lwpid_t)
302fi
303
304dnl Some systems (e.g., Android) have psaddr_t defined in libthread_db.h.
305if test "$bfd_cv_have_sys_procfs_type_psaddr_t" != yes; then
306 GDBSERVER_HAVE_THREAD_DB_TYPE(psaddr_t)
307fi
308
193f13e6
MK
309dnl Check for libdl, but do not add it to LIBS as only gdbserver
310dnl needs it (and gdbreplay doesn't).
311old_LIBS="$LIBS"
312AC_CHECK_LIB(dl, dlopen)
313LIBS="$old_LIBS"
314
0d62e5e8
DJ
315srv_thread_depfiles=
316srv_libs=
0d62e5e8
DJ
317
318if test "$srv_linux_thread_db" = "yes"; then
193f13e6
MK
319 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
320 srv_libs="-ldl"
f6528abd 321 AC_MSG_CHECKING(for the dynamic export flag)
193f13e6 322 old_LDFLAGS="$LDFLAGS"
f6528abd
JK
323 # Older GNU ld supports --export-dynamic but --dynamic-list may not be
324 # supported there.
325 RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
326 LDFLAGS="$LDFLAGS $RDYNAMIC"
327 AC_TRY_LINK([], [],
328 [found="-Wl,--dynamic-list"
329 RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
330 [RDYNAMIC="-rdynamic"
331 LDFLAGS="$old_LDFLAGS $RDYNAMIC"
332 AC_TRY_LINK([], [],
333 [found="-rdynamic"],
334 [found="no"
335 RDYNAMIC=""])])
193f13e6
MK
336 AC_SUBST(RDYNAMIC)
337 LDFLAGS="$old_LDFLAGS"
f6528abd 338 AC_MSG_RESULT($found)
193f13e6
MK
339 else
340 srv_libs="-lthread_db"
341 fi
0d62e5e8 342
0d62e5e8 343 srv_thread_depfiles="thread-db.o proc-service.o"
7d4e5717 344 AC_DEFINE(USE_THREAD_DB, 1, [Define if we should use libthread_db.])
3db0444b
DJ
345 AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
346 [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
1b3f6016
PA
347 [gdbsrv_cv_have_td_version=yes],
348 [gdbsrv_cv_have_td_version=no])])
0ad6b8ee 349 if test "$gdbsrv_cv_have_td_version" = yes; then
3db0444b
DJ
350 AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
351 fi
0d62e5e8
DJ
352fi
353
96f15937
PP
354AC_ARG_WITH(libthread-db,
355AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
356[srv_libthread_db_path="${withval}"
96f15937
PP
357 srv_libs="$srv_libthread_db_path"
358])
359
193f13e6
MK
360if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
361 AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
362fi
363
9b4b61c8 364if test "$srv_xmlfiles" != ""; then
fb1e4ffc
DJ
365 srv_xmlbuiltin="xml-builtin.o"
366 AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
367
368 tmp_xmlfiles=$srv_xmlfiles
9b4b61c8 369 srv_xmlfiles=""
fb1e4ffc
DJ
370 for f in $tmp_xmlfiles; do
371 srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
372 done
373fi
374
cd850b40 375GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles $srv_selftest_objs"
0d62e5e8 376GDBSERVER_LIBS="$srv_libs"
c906108c 377
fa593d66
PA
378dnl Check whether the target supports __sync_*_compare_and_swap.
379AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
380 gdbsrv_cv_have_sync_builtins, [
381AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
382 gdbsrv_cv_have_sync_builtins=yes,
383 gdbsrv_cv_have_sync_builtins=no)])
0ad6b8ee 384if test "$gdbsrv_cv_have_sync_builtins" = yes; then
fa593d66
PA
385 AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
386 [Define to 1 if the target supports __sync_*_compare_and_swap])
387fi
388
389dnl Check for -fvisibility=hidden support in the compiler.
390saved_cflags="$CFLAGS"
391CFLAGS="$CFLAGS -fvisibility=hidden"
d0ac1c44 392AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
fa593d66
PA
393 [gdbsrv_cv_have_visibility_hidden=yes],
394 [gdbsrv_cv_have_visibility_hidden=no])
395CFLAGS="$saved_cflags"
396
397IPA_DEPFILES=""
c2a66c29 398extra_libraries=""
fa593d66 399
c2a66c29 400# check whether to enable the inprocess agent
fa593d66
PA
401if test "$ipa_obj" != "" \
402 -a "$gdbsrv_cv_have_sync_builtins" = yes \
403 -a "$gdbsrv_cv_have_visibility_hidden" = yes; then
c2a66c29
NS
404 have_ipa=true
405else
406 have_ipa=false
407fi
408
409AC_ARG_ENABLE(inprocess-agent,
410AS_HELP_STRING([--enable-inprocess-agent], [inprocess agent]),
411[case "$enableval" in
412 yes) want_ipa=true ;;
413 no) want_ipa=false ;;
414 *) AC_MSG_ERROR([bad value $enableval for inprocess-agent]) ;;
415esac],
416[want_ipa=$have_ipa])
417
418if $want_ipa ; then
419 if $have_ipa ; then
420 IPA_DEPFILES="$ipa_obj"
421 extra_libraries="$extra_libraries libinproctrace.so"
422 else
423 AC_MSG_ERROR([inprocess agent not supported for this target])
424 fi
fa593d66
PA
425fi
426
7ea81414 427AC_SUBST(GDBSERVER_DEPFILES)
0d62e5e8 428AC_SUBST(GDBSERVER_LIBS)
fb1e4ffc
DJ
429AC_SUBST(srv_xmlbuiltin)
430AC_SUBST(srv_xmlfiles)
fa593d66
PA
431AC_SUBST(IPA_DEPFILES)
432AC_SUBST(extra_libraries)
c906108c 433
c971b7fa 434GNULIB=build-gnulib-gdbserver/import
c9a1864a
YQ
435
436GNULIB_STDINT_H=
437if test x"$STDINT_H" != x; then
c971b7fa 438 GNULIB_STDINT_H=$GNULIB/$STDINT_H
c9a1864a
YQ
439fi
440AC_SUBST(GNULIB_STDINT_H)
441
c5adaa19 442AC_CONFIG_FILES([Makefile])
1e94266c
SM
443
444AC_OUTPUT