cleanup
[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         $(AM_V_GEN) rm -f $(top_builddir)/tests/.libs/libmoduletestplugin_*.gcda; \
56           $(LTP) --quiet --directory $(top_builddir) --capture --output-file glib-lcov.info --test-name GLIB_PERF --no-checksum --compat-libtool --ignore-errors source; \
57           $(LTP) --quiet --output-file glib-lcov.info --remove glib-lcov.info docs/reference/\* /tmp/\*  gio/tests/gdbus-object-manager-example/\* ; \
58           LANG=C $(LTP_GENHTML) --quiet --prefix $(top_builddir) --output-directory glib-lcov --title "GLib Code Coverage" --legend --frames --show-details glib-lcov.info --ignore-errors source
59         @echo "file://$(abs_top_builddir)/glib-lcov/index.html"
60
61 lcov-clean:
62         if test -n "$(LTP)"; then \
63           $(LTP) --quiet --directory $(top_builddir) -z; \
64         fi
65
66 # run tests in cwd as part of make check
67 check-local: test-nonrecursive
68
69 # We support a fairly large range of possible variables.  It is expected that all types of files in a test suite
70 # will belong in exactly one of the following variables.
71 #
72 # First, we support the usual automake suffixes, but in lowercase, with the customary meaning:
73 #
74 #   test_programs, test_scripts, test_data, test_ltlibraries
75 #
76 # The above are used to list files that are involved in both uninstalled and installed testing.  The
77 # test_programs and test_scripts are taken to be actual testcases and will be run as part of the test suite.
78 # Note that _data is always used with the nobase_ automake variable name to ensure that installed test data is
79 # installed in the same way as it appears in the package layout.
80 #
81 # In order to mark a particular file as being only for one type of testing, use 'installed' or 'uninstalled',
82 # like so:
83 #
84 #   installed_test_programs, uninstalled_test_programs
85 #   installed_test_scripts, uninstalled_test_scripts
86 #   installed_test_data, uninstalled_test_data
87 #   installed_test_ltlibraries, uninstalled_test_ltlibraries
88 #
89 # Additionally, we support 'extra' infixes for programs and scripts.  This is used for support programs/scripts
90 # that should not themselves be run as testcases (but exist to be used from other testcases):
91 #
92 #   test_extra_programs, installed_test_extra_programs, uninstalled_test_extra_programs
93 #   test_extra_scripts, installed_test_extra_scripts, uninstalled_test_extra_scripts
94 #
95 # Additionally, for _scripts and _data, we support the customary dist_ prefix so that the named script or data
96 # file automatically end up in the tarball.
97 #
98 #   dist_test_scripts, dist_test_data, dist_test_extra_scripts
99 #   dist_installed_test_scripts, dist_installed_test_data, dist_installed_test_extra_scripts
100 #   dist_uninstalled_test_scripts, dist_uninstalled_test_data, dist_uninstalled_test_extra_scripts
101 #
102 # Note that no file is automatically disted unless it appears in one of the dist_ variables.  This follows the
103 # standard automake convention of not disting programs scripts or data by default.
104 #
105 # test_programs, test_scripts, uninstalled_test_programs and uninstalled_test_scripts (as well as their disted
106 # variants) will be run as part of the in-tree 'make check'.  These are all assumed to be runnable under
107 # gtester.  That's a bit strange for scripts, but it's possible.
108
109 # we use test -z "$(TEST_PROGS)" above, so make sure we have no extra whitespace...
110 TEST_PROGS += $(strip $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \
111                       $(dist_test_scripts) $(dist_uninstalled_test_scripts))
112
113 if OS_WIN32
114 TESTS += $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \
115          $(dist_test_scripts) $(dist_uninstalled_test_scripts)
116 endif
117
118 # Note: build even the installed-only targets during 'make check' to ensure that they still work.
119 # We need to do a bit of trickery here and manage disting via EXTRA_DIST instead of using dist_ prefixes to
120 # prevent automake from mistreating gmake functions like $(wildcard ...) and $(addprefix ...) as if they were
121 # filenames, including removing duplicate instances of the opening part before the space, eg. '$(addprefix'.
122 all_test_programs     = $(test_programs) $(uninstalled_test_programs) $(installed_test_programs) \
123                         $(test_extra_programs) $(uninstalled_test_extra_programs) $(installed_test_extra_programs)
124 all_test_scripts      = $(test_scripts) $(uninstalled_test_scripts) $(installed_test_scripts) \
125                         $(test_extra_scripts) $(uninstalled_test_extra_scripts) $(installed_test_extra_scripts)
126 all_dist_test_scripts = $(dist_test_scripts) $(dist_uninstalled_test_scripts) $(dist_installed_test_scripts) \
127                         $(dist_test_extra_scripts) $(dist_uninstalled_test_extra_scripts) $(dist_installed_test_extra_scripts)
128 all_test_scripts     += $(all_dist_test_scripts)
129 EXTRA_DIST           += $(all_dist_test_scripts)
130 all_test_data         = $(test_data) $(uninstalled_test_data) $(installed_test_data)
131 all_dist_test_data    = $(dist_test_data) $(dist_uninstalled_test_data) $(dist_installed_test_data)
132 all_test_data        += $(all_dist_test_data)
133 EXTRA_DIST           += $(all_dist_test_data)
134 all_test_ltlibs       = $(test_ltlibraries) $(uninstalled_test_ltlibraries) $(installed_test_ltlibraries)
135
136 if ENABLE_ALWAYS_BUILD_TESTS
137 noinst_LTLIBRARIES += $(all_test_ltlibs)
138 noinst_PROGRAMS += $(all_test_programs)
139 noinst_SCRIPTS += $(all_test_scripts)
140 noinst_DATA += $(all_test_data)
141 else
142 check_LTLIBRARIES += $(all_test_ltlibs)
143 check_PROGRAMS += $(all_test_programs)
144 check_SCRIPTS += $(all_test_scripts)
145 check_DATA += $(all_test_data)
146 endif
147
148 if ENABLE_INSTALLED_TESTS
149 installed_test_PROGRAMS += $(test_programs) $(installed_test_programs) \
150                           $(test_extra_programs) $(installed_test_extra_programs)
151 installed_test_SCRIPTS += $(test_scripts) $(installed_test_scripts) \
152                           $(test_extra_scripts) $(test_installed_extra_scripts)
153 installed_test_SCRIPTS += $(dist_test_scripts) $(dist_test_extra_scripts) \
154                           $(dist_installed_test_scripts) $(dist_installed_test_extra_scripts)
155 nobase_installed_test_DATA += $(test_data) $(installed_test_data)
156 nobase_installed_test_DATA += $(dist_test_data) $(dist_installed_test_data)
157 installed_test_LTLIBRARIES += $(test_ltlibraries) $(installed_test_ltlibraries)
158 installed_testcases = $(test_programs) $(installed_test_programs) \
159                       $(test_scripts) $(installed_test_scripts) \
160                       $(dist_test_scripts) $(dist_installed_test_scripts)
161
162 installed_test_meta_DATA = $(installed_testcases:=.test)
163
164 %.test: %$(EXEEXT) Makefile
165         $(AM_V_GEN) (echo '[Test]' > $@.tmp; \
166         echo 'Type=session' >> $@.tmp; \
167         echo 'Exec=$(installed_testdir)/$(notdir $<)' >> $@.tmp; \
168         mv $@.tmp $@)
169
170 CLEANFILES += $(installed_test_meta_DATA)
171 endif