expatcfg-compiler-supports-visibility.m4 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # expatcfg-compiler-supports-visibility.m4 --
  2. #
  3. # SYNOPSIS
  4. #
  5. # EXPATCFG_COMPILER_SUPPORTS_VISIBILITY([ACTION-IF-YES],
  6. # [ACTION-IF-NO])
  7. #
  8. # DESCRIPTION
  9. #
  10. # Check if the selected compiler supports the "visibility" attribute
  11. # and set the variable "expatcfg_cv_compiler_supports_visibility"
  12. # accordingly to "yes" or "no".
  13. #
  14. # In addition, execute ACTION-IF-YES or ACTION-IF-NO.
  15. #
  16. # LICENSE
  17. #
  18. # Copyright (c) 2018 The Expat Authors.
  19. #
  20. # Copying and distribution of this file, with or without modification,
  21. # are permitted in any medium without royalty provided the copyright
  22. # notice and this notice are preserved. This file is offered as-is,
  23. # without any warranty.
  24. AC_DEFUN([EXPATCFG_COMPILER_SUPPORTS_VISIBILITY],
  25. [AC_CACHE_CHECK([whether compiler supports visibility],
  26. [expatcfg_cv_compiler_supports_visibility],
  27. [AS_VAR_SET([expatcfg_cv_compiler_supports_visibility],[no])
  28. AS_VAR_COPY([OLDFLAGS],[CFLAGS])
  29. AS_VAR_APPEND([CFLAGS],[" -fvisibility=hidden -Wall -Werror -Wno-unknown-warning-option"])
  30. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  31. void __attribute__((visibility("default"))) foo(void);
  32. void foo(void) {}
  33. ]])],
  34. [AS_VAR_SET([expatcfg_cv_compiler_supports_visibility],[yes])])
  35. AS_VAR_COPY([CFLAGS],[OLDFLAGS])])
  36. AS_IF([test "$expatcfg_cv_compiler_supports_visibility" = yes],[$1],[$2])])
  37. # end of file