]> git.lizzy.rs Git - zlib.git/commitdiff
Add --cover option to ./configure for gcc coverage testing.
authorMark Adler <madler@alumni.caltech.edu>
Sun, 9 Oct 2011 17:16:43 +0000 (10:16 -0700)
committerMark Adler <madler@alumni.caltech.edu>
Sun, 9 Oct 2011 17:25:15 +0000 (10:25 -0700)
This adds the -fprofile-arcs and -ftest-coverage options when compiling
the source code for the static library.  Those same options must then be
used when linking the static library into an executable.  This updates
Makefile.in to remove and .gitignore to ignore the files generated when
testing coverage.

.gitignore
Makefile.in
configure

index 81d3ed29c7d9506a859ecbb5f9273b25d4869dfa..8c6bce0b9df6247416ac9766ce739ebc1b0cd107 100644 (file)
@@ -9,6 +9,10 @@
 *.o
 *.dylib
 
+*.gcda
+*.gcno
+*.gcov
+
 /example
 /example64
 /examplesh
index 1b8bf3f82bead7166bda517b95cc16a2f1aca5c1..9ac04060f76bfeadd89726a7f44844794e061918 100644 (file)
@@ -232,6 +232,7 @@ clean:
           libz.* foo.gz so_locations \
           _match.s maketree contrib/infback9/*.o
        rm -rf objs
+       rm -f *.gcda *.gcno *.gcov
 
 maintainer-clean: distclean
 distclean: clean zconf zconf.h.cmakein docs
index 672b24fec7c6e29d7ad51790e499134d19b66db1..d15c03b69fb89833d05dda8f1e19d36dcde61440 100755 (executable)
--- a/configure
+++ b/configure
@@ -55,6 +55,7 @@ mandir=${mandir-'${prefix}/share/man'}
 shared_ext='.so'
 shared=1
 solo=0
+cover=0
 zprefix=0
 build64=0
 gcc=0
@@ -85,6 +86,7 @@ case "$1" in
     -s* | --shared | --enable-shared) shared=1; shift ;;
     -t | --static) shared=0; shift ;;
     --solo) solo=1; shift ;;
+    --cover) cover=1; shift ;;
     -z* | --zprefix) zprefix=1; shift ;;
     -6* | --64) build64=1; shift ;;
     -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
@@ -345,6 +347,10 @@ OBJC='$(OBJZ)'
 PIC_OBJC='$(PIC_OBJZ)'
 fi
 
+if test $cover -eq 1; then
+  CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
+fi
+
 cat > $test.c <<EOF
 #include <stdio.h>
 #include <stdarg.h>
@@ -578,7 +584,7 @@ case $CFLAGS in
     fi ;;
 esac
 
-rm -f $test.[co] $test $test$shared_ext
+rm -f $test.[co] $test $test$shared_ext $test.gcno
 
 # udpate Makefile
 sed < Makefile.in "