]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdbsupport/common.m4
Do not cast away const in agent_run_command
[thirdparty/binutils-gdb.git] / gdbsupport / common.m4
CommitLineData
3266f10b 1dnl Autoconf configure snippets for common.
213516ef 2dnl Copyright (C) 1995-2023 Free Software Foundation, Inc.
3266f10b
TT
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
8dnl the Free Software Foundation; either version 3 of the License, or
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
17dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19dnl Invoke configury needed by the files in 'common'.
20AC_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 \
f4931779 56 setpgid setpgrp getrusage getauxval sigtimedwait])
05ea2a05 57
0b03c6f0
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
261b0748
LM
79 # ----------------------- #
80 # Check for threading. #
81 # ----------------------- #
82
83 AC_ARG_ENABLE(threading,
84 AS_HELP_STRING([--enable-threading], [include support for parallel processing of data (yes/no)]),
85 [case "$enableval" in
86 yes) want_threading=yes ;;
87 no) want_threading=no ;;
88 *) AC_MSG_ERROR([bad value $enableval for threading]) ;;
89 esac],
90 [want_threading=yes])
91
5e030278
TT
92 # Check for std::thread. This does not work on some platforms, like
93 # mingw and DJGPP.
94 AC_LANG_PUSH([C++])
95 AX_PTHREAD([threads=yes], [threads=no])
c560a5fb
TT
96 save_LIBS="$LIBS"
97 LIBS="$PTHREAD_LIBS $LIBS"
98 save_CXXFLAGS="$CXXFLAGS"
99 CXXFLAGS="$PTHREAD_CFLAGS $save_CXXFLAGS"
100 AC_CACHE_CHECK([for std::thread],
101 gdb_cv_cxx_std_thread,
102 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
2124b2de
TT
103 dnl NOTE: this must be kept in sync with common-defs.h.
104 [[#if defined (__MINGW32__) || defined (__CYGWIN__)
105 # ifdef _WIN32_WINNT
106 # if _WIN32_WINNT < 0x0501
107 # undef _WIN32_WINNT
108 # define _WIN32_WINNT 0x0501
109 # endif
110 # else
111 # define _WIN32_WINNT 0x0501
112 # endif
113 #endif /* __MINGW32__ || __CYGWIN__ */
114 #include <thread>
c560a5fb
TT
115 void callback() { }]],
116 [[std::thread t(callback);]])],
117 gdb_cv_cxx_std_thread=yes,
118 gdb_cv_cxx_std_thread=no)])
21987b9c 119
c560a5fb 120 if test "$threads" = "yes"; then
21987b9c
TT
121 # This check must be here, while LIBS includes any necessary
122 # threading library.
4da8c3a8 123 AC_CHECK_FUNCS([pthread_sigmask pthread_setname_np])
5e030278 124 fi
c560a5fb
TT
125 LIBS="$save_LIBS"
126 CXXFLAGS="$save_CXXFLAGS"
261b0748
LM
127
128 if test "$want_threading" = "yes"; then
129 if test "$gdb_cv_cxx_std_thread" = "yes"; then
130 AC_DEFINE(CXX_STD_THREAD, 1,
131 [Define to 1 if std::thread works.])
132 fi
5e030278
TT
133 fi
134 AC_LANG_POP
135
e9bcb658
GB
136 dnl Check if sigsetjmp is available. Using AC_CHECK_FUNCS won't
137 dnl do since sigsetjmp might only be defined as a macro.
b9442ec1
SM
138 AC_CACHE_CHECK(
139 [for sigsetjmp],
140 [gdb_cv_func_sigsetjmp],
141 [AC_COMPILE_IFELSE(
142 [AC_LANG_PROGRAM(
143 [#include <setjmp.h>],
144 [sigjmp_buf env;
145 while (! sigsetjmp (env, 1))
146 siglongjmp (env, 1);]
147 )],
148 [gdb_cv_func_sigsetjmp=yes],
149 [gdb_cv_func_sigsetjmp=no]
150 )]
151 )
25c51f71
TT
152 if test "$gdb_cv_func_sigsetjmp" = "yes"; then
153 AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ])
154 fi
05ea2a05
TT
155
156 AC_ARG_WITH(intel_pt,
157 AS_HELP_STRING([--with-intel-pt], [include Intel Processor Trace support (auto/yes/no)]),
158 [], [with_intel_pt=auto])
159 AC_MSG_CHECKING([whether to use intel pt])
160 AC_MSG_RESULT([$with_intel_pt])
161
162 if test "${with_intel_pt}" = no; then
163 AC_MSG_WARN([Intel Processor Trace support disabled; some features may be unavailable.])
164 HAVE_LIBIPT=no
165 else
166 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
167 #include <linux/perf_event.h>
168 #ifndef PERF_ATTR_SIZE_VER5
169 # error
170 #endif
171 ]])], [perf_event=yes], [perf_event=no])
172 if test "$perf_event" != yes; then
173 if test "$with_intel_pt" = yes; then
174 AC_MSG_ERROR([linux/perf_event.h missing or too old])
175 else
176 AC_MSG_WARN([linux/perf_event.h missing or too old; some features may be unavailable.])
177 fi
178 fi
179
180 AC_LIB_HAVE_LINKFLAGS([ipt], [], [#include "intel-pt.h"], [pt_insn_alloc_decoder (0);])
181 if test "$HAVE_LIBIPT" != yes; then
182 if test "$with_intel_pt" = yes; then
183 AC_MSG_ERROR([libipt is missing or unusable])
184 else
185 AC_MSG_WARN([libipt is missing or unusable; some features may be unavailable.])
186 fi
187 else
188 save_LIBS=$LIBS
189 LIBS="$LIBS $LIBIPT"
190 AC_CHECK_FUNCS(pt_insn_event)
191 AC_CHECK_MEMBERS([struct pt_insn.enabled, struct pt_insn.resynced], [], [],
192 [#include <intel-pt.h>])
193 LIBS=$save_LIBS
194 fi
195 fi
196
5dfe4bfc
TT
197 # Check if the compiler and runtime support printing long longs.
198
199 AC_CACHE_CHECK([for long long support in printf],
200 gdb_cv_printf_has_long_long,
201 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
202 [[char buf[32];
203 long long l = 0;
204 l = (l << 16) + 0x0123;
205 l = (l << 16) + 0x4567;
206 l = (l << 16) + 0x89ab;
207 l = (l << 16) + 0xcdef;
208 sprintf (buf, "0x%016llx", l);
209 return (strcmp ("0x0123456789abcdef", buf));]])],
210 gdb_cv_printf_has_long_long=yes,
211 gdb_cv_printf_has_long_long=no,
212 gdb_cv_printf_has_long_long=no)])
213 if test "$gdb_cv_printf_has_long_long" = yes; then
214 AC_DEFINE(PRINTF_HAS_LONG_LONG, 1,
215 [Define to 1 if the "%ll" format works to print long longs.])
216 fi
217
c8693053 218 BFD_SYS_PROCFS_H
05ea2a05
TT
219 if test "$ac_cv_header_sys_procfs_h" = yes; then
220 BFD_HAVE_SYS_PROCFS_TYPE(gregset_t)
221 BFD_HAVE_SYS_PROCFS_TYPE(fpregset_t)
222 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
223 BFD_HAVE_SYS_PROCFS_TYPE(prfpregset_t)
224 BFD_HAVE_SYS_PROCFS_TYPE(prgregset32_t)
225 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
226 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
227 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
228 fi
8b35ed1f
SM
229
230 dnl xxhash support
231 # Check for xxhash
232 AC_ARG_WITH(xxhash,
233 AS_HELP_STRING([--with-xxhash], [use libxxhash for hashing (faster) (auto/yes/no)]),
234 [], [with_xxhash=auto])
235
236 if test "x$with_xxhash" != "xno"; then
237 AC_LIB_HAVE_LINKFLAGS([xxhash], [],
238 [#include <xxhash.h>],
239 [XXH32("foo", 3, 0);
240 ])
241 if test "$HAVE_LIBXXHASH" != yes; then
242 if test "$with_xxhash" = yes; then
243 AC_MSG_ERROR([xxhash is missing or unusable])
244 fi
245 fi
246 if test "x$with_xxhash" = "xauto"; then
247 with_xxhash="$HAVE_LIBXXHASH"
248 fi
249 fi
250
251 AC_MSG_CHECKING([whether to use xxhash])
252 AC_MSG_RESULT([$with_xxhash])
3266f10b 253])
4fd404c2
SM
254
255dnl Check that the provided value ($1) is either "yes" or "no". If not,
256dnl emit an error message mentionning the configure option $2, and abort
257dnl the script.
258AC_DEFUN([GDB_CHECK_YES_NO_VAL],
259 [
260 case $1 in
261 yes | no)
262 ;;
263 *)
264 AC_MSG_ERROR([bad value $1 for $2])
265 ;;
266 esac
267 ])
268
269dnl Check that the provided value ($1) is either "yes", "no" or "auto". If not,
270dnl emit an error message mentionning the configure option $2, and abort
271dnl the script.
272AC_DEFUN([GDB_CHECK_YES_NO_AUTO_VAL],
273 [
274 case $1 in
275 yes | no | auto)
276 ;;
277 *)
278 AC_MSG_ERROR([bad value $1 for $2])
279 ;;
280 esac
281 ])