summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2007-03-16 20:12:41 +0000
committerDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2007-03-16 20:12:41 +0000
commitfd70a41ac6df0c3c19458cd9fb9ebcc5c54b8c84 (patch)
treec7663ad7d3648be3140456eb2f5b0ad8ad36e979 /m4
parentf07c6cb7930d9f6e9842cc671ed86f687d456e57 (diff)
downloadxine-lib-fd70a41ac6df0c3c19458cd9fb9ebcc5c54b8c84.tar.gz
xine-lib-fd70a41ac6df0c3c19458cd9fb9ebcc5c54b8c84.tar.bz2
Add a check if the compiler supports weak aliases, to add FreeBSD support to Real codecs.
CVS patchset: 8680 CVS date: 2007/03/16 20:12:41
Diffstat (limited to 'm4')
-rw-r--r--m4/attributes.m481
1 files changed, 71 insertions, 10 deletions
diff --git a/m4/attributes.m4 b/m4/attributes.m4
index fa00a95f8..a83390006 100644
--- a/m4/attributes.m4
+++ b/m4/attributes.m4
@@ -1,13 +1,42 @@
# Functions to check for attributes support in compiler
+AC_DEFUN([CC_CHECK_CFLAGS], [
+ ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $1"
+ AC_MSG_CHECKING([if compiler supports $1])
+ AC_COMPILE_IFELSE([int a;],
+ [cc_check_cflags=yes],
+ [cc_check_cflags=no])
+ AC_MSG_RESULT([$cc_check_cflags])
+ CFLAGS="$ac_save_CFLAGS"
+
+ if test "x$cc_check_cflags" = "xyes"; then
+ true
+ $2
+ else
+ true
+ $3
+ fi
+])
+
+AC_DEFUN([CC_CHECK_WERROR], [
+ CC_CHECK_CFLAGS([-Werror], [werror=-Werror])
+
+ dnl This is for SUN Studio compiler
+ if test "x$werror" = "x"; then
+ CC_CHECK_CFLAGS([-errwarn=%all], [werror=-errwarn=%all])
+ fi
+])
+
AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
+ AC_REQUIRE([CC_CHECK_WERROR])
ac_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Werror"
+ CFLAGS="$CFLAGS $werror"
AC_CACHE_CHECK([if compiler supports __attribute__((constructor))],
[cc_cv_attribute_constructor],
[AC_COMPILE_IFELSE([
void ctor() __attribute__((constructor));
- void ctor() { };
+ void ctor() { int a; };
],
[cc_cv_attribute_constructor=yes],
[cc_cv_attribute_constructor=no])
@@ -24,8 +53,9 @@ AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
])
AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
+ AC_REQUIRE([CC_CHECK_WERROR])
ac_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Werror"
+ CFLAGS="$CFLAGS $werror"
AC_CACHE_CHECK([if compiler supports __attribute__((format(printf, n, n)))],
[cc_cv_attribute_format],
[AC_COMPILE_IFELSE([
@@ -46,8 +76,9 @@ AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
])
AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [
+ AC_REQUIRE([CC_CHECK_WERROR])
ac_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Werror"
+ CFLAGS="$CFLAGS $werror"
AC_CACHE_CHECK([if compiler supports __attribute__((format_arg(printf)))],
[cc_cv_attribute_format_arg],
[AC_COMPILE_IFELSE([
@@ -68,8 +99,9 @@ AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [
])
AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
+ AC_REQUIRE([CC_CHECK_WERROR])
ac_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Werror"
+ CFLAGS="$CFLAGS $werror"
AC_CACHE_CHECK([if compiler supports __attribute__((visibility("...")))],
[cc_cv_attribute_visibility],
[AC_COMPILE_IFELSE([
@@ -92,8 +124,9 @@ AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
])
AC_DEFUN([CC_FLAG_VISIBILITY], [
+ AC_REQUIRE([CC_CHECK_WERROR])
ac_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Werror"
+ CFLAGS="$CFLAGS $werror"
AC_CACHE_CHECK([if compiler supports -fvisibility=hidden],
[cc_cv_flag_visibility],
[
@@ -116,8 +149,9 @@ AC_DEFUN([CC_FLAG_VISIBILITY], [
])
AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
+ AC_REQUIRE([CC_CHECK_WERROR])
ac_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Werror"
+ CFLAGS="$CFLAGS $werror"
AC_CACHE_CHECK([if compiler supports __attribute__((nonnull()))],
[cc_cv_attribute_nonnull],
[AC_COMPILE_IFELSE([
@@ -139,8 +173,9 @@ AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
])
AC_DEFUN([CC_ATTRIBUTE_UNUSED], [
+ AC_REQUIRE([CC_CHECK_WERROR])
ac_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Werror"
+ CFLAGS="$CFLAGS $werror"
AC_CACHE_CHECK([if compiler supports __attribute__((unused))],
[cc_cv_attribute_unused],
[AC_COMPILE_IFELSE([
@@ -161,8 +196,9 @@ AC_DEFUN([CC_ATTRIBUTE_UNUSED], [
])
AC_DEFUN([CC_FUNC_EXPECT], [
+ AC_REQUIRE([CC_CHECK_WERROR])
ac_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Werror"
+ CFLAGS="$CFLAGS $werror"
AC_CACHE_CHECK([if compiler has __builtin_expect function],
[cc_cv_func_expect],
[AC_COMPILE_IFELSE([
@@ -187,8 +223,9 @@ AC_DEFUN([CC_FUNC_EXPECT], [
])
AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [
+ AC_REQUIRE([CC_CHECK_WERROR])
ac_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Werror"
+ CFLAGS="$CFLAGS $werror"
AC_CACHE_CHECK([if compiler supports __attribute__((sentinel))],
[cc_cv_attribute_sentinel],
[AC_COMPILE_IFELSE([
@@ -207,3 +244,27 @@ AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [
$2
fi
])
+
+AC_DEFUN([CC_ATTRIBUTE_ALIAS], [
+ AC_REQUIRE([CC_CHECK_WERROR])
+ ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $werror"
+ AC_CACHE_CHECK([if compiler supports __attribute__((weak, alias))],
+ [cc_cv_attribute_alias],
+ [AC_COMPILE_IFELSE([
+ void other_function(void *foo) { }
+ void some_function(void *foo) __attribute__((weak, alias("other_function")));
+ ],
+ [cc_cv_attribute_alias=yes],
+ [cc_cv_attribute_alias=no])
+ ])
+ CFLAGS="$ac_save_CFLAGS"
+
+ if test "x$cc_cv_attribute_alias" = "xyes"; then
+ AC_DEFINE([SUPPORT_ATTRIBUTE_ALIAS], 1, [Define this if the compiler supports the alias attribute])
+ $1
+ else
+ true
+ $2
+ fi
+])