Commit 03b4fe7de226a54540a487a0dbd4c749c5d1c2af

Authored by aliguori
1 parent 797d5db0

Add sparse checker support to the build system (Gerd Hoffman)

This adds support for running the sparse checker during the build
process.  Left it off by default for now, build becomes very noisy with
sparse checking turned on as it has to complain alot (partly even in the
system headers!).  The qemu code base needs quite some cleanups before
we should consider turning it on by default.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5440 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 16 additions and 0 deletions
configure
@@ -85,6 +85,7 @@ case &quot;$cpu&quot; in @@ -85,6 +85,7 @@ case &quot;$cpu&quot; in
85 ;; 85 ;;
86 esac 86 esac
87 gprof="no" 87 gprof="no"
  88 +sparse="no"
88 bigendian="no" 89 bigendian="no"
89 mingw32="no" 90 mingw32="no"
90 EXESUF="" 91 EXESUF=""
@@ -285,6 +286,10 @@ for opt do @@ -285,6 +286,10 @@ for opt do
285 ;; 286 ;;
286 --audio-drv-list=*) audio_drv_list="$optarg" 287 --audio-drv-list=*) audio_drv_list="$optarg"
287 ;; 288 ;;
  289 + --enable-sparse) sparse="yes"
  290 + ;;
  291 + --disable-sparse) sparse="no"
  292 + ;;
288 --disable-vnc-tls) vnc_tls="no" 293 --disable-vnc-tls) vnc_tls="no"
289 ;; 294 ;;
290 --disable-slirp) slirp="no" 295 --disable-slirp) slirp="no"
@@ -422,6 +427,7 @@ echo &quot; --host-cc=CC use C compiler CC [$host_cc] for dyngen etc.&quot; @@ -422,6 +427,7 @@ echo &quot; --host-cc=CC use C compiler CC [$host_cc] for dyngen etc.&quot;
422 echo " --make=MAKE use specified make [$make]" 427 echo " --make=MAKE use specified make [$make]"
423 echo " --install=INSTALL use specified install [$install]" 428 echo " --install=INSTALL use specified install [$install]"
424 echo " --static enable static build [$static]" 429 echo " --static enable static build [$static]"
  430 +echo " --disable-sparse disable sparse checker"
425 echo " --disable-werror disable compilation abort on warning" 431 echo " --disable-werror disable compilation abort on warning"
426 echo " --disable-sdl disable SDL" 432 echo " --disable-sdl disable SDL"
427 echo " --enable-cocoa enable COCOA (Mac OS X only)" 433 echo " --enable-cocoa enable COCOA (Mac OS X only)"
@@ -532,6 +538,10 @@ EOF @@ -532,6 +538,10 @@ EOF
532 fi 538 fi
533 fi 539 fi
534 540
  541 +if test ! -x "$(which cgcc 2>/dev/null)"; then
  542 + sparse="no"
  543 +fi
  544 +
535 # 545 #
536 # Solaris specific configure tool chain decisions 546 # Solaris specific configure tool chain decisions
537 # 547 #
@@ -987,6 +997,7 @@ echo &quot;host CPU $cpu&quot; @@ -987,6 +997,7 @@ echo &quot;host CPU $cpu&quot;
987 echo "host big endian $bigendian" 997 echo "host big endian $bigendian"
988 echo "target list $target_list" 998 echo "target list $target_list"
989 echo "gprof enabled $gprof" 999 echo "gprof enabled $gprof"
  1000 +echo "sparse enabled $sparse"
990 echo "profiler $profiler" 1001 echo "profiler $profiler"
991 echo "static build $static" 1002 echo "static build $static"
992 echo "-Werror enabled $werror" 1003 echo "-Werror enabled $werror"
@@ -1135,6 +1146,11 @@ case &quot;$cpu&quot; in @@ -1135,6 +1146,11 @@ case &quot;$cpu&quot; in
1135 exit 1 1146 exit 1
1136 ;; 1147 ;;
1137 esac 1148 esac
  1149 +if test "$sparse" = "yes" ; then
  1150 + echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_mak
  1151 + echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_mak
  1152 + echo "CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_mak
  1153 +fi
1138 if test "$bigendian" = "yes" ; then 1154 if test "$bigendian" = "yes" ; then
1139 echo "WORDS_BIGENDIAN=yes" >> $config_mak 1155 echo "WORDS_BIGENDIAN=yes" >> $config_mak
1140 echo "#define WORDS_BIGENDIAN 1" >> $config_h 1156 echo "#define WORDS_BIGENDIAN 1" >> $config_h