Add --cover option to ./configure for gcc coverage testing.

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.
This commit is contained in:
Mark Adler 2011-10-09 10:16:43 -07:00
parent 1bd2fa1b24
commit d66a307941
3 changed files with 12 additions and 1 deletions

4
.gitignore vendored
View File

@ -9,6 +9,10 @@
*.o *.o
*.dylib *.dylib
*.gcda
*.gcno
*.gcov
/example /example
/example64 /example64
/examplesh /examplesh

View File

@ -232,6 +232,7 @@ clean:
libz.* foo.gz so_locations \ libz.* foo.gz so_locations \
_match.s maketree contrib/infback9/*.o _match.s maketree contrib/infback9/*.o
rm -rf objs rm -rf objs
rm -f *.gcda *.gcno *.gcov
maintainer-clean: distclean maintainer-clean: distclean
distclean: clean zconf zconf.h.cmakein docs distclean: clean zconf zconf.h.cmakein docs

8
configure vendored
View File

@ -55,6 +55,7 @@ mandir=${mandir-'${prefix}/share/man'}
shared_ext='.so' shared_ext='.so'
shared=1 shared=1
solo=0 solo=0
cover=0
zprefix=0 zprefix=0
build64=0 build64=0
gcc=0 gcc=0
@ -85,6 +86,7 @@ case "$1" in
-s* | --shared | --enable-shared) shared=1; shift ;; -s* | --shared | --enable-shared) shared=1; shift ;;
-t | --static) shared=0; shift ;; -t | --static) shared=0; shift ;;
--solo) solo=1; shift ;; --solo) solo=1; shift ;;
--cover) cover=1; shift ;;
-z* | --zprefix) zprefix=1; shift ;; -z* | --zprefix) zprefix=1; shift ;;
-6* | --64) build64=1; shift ;; -6* | --64) build64=1; shift ;;
-a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;; -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
@ -345,6 +347,10 @@ OBJC='$(OBJZ)'
PIC_OBJC='$(PIC_OBJZ)' PIC_OBJC='$(PIC_OBJZ)'
fi fi
if test $cover -eq 1; then
CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
fi
cat > $test.c <<EOF cat > $test.c <<EOF
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
@ -578,7 +584,7 @@ case $CFLAGS in
fi ;; fi ;;
esac esac
rm -f $test.[co] $test $test$shared_ext rm -f $test.[co] $test $test$shared_ext $test.gcno
# udpate Makefile # udpate Makefile
sed < Makefile.in " sed < Makefile.in "