Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.5KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_execinfo.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_EXECINFO([ACTION-IF-EXECINFO-H-IS-FOUND], [ACTION-IF-EXECINFO-H-IS-NOT-FOUND], [ADDITIONAL-TYPES-LIST])
  8. #
  9. # DESCRIPTION
  10. #
  11. # Checks for execinfo.h header and if the len parameter/return type can be
  12. # found from a list, also define backtrace_size_t to that type.
  13. #
  14. # By default the list of types to try contains int and size_t, but should
  15. # some yet undiscovered system use e.g. unsigned, the 3rd argument can be
  16. # used for extensions. I'd like to hear of further suggestions.
  17. #
  18. # Executes ACTION-IF-EXECINFO-H-IS-FOUND when present and the execinfo.h
  19. # header is found or ACTION-IF-EXECINFO-H-IS-NOT-FOUND in case the header
  20. # seems unavailable.
  21. #
  22. # Also adds -lexecinfo to LIBS on BSD if needed.
  23. #
  24. # LICENSE
  25. #
  26. # Copyright (c) 2014 Thomas Jahns <jahns@dkrz.de>
  27. #
  28. # Copying and distribution of this file, with or without modification, are
  29. # permitted in any medium without royalty provided the copyright notice
  30. # and this notice are preserved. This file is offered as-is, without any
  31. # warranty.
  32. #serial 2
  33. AC_DEFUN([AX_EXECINFO],
  34. [AC_CHECK_HEADERS([execinfo.h])
  35. AS_IF([test x"$ac_cv_header_execinfo_h" = xyes],
  36. [AC_CACHE_CHECK([size parameter type for backtrace()],
  37. [ax_cv_proto_backtrace_type],
  38. [AC_LANG_PUSH([C])
  39. for ax_cv_proto_backtrace_type in size_t int m4_ifnblank([$3],[$3 ])none; do
  40. AS_IF([test "${ax_cv_proto_backtrace_type}" = none],
  41. [ax_cv_proto_backtrace_type= ; break])
  42. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
  43. #include <execinfo.h>
  44. extern
  45. ${ax_cv_proto_backtrace_type} backtrace(void **addrlist, ${ax_cv_proto_backtrace_type} len);
  46. char **backtrace_symbols(void *const *buffer, ${ax_cv_proto_backtrace_type} size);
  47. ])],
  48. [break])
  49. done
  50. AC_LANG_POP([C])])])
  51. AS_IF([test x${ax_cv_proto_backtrace_type} != x],
  52. [AC_DEFINE_UNQUOTED([backtrace_size_t], [$ax_cv_proto_backtrace_type],
  53. [Defined to return type of backtrace().])])
  54. AC_SEARCH_LIBS([backtrace],[execinfo])
  55. AS_IF([test x"${ax_cv_proto_backtrace_type}" != x -a x"$ac_cv_header_execinfo_h" = xyes -a x"$ac_cv_search_backtrace" != xno],
  56. [AC_DEFINE([HAVE_BACKTRACE],[1],
  57. [Defined if backtrace() could be fully identified.])
  58. ]m4_ifnblank([$1],[$1
  59. ]),m4_ifnblank([$2],[$2
  60. ]))])
  61. dnl
  62. dnl Local Variables:
  63. dnl mode: autoconf
  64. dnl End:
  65. dnl