mhd_check_decls.m4 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # SYNOPSIS
  2. #
  3. # MHD_CHECK_DECLS([SYMBOLS-TO-TEST], [INCLUDES])
  4. #
  5. # DESCRIPTION
  6. #
  7. # This macro checks whether specific symbols is defined in the headers.
  8. # SYMBOLS-TO-TEST is s space-separated list of symbols to check.
  9. # The symbol could be a macro, a variable, a constant, a enum value,
  10. # a function name or other kind of symbols recognisable by compiler (or
  11. # preprocessor).
  12. # For every found symbol a relevant preprocessor macro is defined.
  13. # Unlike AC_CHECK_DECLS this m4 macro does not define preprocossor macro if
  14. # symbol is NOT found.
  15. #
  16. # Example usage:
  17. #
  18. # MHD_CHECK_DECLS([SSIZE_MAX OFF_T_MAX], [[#include <limits.h>]])
  19. #
  20. #
  21. # LICENSE
  22. #
  23. # Copyright (c) 2025 Karlson2k (Evgeny Grin) <k2k@drgrin.dev>
  24. #
  25. # Copying and distribution of this file, with or without modification, are
  26. # permitted in any medium without royalty provided the copyright notice
  27. # and this notice are preserved. This file is offered as-is, without any
  28. # warranty.
  29. #serial 1
  30. AC_DEFUN([MHD_CHECK_DECLS],[dnl
  31. m4_newline([[# Expansion of $0 macro starts here]])
  32. m4_if(m4_index([$1], [(]),[-1],[],[dnl
  33. m4_fatal([SYMBOLS-TO-TEST parameter (first macro argument) contains '('])])dnl m4_if
  34. m4_if(m4_index([$1], [)]),[-1],[],[dnl
  35. m4_fatal([SYMBOLS-TO-TEST parameter (first macro argument) contains ')'])])dnl m4_if
  36. m4_if(m4_index([$1], [,]),[-1],[],[dnl
  37. m4_fatal([SYMBOLS-TO-TEST parameter (first macro argument) contains ','])])dnl m4_if
  38. m4_foreach_w([check_Symbol],[$1],
  39. [AC_CHECK_DECL(check_Symbol,[dnl
  40. AC_DEFINE([HAVE_DCLR_]m4_toupper(check_Symbol),[1],[Define to '1' if you have the declaration of ']check_Symbol['])dnl
  41. ],[],[$2])
  42. ])dnl
  43. m4_newline([[# Expansion of $0 macro ends here]])
  44. ])