common.m4 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. dnl Invoke configury needed by the files in 'common'.
  19. AC_DEFUN([GDB_AC_COMMON], [
  20. # Set the 'development' global.
  21. . $srcdir/../bfd/development.sh
  22. AC_HEADER_STDC
  23. AC_FUNC_ALLOCA
  24. WIN32APILIBS=
  25. case ${host} in
  26. *mingw32*)
  27. AC_DEFINE(USE_WIN32API, 1,
  28. [Define if we should use the Windows API, instead of the
  29. POSIX API. On Windows, we use the Windows API when
  30. building for MinGW, but the POSIX API when building
  31. for Cygwin.])
  32. WIN32APILIBS="-lws2_32"
  33. ;;
  34. esac
  35. dnl Note that this requires codeset.m4, which is included
  36. dnl by the users of common.m4.
  37. AM_LANGINFO_CODESET
  38. AC_CHECK_HEADERS(linux/perf_event.h locale.h memory.h signal.h dnl
  39. sys/resource.h sys/socket.h dnl
  40. sys/un.h sys/wait.h dnl
  41. thread_db.h wait.h dnl
  42. termios.h dnl
  43. dlfcn.h dnl
  44. linux/elf.h proc_service.h dnl
  45. poll.h sys/poll.h sys/select.h)
  46. AC_FUNC_MMAP
  47. AC_FUNC_FORK
  48. AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 poll socketpair sigaction \
  49. ptrace64 sbrk setns sigaltstack sigprocmask \
  50. setpgid setpgrp getrusage getauxval sigtimedwait])
  51. # This is needed for RHEL 5 and uclibc-ng < 1.0.39.
  52. # These did not define ADDR_NO_RANDOMIZE in sys/personality.h,
  53. # only in linux/personality.h.
  54. AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
  55. AC_CHECK_DECLS([strstr])
  56. # ----------------------- #
  57. # Checks for structures. #
  58. # ----------------------- #
  59. AC_CHECK_MEMBERS([struct stat.st_blocks, struct stat.st_blksize])
  60. # On FreeBSD we need libutil for the kinfo_get* functions. On
  61. # GNU/kFreeBSD systems, FreeBSD libutil is renamed to libutil-freebsd.
  62. # Figure out which one to use.
  63. AC_SEARCH_LIBS(kinfo_getfile, util util-freebsd)
  64. # Define HAVE_KINFO_GETFILE if kinfo_getfile is available.
  65. AC_CHECK_FUNCS(kinfo_getfile)
  66. # ----------------------- #
  67. # Check for threading. #
  68. # ----------------------- #
  69. AC_ARG_ENABLE(threading,
  70. AS_HELP_STRING([--enable-threading], [include support for parallel processing of data (yes/no)]),
  71. [case "$enableval" in
  72. yes) want_threading=yes ;;
  73. no) want_threading=no ;;
  74. *) AC_MSG_ERROR([bad value $enableval for threading]) ;;
  75. esac],
  76. [want_threading=yes])
  77. # Check for std::thread. This does not work on some platforms, like
  78. # mingw and DJGPP.
  79. AC_LANG_PUSH([C++])
  80. AX_PTHREAD([threads=yes], [threads=no])
  81. if test "$threads" = "yes"; then
  82. save_LIBS="$LIBS"
  83. LIBS="$PTHREAD_LIBS $LIBS"
  84. save_CXXFLAGS="$CXXFLAGS"
  85. CXXFLAGS="$PTHREAD_CFLAGS $save_CXXFLAGS"
  86. AC_CACHE_CHECK([for std::thread],
  87. gdb_cv_cxx_std_thread,
  88. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  89. [[#include <thread>
  90. void callback() { }]],
  91. [[std::thread t(callback);]])],
  92. gdb_cv_cxx_std_thread=yes,
  93. gdb_cv_cxx_std_thread=no)])
  94. # This check must be here, while LIBS includes any necessary
  95. # threading library.
  96. AC_CHECK_FUNCS([pthread_sigmask pthread_setname_np])
  97. LIBS="$save_LIBS"
  98. CXXFLAGS="$save_CXXFLAGS"
  99. fi
  100. if test "$want_threading" = "yes"; then
  101. if test "$gdb_cv_cxx_std_thread" = "yes"; then
  102. AC_DEFINE(CXX_STD_THREAD, 1,
  103. [Define to 1 if std::thread works.])
  104. fi
  105. fi
  106. AC_LANG_POP
  107. dnl Check if sigsetjmp is available. Using AC_CHECK_FUNCS won't
  108. dnl do since sigsetjmp might only be defined as a macro.
  109. AC_CACHE_CHECK(
  110. [for sigsetjmp],
  111. [gdb_cv_func_sigsetjmp],
  112. [AC_COMPILE_IFELSE(
  113. [AC_LANG_PROGRAM(
  114. [#include <setjmp.h>],
  115. [sigjmp_buf env;
  116. while (! sigsetjmp (env, 1))
  117. siglongjmp (env, 1);]
  118. )],
  119. [gdb_cv_func_sigsetjmp=yes],
  120. [gdb_cv_func_sigsetjmp=no]
  121. )]
  122. )
  123. if test "$gdb_cv_func_sigsetjmp" = "yes"; then
  124. AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ])
  125. fi
  126. AC_ARG_WITH(intel_pt,
  127. AS_HELP_STRING([--with-intel-pt], [include Intel Processor Trace support (auto/yes/no)]),
  128. [], [with_intel_pt=auto])
  129. AC_MSG_CHECKING([whether to use intel pt])
  130. AC_MSG_RESULT([$with_intel_pt])
  131. if test "${with_intel_pt}" = no; then
  132. AC_MSG_WARN([Intel Processor Trace support disabled; some features may be unavailable.])
  133. HAVE_LIBIPT=no
  134. else
  135. AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
  136. #include <linux/perf_event.h>
  137. #ifndef PERF_ATTR_SIZE_VER5
  138. # error
  139. #endif
  140. ]])], [perf_event=yes], [perf_event=no])
  141. if test "$perf_event" != yes; then
  142. if test "$with_intel_pt" = yes; then
  143. AC_MSG_ERROR([linux/perf_event.h missing or too old])
  144. else
  145. AC_MSG_WARN([linux/perf_event.h missing or too old; some features may be unavailable.])
  146. fi
  147. fi
  148. AC_LIB_HAVE_LINKFLAGS([ipt], [], [#include "intel-pt.h"], [pt_insn_alloc_decoder (0);])
  149. if test "$HAVE_LIBIPT" != yes; then
  150. if test "$with_intel_pt" = yes; then
  151. AC_MSG_ERROR([libipt is missing or unusable])
  152. else
  153. AC_MSG_WARN([libipt is missing or unusable; some features may be unavailable.])
  154. fi
  155. else
  156. save_LIBS=$LIBS
  157. LIBS="$LIBS $LIBIPT"
  158. AC_CHECK_FUNCS(pt_insn_event)
  159. AC_CHECK_MEMBERS([struct pt_insn.enabled, struct pt_insn.resynced], [], [],
  160. [#include <intel-pt.h>])
  161. LIBS=$save_LIBS
  162. fi
  163. fi
  164. # Check if the compiler and runtime support printing long longs.
  165. AC_CACHE_CHECK([for long long support in printf],
  166. gdb_cv_printf_has_long_long,
  167. [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
  168. [[char buf[32];
  169. long long l = 0;
  170. l = (l << 16) + 0x0123;
  171. l = (l << 16) + 0x4567;
  172. l = (l << 16) + 0x89ab;
  173. l = (l << 16) + 0xcdef;
  174. sprintf (buf, "0x%016llx", l);
  175. return (strcmp ("0x0123456789abcdef", buf));]])],
  176. gdb_cv_printf_has_long_long=yes,
  177. gdb_cv_printf_has_long_long=no,
  178. gdb_cv_printf_has_long_long=no)])
  179. if test "$gdb_cv_printf_has_long_long" = yes; then
  180. AC_DEFINE(PRINTF_HAS_LONG_LONG, 1,
  181. [Define to 1 if the "%ll" format works to print long longs.])
  182. fi
  183. BFD_SYS_PROCFS_H
  184. if test "$ac_cv_header_sys_procfs_h" = yes; then
  185. BFD_HAVE_SYS_PROCFS_TYPE(gregset_t)
  186. BFD_HAVE_SYS_PROCFS_TYPE(fpregset_t)
  187. BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
  188. BFD_HAVE_SYS_PROCFS_TYPE(prfpregset_t)
  189. BFD_HAVE_SYS_PROCFS_TYPE(prgregset32_t)
  190. BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
  191. BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
  192. BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
  193. fi
  194. ])