]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdbsupport/common.m4
Automatic Copyright Year update after running gdb/copyright.py
[thirdparty/binutils-gdb.git] / gdbsupport / common.m4
1 dnl Autoconf configure snippets for common.
2 dnl Copyright (C) 1995-2022 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 Invoke configury needed by the files in 'common'.
20 AC_DEFUN([GDB_AC_COMMON], [
21 # Set the 'development' global.
22 . $srcdir/../bfd/development.sh
23
24 AC_HEADER_STDC
25 AC_FUNC_ALLOCA
26
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
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
44 sys/resource.h sys/socket.h dnl
45 sys/un.h sys/wait.h dnl
46 thread_db.h wait.h dnl
47 termios.h dnl
48 dlfcn.h dnl
49 linux/elf.h proc_service.h dnl
50 poll.h sys/poll.h sys/select.h)
51
52 AC_FUNC_MMAP
53 AC_FUNC_FORK
54 AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 poll socketpair sigaction \
55 ptrace64 sbrk setns sigaltstack sigprocmask \
56 setpgid setpgrp getrusage getauxval sigtimedwait])
57
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
63 AC_CHECK_DECLS([strstr])
64
65 # ----------------------- #
66 # Checks for structures. #
67 # ----------------------- #
68
69 AC_CHECK_MEMBERS([struct stat.st_blocks, struct stat.st_blksize])
70
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)
78
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
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])
96 if test "$threads" = "yes"; then
97 save_LIBS="$LIBS"
98 LIBS="$PTHREAD_LIBS $LIBS"
99 save_CXXFLAGS="$CXXFLAGS"
100 CXXFLAGS="$PTHREAD_CFLAGS $save_CXXFLAGS"
101 AC_CACHE_CHECK([for std::thread],
102 gdb_cv_cxx_std_thread,
103 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
104 [[#include <thread>
105 void callback() { }]],
106 [[std::thread t(callback);]])],
107 gdb_cv_cxx_std_thread=yes,
108 gdb_cv_cxx_std_thread=no)])
109
110 # This check must be here, while LIBS includes any necessary
111 # threading library.
112 AC_CHECK_FUNCS([pthread_sigmask pthread_setname_np])
113
114 LIBS="$save_LIBS"
115 CXXFLAGS="$save_CXXFLAGS"
116 fi
117
118 if test "$want_threading" = "yes"; then
119 if test "$gdb_cv_cxx_std_thread" = "yes"; then
120 AC_DEFINE(CXX_STD_THREAD, 1,
121 [Define to 1 if std::thread works.])
122 fi
123 fi
124 AC_LANG_POP
125
126 dnl Check if sigsetjmp is available. Using AC_CHECK_FUNCS won't
127 dnl do since sigsetjmp might only be defined as a macro.
128 AC_CACHE_CHECK(
129 [for sigsetjmp],
130 [gdb_cv_func_sigsetjmp],
131 [AC_COMPILE_IFELSE(
132 [AC_LANG_PROGRAM(
133 [#include <setjmp.h>],
134 [sigjmp_buf env;
135 while (! sigsetjmp (env, 1))
136 siglongjmp (env, 1);]
137 )],
138 [gdb_cv_func_sigsetjmp=yes],
139 [gdb_cv_func_sigsetjmp=no]
140 )]
141 )
142 if test "$gdb_cv_func_sigsetjmp" = "yes"; then
143 AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ])
144 fi
145
146 AC_ARG_WITH(intel_pt,
147 AS_HELP_STRING([--with-intel-pt], [include Intel Processor Trace support (auto/yes/no)]),
148 [], [with_intel_pt=auto])
149 AC_MSG_CHECKING([whether to use intel pt])
150 AC_MSG_RESULT([$with_intel_pt])
151
152 if test "${with_intel_pt}" = no; then
153 AC_MSG_WARN([Intel Processor Trace support disabled; some features may be unavailable.])
154 HAVE_LIBIPT=no
155 else
156 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
157 #include <linux/perf_event.h>
158 #ifndef PERF_ATTR_SIZE_VER5
159 # error
160 #endif
161 ]])], [perf_event=yes], [perf_event=no])
162 if test "$perf_event" != yes; then
163 if test "$with_intel_pt" = yes; then
164 AC_MSG_ERROR([linux/perf_event.h missing or too old])
165 else
166 AC_MSG_WARN([linux/perf_event.h missing or too old; some features may be unavailable.])
167 fi
168 fi
169
170 AC_LIB_HAVE_LINKFLAGS([ipt], [], [#include "intel-pt.h"], [pt_insn_alloc_decoder (0);])
171 if test "$HAVE_LIBIPT" != yes; then
172 if test "$with_intel_pt" = yes; then
173 AC_MSG_ERROR([libipt is missing or unusable])
174 else
175 AC_MSG_WARN([libipt is missing or unusable; some features may be unavailable.])
176 fi
177 else
178 save_LIBS=$LIBS
179 LIBS="$LIBS $LIBIPT"
180 AC_CHECK_FUNCS(pt_insn_event)
181 AC_CHECK_MEMBERS([struct pt_insn.enabled, struct pt_insn.resynced], [], [],
182 [#include <intel-pt.h>])
183 LIBS=$save_LIBS
184 fi
185 fi
186
187 # Check if the compiler and runtime support printing long longs.
188
189 AC_CACHE_CHECK([for long long support in printf],
190 gdb_cv_printf_has_long_long,
191 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
192 [[char buf[32];
193 long long l = 0;
194 l = (l << 16) + 0x0123;
195 l = (l << 16) + 0x4567;
196 l = (l << 16) + 0x89ab;
197 l = (l << 16) + 0xcdef;
198 sprintf (buf, "0x%016llx", l);
199 return (strcmp ("0x0123456789abcdef", buf));]])],
200 gdb_cv_printf_has_long_long=yes,
201 gdb_cv_printf_has_long_long=no,
202 gdb_cv_printf_has_long_long=no)])
203 if test "$gdb_cv_printf_has_long_long" = yes; then
204 AC_DEFINE(PRINTF_HAS_LONG_LONG, 1,
205 [Define to 1 if the "%ll" format works to print long longs.])
206 fi
207
208 BFD_SYS_PROCFS_H
209 if test "$ac_cv_header_sys_procfs_h" = yes; then
210 BFD_HAVE_SYS_PROCFS_TYPE(gregset_t)
211 BFD_HAVE_SYS_PROCFS_TYPE(fpregset_t)
212 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
213 BFD_HAVE_SYS_PROCFS_TYPE(prfpregset_t)
214 BFD_HAVE_SYS_PROCFS_TYPE(prgregset32_t)
215 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
216 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
217 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
218 fi
219 ])