Commit | Line | Data |
---|---|---|
3266f10b | 1 | dnl Autoconf configure snippets for common. |
88b9d363 | 2 | dnl Copyright (C) 1995-2022 Free Software Foundation, Inc. |
3266f10b TT |
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 Invoke configury needed by the files in 'common'. | |
20 | AC_DEFUN([GDB_AC_COMMON], [ | |
db6878ac SM |
21 | # Set the 'development' global. |
22 | . $srcdir/../bfd/development.sh | |
23 | ||
3266f10b | 24 | AC_HEADER_STDC |
3266f10b TT |
25 | AC_FUNC_ALLOCA |
26 | ||
b2ceabe8 TT |
27 | WIN32APILIBS= |
28 | case ${host} in | |
29 | *mingw32*) | |
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 | |
34 | for Cygwin.]) | |
35 | WIN32APILIBS="-lws2_32" | |
36 | ;; | |
37 | esac | |
38 | ||
3266f10b TT |
39 | dnl Note that this requires codeset.m4, which is included |
40 | dnl by the users of common.m4. | |
41 | AM_LANGINFO_CODESET | |
42 | ||
43 | AC_CHECK_HEADERS(linux/perf_event.h locale.h memory.h signal.h dnl | |
44122162 | 44 | sys/resource.h sys/socket.h dnl |
3266f10b | 45 | sys/un.h sys/wait.h dnl |
be628ab8 | 46 | thread_db.h wait.h dnl |
2d41fa11 | 47 | termios.h dnl |
05ea2a05 | 48 | dlfcn.h dnl |
c8693053 | 49 | linux/elf.h proc_service.h dnl |
8ae8e197 | 50 | poll.h sys/poll.h sys/select.h) |
3266f10b | 51 | |
05ea2a05 | 52 | AC_FUNC_MMAP |
15dabc52 | 53 | AC_FUNC_FORK |
8ae8e197 | 54 | AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 poll socketpair sigaction \ |
05ea2a05 | 55 | ptrace64 sbrk setns sigaltstack sigprocmask \ |
507af45f | 56 | setpgid setpgrp getrusage getauxval sigtimedwait]) |
05ea2a05 | 57 | |
df9ebc47 TT |
58 | # This is needed for RHEL 5 and uclibc-ng < 1.0.39. |
59 | # These did not define ADDR_NO_RANDOMIZE in sys/personality.h, | |
60 | # only in linux/personality.h. | |
61 | AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>]) | |
62 | ||
ab7d13f0 | 63 | AC_CHECK_DECLS([strstr]) |
e9bcb658 | 64 | |
05ea2a05 TT |
65 | # ----------------------- # |
66 | # Checks for structures. # | |
67 | # ----------------------- # | |
68 | ||
69 | AC_CHECK_MEMBERS([struct stat.st_blocks, struct stat.st_blksize]) | |
70 | ||
e911c666 JB |
71 | # On FreeBSD we need libutil for the kinfo_get* functions. On |
72 | # GNU/kFreeBSD systems, FreeBSD libutil is renamed to libutil-freebsd. | |
73 | # Figure out which one to use. | |
74 | AC_SEARCH_LIBS(kinfo_getfile, util util-freebsd) | |
75 | ||
76 | # Define HAVE_KINFO_GETFILE if kinfo_getfile is available. | |
77 | AC_CHECK_FUNCS(kinfo_getfile) | |
05ea2a05 | 78 | |
5e030278 TT |
79 | # Check for std::thread. This does not work on some platforms, like |
80 | # mingw and DJGPP. | |
81 | AC_LANG_PUSH([C++]) | |
82 | AX_PTHREAD([threads=yes], [threads=no]) | |
83 | if test "$threads" = "yes"; then | |
84 | save_LIBS="$LIBS" | |
85 | LIBS="$PTHREAD_LIBS $LIBS" | |
86 | save_CXXFLAGS="$CXXFLAGS" | |
87 | CXXFLAGS="$PTHREAD_CFLAGS $save_CXXFLAGS" | |
88 | AC_CACHE_CHECK([for std::thread], | |
89 | gdb_cv_cxx_std_thread, | |
90 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( | |
91 | [[#include <thread> | |
92 | void callback() { }]], | |
93 | [[std::thread t(callback);]])], | |
94 | gdb_cv_cxx_std_thread=yes, | |
95 | gdb_cv_cxx_std_thread=no)]) | |
21987b9c TT |
96 | |
97 | # This check must be here, while LIBS includes any necessary | |
98 | # threading library. | |
4da8c3a8 | 99 | AC_CHECK_FUNCS([pthread_sigmask pthread_setname_np]) |
21987b9c | 100 | |
5e030278 TT |
101 | LIBS="$save_LIBS" |
102 | CXXFLAGS="$save_CXXFLAGS" | |
103 | fi | |
0ad6b8ee | 104 | if test "$gdb_cv_cxx_std_thread" = "yes"; then |
5e030278 TT |
105 | AC_DEFINE(CXX_STD_THREAD, 1, |
106 | [Define to 1 if std::thread works.]) | |
107 | fi | |
108 | AC_LANG_POP | |
109 | ||
e9bcb658 GB |
110 | dnl Check if sigsetjmp is available. Using AC_CHECK_FUNCS won't |
111 | dnl do since sigsetjmp might only be defined as a macro. | |
b9442ec1 SM |
112 | AC_CACHE_CHECK( |
113 | [for sigsetjmp], | |
114 | [gdb_cv_func_sigsetjmp], | |
115 | [AC_COMPILE_IFELSE( | |
116 | [AC_LANG_PROGRAM( | |
117 | [#include <setjmp.h>], | |
118 | [sigjmp_buf env; | |
119 | while (! sigsetjmp (env, 1)) | |
120 | siglongjmp (env, 1);] | |
121 | )], | |
122 | [gdb_cv_func_sigsetjmp=yes], | |
123 | [gdb_cv_func_sigsetjmp=no] | |
124 | )] | |
125 | ) | |
25c51f71 TT |
126 | if test "$gdb_cv_func_sigsetjmp" = "yes"; then |
127 | AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ]) | |
128 | fi | |
05ea2a05 TT |
129 | |
130 | AC_ARG_WITH(intel_pt, | |
131 | AS_HELP_STRING([--with-intel-pt], [include Intel Processor Trace support (auto/yes/no)]), | |
132 | [], [with_intel_pt=auto]) | |
133 | AC_MSG_CHECKING([whether to use intel pt]) | |
134 | AC_MSG_RESULT([$with_intel_pt]) | |
135 | ||
136 | if test "${with_intel_pt}" = no; then | |
137 | AC_MSG_WARN([Intel Processor Trace support disabled; some features may be unavailable.]) | |
138 | HAVE_LIBIPT=no | |
139 | else | |
140 | AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ | |
141 | #include <linux/perf_event.h> | |
142 | #ifndef PERF_ATTR_SIZE_VER5 | |
143 | # error | |
144 | #endif | |
145 | ]])], [perf_event=yes], [perf_event=no]) | |
146 | if test "$perf_event" != yes; then | |
147 | if test "$with_intel_pt" = yes; then | |
148 | AC_MSG_ERROR([linux/perf_event.h missing or too old]) | |
149 | else | |
150 | AC_MSG_WARN([linux/perf_event.h missing or too old; some features may be unavailable.]) | |
151 | fi | |
152 | fi | |
153 | ||
154 | AC_LIB_HAVE_LINKFLAGS([ipt], [], [#include "intel-pt.h"], [pt_insn_alloc_decoder (0);]) | |
155 | if test "$HAVE_LIBIPT" != yes; then | |
156 | if test "$with_intel_pt" = yes; then | |
157 | AC_MSG_ERROR([libipt is missing or unusable]) | |
158 | else | |
159 | AC_MSG_WARN([libipt is missing or unusable; some features may be unavailable.]) | |
160 | fi | |
161 | else | |
162 | save_LIBS=$LIBS | |
163 | LIBS="$LIBS $LIBIPT" | |
164 | AC_CHECK_FUNCS(pt_insn_event) | |
165 | AC_CHECK_MEMBERS([struct pt_insn.enabled, struct pt_insn.resynced], [], [], | |
166 | [#include <intel-pt.h>]) | |
167 | LIBS=$save_LIBS | |
168 | fi | |
169 | fi | |
170 | ||
c8693053 | 171 | BFD_SYS_PROCFS_H |
05ea2a05 TT |
172 | if test "$ac_cv_header_sys_procfs_h" = yes; then |
173 | BFD_HAVE_SYS_PROCFS_TYPE(gregset_t) | |
174 | BFD_HAVE_SYS_PROCFS_TYPE(fpregset_t) | |
175 | BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t) | |
176 | BFD_HAVE_SYS_PROCFS_TYPE(prfpregset_t) | |
177 | BFD_HAVE_SYS_PROCFS_TYPE(prgregset32_t) | |
178 | BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t) | |
179 | BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t) | |
180 | BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t) | |
181 | fi | |
3266f10b | 182 | ]) |