[SDK] Clean up symbol visibility flags and compiler vendor handling

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
This commit is contained in:
Stefan Knoblich 2011-09-02 22:46:09 +02:00
parent 6d76dda7f5
commit d0308aaea2
2 changed files with 46 additions and 64 deletions

View File

@ -22,35 +22,42 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
# Checks for programs. # Checks for programs.
AC_PROG_CC AC_PROG_CC
AM_PROG_CC_C_O AM_PROG_CC_C_O
AC_PROG_CC_C99
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
# pkgconfig # pkgconfig
AC_PATH_PROG([PKG_CONFIG], [pkg-config], ["no"]) AC_PATH_PROG([PKG_CONFIG], [pkg-config], ["no"])
if test "x${PKG_CONFIG}" = "xno" AS_IF([test "x${PKG_CONFIG}" = "xno"],
then [AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed in your PATH])]
AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed in your PATH]) )
fi
PKG_PROG_PKG_CONFIG PKG_PROG_PKG_CONFIG
# Checks for cflags
##
## Checks for cflags
##
AC_MSG_RESULT([${as_nl}<<>> Compiler vendor and features]) AC_MSG_RESULT([${as_nl}<<>> Compiler vendor and features])
AX_COMPILER_VENDOR
AM_CONDITIONAL([CC_VENDOR_GNU], [test "x${ax_cv_c_compiler_vendor}" = "xgnu"])
AM_CONDITIONAL([CC_VENDOR_SUN], [test "x${ax_cv_c_compiler_vendor}" = "xsun"])
## ##
## Compiler vendor and flag checks ## Compiler vendor and flag checks
## ##
HAVE_VISIBILITY="no" HAVE_VISIBILITY="no"
AC_ARG_ENABLE([visibility], AC_ARG_ENABLE([visibility],
[AS_HELP_STRING([--disable-visibility], [Disable symbol visibility support (default: enabled, if available)])], [AS_HELP_STRING([--disable-visibility], [Disable symbol visibility support (default: enabled, if available)])],
[case "${enableval}" in [case "${enableval}" in
yes) enable_visibility="yes" ;; yes|no) enable_visibility="${enableval}" ;;
no) enable_visibility="no" ;;
*) AC_MSG_ERROR([Invalid value ${enableval} for parameter --disable-visibility]) ;; *) AC_MSG_ERROR([Invalid value ${enableval} for parameter --disable-visibility]) ;;
esac], esac],
[enable_visibility="yes"] [enable_visibility="yes"]
) )
AX_COMPILER_VENDOR
case "${ax_cv_c_compiler_vendor}" in case "${ax_cv_c_compiler_vendor}" in
gnu) gnu)
AC_MSG_CHECKING([whether the compiler supports -fvisibility=hidden]) AC_MSG_CHECKING([whether the compiler supports -fvisibility=hidden])
@ -63,36 +70,16 @@ gnu)
[;] [;]
)], )],
[AC_MSG_RESULT([yes]) [HAVE_VISIBILITY="yes"
AC_DEFINE([HAVE_VISIBILITY],[1],[GCC visibility support]) AC_DEFINE([HAVE_VISIBILITY], [1], [Symbol visibility support])
HAVE_VISIBILITY="yes"], AC_SUBST([VISIBILITY_CFLAGS], [-fvisibility=hidden])
AC_SUBST([VISIBILITY_CXXFLAGS], [-fvisibility=hidden])],
[AC_MSG_RESULT([no]) [HAVE_VISIBILITY="no"]
HAVE_VISIBILITY="no"]
) )
AC_MSG_RESULT([${HAVE_VISIBILITY}])
CFLAGS="${save_CFLAGS}"], CFLAGS="${save_CFLAGS}"],
[AC_MSG_RESULT([disabled by user])] [AC_MSG_RESULT([disabled by user])]
) )
AS_IF([test "x${HAVE_VISIBILITY}" != "xno"],
[save_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} -fvisibility-inlines-hidden"
AC_MSG_CHECKING([whether the compiler supports -fvisibility-inlines-hidden])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[;], [;]
)],
[AC_MSG_RESULT([yes])
HAVE_VISIBILITY_INLINES_HIDDEN="yes"],
[AC_MSG_RESULT([no])
HAVE_VISIBILITY_INLINES_HIDDEN="no"]
)
CFLAGS="${save_CFLAGS}"],
[:]
)
AC_DEFINE([COMPILER_GCC], [1], [Compiler is GCC])
;; ;;
sun) sun)
AC_MSG_CHECKING([whether the compiler supports -xldscope=hidden]) AC_MSG_CHECKING([whether the compiler supports -xldscope=hidden])
@ -105,28 +92,24 @@ sun)
[;] [;]
)], )],
[AC_MSG_RESULT([yes]) [HAVE_VISIBILITY="yes"
AC_DEFINE([HAVE_VISIBILITY],[1],[SUNCC visibility support]) AC_DEFINE([HAVE_VISIBILITY], [1], [Symbol visibility support])
HAVE_VISIBILITY="yes"], AC_SUBST([VISIBILITY_CFLAGS], [-xldscope=hidden])
AC_SUBST([VISIBILITY_CXXFLAGS], [-xldscope=hidden])],
[AC_MSG_RESULT([no]) [HAVE_VISIBILITY="no"]
HAVE_VISIBILITY="no"]
) )
AC_MSG_RESULT([${HAVE_VISIBILITY}])
CFLAGS="${save_CFLAGS}"], CFLAGS="${save_CFLAGS}"],
[AC_MSG_RESULT([disabled by user])] [AC_MSG_RESULT([disabled by user])]
) )
AC_DEFINE([COMPILER_SUNCC], [1], [Compiler is SunCC])
;; ;;
*) *)
AC_MSG_WARN([No visibility checks for this compiler defined]) AC_MSG_WARN([No visibility checks for this compiler defined])
;; ;;
esac esac
AM_CONDITIONAL([COMPILER_GCC], [test "x${ax_cv_c_compiler_vendor}" = "xgnu"]) AM_CONDITIONAL([CC_HAS_VISIBILITY], [test "x${HAVE_VISIBILITY}" = "xyes"])
AM_CONDITIONAL([COMPILER_SUNCC], [test "x${ax_cv_c_compiler_vendor}" = "xsun"])
AM_CONDITIONAL([HAVE_VISIBILITY], [test "x${HAVE_VISIBILITY}" = "xyes"])
AM_CONDITIONAL([HAVE_VISIBILITY_INLINES_HIDDEN], [test "x${HAVE_VISIBILITY_INLINES_HIDDEN}" = "xyes"])
## ##
## pkgconfig based freeswitch detection code ## pkgconfig based freeswitch detection code
@ -210,6 +193,7 @@ PKG_CHECK_MODULES([freeswitch], [freeswitch],
[AC_MSG_ERROR([FreeSWITCH not found])] [AC_MSG_ERROR([FreeSWITCH not found])]
) )
## ##
## Add your other dependency checks here ## Add your other dependency checks here
## ##
@ -221,6 +205,10 @@ AC_MSG_RESULT([${as_nl}<<>> Other dependencies])
# Checks for library functions. # Checks for library functions.
##
## Done, create output files and print summary
##
AC_MSG_RESULT([${as_nl}<<>> Create output files]) AC_MSG_RESULT([${as_nl}<<>> Create output files])
AC_CONFIG_FILES([Makefile src/Makefile]) AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT AC_OUTPUT

