File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / pcre / m4 / pcre_visibility.m4
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Jul 22 08:25:57 2013 UTC (10 years, 11 months ago) by misho
Branches: pcre, MAIN
CVS tags: v8_34, v8_33, HEAD
8.33

    1: # visibility.m4 serial 4 (gettext-0.18.2)
    2: dnl Copyright (C) 2005, 2008, 2010-2011 Free Software Foundation, Inc.
    3: dnl This file is free software; the Free Software Foundation
    4: dnl gives unlimited permission to copy and/or distribute it,
    5: dnl with or without modifications, as long as this notice is preserved.
    6: 
    7: dnl From Bruno Haible.
    8: 
    9: dnl Tests whether the compiler supports the command-line option
   10: dnl -fvisibility=hidden and the function and variable attributes
   11: dnl __attribute__((__visibility__("hidden"))) and
   12: dnl __attribute__((__visibility__("default"))).
   13: dnl Does *not* test for __visibility__("protected") - which has tricky
   14: dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on
   15: dnl MacOS X.
   16: dnl Does *not* test for __visibility__("internal") - which has processor
   17: dnl dependent semantics.
   18: dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
   19: dnl "really only recommended for legacy code".
   20: dnl Set the variable CFLAG_VISIBILITY.
   21: dnl Defines and sets the variable HAVE_VISIBILITY.
   22: 
   23: dnl Modified to fit with PCRE build environment by Cristian Rodríguez.
   24: 
   25: AC_DEFUN([PCRE_VISIBILITY],
   26: [
   27:   AC_REQUIRE([AC_PROG_CC])
   28:   VISIBILITY_CFLAGS=
   29:   VISIBILITY_CXXFLAGS=
   30:   HAVE_VISIBILITY=0
   31:   if test -n "$GCC"; then
   32:     dnl First, check whether -Werror can be added to the command line, or
   33:     dnl whether it leads to an error because of some other option that the
   34:     dnl user has put into $CC $CFLAGS $CPPFLAGS.
   35:     AC_MSG_CHECKING([whether the -Werror option is usable])
   36:     AC_CACHE_VAL([pcre_cv_cc_vis_werror], [
   37:       pcre_save_CFLAGS="$CFLAGS"
   38:       CFLAGS="$CFLAGS -Werror"
   39:       AC_COMPILE_IFELSE(
   40:         [AC_LANG_PROGRAM([[]], [[]])],
   41:         [pcre_cv_cc_vis_werror=yes],
   42:         [pcre_cv_cc_vis_werror=no])
   43:       CFLAGS="$pcre_save_CFLAGS"])
   44:     AC_MSG_RESULT([$pcre_cv_cc_vis_werror])
   45:     dnl Now check whether visibility declarations are supported.
   46:     AC_MSG_CHECKING([for simple visibility declarations])
   47:     AC_CACHE_VAL([pcre_cv_cc_visibility], [
   48:       pcre_save_CFLAGS="$CFLAGS"
   49:       CFLAGS="$CFLAGS -fvisibility=hidden"
   50:       dnl We use the option -Werror and a function dummyfunc, because on some
   51:       dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning
   52:       dnl "visibility attribute not supported in this configuration; ignored"
   53:       dnl at the first function definition in every compilation unit, and we
   54:       dnl don't want to use the option in this case.
   55:       if test $pcre_cv_cc_vis_werror = yes; then
   56:         CFLAGS="$CFLAGS -Werror"
   57:       fi
   58:       AC_COMPILE_IFELSE(
   59:         [AC_LANG_PROGRAM(
   60:            [[extern __attribute__((__visibility__("hidden"))) int hiddenvar;
   61:              extern __attribute__((__visibility__("default"))) int exportedvar;
   62:              extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
   63:              extern __attribute__((__visibility__("default"))) int exportedfunc (void);
   64:              void dummyfunc (void) {}
   65:            ]],
   66:            [[]])],
   67:         [pcre_cv_cc_visibility=yes],
   68:         [pcre_cv_cc_visibility=no])
   69:       CFLAGS="$pcre_save_CFLAGS"])
   70:     AC_MSG_RESULT([$pcre_cv_cc_visibility])
   71:     if test $pcre_cv_cc_visibility = yes; then
   72:       VISIBILITY_CFLAGS="-fvisibility=hidden"
   73:       VISIBILITY_CXXFLAGS="-fvisibility=hidden -fvisibility-inlines-hidden"
   74:       HAVE_VISIBILITY=1
   75:       AC_DEFINE(PCRE_EXP_DECL, [extern __attribute__ ((visibility ("default")))], [to make a symbol visible])
   76:       AC_DEFINE(PCRE_EXP_DEFN, [__attribute__ ((visibility ("default")))], [to make a symbol visible])
   77:       AC_DEFINE(PCRE_EXP_DATA_DEFN, [__attribute__ ((visibility ("default")))], [to make a symbol visible])
   78:       AC_DEFINE(PCREPOSIX_EXP_DECL, [extern __attribute__ ((visibility ("default")))], [to make a symbol visible])
   79:       AC_DEFINE(PCREPOSIX_EXP_DEFN, [extern __attribute__ ((visibility ("default")))], [to make a symbol visible])
   80:       AC_DEFINE(PCRECPP_EXP_DECL, [extern __attribute__ ((visibility ("default")))], [to make a symbol visible])
   81:       AC_DEFINE(PCRECPP_EXP_DEFN, [__attribute__ ((visibility ("default")))], [to make a symbol visible])
   82:     fi
   83:   fi
   84:   AC_SUBST([VISIBILITY_CFLAGS])
   85:   AC_SUBST([VISIBILITY_CXXFLAGS])
   86:   AC_SUBST([HAVE_VISIBILITY])
   87:   AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY],
   88:     [Define to 1 if the compiler supports simple visibility declarations.])
   89: ])

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>