Generate overview images for coverage
[platform/upstream/glib.git] / glib.mk
1 # GLIB - Library of useful C routines
2
3 #GTESTER = gtester                      # for non-GLIB packages
4 #GTESTER_REPORT = gtester-report        # for non-GLIB packages
5 GTESTER = $(top_builddir)/glib/gtester                  # for the GLIB package
6 GTESTER_REPORT = $(top_builddir)/glib/gtester-report    # for the GLIB package
7 NULL =
8
9 # initialize variables for unconditional += appending
10 BUILT_SOURCES =
11 BUILT_EXTRA_DIST =
12 CLEANFILES = *.log *.trs
13 DISTCLEANFILES =
14 MAINTAINERCLEANFILES =
15 EXTRA_DIST =
16 TEST_PROGS =
17
18 installed_test_LTLIBRARIES =
19 installed_test_PROGRAMS =
20 installed_test_SCRIPTS =
21 nobase_installed_test_DATA =
22
23 noinst_LTLIBRARIES =
24 noinst_PROGRAMS =
25 noinst_SCRIPTS =
26 noinst_DATA =
27
28 check_LTLIBRARIES =
29 check_PROGRAMS =
30 check_SCRIPTS =
31 check_DATA =
32
33 TESTS =
34
35 # test-nonrecursive: run tests only in cwd
36 if OS_UNIX
37 test-nonrecursive: ${TEST_PROGS}
38         @test -z "${TEST_PROGS}" || G_TEST_SRCDIR="$(abs_srcdir)" G_TEST_BUILDDIR="$(abs_builddir)" G_DEBUG=gc-friendly MALLOC_CHECK_=2 MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256)) ${GTESTER} --verbose ${TEST_PROGS}
39 else
40 test-nonrecursive:
41 endif
42
43 .PHONY: test-nonrecursive
44
45 .PHONY: lcov genlcov lcov-clean
46 # use recursive makes in order to ignore errors during check
47 lcov:
48         -$(MAKE) $(AM_MAKEFLAGS) -k check
49         $(MAKE) $(AM_MAKEFLAGS) genlcov
50
51 # we have to massage the lcov.info file slightly to hide the effect of libtool
52 # placing the objects files in the .libs/ directory separate from the *.c
53 # we also have to delete tests/.libs/libmoduletestplugin_*.gcda
54 genlcov:
55         rm -f $(top_builddir)/tests/.libs/libmoduletestplugin_*.gcda
56         $(LTP) --directory $(top_builddir) --capture --output-file glib-lcov.info --test-name GLIB_PERF --no-checksum --compat-libtool
57         LANG=C $(LTP_GENHTML) --prefix $(top_builddir) --output-directory glib-lcov --title "GLib Code Coverage" --legend --frames --show-details glib-lcov.info
58         @echo "file://$(abs_top_builddir)/glib-lcov/index.html"
59
60 lcov-clean:
61         -$(LTP) --directory $(top_builddir) -z
62         -rm -rf glib-lcov.info glib-lcov
63         -find -name '*.gcda' -print | xargs rm
64
65 # run tests in cwd as part of make check
66 check-local: test-nonrecursive
67
68 # We support a fairly large range of possible variables.  It is expected that all types of files in a test suite
69 # will belong in exactly one of the following variables.
70 #
71 # First, we support the usual automake suffixes, but in lowercase, with the customary meaning:
72 #
73 #   test_programs, test_scripts, test_data, test_ltlibraries
74 #
75 # The above are used to list files that are involved in both uninstalled and installed testing.  The
76 # test_programs and test_scripts are taken to be actual testcases and will be run as part of the test suite.
77 # Note that _data is always used with the nobase_ automake variable name to ensure that installed test data is
78 # installed in the same way as it appears in the package layout.
79 #
80 # In order to mark a particular file as being only for one type of testing, use 'installed' or 'uninstalled',
81 # like so:
82 #
83 #   installed_test_programs, uninstalled_test_programs
84 #   installed_test_scripts, uninstalled_test_scripts
85 #   installed_test_data, uninstalled_test_data
86 #   installed_test_ltlibraries, uninstalled_test_ltlibraries
87 #
88 # Additionally, we support 'extra' infixes for programs and scripts.  This is used for support programs/scripts
89 # that should not themselves be run as testcases (but exist to be used from other testcases):
90 #
91 #   test_extra_programs, installed_test_extra_programs, uninstalled_test_extra_programs
92 #   test_extra_scripts, installed_test_extra_scripts, uninstalled_test_extra_scripts
93 #
94 # Additionally, for _scripts and _data, we support the customary dist_ prefix so that the named script or data
95 # file automatically end up in the tarball.
96 #
97 #   dist_test_scripts, dist_test_data, dist_test_extra_scripts
98 #   dist_installed_test_scripts, dist_installed_test_data, dist_installed_test_extra_scripts
99 #   dist_uninstalled_test_scripts, dist_uninstalled_test_data, dist_uninstalled_test_extra_scripts
100 #
101 # Note that no file is automatically disted unless it appears in one of the dist_ variables.  This follows the
102 # standard automake convention of not disting programs scripts or data by default.
103 #
104 # test_programs, test_scripts, uninstalled_test_programs and uninstalled_test_scripts (as well as their disted
105 # variants) will be run as part of the in-tree 'make check'.  These are all assumed to be runnable under
106 # gtester.  That's a bit strange for scripts, but it's possible.
107
108 # we use test -z "$(TEST_PROGS)" above, so make sure we have no extra whitespace...
109 TEST_PROGS += $(strip $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \
110                       $(dist_test_scripts) $(dist_uninstalled_test_scripts))
111
112 if OS_WIN32
113 TESTS += $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \
114          $(dist_test_scripts) $(dist_uninstalled_test_scripts)
115 endif
116
117 # Note: build even the installed-only targets during 'make check' to ensure that they still work.
118 # We need to do a bit of trickery here and manage disting via EXTRA_DIST instead of using dist_ prefixes to
119 # prevent automake from mistreating gmake functions like $(wildcard ...) and $(addprefix ...) as if they were
120 # filenames, including removing duplicate instances of the opening part before the space, eg. '$(addprefix'.
121 all_test_programs     = $(test_programs) $(uninstalled_test_programs) $(installed_test_programs) \
122                         $(test_extra_programs) $(uninstalled_test_extra_programs) $(installed_test_extra_programs)
123 all_test_scripts      = $(test_scripts) $(uninstalled_test_scripts) $(installed_test_scripts) \
124                         $(test_extra_scripts) $(uninstalled_test_extra_scripts) $(installed_test_extra_scripts)
125 all_dist_test_scripts = $(dist_test_scripts) $(dist_uninstalled_test_scripts) $(dist_installed_test_scripts) \
126                         $(dist_test_extra_scripts) $(dist_uninstalled_test_extra_scripts) $(dist_installed_test_extra_scripts)
127 all_test_scripts     += $(all_dist_test_scripts)
128 EXTRA_DIST           += $(all_dist_test_scripts)
129 all_test_data         = $(test_data) $(uninstalled_test_data) $(installed_test_data)
130 all_dist_test_data    = $(dist_test_data) $(dist_uninstalled_test_data) $(dist_installed_test_data)
131 all_test_data        += $(all_dist_test_data)
132 EXTRA_DIST           += $(all_dist_test_data)
133 all_test_ltlibs       = $(test_ltlibraries) $(uninstalled_test_ltlibraries) $(installed_test_ltlibraries)
134
135 if ENABLE_ALWAYS_BUILD_TESTS
136 noinst_LTLIBRARIES += $(all_test_ltlibs)
137 noinst_PROGRAMS += $(all_test_programs)
138 noinst_SCRIPTS += $(all_test_scripts)
139 noinst_DATA += $(all_test_data)
140 else
141 check_LTLIBRARIES += $(all_test_ltlibs)
142 check_PROGRAMS += $(all_test_programs)
143 check_SCRIPTS += $(all_test_scripts)
144 check_DATA += $(all_test_data)
145 endif
146
147 if ENABLE_INSTALLED_TESTS
148 installed_test_PROGRAMS += $(test_programs) $(installed_test_programs) \
149                           $(test_extra_programs) $(installed_test_extra_programs)
150 installed_test_SCRIPTS += $(test_scripts) $(installed_test_scripts) \
151                           $(test_extra_scripts) $(test_installed_extra_scripts)
152 installed_test_SCRIPTS += $(dist_test_scripts) $(dist_test_extra_scripts) \
153                           $(dist_installed_test_scripts) $(dist_installed_test_extra_scripts)
154 nobase_installed_test_DATA += $(test_data) $(installed_test_data)
155 nobase_installed_test_DATA += $(dist_test_data) $(dist_installed_test_data)
156 installed_test_LTLIBRARIES += $(test_ltlibraries) $(installed_test_ltlibraries)
157 installed_testcases = $(test_programs) $(installed_test_programs) \
158                       $(test_scripts) $(installed_test_scripts) \
159                       $(dist_test_scripts) $(dist_installed_test_scripts)
160
161 installed_test_meta_DATA = $(installed_testcases:=.test)
162
163 %.test: %$(EXEEXT) Makefile
164         $(AM_V_GEN) (echo '[Test]' > $@.tmp; \
165         echo 'Type=session' >> $@.tmp; \
166         echo 'Exec=$(installed_testdir)/$<' >> $@.tmp; \
167         mv $@.tmp $@)
168
169 CLEANFILES += $(installed_test_meta_DATA)
170 endif