reorganised check for compiler supporting visibility

This commit is contained in:
Marco Maggi 2018-10-18 13:27:40 +02:00
parent 67342942d6
commit 78646864c9
3 changed files with 24 additions and 8 deletions

View File

@ -8,5 +8,6 @@ m4_include(conftools/ax-append-flag.m4)
m4_include(conftools/ax-append-compile-flags.m4)
m4_include(conftools/ax-append-link-flags.m4)
dnl m4_include(conftools/ax-gcc-version.m4)
m4_include(conftools/expat-compiler-supports-visibility.mp4)
### end of file

View File

@ -90,14 +90,9 @@ AC_LANG_POP([C++])
AS_IF([test "$GCC" = yes],
[AX_APPEND_LINK_FLAGS([-fno-strict-aliasing],[LDFLAGS])])
AC_MSG_CHECKING(whether compiler supports visibility)
AS_VAR_COPY(OLDCFLAGS,CFLAGS)
AS_VAR_APPEND(CFLAGS,[" -fvisibility=hidden -Wall -Werror"])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[void __attribute__((visibility("default"))) foo(void); void foo(void) {}]])],
[AC_MSG_RESULT(yes)
AS_VAR_SET(CFLAGS,"$OLDCFLAGS -fvisibility=hidden -DXML_ENABLE_VISIBILITY=1")],
[AC_MSG_RESULT(no)
AS_VAR_COPY(CFLAGS, OLDCFLAGS)])
EXPAT_COMPILER_SUPPORTS_VISIBILITY([
AX_APPEND_FLAG([-fvisibility=hidden], [CFLAGS])
AX_APPEND_FLAG([-DXML_ENABLE_VISIBILITY=1], [CFLAGS])])
dnl Checks for header files.
AC_HEADER_STDC

View File

@ -0,0 +1,20 @@
dnl expat-compiler-supports-visibility.mp4
dnl
dnl SYNOPSIS
dnl
dnl EXPAT_COMPILER_SUPPORTS_VISIBILITY([ACTION-IF-YES], [ACTION-IF-NO])
dnl
AC_DEFUN([EXPAT_COMPILER_SUPPORTS_VISIBILITY],
[AC_MSG_CHECKING(whether compiler supports visibility)
AS_VAR_COPY([OLDFLAGS],[CFLAGS])
AS_VAR_APPEND(CFLAGS,[" -fvisibility=hidden -Wall -Werror"])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[void __attribute__((visibility("default"))) foo(void); void foo(void) {}]])],
[AC_MSG_RESULT(yes)
AS_VAR_COPY([CFLAGS],[OLDFLAGS])
$1],
[AC_MSG_RESULT(no)
AS_VAR_COPY([CFLAGS],[OLDFLAGS])
$2])])
dnl end of file