autoconfiscate.diff 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. diff --git a/Demo/Makefile.am b/Demo/Makefile.am
  2. new file mode 100644
  3. --- /dev/null
  4. +++ b/Demo/Makefile.am
  5. @@ -0,0 +1,88 @@
  6. +AM_CPPFLAGS = -I$(top_srcdir)/Include
  7. +LDADD = $(top_builddir)/Source/libcsparse.la
  8. +
  9. +EXTRA_DIST = \
  10. + README.txt \
  11. + cs_demo.out
  12. +
  13. +# Disable the .out implicit pattern rule. Prevents GNU make from
  14. +# adding bogus dependencies for the .out files listed above.
  15. +%.out: %
  16. +
  17. +check_PROGRAMS = \
  18. + cs_demo1 \
  19. + cs_demo2 \
  20. + cs_demo3
  21. +
  22. +check_LTLIBRARIES = \
  23. + libcs_demo.la
  24. +
  25. +cs_demo1_SOURCES = cs_demo1.c
  26. +cs_demo2_SOURCES = cs_demo2.c
  27. +cs_demo3_SOURCES = cs_demo3.c
  28. +libcs_demo_la_SOURCES = cs_demo.c cs_demo.h
  29. +cs_demo2_LDADD = libcs_demo.la $(LDADD)
  30. +cs_demo3_LDADD = libcs_demo.la $(LDADD)
  31. +
  32. +if !CODE_COVERAGE_ENABLED
  33. +MATRICES = \
  34. + $(top_srcdir)/Matrix/ash219 \
  35. + $(top_srcdir)/Matrix/bcsstk01 \
  36. + $(top_srcdir)/Matrix/bcsstk16 \
  37. + $(top_srcdir)/Matrix/fs_183_1 \
  38. + $(top_srcdir)/Matrix/lp_afiro \
  39. + $(top_srcdir)/Matrix/mbeacxc \
  40. + $(top_srcdir)/Matrix/t1 \
  41. + $(top_srcdir)/Matrix/west0067
  42. +
  43. +check-local: $(check_PROGRAMS) $(MATRICES)
  44. + -./cs_demo1 < $(top_srcdir)/Matrix/t1
  45. + -./cs_demo2 < $(top_srcdir)/Matrix/t1
  46. + -./cs_demo2 < $(top_srcdir)/Matrix/ash219
  47. + -./cs_demo2 < $(top_srcdir)/Matrix/bcsstk01
  48. + -./cs_demo2 < $(top_srcdir)/Matrix/fs_183_1
  49. + -./cs_demo2 < $(top_srcdir)/Matrix/mbeacxc
  50. + -./cs_demo2 < $(top_srcdir)/Matrix/west0067
  51. + -./cs_demo2 < $(top_srcdir)/Matrix/lp_afiro
  52. + -./cs_demo2 < $(top_srcdir)/Matrix/bcsstk16
  53. + -./cs_demo3 < $(top_srcdir)/Matrix/bcsstk01
  54. + -./cs_demo3 < $(top_srcdir)/Matrix/bcsstk16
  55. +
  56. +else
  57. +MATRICES = \
  58. + $(top_srcdir)/Tcov/nil \
  59. + $(top_srcdir)/Tcov/zero \
  60. + $(top_srcdir)/Matrix/ash219 \
  61. + $(top_srcdir)/Matrix/bcsstk01 \
  62. + $(top_srcdir)/Matrix/bcsstk16 \
  63. + $(top_srcdir)/Matrix/fs_183_1 \
  64. + $(top_srcdir)/Matrix/ibm32a \
  65. + $(top_srcdir)/Matrix/ibm32b \
  66. + $(top_srcdir)/Matrix/lp_afiro \
  67. + $(top_srcdir)/Matrix/mbeacxc \
  68. + $(top_srcdir)/Matrix/t1 \
  69. + $(top_srcdir)/Matrix/west0067
  70. +
  71. +check-local: $(check_PROGRAMS) $(MATRICES)
  72. +# tiny tests
  73. + -./cs_demo1 < $(top_srcdir)/Tcov/nil
  74. + -./cs_demo1 < $(top_srcdir)/Tcov/zero
  75. + -./cs_demo2 < $(top_srcdir)/Tcov/nil
  76. + -./cs_demo2 < $(top_srcdir)/Tcov/zero
  77. + -./cs_demo3 < $(top_srcdir)/Tcov/nil
  78. +# test coverage for book:
  79. + -./cs_demo1 < $(top_srcdir)/Matrix/t1
  80. + -./cs_demo2 < $(top_srcdir)/Matrix/bcsstk01
  81. + -./cs_demo2 < $(top_srcdir)/Matrix/fs_183_1
  82. + -./cs_demo2 < $(top_srcdir)/Matrix/mbeacxc
  83. + -./cs_demo2 < $(top_srcdir)/Matrix/west0067
  84. + -./cs_demo2 < $(top_srcdir)/Matrix/lp_afiro
  85. + -./cs_demo3 < $(top_srcdir)/Matrix/bcsstk16
  86. +# other tests
  87. + -./cs_demo2 < $(top_srcdir)/Matrix/t1
  88. + -./cs_demo2 < $(top_srcdir)/Matrix/ash219
  89. + -./cs_demo3 < $(top_srcdir)/Matrix/bcsstk01
  90. + -./cs_demo2 < $(top_srcdir)/Matrix/bcsstk16
  91. + -./cs_demo2 < $(top_srcdir)/Matrix/ibm32a
  92. + -./cs_demo2 < $(top_srcdir)/Matrix/ibm32b
  93. +endif
  94. diff --git a/Include/Makefile.am b/Include/Makefile.am
  95. new file mode 100644
  96. --- /dev/null
  97. +++ b/Include/Makefile.am
  98. @@ -0,0 +1 @@
  99. +pkginclude_HEADERS = cs.h
  100. diff --git a/Makefile.am b/Makefile.am
  101. new file mode 100644
  102. --- /dev/null
  103. +++ b/Makefile.am
  104. @@ -0,0 +1,9 @@
  105. +ACLOCAL_AMFLAGS = -I m4
  106. +
  107. +SUBDIRS = Include Source Matrix Demo Tcov
  108. +EXTRA_DIST = README.txt Doc/ChangeLog Doc/License.txt Doc/lesser.txt
  109. +
  110. +pkgconfig_DATA = csparse.pc
  111. +
  112. +CODE_COVERAGE_BRANCH_COVERAGE = 1
  113. +@CODE_COVERAGE_RULES@
  114. diff --git a/Matrix/Makefile.am b/Matrix/Makefile.am
  115. new file mode 100644
  116. --- /dev/null
  117. +++ b/Matrix/Makefile.am
  118. @@ -0,0 +1,11 @@
  119. +dist_noinst_DATA = \
  120. + ash219 \
  121. + bcsstk01 \
  122. + bcsstk16 \
  123. + fs_183_1 \
  124. + ibm32a \
  125. + ibm32b \
  126. + lp_afiro \
  127. + mbeacxc \
  128. + t1 \
  129. + west0067
  130. diff --git a/Source/Makefile.am b/Source/Makefile.am
  131. new file mode 100644
  132. --- /dev/null
  133. +++ b/Source/Makefile.am
  134. @@ -0,0 +1,72 @@
  135. +AM_CPPFLAGS = -I$(top_srcdir)/Include
  136. +
  137. +EXTRA_DIST = \
  138. + README.txt
  139. +
  140. +CSPARSESRC = \
  141. + cs_add.c \
  142. + cs_amd.c \
  143. + cs_chol.c \
  144. + cs_cholsol.c \
  145. + cs_compress.c \
  146. + cs_counts.c \
  147. + cs_cumsum.c \
  148. + cs_dfs.c \
  149. + cs_dmperm.c \
  150. + cs_droptol.c \
  151. + cs_dropzeros.c \
  152. + cs_dupl.c \
  153. + cs_entry.c \
  154. + cs_ereach.c \
  155. + cs_etree.c \
  156. + cs_fkeep.c \
  157. + cs_gaxpy.c \
  158. + cs_happly.c \
  159. + cs_house.c \
  160. + cs_ipvec.c \
  161. + cs_leaf.c \
  162. + cs_load.c \
  163. + cs_lsolve.c \
  164. + cs_ltsolve.c \
  165. + cs_lu.c \
  166. + cs_lusol.c \
  167. + cs_maxtrans.c \
  168. + cs_multiply.c \
  169. + cs_norm.c \
  170. + cs_permute.c \
  171. + cs_pinv.c \
  172. + cs_post.c \
  173. + cs_print.c \
  174. + cs_pvec.c \
  175. + cs_qr.c \
  176. + cs_qrsol.c \
  177. + cs_randperm.c \
  178. + cs_reach.c \
  179. + cs_scatter.c \
  180. + cs_scc.c \
  181. + cs_schol.c \
  182. + cs_spsolve.c \
  183. + cs_sqr.c \
  184. + cs_symperm.c \
  185. + cs_tdfs.c \
  186. + cs_transpose.c \
  187. + cs_updown.c \
  188. + cs_usolve.c \
  189. + cs_util.c \
  190. + cs_utsolve.c
  191. +
  192. +if !CODE_COVERAGE_ENABLED
  193. +CSPARSESRC += \
  194. + cs_malloc.c
  195. +else
  196. +CSPARSESRC += \
  197. + $(top_srcdir)/Tcov/cstcov_malloc_test.c \
  198. + $(top_srcdir)/Tcov/cstcov_malloc_test.h
  199. +endif
  200. +
  201. +lib_LTLIBRARIES = libcsparse.la
  202. +libcsparse_la_SOURCES = $(CSPARSESRC)
  203. +libcsparse_la_LIBADD = -lm $(CODE_COVERAGE_LIBS)
  204. +libcsparse_la_CPPFLAGS = $(AM_CPPFLAGS) $(CODE_COVERAGE_CPPFLAGS)
  205. +libcsparse_la_CFLAGS = $(AM_CFLAGS) $(CODE_COVERAGE_CFLAGS)
  206. +libcsparse_la_LDFLAGS = -no-undefined -release $(PACKAGE_VERSION)
  207. diff --git a/Tcov/Makefile.am b/Tcov/Makefile.am
  208. new file mode 100644
  209. --- /dev/null
  210. +++ b/Tcov/Makefile.am
  211. @@ -0,0 +1,40 @@
  212. +AM_CPPFLAGS = -I$(top_srcdir)/Include -I$(top_srcdir)/Demo
  213. +LDADD = $(top_builddir)/Source/libcsparse.la
  214. +
  215. +EXTRA_DIST = \
  216. + README.txt
  217. +
  218. +dist_noinst_DATA = \
  219. + nil \
  220. + zero
  221. +
  222. +if CODE_COVERAGE_ENABLED
  223. +check_PROGRAMS = \
  224. + cstcov_test
  225. +
  226. +cstcov_test_SOURCES = cstcov_test.c
  227. +cstcov_test_LDADD = $(top_builddir)/Demo/libcs_demo.la $(LDADD)
  228. +
  229. +MATRICES = \
  230. + $(top_srcdir)/Tcov/nil \
  231. + $(top_srcdir)/Tcov/zero \
  232. + $(top_srcdir)/Matrix/ash219 \
  233. + $(top_srcdir)/Matrix/bcsstk01 \
  234. + $(top_srcdir)/Matrix/fs_183_1 \
  235. + $(top_srcdir)/Matrix/lp_afiro \
  236. + $(top_srcdir)/Matrix/t1 \
  237. + $(top_srcdir)/Matrix/west0067
  238. +
  239. +check-local: $(check_PROGRAMS) $(MATRICES)
  240. +# exhaustive memory tests
  241. + -./cstcov_test $(top_srcdir)/Tcov/nil > test_nil.out
  242. + -./cstcov_test $(top_srcdir)/Tcov/zero > test_zero.out
  243. + -./cstcov_test $(top_srcdir)/Matrix/t1 > test_t1.out
  244. + -./cstcov_test $(top_srcdir)/Matrix/bcsstk01 > test_k1.out
  245. + -./cstcov_test $(top_srcdir)/Matrix/fs_183_1 > test_fs.out
  246. + -./cstcov_test $(top_srcdir)/Matrix/west0067 > test_we.out
  247. + -./cstcov_test $(top_srcdir)/Matrix/ash219 > test_ash.out
  248. + -./cstcov_test $(top_srcdir)/Matrix/lp_afiro > test_afiro.out
  249. +endif
  250. +
  251. +CLEANFILES = *.out
  252. diff --git a/configure.ac b/configure.ac
  253. new file mode 100644
  254. --- /dev/null
  255. +++ b/configure.ac
  256. @@ -0,0 +1,47 @@
  257. +# -*- Autoconf -*-
  258. +# Process this file with autoconf to produce a configure script.
  259. +
  260. +AC_PREREQ([2.69])
  261. +AC_INIT([CSparse],[3.2.0],[https://github.com/DrTimothyAldenDavis/SuiteSparse],[csparse],[http://www.suitesparse.com/])
  262. +AC_CONFIG_SRCDIR([Source/cs_print.c])
  263. +AC_CONFIG_AUX_DIR([build-aux])
  264. +AC_CONFIG_MACRO_DIR([m4])
  265. +AC_CONFIG_HEADERS([config.h])
  266. +AM_INIT_AUTOMAKE([foreign])
  267. +AM_SILENT_RULES([yes])
  268. +LT_INIT([disable-static])
  269. +
  270. +# Checks for programs.
  271. +AC_PROG_INSTALL
  272. +AC_PROG_CC
  273. +AX_CODE_COVERAGE
  274. +
  275. +AS_VAR_SET([LIBS_SAVED], [$LIBS])
  276. +
  277. +# Checks for libraries.
  278. +AC_CHECK_LIB([m], [sqrt])
  279. +
  280. +# Checks for header files.
  281. +AC_CHECK_HEADERS([limits.h stddef.h stdlib.h])
  282. +
  283. +# Checks for typedefs, structures, and compiler characteristics.
  284. +AC_TYPE_SIZE_T
  285. +
  286. +# Checks for library functions.
  287. +AC_FUNC_MALLOC
  288. +AC_FUNC_REALLOC
  289. +AC_CHECK_FUNCS([sqrt])
  290. +
  291. +AS_VAR_SET([LIBS], [$LIBS_SAVED])
  292. +
  293. +m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], [AC_SUBST([pkgconfigdir], [${libdir}/pkgconfig])])
  294. +AC_CONFIG_FILES([
  295. + csparse.pc
  296. + Makefile
  297. + Demo/Makefile
  298. + Include/Makefile
  299. + Matrix/Makefile
  300. + Source/Makefile
  301. + Tcov/Makefile
  302. +])
  303. +AC_OUTPUT
  304. diff --git a/csparse.pc.in b/csparse.pc.in
  305. new file mode 100644
  306. --- /dev/null
  307. +++ b/csparse.pc.in
  308. @@ -0,0 +1,12 @@
  309. +prefix=@prefix@
  310. +exec_prefix=@exec_prefix@
  311. +libdir=@libdir@
  312. +includedir=@includedir@
  313. +
  314. +Name: @PACKAGE_NAME@
  315. +Description: A concise sparse matrix package
  316. +Version: @PACKAGE_VERSION@
  317. +URL: @PACKAGE_URL@
  318. +Libs: -L${libdir} -lcsparse
  319. +Libs.private: -lm
  320. +Cflags: -I${includedir}/csparse
  321. diff --git a/m4/ax_code_coverage.m4 b/m4/ax_code_coverage.m4
  322. new file mode 100644
  323. --- /dev/null
  324. +++ b/m4/ax_code_coverage.m4
  325. @@ -0,0 +1,271 @@
  326. +# ===========================================================================
  327. +# https://www.gnu.org/software/autoconf-archive/ax_code_coverage.html
  328. +# ===========================================================================
  329. +#
  330. +# SYNOPSIS
  331. +#
  332. +# AX_CODE_COVERAGE()
  333. +#
  334. +# DESCRIPTION
  335. +#
  336. +# Defines CODE_COVERAGE_CPPFLAGS, CODE_COVERAGE_CFLAGS,
  337. +# CODE_COVERAGE_CXXFLAGS and CODE_COVERAGE_LIBS which should be included
  338. +# in the CPPFLAGS, CFLAGS CXXFLAGS and LIBS/LIBADD variables of every
  339. +# build target (program or library) which should be built with code
  340. +# coverage support. Also defines CODE_COVERAGE_RULES which should be
  341. +# substituted in your Makefile; and $enable_code_coverage which can be
  342. +# used in subsequent configure output. CODE_COVERAGE_ENABLED is defined
  343. +# and substituted, and corresponds to the value of the
  344. +# --enable-code-coverage option, which defaults to being disabled.
  345. +#
  346. +# Test also for gcov program and create GCOV variable that could be
  347. +# substituted.
  348. +#
  349. +# Note that all optimization flags in CFLAGS must be disabled when code
  350. +# coverage is enabled.
  351. +#
  352. +# Usage example:
  353. +#
  354. +# configure.ac:
  355. +#
  356. +# AX_CODE_COVERAGE
  357. +#
  358. +# Makefile.am:
  359. +#
  360. +# @CODE_COVERAGE_RULES@
  361. +# my_program_LIBS = ... $(CODE_COVERAGE_LIBS) ...
  362. +# my_program_CPPFLAGS = ... $(CODE_COVERAGE_CPPFLAGS) ...
  363. +# my_program_CFLAGS = ... $(CODE_COVERAGE_CFLAGS) ...
  364. +# my_program_CXXFLAGS = ... $(CODE_COVERAGE_CXXFLAGS) ...
  365. +#
  366. +# This results in a "check-code-coverage" rule being added to any
  367. +# Makefile.am which includes "@CODE_COVERAGE_RULES@" (assuming the module
  368. +# has been configured with --enable-code-coverage). Running `make
  369. +# check-code-coverage` in that directory will run the module's test suite
  370. +# (`make check`) and build a code coverage report detailing the code which
  371. +# was touched, then print the URI for the report.
  372. +#
  373. +# In earlier versions of this macro, CODE_COVERAGE_LDFLAGS was defined
  374. +# instead of CODE_COVERAGE_LIBS. They are both still defined, but use of
  375. +# CODE_COVERAGE_LIBS is preferred for clarity; CODE_COVERAGE_LDFLAGS is
  376. +# deprecated. They have the same value.
  377. +#
  378. +# This code was derived from Makefile.decl in GLib, originally licenced
  379. +# under LGPLv2.1+.
  380. +#
  381. +# LICENSE
  382. +#
  383. +# Copyright (c) 2012, 2016 Philip Withnall
  384. +# Copyright (c) 2012 Xan Lopez
  385. +# Copyright (c) 2012 Christian Persch
  386. +# Copyright (c) 2012 Paolo Borelli
  387. +# Copyright (c) 2012 Dan Winship
  388. +# Copyright (c) 2015 Bastien ROUCARIES
  389. +#
  390. +# This library is free software; you can redistribute it and/or modify it
  391. +# under the terms of the GNU Lesser General Public License as published by
  392. +# the Free Software Foundation; either version 2.1 of the License, or (at
  393. +# your option) any later version.
  394. +#
  395. +# This library is distributed in the hope that it will be useful, but
  396. +# WITHOUT ANY WARRANTY; without even the implied warranty of
  397. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
  398. +# General Public License for more details.
  399. +#
  400. +# You should have received a copy of the GNU Lesser General Public License
  401. +# along with this program. If not, see <https://www.gnu.org/licenses/>.
  402. +
  403. +#serial 27
  404. +
  405. +AC_DEFUN([_AX_CODE_COVERAGE_ENABLED],[
  406. + # check for gcov
  407. + AC_CHECK_TOOL([GCOV],
  408. + [$_AX_CODE_COVERAGE_GCOV_PROG_WITH],
  409. + [:])
  410. + AS_IF([test "X$GCOV" = "X:"],
  411. + [AC_MSG_ERROR([gcov is needed to do coverage])])
  412. + AC_SUBST([GCOV])
  413. +
  414. + dnl Check if gcc is being used
  415. + AS_IF([ test "$GCC" = "no" ], [
  416. + AC_MSG_ERROR([not compiling with gcc, which is required for gcov code coverage])
  417. + ])
  418. +
  419. + AC_CHECK_PROG([LCOV], [lcov], [lcov])
  420. + AC_CHECK_PROG([GENHTML], [genhtml], [genhtml])
  421. +
  422. + AS_IF([ test x"$LCOV" = x ], [
  423. + AC_MSG_ERROR([To enable code coverage reporting you must have lcov installed])
  424. + ])
  425. +
  426. + AS_IF([ test x"$GENHTML" = x ], [
  427. + AC_MSG_ERROR([Could not find genhtml from the lcov package])
  428. + ])
  429. +
  430. + dnl Build the code coverage flags
  431. + dnl Define CODE_COVERAGE_LDFLAGS for backwards compatibility
  432. + CODE_COVERAGE_CPPFLAGS="-DNDEBUG"
  433. + CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
  434. + CODE_COVERAGE_CXXFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
  435. + CODE_COVERAGE_LIBS="-lgcov"
  436. + CODE_COVERAGE_LDFLAGS="$CODE_COVERAGE_LIBS"
  437. +
  438. + AC_SUBST([CODE_COVERAGE_CPPFLAGS])
  439. + AC_SUBST([CODE_COVERAGE_CFLAGS])
  440. + AC_SUBST([CODE_COVERAGE_CXXFLAGS])
  441. + AC_SUBST([CODE_COVERAGE_LIBS])
  442. + AC_SUBST([CODE_COVERAGE_LDFLAGS])
  443. +
  444. + [CODE_COVERAGE_RULES_CHECK='
  445. + -$(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) -k check
  446. + $(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) code-coverage-capture
  447. +']
  448. + [CODE_COVERAGE_RULES_CAPTURE='
  449. + $(code_coverage_v_lcov_cap)$(LCOV) $(code_coverage_quiet) $(addprefix --directory ,$(CODE_COVERAGE_DIRECTORY)) --capture --output-file "$(CODE_COVERAGE_OUTPUT_FILE).tmp" --test-name "$(call code_coverage_sanitize,$(PACKAGE_NAME)-$(PACKAGE_VERSION))" --no-checksum --compat-libtool $(CODE_COVERAGE_LCOV_SHOPTS) $(CODE_COVERAGE_LCOV_OPTIONS)
  450. + $(code_coverage_v_lcov_ign)$(LCOV) $(code_coverage_quiet) $(addprefix --directory ,$(CODE_COVERAGE_DIRECTORY)) --remove "$(CODE_COVERAGE_OUTPUT_FILE).tmp" "/tmp/*" $(CODE_COVERAGE_IGNORE_PATTERN) --output-file "$(CODE_COVERAGE_OUTPUT_FILE)" $(CODE_COVERAGE_LCOV_SHOPTS) $(CODE_COVERAGE_LCOV_RMOPTS)
  451. + -@rm -f $(CODE_COVERAGE_OUTPUT_FILE).tmp
  452. + $(code_coverage_v_genhtml)LANG=C $(GENHTML) $(code_coverage_quiet) $(addprefix --prefix ,$(CODE_COVERAGE_DIRECTORY)) --output-directory "$(CODE_COVERAGE_OUTPUT_DIRECTORY)" --title "$(PACKAGE_NAME)-$(PACKAGE_VERSION) Code Coverage" --legend --show-details "$(CODE_COVERAGE_OUTPUT_FILE)" $(CODE_COVERAGE_GENHTML_OPTIONS)
  453. + @echo "file://$(abs_builddir)/$(CODE_COVERAGE_OUTPUT_DIRECTORY)/index.html"
  454. +']
  455. + [CODE_COVERAGE_RULES_CLEAN='
  456. +clean: code-coverage-clean
  457. +distclean: code-coverage-clean
  458. +code-coverage-clean:
  459. + -$(LCOV) --directory $(top_builddir) -z
  460. + -rm -rf $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_FILE).tmp $(CODE_COVERAGE_OUTPUT_DIRECTORY)
  461. + -find . \( -name "*.gcda" -o -name "*.gcno" -o -name "*.gcov" \) -delete
  462. +']
  463. +])
  464. +
  465. +AC_DEFUN([_AX_CODE_COVERAGE_DISABLED],[
  466. + [CODE_COVERAGE_RULES_CHECK='
  467. + @echo "Need to reconfigure with --enable-code-coverage"
  468. + ']
  469. + CODE_COVERAGE_RULES_CAPTURE="$CODE_COVERAGE_RULES_CHECK"
  470. + CODE_COVERAGE_RULES_CLEAN=''
  471. +])
  472. +
  473. +AC_DEFUN([AX_CODE_COVERAGE],[
  474. + dnl Check for --enable-code-coverage
  475. +
  476. + # allow to override gcov location
  477. + AC_ARG_WITH([gcov],
  478. + [AS_HELP_STRING([--with-gcov[=GCOV]], [use given GCOV for coverage (GCOV=gcov).])],
  479. + [_AX_CODE_COVERAGE_GCOV_PROG_WITH=$with_gcov],
  480. + [_AX_CODE_COVERAGE_GCOV_PROG_WITH=gcov])
  481. +
  482. + AC_MSG_CHECKING([whether to build with code coverage support])
  483. + AC_ARG_ENABLE([code-coverage],
  484. + AS_HELP_STRING([--enable-code-coverage],
  485. + [Whether to enable code coverage support]),,
  486. + enable_code_coverage=no)
  487. +
  488. + AM_CONDITIONAL([CODE_COVERAGE_ENABLED], [test "x$enable_code_coverage" = xyes])
  489. + AC_SUBST([CODE_COVERAGE_ENABLED], [$enable_code_coverage])
  490. + AC_MSG_RESULT($enable_code_coverage)
  491. +
  492. + AS_IF([ test "x$enable_code_coverage" = xyes ], [
  493. + _AX_CODE_COVERAGE_ENABLED
  494. + ], [
  495. + _AX_CODE_COVERAGE_DISABLED
  496. + ])
  497. +
  498. +[CODE_COVERAGE_RULES='
  499. +# Code coverage
  500. +#
  501. +# Optional:
  502. +# - CODE_COVERAGE_DIRECTORY: Top-level directory for code coverage reporting.
  503. +# Multiple directories may be specified, separated by whitespace.
  504. +# (Default: $(top_builddir))
  505. +# - CODE_COVERAGE_OUTPUT_FILE: Filename and path for the .info file generated
  506. +# by lcov for code coverage. (Default:
  507. +# $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info)
  508. +# - CODE_COVERAGE_OUTPUT_DIRECTORY: Directory for generated code coverage
  509. +# reports to be created. (Default:
  510. +# $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage)
  511. +# - CODE_COVERAGE_BRANCH_COVERAGE: Set to 1 to enforce branch coverage,
  512. +# set to 0 to disable it and leave empty to stay with the default.
  513. +# (Default: empty)
  514. +# - CODE_COVERAGE_LCOV_SHOPTS_DEFAULT: Extra options shared between both lcov
  515. +# instances. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE)
  516. +# - CODE_COVERAGE_LCOV_SHOPTS: Extra options to shared between both lcov
  517. +# instances. (Default: $CODE_COVERAGE_LCOV_SHOPTS_DEFAULT)
  518. +# - CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH: --gcov-tool pathtogcov
  519. +# - CODE_COVERAGE_LCOV_OPTIONS_DEFAULT: Extra options to pass to the
  520. +# collecting lcov instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH)
  521. +# - CODE_COVERAGE_LCOV_OPTIONS: Extra options to pass to the collecting lcov
  522. +# instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_DEFAULT)
  523. +# - CODE_COVERAGE_LCOV_RMOPTS_DEFAULT: Extra options to pass to the filtering
  524. +# lcov instance. (Default: empty)
  525. +# - CODE_COVERAGE_LCOV_RMOPTS: Extra options to pass to the filtering lcov
  526. +# instance. (Default: $CODE_COVERAGE_LCOV_RMOPTS_DEFAULT)
  527. +# - CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT: Extra options to pass to the
  528. +# genhtml instance. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE)
  529. +# - CODE_COVERAGE_GENHTML_OPTIONS: Extra options to pass to the genhtml
  530. +# instance. (Default: $CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT)
  531. +# - CODE_COVERAGE_IGNORE_PATTERN: Extra glob pattern of files to ignore
  532. +#
  533. +# The generated report will be titled using the $(PACKAGE_NAME) and
  534. +# $(PACKAGE_VERSION). In order to add the current git hash to the title,
  535. +# use the git-version-gen script, available online.
  536. +
  537. +# Optional variables
  538. +CODE_COVERAGE_DIRECTORY ?= $(top_builddir)
  539. +CODE_COVERAGE_OUTPUT_FILE ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info
  540. +CODE_COVERAGE_OUTPUT_DIRECTORY ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage
  541. +CODE_COVERAGE_BRANCH_COVERAGE ?=
  542. +CODE_COVERAGE_LCOV_SHOPTS_DEFAULT ?= $(if $(CODE_COVERAGE_BRANCH_COVERAGE),\
  543. +--rc lcov_branch_coverage=$(CODE_COVERAGE_BRANCH_COVERAGE))
  544. +CODE_COVERAGE_LCOV_SHOPTS ?= $(CODE_COVERAGE_LCOV_SHOPTS_DEFAULT)
  545. +CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH ?= --gcov-tool "$(GCOV)"
  546. +CODE_COVERAGE_LCOV_OPTIONS_DEFAULT ?= $(CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH)
  547. +CODE_COVERAGE_LCOV_OPTIONS ?= $(CODE_COVERAGE_LCOV_OPTIONS_DEFAULT)
  548. +CODE_COVERAGE_LCOV_RMOPTS_DEFAULT ?=
  549. +CODE_COVERAGE_LCOV_RMOPTS ?= $(CODE_COVERAGE_LCOV_RMOPTS_DEFAULT)
  550. +CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT ?=\
  551. +$(if $(CODE_COVERAGE_BRANCH_COVERAGE),\
  552. +--rc genhtml_branch_coverage=$(CODE_COVERAGE_BRANCH_COVERAGE))
  553. +CODE_COVERAGE_GENHTML_OPTIONS ?= $(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT)
  554. +CODE_COVERAGE_IGNORE_PATTERN ?=
  555. +
  556. +GITIGNOREFILES ?=
  557. +GITIGNOREFILES += $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_DIRECTORY)
  558. +
  559. +code_coverage_v_lcov_cap = $(code_coverage_v_lcov_cap_$(V))
  560. +code_coverage_v_lcov_cap_ = $(code_coverage_v_lcov_cap_$(AM_DEFAULT_VERBOSITY))
  561. +code_coverage_v_lcov_cap_0 = @echo " LCOV --capture"\
  562. + $(CODE_COVERAGE_OUTPUT_FILE);
  563. +code_coverage_v_lcov_ign = $(code_coverage_v_lcov_ign_$(V))
  564. +code_coverage_v_lcov_ign_ = $(code_coverage_v_lcov_ign_$(AM_DEFAULT_VERBOSITY))
  565. +code_coverage_v_lcov_ign_0 = @echo " LCOV --remove /tmp/*"\
  566. + $(CODE_COVERAGE_IGNORE_PATTERN);
  567. +code_coverage_v_genhtml = $(code_coverage_v_genhtml_$(V))
  568. +code_coverage_v_genhtml_ = $(code_coverage_v_genhtml_$(AM_DEFAULT_VERBOSITY))
  569. +code_coverage_v_genhtml_0 = @echo " GEN " $(CODE_COVERAGE_OUTPUT_DIRECTORY);
  570. +code_coverage_quiet = $(code_coverage_quiet_$(V))
  571. +code_coverage_quiet_ = $(code_coverage_quiet_$(AM_DEFAULT_VERBOSITY))
  572. +code_coverage_quiet_0 = --quiet
  573. +
  574. +# sanitizes the test-name: replaces with underscores: dashes and dots
  575. +code_coverage_sanitize = $(subst -,_,$(subst .,_,$(1)))
  576. +
  577. +# Use recursive makes in order to ignore errors during check
  578. +check-code-coverage:'"$CODE_COVERAGE_RULES_CHECK"'
  579. +
  580. +# Capture code coverage data
  581. +code-coverage-capture: code-coverage-capture-hook'"$CODE_COVERAGE_RULES_CAPTURE"'
  582. +
  583. +# Hook rule executed before code-coverage-capture, overridable by the user
  584. +code-coverage-capture-hook:
  585. +
  586. +'"$CODE_COVERAGE_RULES_CLEAN"'
  587. +
  588. +A''M_DISTCHECK_CONFIGURE_FLAGS ?=
  589. +A''M_DISTCHECK_CONFIGURE_FLAGS += --disable-code-coverage
  590. +
  591. +.PHONY: check-code-coverage code-coverage-capture code-coverage-capture-hook code-coverage-clean
  592. +']
  593. +
  594. + AC_SUBST([CODE_COVERAGE_RULES])
  595. + m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([CODE_COVERAGE_RULES])])
  596. +])