qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] move -Wno-error=uninitialized to configure
@ 2009-06-30 11:39 Michael S. Tsirkin
  2009-06-30 12:07 ` Paul Brook
  0 siblings, 1 reply; 8+ messages in thread
From: Michael S. Tsirkin @ 2009-06-30 11:39 UTC (permalink / raw)
  To: Laurent Desnogues; +Cc: Anthony Liguori, qemu-devel

Move -Wno-error=uninitialized out of rules.mak and into configure. Only
use it if supported by compiler.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 configure |   15 ++++++++++++++-
 rules.mak |    2 +-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index eb9d73a..69c7471 100755
--- a/configure
+++ b/configure
@@ -526,8 +526,21 @@ if test -z "$werror" ; then
     fi
 fi
 
+# Disable uninitialized variable warning or convert it to non-error, if possible
+cat > $TMPC <<EOF
+int main(void) {}
+EOF
+if $cc -Werror -Wno-error=uninitialized -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
+    # Enable werror by default for recent compilers
+    werror_cflags="-Werror -Wno-error=uninitialized"
+elif $cc -Werror -Wno-uninitialized -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
+    werror_cflags="-Werror -Wno-uninitialized"
+else
+    werror_cflags="-Werror"
+fi
+
 if test "$werror" = "yes" ; then
-    CFLAGS="$CFLAGS -Werror"
+    CFLAGS="$CFLAGS $werror_cflags"
 fi
 
 if test "$solaris" = "no" ; then
diff --git a/rules.mak b/rules.mak
index defee1d..8d6d96e 100644
--- a/rules.mak
+++ b/rules.mak
@@ -1,6 +1,6 @@
 
 %.o: %.c
-	$(call quiet-command,$(CC) $(CPPFLAGS) $(CFLAGS) -Werror -Wno-error=uninitialized -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
+	$(call quiet-command,$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
 
 %.o: %.S
 	$(call quiet-command,$(CC) $(CPPFLAGS) -c -o $@ $<,"  AS    $(TARGET_DIR)$@")
-- 
1.6.2.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-06-30 15:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-30 11:39 [Qemu-devel] [PATCH] move -Wno-error=uninitialized to configure Michael S. Tsirkin
2009-06-30 12:07 ` Paul Brook
2009-06-30 12:12   ` Michael S. Tsirkin
2009-06-30 12:16     ` Michael S. Tsirkin
2009-06-30 12:44       ` Paul Brook
2009-06-30 12:58         ` Michael S. Tsirkin
2009-06-30 15:22           ` Stuart Brady
2009-06-30 12:30   ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).