View File

@ -10,32 +10,26 @@ AM_CPPFLAGS= -I. -I$(includedir)
AM_LDFLAGS = -L. -L$(libdir) -avoid-version -module -no-undefined -shared AM_LDFLAGS = -L. -L$(libdir) -avoid-version -module -no-undefined -shared
### ###
# GCC specific flags # GCC (and compatible) specific flags
# #
if COMPILER_GCC if CC_VENDOR_GNU
AM_CFLAGS += -Wall AM_CFLAGS += -Wall
# symbol visibility support
if HAVE_VISIBILITY
AM_CFLAGS += -fvisibility=hidden
AM_CXXFLAGS+= -fvisibility=hidden
AM_CPPFLAGS+= -DSWITCH_API_VISIBILITY=1
endif
if HAVE_VISIBILITY_INLINES_HIDDEN
AM_CXXFLAGS += -fvisibility-inlines-hidden
endif
endif endif
### ###
# SunCC specific flags # SunCC specific flags
# #
if COMPILER_SUNCC if CC_VENDOR_SUN
AM_CFLAGS += AM_CFLAGS +=
# symbol visibility support
if HAVE_VISIBILITY
AM_CFLAGS += -xldscope=hidden
AM_CXXFLAGS += -xldscope=hidden
AM_CPPFLAGS += -DSWITCH_API_VISIBILITY=1
endif endif
###
# symbol visibility support
#
if CC_HAS_VISIBILITY
AM_CFLAGS += $(VISIBILITY_CFLAGS)
AM_CXXFLAGS += $(VISIBILITY_CXXFLAGS)
AM_CPPFLAGS += -DSWITCH_API_VISIBILITY=1
endif endif