1
1
dnl Macros to check the presence of generic (non-typed) symbols.
2
2
dnl Copyright (c) 2006-2008 Diego Pettenò <[email protected] >
3
3
dnl Copyright (c) 2006-2008 xine project
4
+ dnl Copyright (c) 2012 Lucas De Marchi <[email protected] >
4
5
dnl
5
6
dnl This program is free software; you can redistribute it and/or modify
6
7
dnl it under the terms of the GNU General Public License as published by
@@ -32,52 +33,32 @@ dnl distribute a modified version of the Autoconf Macro, you may extend
32
33
dnl this special exception to the GPL to apply to your modified version as
33
34
dnl well.
34
35
35
- dnl Check if the flag is supported by compiler
36
- dnl CC_CHECK_CFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
37
-
38
- AC_DEFUN ( [ CC_CHECK_CFLAGS_SILENT] , [
39
- AC_CACHE_VAL ( AS_TR_SH ( [ cc_cv_cflags_$1 ] ) ,
40
- [ ac_save_CFLAGS="$CFLAGS"
41
- CFLAGS="$CFLAGS $1 "
42
- AC_COMPILE_IFELSE ( [ int a;] ,
43
- [ eval "AS_TR_SH ( [ cc_cv_cflags_$1 ] ) ='yes'"] ,
44
- [ eval "AS_TR_SH ( [ cc_cv_cflags_$1 ] ) ='no'"] )
45
- CFLAGS="$ac_save_CFLAGS"
46
- ] )
47
-
48
- AS_IF ( [ eval test x$] AS_TR_SH ( [ cc_cv_cflags_$1 ] ) [ = xyes] ,
49
- [ $2 ] , [ $3 ] )
50
- ] )
51
-
52
- dnl Check if the flag is supported by compiler (cacheable)
53
- dnl CC_CHECK_CFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
54
-
55
- AC_DEFUN ( [ CC_CHECK_CFLAGS] , [
56
- AC_CACHE_CHECK ( [ if $CC supports $1 flag] ,
57
- AS_TR_SH ( [ cc_cv_cflags_$1 ] ) ,
58
- CC_CHECK_CFLAGS_SILENT ( [ $1 ] ) dnl Don't execute actions here!
59
- )
60
-
61
- AS_IF ( [ eval test x$] AS_TR_SH ( [ cc_cv_cflags_$1 ] ) [ = xyes] ,
62
- [ $2 ] , [ $3 ] )
63
- ] )
64
-
65
- dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found])
66
- dnl Check for CFLAG and appends them to CFLAGS if supported
67
- AC_DEFUN ( [ CC_CHECK_CFLAG_APPEND] , [
68
- AC_CACHE_CHECK ( [ if $CC supports $1 flag] ,
69
- AS_TR_SH ( [ cc_cv_cflags_$1 ] ) ,
70
- CC_CHECK_CFLAGS_SILENT ( [ $1 ] ) dnl Don't execute actions here!
71
- )
72
-
73
- AS_IF ( [ eval test x$] AS_TR_SH ( [ cc_cv_cflags_$1 ] ) [ = xyes] ,
74
- [ CFLAGS="$CFLAGS $1 "; DEBUG_CFLAGS="$DEBUG_CFLAGS $1 "; $2 ] , [ $3 ] )
36
+ dnl Check if FLAG in ENV-VAR is supported by compiler and append it
37
+ dnl to WHERE-TO-APPEND variable. Note that we invert -Wno-* checks to
38
+ dnl -W* as gcc cannot test for negated warnings. If a C snippet is passed,
39
+ dnl use it, otherwise use a simple main() definition that just returns 0.
40
+ dnl CC_CHECK_FLAG_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG], [C-SNIPPET])
41
+
42
+ AC_DEFUN ( [ CC_CHECK_FLAG_APPEND] , [
43
+ AC_CACHE_CHECK ( [ if $CC supports flag $3 in envvar $2 ] ,
44
+ AS_TR_SH ( [ cc_cv_$2 _$3 ] ) ,
45
+ [ eval "AS_TR_SH ( [ cc_save_$2 ] ) ='${$2 }'"
46
+ eval "AS_TR_SH ( [ $2 ] ) ='${cc_save_$2 } -Werror `echo "$3 " | sed 's/^-Wno-/-W/'`'"
47
+ AC_LINK_IFELSE ( [ AC_LANG_SOURCE ( ifelse ( [ $4 ] , [ ] ,
48
+ [ int main(void) { return 0; } ] ,
49
+ [ $4 ] ) ) ] ,
50
+ [ eval "AS_TR_SH ( [ cc_cv_$2 _$3 ] ) ='yes'"] ,
51
+ [ eval "AS_TR_SH ( [ cc_cv_$2 _$3 ] ) ='no'"] )
52
+ eval "AS_TR_SH ( [ $2 ] ) ='$cc_save_$2 '"] )
53
+
54
+ AS_IF ( [ eval test x$] AS_TR_SH ( [ cc_cv_$2 _$3 ] ) [ = xyes] ,
55
+ [ eval "$1 ='${$1 } $3 '"] )
75
56
] )
76
57
77
- dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2 ], [action-if-found ], [action-if-not ])
78
- AC_DEFUN ( [ CC_CHECK_CFLAGS_APPEND ] , [
79
- for flag in $1 ; do
80
- CC_CHECK_CFLAG_APPEND($flag , [ $2 ] , [ $3 ] )
58
+ dnl CC_CHECK_FLAGS_APPEND([WHERE-TO-APPEND ], [ENV-VAR ], [FLAG1 FLAG2], [C-SNIPPET ])
59
+ AC_DEFUN ( [ CC_CHECK_FLAGS_APPEND ] , [
60
+ for flag in [ $3 ] ; do
61
+ CC_CHECK_FLAG_APPEND( [ $1 ] , [ $2 ] , $flag, [ $4 ] )
81
62
done
82
63
] )
83
64
@@ -112,13 +93,13 @@ AC_DEFUN([CC_NOUNDEFINED], [
112
93
*-freebsd* | *-openbsd*) ;;
113
94
*)
114
95
dnl First of all check for the --no-undefined variant of GNU ld. This allows
115
- dnl for a much more readable commandline , so that people can understand what
96
+ dnl for a much more readable command line , so that people can understand what
116
97
dnl it does without going to look for what the heck -z defs does.
117
- for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do
118
- CC_CHECK_LDFLAGS([ $possible_flags] , [ LDFLAGS_NOUNDEFINED="$possible_flags"] )
119
- break
98
+ for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do
99
+ CC_CHECK_LDFLAGS([ $possible_flags] , [ LDFLAGS_NOUNDEFINED="$possible_flags"] )
100
+ break
120
101
done
121
- ;;
102
+ ;;
122
103
esac
123
104
124
105
AC_SUBST ( [ LDFLAGS_NOUNDEFINED] )
@@ -147,7 +128,7 @@ AC_DEFUN([CC_CHECK_ATTRIBUTE], [
147
128
AS_TR_SH ( [ cc_cv_attribute_$1 ] ) ,
148
129
[ ac_save_CFLAGS="$CFLAGS"
149
130
CFLAGS="$CFLAGS $cc_cv_werror"
150
- AC_COMPILE_IFELSE ( [ $3 ] ,
131
+ AC_COMPILE_IFELSE ( [ AC_LANG_SOURCE ( [ $3 ] ) ] ,
151
132
[ eval "AS_TR_SH ( [ cc_cv_attribute_$1 ] ) ='yes'"] ,
152
133
[ eval "AS_TR_SH ( [ cc_cv_attribute_$1 ] ) ='no'"] )
153
134
CFLAGS="$ac_save_CFLAGS"
@@ -254,8 +235,8 @@ AC_DEFUN([CC_FLAG_VISIBILITY], [
254
235
[ cc_flag_visibility_save_CFLAGS="$CFLAGS"
255
236
CFLAGS="$CFLAGS $cc_cv_werror"
256
237
CC_CHECK_CFLAGS_SILENT([ -fvisibility=hidden] ,
257
- cc_cv_flag_visibility='yes',
258
- cc_cv_flag_visibility='no')
238
+ cc_cv_flag_visibility='yes',
239
+ cc_cv_flag_visibility='no')
259
240
CFLAGS="$cc_flag_visibility_save_CFLAGS"] )
260
241
261
242
AS_IF ( [ test "x$cc_cv_flag_visibility" = "xyes"] ,
@@ -271,11 +252,11 @@ AC_DEFUN([CC_FUNC_EXPECT], [
271
252
[ cc_cv_func_expect] ,
272
253
[ ac_save_CFLAGS="$CFLAGS"
273
254
CFLAGS="$CFLAGS $cc_cv_werror"
274
- AC_COMPILE_IFELSE (
255
+ AC_COMPILE_IFELSE ( [ AC_LANG_SOURCE (
275
256
[ int some_function() {
276
257
int a = 3;
277
258
return (int)__builtin_expect(a, 3);
278
- } ] ,
259
+ } ] ) ] ,
279
260
[ cc_cv_func_expect=yes] ,
280
261
[ cc_cv_func_expect=no] )
281
262
CFLAGS="$ac_save_CFLAGS"
@@ -295,11 +276,11 @@ AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [
295
276
[ ac_save_CFLAGS="$CFLAGS"
296
277
CFLAGS="$CFLAGS $cc_cv_werror"
297
278
for cc_attribute_align_try in 64 32 16 8 4 2; do
298
- AC_COMPILE_IFELSE ( [
279
+ AC_COMPILE_IFELSE ( [ AC_LANG_SOURCE ( [
299
280
int main() {
300
281
static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0;
301
282
return c;
302
- }] , [ cc_cv_attribute_aligned=$cc_attribute_align_try; break] )
283
+ }] ) ] , [ cc_cv_attribute_aligned=$cc_attribute_align_try; break] )
303
284
done
304
285
CFLAGS="$ac_save_CFLAGS"
305
286
] )
0 commit comments