[FFmpeg-devel] [PATCH] When checking for compiler flags, check if warnings are reported.
Diego 'Flameeyes' Pettenò
flameeyes
Thu Oct 2 11:56:45 CEST 2008
Some compilers, namely the Sun Studio compiler, don't abort the build
when a flag is not supported, but just throw a warning. With these
changes, the output of the compiler is logged down, and can be grepped
for particular common warnings.
Also, the output is forced to use C-locale, as translated output
messages wouldn't be able to be read through grepping.
With this change there is no change in GCC's behaviour, but the Sun
Studio compiler won't be asked to use any flag it does not support
properly.
---
configure | 26 ++++++++++++++++++--------
1 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/configure b/configure
index 0fb0721..61055fd 100755
--- a/configure
+++ b/configure
@@ -222,7 +222,7 @@ Include the log file "$logfile" produced by configure as this will help
solving the problem.
EOF
fi
- rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
+ rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH $TMPLOG $TMPRES
exit 1
}
@@ -419,21 +419,23 @@ add_extralibs(){
check_cmd(){
log "$@"
- "$@" >> $logfile 2>&1
+ rm -f $TMPRES
+ ( "$@" 2>&1 && touch $TMPRES; ) | tee $TMPLOG >> $logfile
+ test -f $TMPRES
}
check_cc(){
log check_cc "$@"
cat > $TMPC
log_file $TMPC
- check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
+ LC_ALL=C check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
}
check_cpp(){
log check_cpp "$@"
cat > $TMPC
log_file $TMPC
- check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
+ LC_ALL=C check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
}
check_asm(){
@@ -441,7 +443,7 @@ check_asm(){
name="$1"
asm="$2"
shift 2
- check_cc "$@" <<EOF && enable $name || disable $name
+ LC_ALL=C check_cc "$@" <<EOF && enable $name || disable $name
int foo(void){ asm volatile($asm); }
EOF
}
@@ -451,7 +453,7 @@ check_yasm(){
echo "$1" > $TMPS
log_file $TMPS
shift 1
- check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
+ LC_ALL=C check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
}
check_ld(){
@@ -462,14 +464,20 @@ check_ld(){
for f; do
test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
done
- check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
+ LC_ALL=C check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
}
check_cflags(){
log check_cflags "$@"
- check_cc "$@" <<EOF && add_cflags "$@"
+ check_cc "$@" <<EOF || return
int x;
EOF
+
+ grep -qi "warning" $TMPLOG && return
+ grep -qi "illegal option" $TMPLOG && return
+ grep -qi "unrecognized" $TMPLOG && return
+
+ add_cflags "$@"
}
check_ldflags(){
@@ -1128,6 +1136,8 @@ TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
TMPSH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
+TMPLOG="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.log"
+TMPRES="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.res"
check_cflags -fasm
check_cflags -std=c99
More information about the ffmpeg-devel
mailing list