1dnl Autoconf configure snippets for common. 2dnl Copyright (C) 1995-2024 Free Software Foundation, Inc. 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], [ 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 # Some systems (e.g. Solaris) have `socketpair' in libsocket. 55 AC_SEARCH_LIBS(socketpair, socket) 56 AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 poll socketpair sigaction \ 57 ptrace64 sbrk setns sigaltstack sigprocmask \ 58 setpgid setpgrp getrusage getauxval sigtimedwait]) 59 60 # This is needed for RHEL 5 and uclibc-ng < 1.0.39. 61 # These did not define ADDR_NO_RANDOMIZE in sys/personality.h, 62 # only in linux/personality.h. 63 AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>]) 64 65 AC_CHECK_DECLS([strstr]) 66 67 # ----------------------- # 68 # Checks for structures. # 69 # ----------------------- # 70 71 AC_CHECK_MEMBERS([struct stat.st_blocks, struct stat.st_blksize]) 72 73 # On FreeBSD we need libutil for the kinfo_get* functions. On 74 # GNU/kFreeBSD systems, FreeBSD libutil is renamed to libutil-freebsd. 75 # Figure out which one to use. 76 AC_SEARCH_LIBS(kinfo_getfile, util util-freebsd) 77 78 # Define HAVE_KINFO_GETFILE if kinfo_getfile is available. 79 AC_CHECK_FUNCS(kinfo_getfile) 80 81 # ----------------------- # 82 # Check for threading. # 83 # ----------------------- # 84 85 AC_ARG_ENABLE(threading, 86 AS_HELP_STRING([--enable-threading], [include support for parallel processing of data (yes/no)]), 87 [case "$enableval" in 88 yes) want_threading=yes ;; 89 no) want_threading=no ;; 90 *) AC_MSG_ERROR([bad value $enableval for threading]) ;; 91 esac], 92 [want_threading=auto]) 93 94 # Check for std::thread. This does not work on some platforms, like 95 # mingw using the win32 threads model with gcc older than 13, and 96 # DJGPP. 97 AC_LANG_PUSH([C++]) 98 AX_PTHREAD([threads=yes], [threads=no]) 99 save_LIBS="$LIBS" 100 LIBS="$PTHREAD_LIBS $LIBS" 101 save_CXXFLAGS="$CXXFLAGS" 102 CXXFLAGS="$PTHREAD_CFLAGS $save_CXXFLAGS" 103 AC_CACHE_CHECK([for std::thread], 104 gdb_cv_cxx_std_thread, 105 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 106 dnl NOTE: this must be kept in sync with common-defs.h. 107 [[#if defined (__MINGW32__) || defined (__CYGWIN__) 108 # ifdef _WIN32_WINNT 109 # if _WIN32_WINNT < 0x0501 110 # undef _WIN32_WINNT 111 # define _WIN32_WINNT 0x0501 112 # endif 113 # else 114 # define _WIN32_WINNT 0x0501 115 # endif 116 #endif /* __MINGW32__ || __CYGWIN__ */ 117 #include <thread> 118 #include <mutex> 119 void callback() { }]], 120 [[std::thread t(callback);]])], 121 gdb_cv_cxx_std_thread=yes, 122 gdb_cv_cxx_std_thread=no)]) 123 124 if test "$threads" = "yes"; then 125 # This check must be here, while LIBS includes any necessary 126 # threading library. 127 AC_CHECK_FUNCS([pthread_sigmask pthread_setname_np]) 128 fi 129 LIBS="$save_LIBS" 130 CXXFLAGS="$save_CXXFLAGS" 131 132 if test "$want_threading" != "no"; then 133 if test "$gdb_cv_cxx_std_thread" = "yes"; then 134 AC_DEFINE(CXX_STD_THREAD, 1, 135 [Define to 1 if std::thread works.]) 136 else 137 if test "$want_threading" = "yes"; then 138 AC_MSG_ERROR([std::thread does not work; disable threading]) 139 else 140 AC_MSG_WARN([std::thread does not work; disabling threading]) 141 fi 142 fi 143 fi 144 AC_LANG_POP 145 146 dnl Check if sigsetjmp is available. Using AC_CHECK_FUNCS won't 147 dnl do since sigsetjmp might only be defined as a macro. 148 AC_CACHE_CHECK( 149 [for sigsetjmp], 150 [gdb_cv_func_sigsetjmp], 151 [AC_COMPILE_IFELSE( 152 [AC_LANG_PROGRAM( 153 [#include <setjmp.h>], 154 [sigjmp_buf env; 155 while (! sigsetjmp (env, 1)) 156 siglongjmp (env, 1);] 157 )], 158 [gdb_cv_func_sigsetjmp=yes], 159 [gdb_cv_func_sigsetjmp=no] 160 )] 161 ) 162 if test "$gdb_cv_func_sigsetjmp" = "yes"; then 163 AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ]) 164 fi 165 166 AC_ARG_WITH(intel_pt, 167 AS_HELP_STRING([--with-intel-pt], [include Intel Processor Trace support (auto/yes/no)]), 168 [], [with_intel_pt=auto]) 169 AC_MSG_CHECKING([whether to use intel pt]) 170 AC_MSG_RESULT([$with_intel_pt]) 171 172 if test "${with_intel_pt}" = no; then 173 AC_MSG_WARN([Intel Processor Trace support disabled; some features may be unavailable.]) 174 HAVE_LIBIPT=no 175 else 176 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ 177 #include <linux/perf_event.h> 178 #ifndef PERF_ATTR_SIZE_VER5 179 # error 180 #endif 181 ]])], [perf_event=yes], [perf_event=no]) 182 if test "$perf_event" != yes; then 183 if test "$with_intel_pt" = yes; then 184 AC_MSG_ERROR([linux/perf_event.h missing or too old]) 185 else 186 AC_MSG_WARN([linux/perf_event.h missing or too old; some features may be unavailable.]) 187 fi 188 fi 189 190 AC_LIB_HAVE_LINKFLAGS([ipt], [], [#include "intel-pt.h"], [pt_insn_alloc_decoder (0);]) 191 if test "$HAVE_LIBIPT" != yes; then 192 if test "$with_intel_pt" = yes; then 193 AC_MSG_ERROR([libipt is missing or unusable]) 194 else 195 AC_MSG_WARN([libipt is missing or unusable; some features may be unavailable.]) 196 fi 197 else 198 save_LIBS=$LIBS 199 LIBS="$LIBS $LIBIPT" 200 AC_CHECK_FUNCS(pt_insn_event) 201 AC_CHECK_MEMBERS([struct pt_insn.enabled, struct pt_insn.resynced], [], [], 202 [#include <intel-pt.h>]) 203 LIBS=$save_LIBS 204 fi 205 fi 206 207 # Check if the compiler and runtime support printing long longs. 208 209 AC_CACHE_CHECK([for long long support in printf], 210 gdb_cv_printf_has_long_long, 211 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], 212 [[char buf[32]; 213 long long l = 0; 214 l = (l << 16) + 0x0123; 215 l = (l << 16) + 0x4567; 216 l = (l << 16) + 0x89ab; 217 l = (l << 16) + 0xcdef; 218 sprintf (buf, "0x%016llx", l); 219 return (strcmp ("0x0123456789abcdef", buf));]])], 220 gdb_cv_printf_has_long_long=yes, 221 gdb_cv_printf_has_long_long=no, 222 gdb_cv_printf_has_long_long=no)]) 223 if test "$gdb_cv_printf_has_long_long" = yes; then 224 AC_DEFINE(PRINTF_HAS_LONG_LONG, 1, 225 [Define to 1 if the "%ll" format works to print long longs.]) 226 fi 227 228 BFD_SYS_PROCFS_H 229 if test "$ac_cv_header_sys_procfs_h" = yes; then 230 BFD_HAVE_SYS_PROCFS_TYPE(gregset_t) 231 BFD_HAVE_SYS_PROCFS_TYPE(fpregset_t) 232 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t) 233 BFD_HAVE_SYS_PROCFS_TYPE(prfpregset_t) 234 BFD_HAVE_SYS_PROCFS_TYPE(prgregset32_t) 235 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t) 236 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t) 237 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t) 238 fi 239 240 dnl xxhash support 241 # Check for xxhash 242 AC_ARG_WITH(xxhash, 243 AS_HELP_STRING([--with-xxhash], [use libxxhash for hashing (faster) (auto/yes/no)]), 244 [], [with_xxhash=auto]) 245 246 if test "x$with_xxhash" != "xno"; then 247 AC_LIB_HAVE_LINKFLAGS([xxhash], [], 248 [#include <xxhash.h>], 249 [XXH32("foo", 3, 0); 250 ]) 251 if test "$HAVE_LIBXXHASH" != yes; then 252 if test "$with_xxhash" = yes; then 253 AC_MSG_ERROR([xxhash is missing or unusable]) 254 fi 255 fi 256 if test "x$with_xxhash" = "xauto"; then 257 with_xxhash="$HAVE_LIBXXHASH" 258 fi 259 fi 260 261 AC_MSG_CHECKING([whether to use xxhash]) 262 AC_MSG_RESULT([$with_xxhash]) 263]) 264 265dnl Check that the provided value ($1) is either "yes" or "no". If not, 266dnl emit an error message mentionning the configure option $2, and abort 267dnl the script. 268AC_DEFUN([GDB_CHECK_YES_NO_VAL], 269 [ 270 case $1 in 271 yes | no) 272 ;; 273 *) 274 AC_MSG_ERROR([bad value $1 for $2]) 275 ;; 276 esac 277 ]) 278 279dnl Check that the provided value ($1) is either "yes", "no" or "auto". If not, 280dnl emit an error message mentionning the configure option $2, and abort 281dnl the script. 282AC_DEFUN([GDB_CHECK_YES_NO_AUTO_VAL], 283 [ 284 case $1 in 285 yes | no | auto) 286 ;; 287 *) 288 AC_MSG_ERROR([bad value $1 for $2]) 289 ;; 290 esac 291 ]) 292