-
Notifications
You must be signed in to change notification settings - Fork 3
/
acsm_code_coverage.m4
100 lines (75 loc) · 2.46 KB
/
acsm_code_coverage.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# SYNOPSIS
#
# Add code coverage support with gcov/lcov.
#
# ACSM_CODE_COVERAGE()
#
# DESCRIPTION
#
# Provides a --enable-coverage option which checks for available
# gcov/lcov binaries and provides ENABLE_CODE_COVERAGE conditional.
#
# LAST MODIFICATION
#
# git log -n1 m4/coverage.m4
#
# COPYLEFT
#
# Copyright (c) 2012 Roy H. Stogner <[email protected]>
# Copyright (c) 2010 Karl W. Schulz <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved.
AC_DEFUN([ACSM_CODE_COVERAGE],
[
AC_ARG_ENABLE(coverage, AS_HELP_STRING([--enable-coverage],[configure code coverage analysis tools]))
HAVE_GCOV_TOOLS=0
GCOV_FLAGS=""
if test "x$enable_coverage" = "xyes"; then
# ----------------------------
# Check for gcov/lcov binaries
# ----------------------------
AC_CHECK_PROG(have_gcov,gcov, yes, no)
if test "x$have_gcov" = "xno"; then
AC_MSG_ERROR([
gcov coverage testing tool not found. Please install or update
your PATH accordingly prior to enabling code coverage features.
])
fi
# ----------------------------------
# include coverage compiler options
# ----------------------------------
HAVE_GCOV_TOOLS=1
GCOV_FLAGS="-fprofile-arcs -ftest-coverage --coverage"
GCOV_LDFLAGS="--coverage -lgcov"
ac_coverage_save_LDFLAGS="$LDFLAGS"
LDFLAGS="${LDFLAGS} ${GCOV_LDFLAGS}"
# Test for C...
ac_coverage_save_CFLAGS="$CFLAGS"
AC_LANG_PUSH([C])
CFLAGS="${GCOV_FLAGS} ${CFLAGS}"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],[],
[AC_MSG_ERROR([unable to compile with code coverage ($CC --coverage)])])
AC_LANG_POP([C])
# Test for C++...
ac_coverage_save_CXXFLAGS="$CXXFLAGS"
AC_LANG_PUSH([C++])
CXXFLAGS="${GCOV_FLAGS} ${CXXFLAGS}"
LIBS="-lgcov ${LIBS}"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],[],
[AC_MSG_ERROR([unable to compile with code coverage ($CXX --coverage)])])
AC_LANG_POP([C++])
# Test for Fortran...
ac_coverage_save_FCFLAGS="$FCFLAGS"
AC_LANG_PUSH([Fortran])
FCFLAGS="${GCOV_FLAGS} ${FCFLAGS}"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],[],
[AC_MSG_ERROR([unable to compile with code coverage ($FC --coverage)])])
AC_LANG_POP([Fortran])
fi
AC_SUBST(GCOV_FLAGS)
AC_SUBST(GCOV_LDFLAGS)
AC_SUBST(HAVE_GCOV_TOOLS)
AM_CONDITIONAL(CODE_COVERAGE_ENABLED,test x$HAVE_GCOV_TOOLS = x1)
])