autoconfiscate.diff 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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,46 @@
  6. +AM_CPPFLAGS = -I$(top_srcdir)/Include $(AMD_CFLAGS) $(COLAMD_CFLAGS) $(BTF_CFLAGS) $(CHOLMOD_CFLAGS)
  7. +LDADD = $(top_builddir)/Source/libklu.la
  8. +
  9. +EXTRA_DIST = \
  10. + klu_simple.out \
  11. + kludemo.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 = klu_simple
  18. +TESTS = klu_simple
  19. +klu_simple_SOURCES = klu_simple.c
  20. +
  21. +if CHOLMOD
  22. +check_PROGRAMS += kludemo kluldemo
  23. +
  24. +kludemo_SOURCES = kludemo.c
  25. +kludemo_LDADD = $(LDADD) $(CHOLMOD_LIBS) -lm
  26. +
  27. +kluldemo_SOURCES = kluldemo.c
  28. +kluldemo_LDADD = $(LDADD) $(CHOLMOD_LIBS) -lm
  29. +
  30. +MATRICES = \
  31. + $(top_srcdir)/Matrix/1c.mtx \
  32. + $(top_srcdir)/Matrix/arrowc.mtx \
  33. + $(top_srcdir)/Matrix/arrow.mtx \
  34. + $(top_srcdir)/Matrix/impcol_a.mtx \
  35. + $(top_srcdir)/Matrix/w156.mtx \
  36. + $(top_srcdir)/Matrix/ctina.mtx
  37. +
  38. +check-local: kludemo kluldemo $(MATRICES)
  39. + -./kludemo < $(top_srcdir)/Matrix/1c.mtx
  40. + -./kludemo < $(top_srcdir)/Matrix/arrowc.mtx
  41. + -./kludemo < $(top_srcdir)/Matrix/arrow.mtx
  42. + -./kludemo < $(top_srcdir)/Matrix/impcol_a.mtx
  43. + -./kludemo < $(top_srcdir)/Matrix/w156.mtx
  44. + -./kludemo < $(top_srcdir)/Matrix/ctina.mtx
  45. + -./kluldemo < $(top_srcdir)/Matrix/1c.mtx
  46. + -./kluldemo < $(top_srcdir)/Matrix/arrowc.mtx
  47. + -./kluldemo < $(top_srcdir)/Matrix/arrow.mtx
  48. + -./kluldemo < $(top_srcdir)/Matrix/impcol_a.mtx
  49. + -./kluldemo < $(top_srcdir)/Matrix/w156.mtx
  50. + -./kluldemo < $(top_srcdir)/Matrix/ctina.mtx
  51. +endif
  52. diff --git a/Doc/Makefile.am b/Doc/Makefile.am
  53. new file mode 100644
  54. --- /dev/null
  55. +++ b/Doc/Makefile.am
  56. @@ -0,0 +1,51 @@
  57. +EXTRA_DIST = \
  58. + ChangeLog \
  59. + License.txt \
  60. + lesser.txt
  61. +
  62. +dist_noinst_DATA = KLU_UserGuide.tex KLU_UserGuide.bib
  63. +dist_pdf_DATA = KLU_UserGuide.pdf palamadai_e.pdf
  64. +
  65. +SRC = \
  66. + klu_h.tex \
  67. + btf_h.tex \
  68. + klu_simple_c.tex
  69. +
  70. +KLU_UserGuide.pdf KLU_UserGuide.aux: $(SRC)
  71. +.INTERMEDIATE: KLU_UserGuide.aux $(SRC)
  72. +
  73. +define verbatim =
  74. +echo '\begin{verbatim}' > $@
  75. +expand -8 $< >> $@
  76. +echo '\end{verbatim}' >> $@
  77. +endef
  78. +
  79. +klu_h.tex: $(top_srcdir)/Include/klu.h
  80. + $(verbatim)
  81. +
  82. +# FIXME: We don't know the location of btf.h.
  83. +# Insert a placeholder for now.
  84. +#btf_h.tex: /usr/include/btf.h
  85. +# $(verbatim)
  86. +btf_h.tex:
  87. + echo '\begin{verbatim}' > $@
  88. + echo 'See your btf.h local install' >> $@
  89. + echo '\end{verbatim}' >> $@
  90. +
  91. +klu_simple_c.tex: $(top_srcdir)/Demo/klu_simple.c
  92. + $(verbatim)
  93. +
  94. +TEX = TEXINPUTS="$(srcdir):" pdflatex -interaction nonstopmode -file-line-error
  95. +BIB = BIBINPUTS="$(srcdir):" bibtex
  96. +%.pdf: %.tex %.bbl
  97. + $(TEX) $*
  98. + while grep -q "Rerun to get cross-references right" $*.log; do \
  99. + $(TEX) $*; \
  100. + done
  101. +%.bbl: %.aux %.bib
  102. + $(BIB) $*
  103. +%.aux: %.tex
  104. + $(TEX) $*
  105. +
  106. +CLEANFILES = *.aux *.bbl *.blg *.log *.toc $(SRC)
  107. +MAINTAINERCLEANFILES = $(dist_pdf_DATA)
  108. diff --git a/Include/Makefile.am b/Include/Makefile.am
  109. new file mode 100644
  110. --- /dev/null
  111. +++ b/Include/Makefile.am
  112. @@ -0,0 +1 @@
  113. +pkginclude_HEADERS = klu.h klu_internal.h klu_version.h
  114. diff --git a/Makefile.am b/Makefile.am
  115. new file mode 100644
  116. --- /dev/null
  117. +++ b/Makefile.am
  118. @@ -0,0 +1,9 @@
  119. +ACLOCAL_AMFLAGS = -I m4
  120. +
  121. +SUBDIRS = Include Source User Matrix Demo Tcov Doc
  122. +EXTRA_DIST = README.txt
  123. +
  124. +pkgconfig_DATA = klu.pc
  125. +
  126. +CODE_COVERAGE_BRANCH_COVERAGE = 1
  127. +@CODE_COVERAGE_RULES@
  128. diff --git a/Matrix/Makefile.am b/Matrix/Makefile.am
  129. new file mode 100644
  130. --- /dev/null
  131. +++ b/Matrix/Makefile.am
  132. @@ -0,0 +1,11 @@
  133. +dist_noinst_DATA = \
  134. + 1c.mtx \
  135. + GD99_cc.mtx \
  136. + arrow.mtx \
  137. + arrowc.mtx \
  138. + ctina.mtx \
  139. + impcol_a.mtx \
  140. + one.mtx \
  141. + onec.mtx \
  142. + two.mtx \
  143. + w156.mtx
  144. diff --git a/Source/Makefile.am b/Source/Makefile.am
  145. new file mode 100644
  146. --- /dev/null
  147. +++ b/Source/Makefile.am
  148. @@ -0,0 +1,49 @@
  149. +AM_CPPFLAGS = -I$(top_srcdir)/Include $(AMD_CFLAGS) $(COLAMD_CFLAGS) $(BTF_CFLAGS) $(SUITESPARSECONFIG_CFLAGS)
  150. +
  151. +noinst_LTLIBRARIES = libklud.la libkluz.la libklul.la libkluzl.la
  152. +
  153. +KLUSRC = \
  154. + klu.c \
  155. + klu_diagnostics.c \
  156. + klu_dump.c \
  157. + klu_extract.c \
  158. + klu_factor.c \
  159. + klu_free_numeric.c \
  160. + klu_kernel.c \
  161. + klu_refactor.c \
  162. + klu_scale.c \
  163. + klu_solve.c \
  164. + klu_sort.c \
  165. + klu_tsolve.c
  166. +
  167. +CKLUSRC = \
  168. + klu_analyze.c \
  169. + klu_analyze_given.c \
  170. + klu_defaults.c \
  171. + klu_free_symbolic.c \
  172. + klu_memory.c
  173. +
  174. +libklud_la_SOURCES = $(KLUSRC) $(CKLUSRC)
  175. +libklud_la_LIBADD = $(CODE_COVERAGE_LIBS)
  176. +libklud_la_CPPFLAGS = $(AM_CPPFLAGS) $(CODE_COVERAGE_CPPFLAGS)
  177. +libklud_la_CFLAGS = $(AM_CFLAGS) $(CODE_COVERAGE_CFLAGS)
  178. +
  179. +libkluz_la_SOURCES = $(KLUSRC)
  180. +libkluz_la_LIBADD = $(CODE_COVERAGE_LIBS)
  181. +libkluz_la_CPPFLAGS = $(AM_CPPFLAGS) $(CODE_COVERAGE_CPPFLAGS) -DCOMPLEX
  182. +libkluz_la_CFLAGS = $(AM_CFLAGS) $(CODE_COVERAGE_CFLAGS)
  183. +
  184. +libklul_la_SOURCES = $(KLUSRC) $(CKLUSRC)
  185. +libklul_la_LIBADD = $(CODE_COVERAGE_LIBS)
  186. +libklul_la_CPPFLAGS = $(AM_CPPFLAGS) $(CODE_COVERAGE_CPPFLAGS) -DDLONG
  187. +libklul_la_CFLAGS = $(AM_CFLAGS) $(CODE_COVERAGE_CFLAGS)
  188. +
  189. +libkluzl_la_SOURCES = $(KLUSRC)
  190. +libkluzl_la_LIBADD = $(CODE_COVERAGE_LIBS)
  191. +libkluzl_la_CPPFLAGS = $(AM_CPPFLAGS) $(CODE_COVERAGE_CPPFLAGS) -DDLONG -DCOMPLEX
  192. +libkluzl_la_CFLAGS = $(AM_CFLAGS) $(CODE_COVERAGE_CFLAGS)
  193. +
  194. +lib_LTLIBRARIES = libklu.la
  195. +libklu_la_SOURCES =
  196. +libklu_la_LIBADD = libklud.la libkluz.la libklul.la libkluzl.la $(AMD_LIBS) $(COLAMD_LIBS) $(BTF_LIBS) $(SUITESPARSECONFIG_LIBS)
  197. +libklu_la_LDFLAGS = -no-undefined -release $(PACKAGE_VERSION)
  198. diff --git a/Tcov/Makefile.am b/Tcov/Makefile.am
  199. new file mode 100644
  200. --- /dev/null
  201. +++ b/Tcov/Makefile.am
  202. @@ -0,0 +1,54 @@
  203. +AM_CPPFLAGS = -I$(top_srcdir)/Include -I$(top_srcdir)/User $(AMD_CFLAGS) $(COLAMD_CFLAGS) $(BTF_CFLAGS) $(CHOLMOD_CFLAGS)
  204. +LDADD = $(top_builddir)/Source/libklu.la $(top_builddir)/User/libklu_cholmod.la
  205. +
  206. +EXTRA_DIST = \
  207. + README.txt
  208. +
  209. +if CODE_COVERAGE_ENABLED
  210. +check_PROGRAMS = \
  211. + klutest \
  212. + klultest
  213. +
  214. +klutest_SOURCES = klutest.c
  215. +klutest_LDADD = $(LDADD) $(CHOLMOD_LIBS) $(SUITESPARSECONFIG_LIBS)
  216. +
  217. +klultest_SOURCES = klutest.c
  218. +klultest_LDADD = $(LDADD) $(CHOLMOD_LIBS) $(SUITESPARSECONFIG_LIBS)
  219. +klultest_CPPFLAGS = $(AM_CPPFLAGS) -DDLONG
  220. +
  221. +MATRICES = \
  222. + $(top_srcdir)/Matrix/1c.mtx \
  223. + $(top_srcdir)/Matrix/GD99_cc.mtx \
  224. + $(top_srcdir)/Matrix/arrow.mtx \
  225. + $(top_srcdir)/Matrix/arrowc.mtx \
  226. + $(top_srcdir)/Matrix/ctina.mtx \
  227. + $(top_srcdir)/Matrix/impcol_a.mtx \
  228. + $(top_srcdir)/Matrix/one.mtx \
  229. + $(top_srcdir)/Matrix/onec.mtx \
  230. + $(top_srcdir)/Matrix/two.mtx \
  231. + $(top_srcdir)/Matrix/w156.mtx
  232. +
  233. +check-local: $(check_PROGRAMS) $(MATRICES)
  234. + ./klultest < $(top_srcdir)/Matrix/impcol_a.mtx > klultests.out
  235. + ./klultest < $(top_srcdir)/Matrix/GD99_cc.mtx >> klultests.out
  236. + ./klultest < $(top_srcdir)/Matrix/two.mtx >> klultests.out
  237. + ./klultest < $(top_srcdir)/Matrix/w156.mtx >> klultests.out
  238. + ./klultest < $(top_srcdir)/Matrix/arrow.mtx >> klultests.out
  239. + ./klultest < $(top_srcdir)/Matrix/arrowc.mtx >> klultests.out
  240. + ./klultest < $(top_srcdir)/Matrix/onec.mtx >> klultests.out
  241. + ./klultest < $(top_srcdir)/Matrix/one.mtx >> klultests.out
  242. + ./klultest < $(top_srcdir)/Matrix/1c.mtx >> klultests.out
  243. + ./klultest < $(top_srcdir)/Matrix/ctina.mtx >> klultests.out
  244. + ./klutest < $(top_srcdir)/Matrix/impcol_a.mtx > klutests.out
  245. + ./klutest < $(top_srcdir)/Matrix/GD99_cc.mtx >> klutests.out
  246. + ./klutest < $(top_srcdir)/Matrix/two.mtx >> klutests.out
  247. + ./klutest < $(top_srcdir)/Matrix/w156.mtx >> klutests.out
  248. + ./klutest < $(top_srcdir)/Matrix/arrow.mtx >> klutests.out
  249. + ./klutest < $(top_srcdir)/Matrix/arrowc.mtx >> klutests.out
  250. + ./klutest < $(top_srcdir)/Matrix/onec.mtx >> klutests.out
  251. + ./klutest < $(top_srcdir)/Matrix/one.mtx >> klutests.out
  252. + ./klutest < $(top_srcdir)/Matrix/1c.mtx >> klutests.out
  253. + ./klutest < $(top_srcdir)/Matrix/ctina.mtx >> klutests.out
  254. +endif
  255. +
  256. +CLEANFILES = *.out
  257. diff --git a/User/Makefile.am b/User/Makefile.am
  258. new file mode 100644
  259. --- /dev/null
  260. +++ b/User/Makefile.am
  261. @@ -0,0 +1,14 @@
  262. +AM_CPPFLAGS = -I$(top_srcdir)/Include $(AMD_CFLAGS) $(COLAMD_CFLAGS) $(BTF_CFLAGS) $(CHOLMOD_CFLAGS) $(SUITESPARSECONFIG_CFLAGS)
  263. +
  264. +EXTRA_DIST = README.txt
  265. +
  266. +if CHOLMOD
  267. +pkginclude_HEADERS = klu_cholmod.h
  268. +
  269. +lib_LTLIBRARIES = libklu_cholmod.la
  270. +libklu_cholmod_la_SOURCES = klu_cholmod.c klu_l_cholmod.c
  271. +libklu_cholmod_la_LIBADD = $(CHOLMOD_LIBS) $(CODE_COVERAGE_LIBS)
  272. +libklu_cholmod_la_CPPFLAGS = $(AM_CPPFLAGS) $(CODE_COVERAGE_CPPFLAGS)
  273. +libklu_cholmod_la_CFLAGS = $(AM_CFLAGS) $(CODE_COVERAGE_CFLAGS)
  274. +libklu_cholmod_la_LDFLAGS = -no-undefined -release $(PACKAGE_VERSION)
  275. +endif
  276. diff --git a/configure.ac b/configure.ac
  277. new file mode 100644
  278. --- /dev/null
  279. +++ b/configure.ac
  280. @@ -0,0 +1,59 @@
  281. +# -*- Autoconf -*-
  282. +# Process this file with autoconf to produce a configure script.
  283. +
  284. +AC_PREREQ([2.69])
  285. +AC_INIT([KLU],[1.3.9],[https://github.com/DrTimothyAldenDavis/SuiteSparse],[klu],[http://www.suitesparse.com/])
  286. +AC_CONFIG_SRCDIR([Source/klu.c])
  287. +AC_CONFIG_AUX_DIR([build-aux])
  288. +AC_CONFIG_MACRO_DIR([m4])
  289. +AC_CONFIG_HEADERS([config.h])
  290. +AM_INIT_AUTOMAKE([foreign])
  291. +AM_SILENT_RULES([yes])
  292. +LT_INIT([disable-static])
  293. +
  294. +# Checks for programs.
  295. +PKG_PROG_PKG_CONFIG
  296. +AC_PROG_INSTALL
  297. +AC_PROG_CC
  298. +AX_CODE_COVERAGE
  299. +
  300. +AS_VAR_SET([LIBS_SAVED], [$LIBS])
  301. +
  302. +# Checks for libraries.
  303. +AC_CHECK_LIB([m], [sqrt])
  304. +
  305. +PKG_CHECK_MODULES([SUITESPARSECONFIG], [suitesparseconfig])
  306. +PKG_CHECK_MODULES([AMD], [amd])
  307. +PKG_CHECK_MODULES([COLAMD], [colamd])
  308. +PKG_CHECK_MODULES([BTF], [btf])
  309. +PKG_CHECK_MODULES([CHOLMOD], [cholmod],
  310. + [AS_VAR_SET([have_cholmod], [yes])],
  311. + [AS_VAR_SET([have_cholmod], [no])
  312. + AC_MSG_WARN([$CHOLMOD_PKG_ERRORS, disabling some functionality])])
  313. +
  314. +# Checks for header files.
  315. +AC_CHECK_HEADERS([limits.h stdlib.h])
  316. +
  317. +# Checks for typedefs, structures, and compiler characteristics.
  318. +AC_TYPE_SIZE_T
  319. +
  320. +# Checks for library functions.
  321. +AC_CHECK_FUNCS([sqrt])
  322. +
  323. +AS_VAR_SET([LIBS], [$LIBS_SAVED])
  324. +
  325. +AM_CONDITIONAL([CHOLMOD], [test "x$have_cholmod" = "xyes"])
  326. +
  327. +m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], [AC_SUBST([pkgconfigdir], [${libdir}/pkgconfig])])
  328. +AC_CONFIG_FILES([
  329. + klu.pc
  330. + Makefile
  331. + Demo/Makefile
  332. + Doc/Makefile
  333. + Include/Makefile
  334. + Matrix/Makefile
  335. + Source/Makefile
  336. + Tcov/Makefile
  337. + User/Makefile
  338. +])
  339. +AC_OUTPUT
  340. diff --git a/klu.pc.in b/klu.pc.in
  341. new file mode 100644
  342. --- /dev/null
  343. +++ b/klu.pc.in
  344. @@ -0,0 +1,13 @@
  345. +prefix=@prefix@
  346. +exec_prefix=@exec_prefix@
  347. +libdir=@libdir@
  348. +includedir=@includedir@
  349. +
  350. +Name: @PACKAGE_NAME@
  351. +Description: Sparse LU factorization for circuit simulation
  352. +Version: @PACKAGE_VERSION@
  353. +URL: @PACKAGE_URL@
  354. +Requires.private: suitesparseconfig amd colamd btf
  355. +Libs: -L${libdir} -lklu
  356. +Libs.private: -lm
  357. +Cflags: -I${includedir}/klu
  358. diff --git a/m4/ax_code_coverage.m4 b/m4/ax_code_coverage.m4
  359. new file mode 100644
  360. --- /dev/null
  361. +++ b/m4/ax_code_coverage.m4
  362. @@ -0,0 +1,271 @@
  363. +# ===========================================================================
  364. +# https://www.gnu.org/software/autoconf-archive/ax_code_coverage.html
  365. +# ===========================================================================
  366. +#
  367. +# SYNOPSIS
  368. +#
  369. +# AX_CODE_COVERAGE()
  370. +#
  371. +# DESCRIPTION
  372. +#
  373. +# Defines CODE_COVERAGE_CPPFLAGS, CODE_COVERAGE_CFLAGS,
  374. +# CODE_COVERAGE_CXXFLAGS and CODE_COVERAGE_LIBS which should be included
  375. +# in the CPPFLAGS, CFLAGS CXXFLAGS and LIBS/LIBADD variables of every
  376. +# build target (program or library) which should be built with code
  377. +# coverage support. Also defines CODE_COVERAGE_RULES which should be
  378. +# substituted in your Makefile; and $enable_code_coverage which can be
  379. +# used in subsequent configure output. CODE_COVERAGE_ENABLED is defined
  380. +# and substituted, and corresponds to the value of the
  381. +# --enable-code-coverage option, which defaults to being disabled.
  382. +#
  383. +# Test also for gcov program and create GCOV variable that could be
  384. +# substituted.
  385. +#
  386. +# Note that all optimization flags in CFLAGS must be disabled when code
  387. +# coverage is enabled.
  388. +#
  389. +# Usage example:
  390. +#
  391. +# configure.ac:
  392. +#
  393. +# AX_CODE_COVERAGE
  394. +#
  395. +# Makefile.am:
  396. +#
  397. +# @CODE_COVERAGE_RULES@
  398. +# my_program_LIBS = ... $(CODE_COVERAGE_LIBS) ...
  399. +# my_program_CPPFLAGS = ... $(CODE_COVERAGE_CPPFLAGS) ...
  400. +# my_program_CFLAGS = ... $(CODE_COVERAGE_CFLAGS) ...
  401. +# my_program_CXXFLAGS = ... $(CODE_COVERAGE_CXXFLAGS) ...
  402. +#
  403. +# This results in a "check-code-coverage" rule being added to any
  404. +# Makefile.am which includes "@CODE_COVERAGE_RULES@" (assuming the module
  405. +# has been configured with --enable-code-coverage). Running `make
  406. +# check-code-coverage` in that directory will run the module's test suite
  407. +# (`make check`) and build a code coverage report detailing the code which
  408. +# was touched, then print the URI for the report.
  409. +#
  410. +# In earlier versions of this macro, CODE_COVERAGE_LDFLAGS was defined
  411. +# instead of CODE_COVERAGE_LIBS. They are both still defined, but use of
  412. +# CODE_COVERAGE_LIBS is preferred for clarity; CODE_COVERAGE_LDFLAGS is
  413. +# deprecated. They have the same value.
  414. +#
  415. +# This code was derived from Makefile.decl in GLib, originally licenced
  416. +# under LGPLv2.1+.
  417. +#
  418. +# LICENSE
  419. +#
  420. +# Copyright (c) 2012, 2016 Philip Withnall
  421. +# Copyright (c) 2012 Xan Lopez
  422. +# Copyright (c) 2012 Christian Persch
  423. +# Copyright (c) 2012 Paolo Borelli
  424. +# Copyright (c) 2012 Dan Winship
  425. +# Copyright (c) 2015 Bastien ROUCARIES
  426. +#
  427. +# This library is free software; you can redistribute it and/or modify it
  428. +# under the terms of the GNU Lesser General Public License as published by
  429. +# the Free Software Foundation; either version 2.1 of the License, or (at
  430. +# your option) any later version.
  431. +#
  432. +# This library is distributed in the hope that it will be useful, but
  433. +# WITHOUT ANY WARRANTY; without even the implied warranty of
  434. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
  435. +# General Public License for more details.
  436. +#
  437. +# You should have received a copy of the GNU Lesser General Public License
  438. +# along with this program. If not, see <https://www.gnu.org/licenses/>.
  439. +
  440. +#serial 27
  441. +
  442. +AC_DEFUN([_AX_CODE_COVERAGE_ENABLED],[
  443. + # check for gcov
  444. + AC_CHECK_TOOL([GCOV],
  445. + [$_AX_CODE_COVERAGE_GCOV_PROG_WITH],
  446. + [:])
  447. + AS_IF([test "X$GCOV" = "X:"],
  448. + [AC_MSG_ERROR([gcov is needed to do coverage])])
  449. + AC_SUBST([GCOV])
  450. +
  451. + dnl Check if gcc is being used
  452. + AS_IF([ test "$GCC" = "no" ], [
  453. + AC_MSG_ERROR([not compiling with gcc, which is required for gcov code coverage])
  454. + ])
  455. +
  456. + AC_CHECK_PROG([LCOV], [lcov], [lcov])
  457. + AC_CHECK_PROG([GENHTML], [genhtml], [genhtml])
  458. +
  459. + AS_IF([ test x"$LCOV" = x ], [
  460. + AC_MSG_ERROR([To enable code coverage reporting you must have lcov installed])
  461. + ])
  462. +
  463. + AS_IF([ test x"$GENHTML" = x ], [
  464. + AC_MSG_ERROR([Could not find genhtml from the lcov package])
  465. + ])
  466. +
  467. + dnl Build the code coverage flags
  468. + dnl Define CODE_COVERAGE_LDFLAGS for backwards compatibility
  469. + CODE_COVERAGE_CPPFLAGS="-DNDEBUG"
  470. + CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
  471. + CODE_COVERAGE_CXXFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
  472. + CODE_COVERAGE_LIBS="-lgcov"
  473. + CODE_COVERAGE_LDFLAGS="$CODE_COVERAGE_LIBS"
  474. +
  475. + AC_SUBST([CODE_COVERAGE_CPPFLAGS])
  476. + AC_SUBST([CODE_COVERAGE_CFLAGS])
  477. + AC_SUBST([CODE_COVERAGE_CXXFLAGS])
  478. + AC_SUBST([CODE_COVERAGE_LIBS])
  479. + AC_SUBST([CODE_COVERAGE_LDFLAGS])
  480. +
  481. + [CODE_COVERAGE_RULES_CHECK='
  482. + -$(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) -k check
  483. + $(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) code-coverage-capture
  484. +']
  485. + [CODE_COVERAGE_RULES_CAPTURE='
  486. + $(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)
  487. + $(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)
  488. + -@rm -f $(CODE_COVERAGE_OUTPUT_FILE).tmp
  489. + $(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)
  490. + @echo "file://$(abs_builddir)/$(CODE_COVERAGE_OUTPUT_DIRECTORY)/index.html"
  491. +']
  492. + [CODE_COVERAGE_RULES_CLEAN='
  493. +clean: code-coverage-clean
  494. +distclean: code-coverage-clean
  495. +code-coverage-clean:
  496. + -$(LCOV) --directory $(top_builddir) -z
  497. + -rm -rf $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_FILE).tmp $(CODE_COVERAGE_OUTPUT_DIRECTORY)
  498. + -find . \( -name "*.gcda" -o -name "*.gcno" -o -name "*.gcov" \) -delete
  499. +']
  500. +])
  501. +
  502. +AC_DEFUN([_AX_CODE_COVERAGE_DISABLED],[
  503. + [CODE_COVERAGE_RULES_CHECK='
  504. + @echo "Need to reconfigure with --enable-code-coverage"
  505. + ']
  506. + CODE_COVERAGE_RULES_CAPTURE="$CODE_COVERAGE_RULES_CHECK"
  507. + CODE_COVERAGE_RULES_CLEAN=''
  508. +])
  509. +
  510. +AC_DEFUN([AX_CODE_COVERAGE],[
  511. + dnl Check for --enable-code-coverage
  512. +
  513. + # allow to override gcov location
  514. + AC_ARG_WITH([gcov],
  515. + [AS_HELP_STRING([--with-gcov[=GCOV]], [use given GCOV for coverage (GCOV=gcov).])],
  516. + [_AX_CODE_COVERAGE_GCOV_PROG_WITH=$with_gcov],
  517. + [_AX_CODE_COVERAGE_GCOV_PROG_WITH=gcov])
  518. +
  519. + AC_MSG_CHECKING([whether to build with code coverage support])
  520. + AC_ARG_ENABLE([code-coverage],
  521. + AS_HELP_STRING([--enable-code-coverage],
  522. + [Whether to enable code coverage support]),,
  523. + enable_code_coverage=no)
  524. +
  525. + AM_CONDITIONAL([CODE_COVERAGE_ENABLED], [test "x$enable_code_coverage" = xyes])
  526. + AC_SUBST([CODE_COVERAGE_ENABLED], [$enable_code_coverage])
  527. + AC_MSG_RESULT($enable_code_coverage)
  528. +
  529. + AS_IF([ test "x$enable_code_coverage" = xyes ], [
  530. + _AX_CODE_COVERAGE_ENABLED
  531. + ], [
  532. + _AX_CODE_COVERAGE_DISABLED
  533. + ])
  534. +
  535. +[CODE_COVERAGE_RULES='
  536. +# Code coverage
  537. +#
  538. +# Optional:
  539. +# - CODE_COVERAGE_DIRECTORY: Top-level directory for code coverage reporting.
  540. +# Multiple directories may be specified, separated by whitespace.
  541. +# (Default: $(top_builddir))
  542. +# - CODE_COVERAGE_OUTPUT_FILE: Filename and path for the .info file generated
  543. +# by lcov for code coverage. (Default:
  544. +# $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info)
  545. +# - CODE_COVERAGE_OUTPUT_DIRECTORY: Directory for generated code coverage
  546. +# reports to be created. (Default:
  547. +# $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage)
  548. +# - CODE_COVERAGE_BRANCH_COVERAGE: Set to 1 to enforce branch coverage,
  549. +# set to 0 to disable it and leave empty to stay with the default.
  550. +# (Default: empty)
  551. +# - CODE_COVERAGE_LCOV_SHOPTS_DEFAULT: Extra options shared between both lcov
  552. +# instances. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE)
  553. +# - CODE_COVERAGE_LCOV_SHOPTS: Extra options to shared between both lcov
  554. +# instances. (Default: $CODE_COVERAGE_LCOV_SHOPTS_DEFAULT)
  555. +# - CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH: --gcov-tool pathtogcov
  556. +# - CODE_COVERAGE_LCOV_OPTIONS_DEFAULT: Extra options to pass to the
  557. +# collecting lcov instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH)
  558. +# - CODE_COVERAGE_LCOV_OPTIONS: Extra options to pass to the collecting lcov
  559. +# instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_DEFAULT)
  560. +# - CODE_COVERAGE_LCOV_RMOPTS_DEFAULT: Extra options to pass to the filtering
  561. +# lcov instance. (Default: empty)
  562. +# - CODE_COVERAGE_LCOV_RMOPTS: Extra options to pass to the filtering lcov
  563. +# instance. (Default: $CODE_COVERAGE_LCOV_RMOPTS_DEFAULT)
  564. +# - CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT: Extra options to pass to the
  565. +# genhtml instance. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE)
  566. +# - CODE_COVERAGE_GENHTML_OPTIONS: Extra options to pass to the genhtml
  567. +# instance. (Default: $CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT)
  568. +# - CODE_COVERAGE_IGNORE_PATTERN: Extra glob pattern of files to ignore
  569. +#
  570. +# The generated report will be titled using the $(PACKAGE_NAME) and
  571. +# $(PACKAGE_VERSION). In order to add the current git hash to the title,
  572. +# use the git-version-gen script, available online.
  573. +
  574. +# Optional variables
  575. +CODE_COVERAGE_DIRECTORY ?= $(top_builddir)
  576. +CODE_COVERAGE_OUTPUT_FILE ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info
  577. +CODE_COVERAGE_OUTPUT_DIRECTORY ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage
  578. +CODE_COVERAGE_BRANCH_COVERAGE ?=
  579. +CODE_COVERAGE_LCOV_SHOPTS_DEFAULT ?= $(if $(CODE_COVERAGE_BRANCH_COVERAGE),\
  580. +--rc lcov_branch_coverage=$(CODE_COVERAGE_BRANCH_COVERAGE))
  581. +CODE_COVERAGE_LCOV_SHOPTS ?= $(CODE_COVERAGE_LCOV_SHOPTS_DEFAULT)
  582. +CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH ?= --gcov-tool "$(GCOV)"
  583. +CODE_COVERAGE_LCOV_OPTIONS_DEFAULT ?= $(CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH)
  584. +CODE_COVERAGE_LCOV_OPTIONS ?= $(CODE_COVERAGE_LCOV_OPTIONS_DEFAULT)
  585. +CODE_COVERAGE_LCOV_RMOPTS_DEFAULT ?=
  586. +CODE_COVERAGE_LCOV_RMOPTS ?= $(CODE_COVERAGE_LCOV_RMOPTS_DEFAULT)
  587. +CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT ?=\
  588. +$(if $(CODE_COVERAGE_BRANCH_COVERAGE),\
  589. +--rc genhtml_branch_coverage=$(CODE_COVERAGE_BRANCH_COVERAGE))
  590. +CODE_COVERAGE_GENHTML_OPTIONS ?= $(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT)
  591. +CODE_COVERAGE_IGNORE_PATTERN ?=
  592. +
  593. +GITIGNOREFILES ?=
  594. +GITIGNOREFILES += $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_DIRECTORY)
  595. +
  596. +code_coverage_v_lcov_cap = $(code_coverage_v_lcov_cap_$(V))
  597. +code_coverage_v_lcov_cap_ = $(code_coverage_v_lcov_cap_$(AM_DEFAULT_VERBOSITY))
  598. +code_coverage_v_lcov_cap_0 = @echo " LCOV --capture"\
  599. + $(CODE_COVERAGE_OUTPUT_FILE);
  600. +code_coverage_v_lcov_ign = $(code_coverage_v_lcov_ign_$(V))
  601. +code_coverage_v_lcov_ign_ = $(code_coverage_v_lcov_ign_$(AM_DEFAULT_VERBOSITY))
  602. +code_coverage_v_lcov_ign_0 = @echo " LCOV --remove /tmp/*"\
  603. + $(CODE_COVERAGE_IGNORE_PATTERN);
  604. +code_coverage_v_genhtml = $(code_coverage_v_genhtml_$(V))
  605. +code_coverage_v_genhtml_ = $(code_coverage_v_genhtml_$(AM_DEFAULT_VERBOSITY))
  606. +code_coverage_v_genhtml_0 = @echo " GEN " $(CODE_COVERAGE_OUTPUT_DIRECTORY);
  607. +code_coverage_quiet = $(code_coverage_quiet_$(V))
  608. +code_coverage_quiet_ = $(code_coverage_quiet_$(AM_DEFAULT_VERBOSITY))
  609. +code_coverage_quiet_0 = --quiet
  610. +
  611. +# sanitizes the test-name: replaces with underscores: dashes and dots
  612. +code_coverage_sanitize = $(subst -,_,$(subst .,_,$(1)))
  613. +
  614. +# Use recursive makes in order to ignore errors during check
  615. +check-code-coverage:'"$CODE_COVERAGE_RULES_CHECK"'
  616. +
  617. +# Capture code coverage data
  618. +code-coverage-capture: code-coverage-capture-hook'"$CODE_COVERAGE_RULES_CAPTURE"'
  619. +
  620. +# Hook rule executed before code-coverage-capture, overridable by the user
  621. +code-coverage-capture-hook:
  622. +
  623. +'"$CODE_COVERAGE_RULES_CLEAN"'
  624. +
  625. +A''M_DISTCHECK_CONFIGURE_FLAGS ?=
  626. +A''M_DISTCHECK_CONFIGURE_FLAGS += --disable-code-coverage
  627. +
  628. +.PHONY: check-code-coverage code-coverage-capture code-coverage-capture-hook code-coverage-clean
  629. +']
  630. +
  631. + AC_SUBST([CODE_COVERAGE_RULES])
  632. + m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([CODE_COVERAGE_RULES])])
  633. +])