summaryrefslogtreecommitdiff
path: root/expat/conftools/expatcfg-compiler-supports-visibility.m4
blob: 45d07edfd2ca3a27fdf016f288a16972481074a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# expatcfg-compiler-supports-visibility.m4 --
#
# SYNOPSIS
#
#    EXPATCFG_COMPILER_SUPPORTS_VISIBILITY([ACTION-IF-YES],
#                                          [ACTION-IF-NO])
#
# DESCRIPTION
#
#   Check if  the selected compiler supports  the "visibility" attribute
#   and  set   the  variable  "expatcfg_cv_compiler_supports_visibility"
#   accordingly to "yes" or "no".
#
#   In addition, execute ACTION-IF-YES or ACTION-IF-NO.
#
# LICENSE
#
#   Copyright (c) 2018 The Expat Authors.
#
#   Copying and distribution of this file, with or without modification,
#   are permitted in  any medium without royalty  provided the copyright
#   notice and this  notice are preserved.  This file  is offered as-is,
#   without any warranty.

AC_DEFUN([EXPATCFG_COMPILER_SUPPORTS_VISIBILITY],
  [AC_CACHE_CHECK([whether compiler supports visibility],
     [expatcfg_cv_compiler_supports_visibility],
     [AS_VAR_SET([expatcfg_cv_compiler_supports_visibility],[no])
      AS_VAR_COPY([OLDFLAGS],[CFLAGS])
      AS_VAR_APPEND([CFLAGS],[" -fvisibility=hidden -Wall -Werror -Wno-unknown-warning-option"])
      AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
          void __attribute__((visibility("default"))) foo(void);
          void foo(void) {}
        ]])],
        [AS_VAR_SET([expatcfg_cv_compiler_supports_visibility],[yes])])
      AS_VAR_COPY([CFLAGS],[OLDFLAGS])])
   AS_IF([test "$expatcfg_cv_compiler_supports_visibility" = yes],[$1],[$2])])

# end of file