Debian Codegraph @

gdbserver/configure.ac

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