annotate src/opusfile-0.9/m4/attributes.m4 @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents 4664ac0c1032
children
rev   line source
cannam@154 1 dnl Macros to check the presence of generic (non-typed) symbols.
cannam@154 2 dnl Copyright (c) 2006-2007 Diego Pettenò <flameeyes@gmail.com>
cannam@154 3 dnl Copyright (c) 2006-2007 xine project
cannam@154 4 dnl
cannam@154 5 dnl This program is free software; you can redistribute it and/or modify
cannam@154 6 dnl it under the terms of the GNU General Public License as published by
cannam@154 7 dnl the Free Software Foundation; either version 2, or (at your option)
cannam@154 8 dnl any later version.
cannam@154 9 dnl
cannam@154 10 dnl This program is distributed in the hope that it will be useful,
cannam@154 11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@154 12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@154 13 dnl GNU General Public License for more details.
cannam@154 14 dnl
cannam@154 15 dnl You should have received a copy of the GNU General Public License
cannam@154 16 dnl along with this program; if not, write to the Free Software
cannam@154 17 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
cannam@154 18 dnl 02110-1301, USA.
cannam@154 19 dnl
cannam@154 20 dnl As a special exception, the copyright owners of the
cannam@154 21 dnl macro gives unlimited permission to copy, distribute and modify the
cannam@154 22 dnl configure scripts that are the output of Autoconf when processing the
cannam@154 23 dnl Macro. You need not follow the terms of the GNU General Public
cannam@154 24 dnl License when using or distributing such scripts, even though portions
cannam@154 25 dnl of the text of the Macro appear in them. The GNU General Public
cannam@154 26 dnl License (GPL) does govern all other use of the material that
cannam@154 27 dnl constitutes the Autoconf Macro.
cannam@154 28 dnl
cannam@154 29 dnl This special exception to the GPL applies to versions of the
cannam@154 30 dnl Autoconf Macro released by this project. When you make and
cannam@154 31 dnl distribute a modified version of the Autoconf Macro, you may extend
cannam@154 32 dnl this special exception to the GPL to apply to your modified version as
cannam@154 33 dnl well.
cannam@154 34
cannam@154 35 dnl Check if the flag is supported by compiler
cannam@154 36 dnl CC_CHECK_CFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
cannam@154 37
cannam@154 38 AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [
cannam@154 39 AC_CACHE_VAL(AS_TR_SH([cc_cv_cflags_$1]),
cannam@154 40 [ac_save_CFLAGS="$CFLAGS"
cannam@154 41 CFLAGS="$CFLAGS $1"
cannam@154 42 AC_LINK_IFELSE([AC_LANG_SOURCE([int main() { return 0; }])],
cannam@154 43 [eval "AS_TR_SH([cc_cv_cflags_$1])='yes'"],
cannam@154 44 [eval "AS_TR_SH([cc_cv_cflags_$1])='no'"])
cannam@154 45 CFLAGS="$ac_save_CFLAGS"
cannam@154 46 ])
cannam@154 47
cannam@154 48 AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
cannam@154 49 [$2], [$3])
cannam@154 50 ])
cannam@154 51
cannam@154 52 dnl Check if the flag is supported by compiler (cacheable)
cannam@154 53 dnl CC_CHECK_CFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
cannam@154 54
cannam@154 55 AC_DEFUN([CC_CHECK_CFLAGS], [
cannam@154 56 AC_CACHE_CHECK([if $CC supports $1 flag],
cannam@154 57 AS_TR_SH([cc_cv_cflags_$1]),
cannam@154 58 CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here!
cannam@154 59 )
cannam@154 60
cannam@154 61 AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
cannam@154 62 [$2], [$3])
cannam@154 63 ])
cannam@154 64
cannam@154 65 dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found])
cannam@154 66 dnl Check for CFLAG and appends them to CFLAGS if supported
cannam@154 67 AC_DEFUN([CC_CHECK_CFLAG_APPEND], [
cannam@154 68 AC_CACHE_CHECK([if $CC supports $1 flag],
cannam@154 69 AS_TR_SH([cc_cv_cflags_$1]),
cannam@154 70 CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here!
cannam@154 71 )
cannam@154 72
cannam@154 73 AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
cannam@154 74 [CFLAGS="$CFLAGS $1"; $2], [$3])
cannam@154 75 ])
cannam@154 76
cannam@154 77 dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not])
cannam@154 78 AC_DEFUN([CC_CHECK_CFLAGS_APPEND], [
cannam@154 79 for flag in $1; do
cannam@154 80 CC_CHECK_CFLAG_APPEND($flag, [$2], [$3])
cannam@154 81 done
cannam@154 82 ])
cannam@154 83
cannam@154 84 dnl Check if the flag is supported by linker (cacheable)
cannam@154 85 dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
cannam@154 86
cannam@154 87 AC_DEFUN([CC_CHECK_LDFLAGS], [
cannam@154 88 AC_CACHE_CHECK([if $CC supports $1 flag],
cannam@154 89 AS_TR_SH([cc_cv_ldflags_$1]),
cannam@154 90 [ac_save_LDFLAGS="$LDFLAGS"
cannam@154 91 LDFLAGS="$LDFLAGS $1"
cannam@154 92 AC_LINK_IFELSE([AC_LANG_SOURCE([int main() { return 1; }])],
cannam@154 93 [eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"],
cannam@154 94 [eval "AS_TR_SH([cc_cv_ldflags_$1])="])
cannam@154 95 LDFLAGS="$ac_save_LDFLAGS"
cannam@154 96 ])
cannam@154 97
cannam@154 98 AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes],
cannam@154 99 [$2], [$3])
cannam@154 100 ])
cannam@154 101
cannam@154 102 dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for
cannam@154 103 dnl the current linker to avoid undefined references in a shared object.
cannam@154 104 AC_DEFUN([CC_NOUNDEFINED], [
cannam@154 105 dnl We check $host for which systems to enable this for.
cannam@154 106 AC_REQUIRE([AC_CANONICAL_HOST])
cannam@154 107
cannam@154 108 case $host in
cannam@154 109 dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads
cannam@154 110 dnl are requested, as different implementations are present; to avoid problems
cannam@154 111 dnl use -Wl,-z,defs only for those platform not behaving this way.
cannam@154 112 *-freebsd* | *-openbsd*) ;;
cannam@154 113 *)
cannam@154 114 dnl First of all check for the --no-undefined variant of GNU ld. This allows
cannam@154 115 dnl for a much more readable commandline, so that people can understand what
cannam@154 116 dnl it does without going to look for what the heck -z defs does.
cannam@154 117 for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do
cannam@154 118 CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"])
cannam@154 119 break
cannam@154 120 done
cannam@154 121 ;;
cannam@154 122 esac
cannam@154 123
cannam@154 124 AC_SUBST([LDFLAGS_NOUNDEFINED])
cannam@154 125 ])
cannam@154 126
cannam@154 127 dnl Check for a -Werror flag or equivalent. -Werror is the GCC
cannam@154 128 dnl and ICC flag that tells the compiler to treat all the warnings
cannam@154 129 dnl as fatal. We usually need this option to make sure that some
cannam@154 130 dnl constructs (like attributes) are not simply ignored.
cannam@154 131 dnl
cannam@154 132 dnl Other compilers don't support -Werror per se, but they support
cannam@154 133 dnl an equivalent flag:
cannam@154 134 dnl - Sun Studio compiler supports -errwarn=%all
cannam@154 135 AC_DEFUN([CC_CHECK_WERROR], [
cannam@154 136 AC_CACHE_CHECK(
cannam@154 137 [for $CC way to treat warnings as errors],
cannam@154 138 [cc_cv_werror],
cannam@154 139 [CC_CHECK_CFLAGS_SILENT([-Werror], [cc_cv_werror=-Werror],
cannam@154 140 [CC_CHECK_CFLAGS_SILENT([-errwarn=%all], [cc_cv_werror=-errwarn=%all])])
cannam@154 141 ])
cannam@154 142 ])
cannam@154 143
cannam@154 144 AC_DEFUN([CC_CHECK_ATTRIBUTE], [
cannam@154 145 AC_REQUIRE([CC_CHECK_WERROR])
cannam@154 146 AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))],
cannam@154 147 AS_TR_SH([cc_cv_attribute_$1]),
cannam@154 148 [ac_save_CFLAGS="$CFLAGS"
cannam@154 149 CFLAGS="$CFLAGS $cc_cv_werror"
cannam@154 150 AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])],
cannam@154 151 [eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"],
cannam@154 152 [eval "AS_TR_SH([cc_cv_attribute_$1])='no'"])
cannam@154 153 CFLAGS="$ac_save_CFLAGS"
cannam@154 154 ])
cannam@154 155
cannam@154 156 AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes],
cannam@154 157 [AC_DEFINE(
cannam@154 158 AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1,
cannam@154 159 [Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))]
cannam@154 160 )
cannam@154 161 $4],
cannam@154 162 [$5])
cannam@154 163 ])
cannam@154 164
cannam@154 165 AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
cannam@154 166 CC_CHECK_ATTRIBUTE(
cannam@154 167 [constructor],,
cannam@154 168 [extern void foo();
cannam@154 169 void __attribute__((constructor)) ctor() { foo(); }],
cannam@154 170 [$1], [$2])
cannam@154 171 ])
cannam@154 172
cannam@154 173 AC_DEFUN([CC_ATTRIBUTE_DESTRUCTOR], [
cannam@154 174 CC_CHECK_ATTRIBUTE(
cannam@154 175 [destructor],,
cannam@154 176 [extern void foo();
cannam@154 177 void __attribute__((destructor)) dtor() { foo(); }],
cannam@154 178 [$1], [$2])
cannam@154 179 ])
cannam@154 180
cannam@154 181 AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
cannam@154 182 CC_CHECK_ATTRIBUTE(
cannam@154 183 [format], [format(printf, n, n)],
cannam@154 184 [void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }],
cannam@154 185 [$1], [$2])
cannam@154 186 ])
cannam@154 187
cannam@154 188 AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [
cannam@154 189 CC_CHECK_ATTRIBUTE(
cannam@154 190 [format_arg], [format_arg(printf)],
cannam@154 191 [char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }],
cannam@154 192 [$1], [$2])
cannam@154 193 ])
cannam@154 194
cannam@154 195 AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
cannam@154 196 CC_CHECK_ATTRIBUTE(
cannam@154 197 [visibility_$1], [visibility("$1")],
cannam@154 198 [void __attribute__((visibility("$1"))) $1_function() { }],
cannam@154 199 [$2], [$3])
cannam@154 200 ])
cannam@154 201
cannam@154 202 AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
cannam@154 203 CC_CHECK_ATTRIBUTE(
cannam@154 204 [nonnull], [nonnull()],
cannam@154 205 [void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }],
cannam@154 206 [$1], [$2])
cannam@154 207 ])
cannam@154 208
cannam@154 209 AC_DEFUN([CC_ATTRIBUTE_UNUSED], [
cannam@154 210 CC_CHECK_ATTRIBUTE(
cannam@154 211 [unused], ,
cannam@154 212 [void some_function(void *foo, __attribute__((unused)) void *bar);],
cannam@154 213 [$1], [$2])
cannam@154 214 ])
cannam@154 215
cannam@154 216 AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [
cannam@154 217 CC_CHECK_ATTRIBUTE(
cannam@154 218 [sentinel], ,
cannam@154 219 [void some_function(void *foo, ...) __attribute__((sentinel));],
cannam@154 220 [$1], [$2])
cannam@154 221 ])
cannam@154 222
cannam@154 223 AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [
cannam@154 224 CC_CHECK_ATTRIBUTE(
cannam@154 225 [deprecated], ,
cannam@154 226 [void some_function(void *foo, ...) __attribute__((deprecated));],
cannam@154 227 [$1], [$2])
cannam@154 228 ])
cannam@154 229
cannam@154 230 AC_DEFUN([CC_ATTRIBUTE_ALIAS], [
cannam@154 231 CC_CHECK_ATTRIBUTE(
cannam@154 232 [alias], [weak, alias],
cannam@154 233 [void other_function(void *foo) { }
cannam@154 234 void some_function(void *foo) __attribute__((weak, alias("other_function")));],
cannam@154 235 [$1], [$2])
cannam@154 236 ])
cannam@154 237
cannam@154 238 AC_DEFUN([CC_ATTRIBUTE_MALLOC], [
cannam@154 239 CC_CHECK_ATTRIBUTE(
cannam@154 240 [malloc], ,
cannam@154 241 [void * __attribute__((malloc)) my_alloc(int n);],
cannam@154 242 [$1], [$2])
cannam@154 243 ])
cannam@154 244
cannam@154 245 AC_DEFUN([CC_ATTRIBUTE_PACKED], [
cannam@154 246 CC_CHECK_ATTRIBUTE(
cannam@154 247 [packed], ,
cannam@154 248 [struct astructure { char a; int b; long c; void *d; } __attribute__((packed));
cannam@154 249 char assert@<:@(sizeof(struct astructure) == (sizeof(char)+sizeof(int)+sizeof(long)+sizeof(void*)))-1@:>@;],
cannam@154 250 [$1], [$2])
cannam@154 251 ])
cannam@154 252
cannam@154 253 AC_DEFUN([CC_ATTRIBUTE_CONST], [
cannam@154 254 CC_CHECK_ATTRIBUTE(
cannam@154 255 [const], ,
cannam@154 256 [int __attribute__((const)) twopow(int n) { return 1 << n; } ],
cannam@154 257 [$1], [$2])
cannam@154 258 ])
cannam@154 259
cannam@154 260 AC_DEFUN([CC_FLAG_VISIBILITY], [
cannam@154 261 AC_REQUIRE([CC_CHECK_WERROR])
cannam@154 262 AC_CACHE_CHECK([if $CC supports -fvisibility=hidden],
cannam@154 263 [cc_cv_flag_visibility],
cannam@154 264 [cc_flag_visibility_save_CFLAGS="$CFLAGS"
cannam@154 265 CFLAGS="$CFLAGS $cc_cv_werror"
cannam@154 266 CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden],
cannam@154 267 cc_cv_flag_visibility='yes',
cannam@154 268 cc_cv_flag_visibility='no')
cannam@154 269 CFLAGS="$cc_flag_visibility_save_CFLAGS"])
cannam@154 270
cannam@154 271 AS_IF([test "x$cc_cv_flag_visibility" = "xyes"],
cannam@154 272 [AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1,
cannam@154 273 [Define this if the compiler supports the -fvisibility flag])
cannam@154 274 $1],
cannam@154 275 [$2])
cannam@154 276 ])
cannam@154 277
cannam@154 278 AC_DEFUN([CC_FUNC_EXPECT], [
cannam@154 279 AC_REQUIRE([CC_CHECK_WERROR])
cannam@154 280 AC_CACHE_CHECK([if compiler has __builtin_expect function],
cannam@154 281 [cc_cv_func_expect],
cannam@154 282 [ac_save_CFLAGS="$CFLAGS"
cannam@154 283 CFLAGS="$CFLAGS $cc_cv_werror"
cannam@154 284 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
cannam@154 285 [int some_function() {
cannam@154 286 int a = 3;
cannam@154 287 return (int)__builtin_expect(a, 3);
cannam@154 288 }])],
cannam@154 289 [cc_cv_func_expect=yes],
cannam@154 290 [cc_cv_func_expect=no])
cannam@154 291 CFLAGS="$ac_save_CFLAGS"
cannam@154 292 ])
cannam@154 293
cannam@154 294 AS_IF([test "x$cc_cv_func_expect" = "xyes"],
cannam@154 295 [AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1,
cannam@154 296 [Define this if the compiler supports __builtin_expect() function])
cannam@154 297 $1],
cannam@154 298 [$2])
cannam@154 299 ])
cannam@154 300
cannam@154 301 AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [
cannam@154 302 AC_REQUIRE([CC_CHECK_WERROR])
cannam@154 303 AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported],
cannam@154 304 [cc_cv_attribute_aligned],
cannam@154 305 [ac_save_CFLAGS="$CFLAGS"
cannam@154 306 CFLAGS="$CFLAGS $cc_cv_werror"
cannam@154 307 for cc_attribute_align_try in 64 32 16 8 4 2; do
cannam@154 308 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
cannam@154 309 int main() {
cannam@154 310 static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0;
cannam@154 311 return c;
cannam@154 312 }])], [cc_cv_attribute_aligned=$cc_attribute_align_try; break])
cannam@154 313 done
cannam@154 314 CFLAGS="$ac_save_CFLAGS"
cannam@154 315 ])
cannam@154 316
cannam@154 317 if test "x$cc_cv_attribute_aligned" != "x"; then
cannam@154 318 AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned],
cannam@154 319 [Define the highest alignment supported])
cannam@154 320 fi
cannam@154 321 ])