More test fixes for builddir != srcdir
[platform/upstream/glib.git] / tests / Makefile.am
1 include $(top_srcdir)/Makefile.decl
2
3 insttestdir = $(pkglibexecdir)/installed-tests
4
5 SUBDIRS=gobject refcount
6
7 AM_CPPFLAGS = \
8         $(gmodule_INCLUDES)                     \
9         -DGLIB_DISABLE_DEPRECATION_WARNINGS     \
10         -DG_LOG_DOMAIN=\"GLib\"                 \
11         -DSRCDIR=\"$(srcdir)\"                  \
12         $(GLIB_DEBUG_FLAGS)
13
14 AM_CFLAGS = -g
15
16 EFENCE=
17
18 libglib = $(top_builddir)/glib/libglib-2.0.la
19 libgthread = $(top_builddir)/gthread/libgthread-2.0.la
20 libgmodule = $(top_builddir)/gmodule/libgmodule-2.0.la
21 libgobject = $(top_builddir)/gobject/libgobject-2.0.la
22
23 libadd_libgmodule = $(libgmodule)
24 libadd_libglib = $(libglib)
25 if PLATFORM_WIN32
26 no_undefined = -no-undefined
27
28 module_test_exp = module-test.exp
29
30 module-test.exp: module-test.o
31         $(DLLTOOL) --output-exp module-test.exp module-test.o
32
33 spawn_test_win32_gui = spawn-test-win32-gui
34
35 spawn_test_win32_gui_LDFLAGS = -mwindows
36
37 endif
38
39 EXTRA_DIST +=                                   \
40         $(test_scripts)                         \
41         makefile.msc.in                         \
42         casefold.txt                            \
43         casemap.txt                             \
44         gen-casefold-txt.pl                     \
45         gen-casemap-txt.pl                      \
46         iochannel-test-infile                   \
47         utf8.txt                                \
48         timeloop-basic.c                        \
49         assert-msg-test.gdb
50
51 BUILT_EXTRA_DIST =                              \
52         makefile.msc
53
54 if HAVE_CXX
55 CXX_TEST = cxx-test
56 cxx_test_LDADD = $(progs_ldadd)
57 cxx_test_SOURCES = cxx-test.C
58 else
59 CXX_TEST =
60 endif
61
62 if ENABLE_TIMELOOP
63 timeloop = timeloop timeloop-closure
64 endif
65 noinst_PROGRAMS = $(TEST_PROGS) \
66         testgdate               \
67         testgdateparser         \
68         unicode-normalize       \
69         unicode-collate         \
70         $(timeloop)             \
71         assert-msg-test         \
72         datetime                \
73         testgobject
74
75 TEST_PROGS              += testglib
76 testglib_SOURCES         = testglib.c
77 testglib_LDADD           = $(libglib)
78
79
80 testgdate_LDADD = $(libglib)
81 testgdateparser_LDADD = $(libglib)
82 unicode_normalize_LDADD = $(libglib)
83 unicode_collate_LDADD = $(libglib)
84 assert_msg_test_LDADD = $(libglib)
85 if ENABLE_TIMELOOP
86 timeloop_LDADD = $(libglib)
87 timeloop_closure_LDADD = $(libglib) $(libgobject)
88 endif
89 datetime_LDADD = $(libglib)
90 testgobject_LDADD = $(libglib) $(libgobject)
91
92 test_programs =                                 \
93         atomic-test                             \
94         bit-test                                \
95         $(CXX_TEST)                             \
96         child-test                              \
97         completion-test                         \
98         dirname-test                            \
99         file-test                               \
100         env-test                                \
101         gio-test                                \
102         iochannel-test                          \
103         mainloop-test                           \
104         mapping-test                            \
105         module-test                             \
106         onceinit                                \
107         asyncqueue-test                         \
108         qsort-test                              \
109         relation-test                           \
110         slice-test                              \
111         slice-color                             \
112         slice-concurrent                        \
113         slice-threadinit                        \
114         sources                                 \
115         spawn-test                              \
116         $(spawn_test_win32_gui)                 \
117         thread-test                             \
118         threadpool-test                         \
119         type-test                               \
120         unicode-caseconv                        \
121         unicode-encoding
122
123 test_scripts = run-collate-tests.sh run-assert-msg-test.sh
124
125 test_script_support_programs = unicode-collate
126
127 check_PROGRAMS = $(test_programs) $(test_script_support_programs)
128
129 TESTS = $(test_programs) $(test_scripts)
130 TESTS_ENVIRONMENT = srcdir=$(srcdir) \
131         LIBCHARSET_ALIAS_DIR=$(top_builddir)/glib/libcharset \
132         MALLOC_CHECK_=2 \
133         MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256))
134
135 test_data =                             \
136         iochannel-test-infile           \
137         casemap.txt                     \
138         casefold.txt                    \
139         utf8.txt                        \
140         $(NULL)
141
142 if BUILDOPT_INSTALL_TESTS
143 insttest_PROGRAMS = $(test_programs)
144
145 testmetadir = $(datadir)/installed-tests/$(PACKAGE)
146 testmeta_DATA = $(test_programs:=.test)
147
148 insttest_DATA = $(test_data)
149
150 %.test: %$(EXEEXT) Makefile
151         $(AM_V_GEN) (echo '[Test]' > $@.tmp; \
152          echo 'Type=session' >> $@.tmp; \
153          echo 'Exec=env G_TEST_DATA=$(pkglibexecdir)/installed-tests $(pkglibexecdir)/installed-tests/$<' >> $@.tmp; \
154          mv $@.tmp $@)
155
156 endif
157
158 progs_ldadd = $(EFENCE) $(libglib) $(EFENCE)
159 thread_ldadd = $(libgthread) $(G_THREAD_LIBS) $(progs_ldadd)
160 module_ldadd = $(libgmodule) $(G_MODULE_LIBS) $(progs_ldadd)
161
162 atomic_test_LDADD = $(progs_ldadd)
163 bit_test_LDADD = $(progs_ldadd)
164 child_test_LDADD = $(thread_ldadd)
165 completion_test_LDADD = $(progs_ldadd)
166 dirname_test_LDADD = $(progs_ldadd)
167 file_test_LDADD = $(progs_ldadd)
168 env_test_LDADD = $(progs_ldadd)
169 gio_test_LDADD = $(progs_ldadd)
170 iochannel_test_LDADD = $(progs_ldadd)
171 mainloop_test_LDADD = $(thread_ldadd)
172 mapping_test_LDADD = $(progs_ldadd)
173 module_test_LDADD = $(module_ldadd) $(module_test_exp)
174 module_test_LDFLAGS = $(G_MODULE_LDFLAGS)
175 onceinit_LDADD = $(thread_ldadd)
176 asyncqueue_test_LDADD = $(thread_ldadd)
177 qsort_test_LDADD = $(progs_ldadd)
178 relation_test_LDADD = $(progs_ldadd)
179 slice_test_SOURCES = slice-test.c memchunks.c
180 slice_test_LDADD = $(thread_ldadd)
181 slice_color_SOURCES = slice-color.c memchunks.c
182 slice_color_LDADD = $(thread_ldadd)
183 slice_concurrent_SOURCES = slice-concurrent.c
184 slice_concurrent_LDADD = $(thread_ldadd)
185 slice_threadinit_SOURCES = slice-threadinit.c
186 slice_threadinit_LDADD = $(thread_ldadd)
187 sources_LDADD = $(progs_ldadd)
188 spawn_test_LDADD = $(progs_ldadd)
189 thread_test_LDADD = $(thread_ldadd)
190 threadpool_test_LDADD = $(thread_ldadd)
191 type_test_LDADD = $(progs_ldadd)
192 unicode_encoding_LDADD = $(progs_ldadd)
193 unicode_caseconv_LDADD = $(progs_ldadd)
194
195 if BUILDOPT_INSTALL_TESTS
196 insttest_LTLIBRARIES = libmoduletestplugin_a.la libmoduletestplugin_b.la
197 else
198 noinst_LTLIBRARIES = libmoduletestplugin_a.la libmoduletestplugin_b.la
199 endif
200
201 libmoduletestplugin_a_la_SOURCES = libmoduletestplugin_a.c
202 libmoduletestplugin_a_la_LDFLAGS = $(G_MODULE_LDFLAGS) -avoid-version -module $(no_undefined) -rpath $(insttestdir)
203 libmoduletestplugin_a_la_LIBADD = $(G_MODULE_LIBS) $(libadd_libgmodule) $(libadd_libglib)
204
205 libmoduletestplugin_b_la_SOURCES = libmoduletestplugin_b.c
206 libmoduletestplugin_b_la_LDFLAGS = $(G_MODULE_LDFLAGS) -avoid-version -module $(no_undefined) -rpath $(insttestdir)
207 libmoduletestplugin_b_la_LIBADD = $(G_MODULE_LIBS) $(libadd_libgmodule) $(libadd_libglib)
208
209 dist-hook: $(BUILT_EXTRA_DIST)
210         files='$(BUILT_EXTRA_DIST)';                            \
211         for f in $$files; do                                    \
212           if test -f $$f; then d=.; else d=$(srcdir); fi;       \
213           cp $$d/$$f $(distdir) || exit 1; done
214         mkdir $(distdir)/collate;                               \
215         for f in $(srcdir)/collate/* ; do                       \
216           if test -f $$f; then cp $$f $(distdir)/collate; fi; done
217
218 DISTCLEANFILES =                \
219         iochannel-test-outfile  \
220         file-test-get-contents  \
221         maptest                 \
222         mapchild                \
223         collate.out