1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
dnl Macros for checking if various gcc compiler attributes are present
dnl
dnl Written by Shane Alcock <salcock@waikato.ac.nz>, but some credit
dnl should be given to Diego Pettenò <flameeyes@gmail.com> whose
dnl macros were very useful in helping me figure out how to write my
dnl own.
dnl
dnl
AC_DEFUN([check_WERROR],
[
AC_REQUIRE([AC_PROG_CC])
AC_CACHE_CHECK(
[if -Werror flag is supported by compiler],
[lt_cv_werror_flag],
[saved="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a;])],
[eval lt_cv_werror_flag='yes'],
[eval lt_cv_werror_flag='no'])
CFLAGS="$saved"
])
])
AC_DEFUN([gcc_PACKED],
[
AC_REQUIRE([check_WERROR])
HAVE_ATTRIBUTE_PACKED=0
if test -n "$CC"; then
AS_IF([eval test x$lt_cv_werror_flag = xyes], [errflag=-Werror], [])
AC_CACHE_CHECK([if compiler supports __attribute__((packed))],
[lt_cv_attribute_packed],
[saved="$CFLAGS"
CFLAGS="$CFLAGS $errflag"
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[struct s { char a; char b; int val; long val2; void *ptr;} __attribute__((packed));])],
[lt_cv_attribute_packed=yes],
[lt_cv_attribute_packed=no]
)
CFLAGS="$saved"
])
if test x$lt_cv_attribute_packed = xyes; then
HAVE_ATTRIBUTE_PACKED=1
fi
fi
AC_SUBST([HAVE_ATTRIBUTE_PACKED])
AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_PACKED], [$HAVE_ATTRIBUTE_PACKED],
[Define to 1 or 0, depending on whether the compiler supports the gcc packed attribute.])
])
AC_DEFUN([gcc_UNUSED],
[
AC_REQUIRE([check_WERROR])
HAVE_ATTRIBUTE_UNUSED=0
if test -n "$CC"; then
AS_IF([eval test x$lt_cv_werror_flag = xyes], [errflag=-Werror], [])
AC_CACHE_CHECK([if compiler supports __attribute__((unused))],
[lt_cv_attribute_unused],
[saved="$CFLAGS"
CFLAGS="$CFLAGS $errflag"
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[void func(int a, __attribute__((unused)) int b);])],
[lt_cv_attribute_unused=yes],
[lt_cv_attribute_unused=no]
)
CFLAGS="$saved"
])
if test x$lt_cv_attribute_unused = xyes; then
HAVE_ATTRIBUTE_UNUSED=1
fi
fi
AC_SUBST([HAVE_ATTRIBUTE_UNUSED])
AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_UNUSED], [$HAVE_ATTRIBUTE_UNUSED],
[Define to 1 or 0, depending on whether the compiler supports the gcc unused attribute.])
])
AC_DEFUN([gcc_DEPRECATED],
[
AC_REQUIRE([check_WERROR])
HAVE_ATTRIBUTE_DEPRECATED=0
if test -n "$CC"; then
AS_IF([eval test x$lt_cv_werror_flag = xyes], [errflag=-Werror], [])
AC_CACHE_CHECK([if compiler supports __attribute__((deprecated))],
[lt_cv_attribute_deprecated],
[saved="$CFLAGS"
CFLAGS="$CFLAGS $errflag"
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[void func(int a, int b) __attribute__((deprecated));])],
[lt_cv_attribute_deprecated=yes],
[lt_cv_attribute_deprecated=no]
)
CFLAGS="$saved"
])
if test x$lt_cv_attribute_deprecated = xyes; then
HAVE_ATTRIBUTE_DEPRECATED=1
fi
fi
AC_SUBST([HAVE_ATTRIBUTE_DEPRECATED])
AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_DEPRECATED], [$HAVE_ATTRIBUTE_DEPRECATED],
[Define to 1 or 0, depending on whether the compiler supports the gcc deprecated attribute.])
])
AC_DEFUN([gcc_FORMAT],
[
AC_REQUIRE([check_WERROR])
HAVE_ATTRIBUTE_FORMAT=0
if test -n "$CC"; then
AS_IF([eval test x$lt_cv_werror_flag = xyes], [errflag=-Werror], [])
AC_CACHE_CHECK([if compiler supports __attribute__((format(printf)))],
[lt_cv_attribute_format],
[saved="$CFLAGS"
CFLAGS="$CFLAGS $errflag"
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[void __attribute__((format(printf, 1, 2))) foo(const char *fmt, ...);])],
[lt_cv_attribute_format=yes],
[lt_cv_attribute_format=no]
)
CFLAGS="$saved"
])
if test x$lt_cv_attribute_format = xyes; then
HAVE_ATTRIBUTE_FORMAT=1
fi
fi
AC_SUBST([HAVE_ATTRIBUTE_FORMAT])
AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_FORMAT], [$HAVE_ATTRIBUTE_FORMAT],
[Define to 1 or 0, depending on whether the compiler supports the format(printf) attribute.])
])
AC_DEFUN([gcc_PURE],
[
AC_REQUIRE([check_WERROR])
HAVE_ATTRIBUTE_PURE=0
if test -n "$CC"; then
AS_IF([eval test x$lt_cv_werror_flag = xyes], [errflag=-Werror], [])
AC_CACHE_CHECK([if compiler supports __attribute__((pure))],
[lt_cv_attribute_pure],
[saved="$CFLAGS"
CFLAGS="$CFLAGS $errflag"
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[void func(int a, int b) __attribute__((pure));])],
[lt_cv_attribute_pure=yes],
[lt_cv_attribute_pure=no]
)
CFLAGS="$saved"
])
if test x$lt_cv_attribute_pure = xyes; then
HAVE_ATTRIBUTE_PURE=1
fi
fi
AC_SUBST([HAVE_ATTRIBUTE_PURE])
AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_PURE], [$HAVE_ATTRIBUTE_PURE],
[Define to 1 or 0, depending on whether the compiler supports the pure attribute.])
])
|