]> xenbits.xensource.com Git - libvirt.git/commitdiff
Improve compiler flag checking
authorJohn Levon <john.levon@sun.com>
Wed, 14 Jan 2009 15:23:26 +0000 (15:23 +0000)
committerJohn Levon <john.levon@sun.com>
Wed, 14 Jan 2009 15:23:26 +0000 (15:23 +0000)
ChangeLog
acinclude.m4
m4/compiler-flags.m4

index 9e9875f6a884bbf8949579a08305b16145b75efd..a425b2d488efd0676aa34b9f24329bc8da263efd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Jan 14 15:13:17 GMT 2009  John Levon  <levon@movementarian.org>
+
+       * acinclude.m4:
+       * m4/compiler-flags.m4: Some compilers (including GCC) don't set
+       the return value consistently if an erroneous option is passed on
+       the command line. Account for that.
+
 Tue Jan 13 13:21:13 +0100 2009 Jim Meyering <meyering@redhat.com>
 
        qemud.c: fix error in yesterday's change: s/X_OK/R_OK/
index e93ac2ad821bedc09c3dc7811ff29676e7bbe1a4..8962e34ce8be8bc2c86cbd657037fb72ade99976 100644 (file)
@@ -45,21 +45,9 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
        ;;
     esac
 
-    compiler_flags=
+    COMPILER_FLAGS=
     for option in $try_compiler_flags; do
-       SAVE_CFLAGS="$CFLAGS"
-       CFLAGS="$CFLAGS $option"
-       AC_MSG_CHECKING([whether gcc understands $option])
-       AC_TRY_LINK([], [],
-               has_option=yes,
-               has_option=no,)
-       CFLAGS="$SAVE_CFLAGS"
-       AC_MSG_RESULT($has_option)
-       if test $has_option = yes; then
-         compiler_flags="$compiler_flags $option"
-       fi
-       unset has_option
-       unset SAVE_CFLAGS
+        gl_COMPILER_FLAGS($option)
     done
     unset option
     unset try_compiler_flags
@@ -85,7 +73,7 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
     fi
     AC_MSG_RESULT($complCFLAGS)
 
-    WARN_CFLAGS="$compiler_flags $complCFLAGS"
+    WARN_CFLAGS="$COMPILER_FLAGS $complCFLAGS"
     AC_SUBST(WARN_CFLAGS)
 
     dnl Needed to keep compile quiet on python 2.4
index cf4cba938aec70f18e5a9f8051ba470a03e2351c..4940a1e6dcdb73f2d71dc5155f0fa3ffec31c3f7 100644 (file)
@@ -25,10 +25,16 @@ AC_DEFUN([gl_COMPILER_FLAGS],
    AC_SUBST(COMPILER_FLAGS)
    ac_save_CFLAGS="$CFLAGS"
    CFLAGS="$CFLAGS $1"
-   AC_TRY_COMPILE(,
-    [int x;],
-    COMPILER_FLAGS="$COMPILER_FLAGS $1"
-    AC_MSG_RESULT(yes),
-    AC_MSG_RESULT(no))
-  CFLAGS="$ac_save_CFLAGS"
+   AC_TRY_LINK([], [], has_option=yes, has_option=no,)
+   echo 'int x;' >conftest.c
+   $CC $CFLAGS -c conftest.c 2>conftest.err
+   ret=$?
+   if test $ret != 0 -o -s conftest.err -o $has_option = "no"; then
+       AC_MSG_RESULT(no)
+   else
+       AC_MSG_RESULT(yes)
+       COMPILER_FLAGS="$COMPILER_FLAGS $1"
+   fi
+   CFLAGS="$ac_save_CFLAGS"
+   rm -f conftest*
  ])