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