Git init
[framework/base/acl.git] / m4 / visibility_hidden.m4
1 dnl Copyright (C) 2003, 2008  Silicon Graphics, Inc.
2 dnl
3 dnl This program is free software: you can redistribute it and/or modify it
4 dnl under the terms of the GNU General Public License as published by
5 dnl the Free Software Foundation, either version 2 of the License, or
6 dnl (at your option) any later version.
7 dnl
8 dnl This program is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 dnl GNU General Public License for more details.
12 dnl
13 dnl You should have received a copy of the GNU General Public License
14 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 AC_DEFUN([AC_FUNC_GCC_VISIBILITY],
16   [AC_CACHE_CHECK(whether __attribute__((visibility())) is supported,
17                   libc_cv_visibility_attribute,
18                   [cat > conftest.c <<EOF
19                    int foo __attribute__ ((visibility ("hidden"))) = 1;
20                    int bar __attribute__ ((visibility ("protected"))) = 1;
21 EOF
22                   libc_cv_visibility_attribute=no
23                   if ${CC-cc} -Werror -S conftest.c -o conftest.s \
24                         >/dev/null 2>&1; then
25                     if grep '\.hidden.*foo' conftest.s >/dev/null; then
26                       if grep '\.protected.*bar' conftest.s >/dev/null; then
27                         libc_cv_visibility_attribute=yes
28                       fi
29                     fi
30                   fi
31                   rm -f conftest.[cs]
32                   ])
33    if test $libc_cv_visibility_attribute = yes; then
34      AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE, [], [GCC supports visibility attributes])
35    fi
36   ])