• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
25AC_DEFUN([EXPATCFG_COMPILER_SUPPORTS_VISIBILITY],
26  [AC_CACHE_CHECK([whether compiler supports visibility],
27     [expatcfg_cv_compiler_supports_visibility],
28     [AS_VAR_SET([expatcfg_cv_compiler_supports_visibility],[no])
29      AS_VAR_COPY([OLDFLAGS],[CFLAGS])
30      AS_VAR_APPEND([CFLAGS],[" -fvisibility=hidden -Wall -Werror -Wno-unknown-warning-option"])
31      AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
32          void __attribute__((visibility("default"))) foo(void);
33          void foo(void) {}
34        ]])],
35        [AS_VAR_SET([expatcfg_cv_compiler_supports_visibility],[yes])])
36      AS_VAR_COPY([CFLAGS],[OLDFLAGS])])
37   AS_IF([test "$expatcfg_cv_compiler_supports_visibility" = yes],[$1],[$2])])
38
39# end of file
40