1 dnl Autoconf configure snippets for common.
2 dnl Copyright (C) 1995-2020 Free Software Foundation, Inc.
4 dnl This file is part of GDB.
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.
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.
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/>.
19 dnl Invoke configury needed by the files in 'common'.
20 AC_DEFUN([GDB_AC_COMMON], [
21 # Set the 'development' global.
22 . $srcdir/../bfd/development.sh
30 AC_DEFINE(USE_WIN32API, 1,
31 [Define if we should use the Windows API, instead of the
32 POSIX API. On Windows, we use the Windows API when
33 building for MinGW, but the POSIX API when building
35 WIN32APILIBS="-lws2_32"
39 dnl Note that this requires codeset.m4, which is included
40 dnl by the users of common.m4.
43 AC_CHECK_HEADERS(linux/perf_event.h locale.h memory.h signal.h dnl
44 sys/resource.h sys/socket.h dnl
45 sys/un.h sys/wait.h dnl
46 thread_db.h wait.h dnl
49 linux/elf.h proc_service.h dnl
50 poll.h sys/poll.h sys/select.h)
54 AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 poll socketpair sigaction \
55 ptrace64 sbrk setns sigaltstack sigprocmask \
56 setpgid setpgrp getrusage getauxval])
58 dnl Check if we can disable the virtual address space randomization.
59 dnl The functionality of setarch -R.
60 AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
61 define([PERSONALITY_TEST], [AC_LANG_PROGRAM([#include <sys/personality.h>], [
62 # if !HAVE_DECL_ADDR_NO_RANDOMIZE
63 # define ADDR_NO_RANDOMIZE 0x0040000
65 /* Test the flag could be set and stays set. */
66 personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
67 if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
69 AC_RUN_IFELSE([PERSONALITY_TEST],
70 [have_personality=true],
71 [have_personality=false],
72 [AC_LINK_IFELSE([PERSONALITY_TEST],
73 [have_personality=true],
74 [have_personality=false])])
77 AC_DEFINE([HAVE_PERSONALITY], 1,
78 [Define if you support the personality syscall.])
81 AC_CHECK_DECLS([strstr])
83 # ----------------------- #
84 # Checks for structures. #
85 # ----------------------- #
87 AC_CHECK_MEMBERS([struct stat.st_blocks, struct stat.st_blksize])
89 # On FreeBSD we need libutil for the kinfo_get* functions. On
90 # GNU/kFreeBSD systems, FreeBSD libutil is renamed to libutil-freebsd.
91 # Figure out which one to use.
92 AC_SEARCH_LIBS(kinfo_getfile, util util-freebsd)
94 # Define HAVE_KINFO_GETFILE if kinfo_getfile is available.
95 AC_CHECK_FUNCS(kinfo_getfile)
97 # Check for std::thread. This does not work on some platforms, like
100 AX_PTHREAD([threads=yes], [threads=no])
101 if test "$threads" = "yes"; then
103 LIBS="$PTHREAD_LIBS $LIBS"
104 save_CXXFLAGS="$CXXFLAGS"
105 CXXFLAGS="$PTHREAD_CFLAGS $save_CXXFLAGS"
106 AC_CACHE_CHECK([for std::thread],
107 gdb_cv_cxx_std_thread,
108 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
110 void callback() { }]],
111 [[std::thread t(callback);]])],
112 gdb_cv_cxx_std_thread=yes,
113 gdb_cv_cxx_std_thread=no)])
115 # This check must be here, while LIBS includes any necessary
117 AC_CHECK_FUNCS([pthread_sigmask pthread_setname_np])
120 CXXFLAGS="$save_CXXFLAGS"
122 if test "$gdb_cv_cxx_std_thread" = "yes"; then
123 AC_DEFINE(CXX_STD_THREAD, 1,
124 [Define to 1 if std::thread works.])
128 dnl Check if sigsetjmp is available. Using AC_CHECK_FUNCS won't
129 dnl do since sigsetjmp might only be defined as a macro.
132 [gdb_cv_func_sigsetjmp],
135 [#include <setjmp.h>],
137 while (! sigsetjmp (env, 1))
138 siglongjmp (env, 1);]
140 [gdb_cv_func_sigsetjmp=yes],
141 [gdb_cv_func_sigsetjmp=no]
144 if test "$gdb_cv_func_sigsetjmp" = "yes"; then
145 AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ])
148 AC_ARG_WITH(intel_pt,
149 AS_HELP_STRING([--with-intel-pt], [include Intel Processor Trace support (auto/yes/no)]),
150 [], [with_intel_pt=auto])
151 AC_MSG_CHECKING([whether to use intel pt])
152 AC_MSG_RESULT([$with_intel_pt])
154 if test "${with_intel_pt}" = no; then
155 AC_MSG_WARN([Intel Processor Trace support disabled; some features may be unavailable.])
158 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
159 #include <linux/perf_event.h>
160 #ifndef PERF_ATTR_SIZE_VER5
163 ]])], [perf_event=yes], [perf_event=no])
164 if test "$perf_event" != yes; then
165 if test "$with_intel_pt" = yes; then
166 AC_MSG_ERROR([linux/perf_event.h missing or too old])
168 AC_MSG_WARN([linux/perf_event.h missing or too old; some features may be unavailable.])
172 AC_LIB_HAVE_LINKFLAGS([ipt], [], [#include "intel-pt.h"], [pt_insn_alloc_decoder (0);])
173 if test "$HAVE_LIBIPT" != yes; then
174 if test "$with_intel_pt" = yes; then
175 AC_MSG_ERROR([libipt is missing or unusable])
177 AC_MSG_WARN([libipt is missing or unusable; some features may be unavailable.])
182 AC_CHECK_FUNCS(pt_insn_event)
183 AC_CHECK_MEMBERS([struct pt_insn.enabled, struct pt_insn.resynced], [], [],
184 [#include <intel-pt.h>])
190 if test "$ac_cv_header_sys_procfs_h" = yes; then
191 BFD_HAVE_SYS_PROCFS_TYPE(gregset_t)
192 BFD_HAVE_SYS_PROCFS_TYPE(fpregset_t)
193 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
194 BFD_HAVE_SYS_PROCFS_TYPE(prfpregset_t)
195 BFD_HAVE_SYS_PROCFS_TYPE(prgregset32_t)
196 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
197 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
198 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)