fix for different results message
[mono.git] / mcs / build / library.make
1 # -*- makefile -*-
2 #
3 # The rules for building our class libraries.
4 #
5 # The NO_TEST stuff is not too pleasant but whatcha
6 # gonna do.
7
8 # All the dep files now land in the same directory so we
9 # munge in the library name to keep the files from clashing.
10
11 sourcefile = $(LIBRARY).sources
12 PLATFORM_excludes := $(wildcard $(LIBRARY).$(PLATFORM)-excludes)
13
14 ifndef PLATFORM_excludes
15 ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
16 response = $(sourcefile)
17 endif
18 endif
19
20 ifndef response
21 response = $(depsdir)/$(PROFILE)_$(LIBRARY).response
22 library_CLEAN_FILES += $(response) $(LIBRARY).mdb $(BUILT_SOURCES)
23 endif
24
25 ifndef LIBRARY_NAME
26 LIBRARY_NAME = $(LIBRARY)
27 endif
28
29 makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
30 the_lib = $(topdir)/class/lib/$(PROFILE)/$(LIBRARY_NAME)
31 the_pdb = $(the_lib:.dll=.pdb)
32 the_mdb = $(the_lib).mdb
33 library_CLEAN_FILES += $(makefrag) $(the_lib) $(the_pdb) $(the_mdb)
34
35 ifdef LIBRARY_NEEDS_POSTPROCESSING
36 build_lib = fixup/$(PROFILE)/$(LIBRARY_NAME)
37 library_CLEAN_FILES += $(build_lib) $(build_lib:.dll=.pdb)
38 else
39 build_lib = $(the_lib)
40 endif
41
42 ifndef NO_TEST
43 test_nunit_lib = nunit.framework.dll nunit.core.dll nunit.util.dll
44 test_nunit_dep = $(test_nunit_lib:%=$(topdir)/class/lib/$(PROFILE)/%)
45 test_nunit_ref = $(test_nunit_dep:%=-r:%)
46 library_CLEAN_FILES += TestResult*.xml
47
48 ifndef test_against
49 test_against = $(the_lib)
50 test_dep = $(the_lib)
51 endif
52
53 ifndef test_lib
54 test_lib = $(LIBRARY:.dll=_test_$(PROFILE).dll)
55 test_sourcefile = $(LIBRARY:.dll=_test.dll.sources)
56 else
57 test_sourcefile = $(test_lib).sources
58 endif
59 test_pdb = $(test_lib:.dll=.pdb)
60 test_response = $(depsdir)/$(test_lib).response
61 test_makefrag = $(depsdir)/$(test_lib).makefrag
62 test_flags = -r:$(test_against) $(test_nunit_ref) $(TEST_MCS_FLAGS)
63 library_CLEAN_FILES += $(LIBRARY:.dll=_test*.dll) $(LIBRARY:.dll=_test*.pdb) $(test_response) $(test_makefrag)
64
65 ifndef btest_lib
66 btest_lib = $(LIBRARY:.dll=_btest_$(PROFILE).dll)
67 btest_sourcefile = $(LIBRARY:.dll=_btest.dll.sources)
68 else
69 btest_sourcefile = $(btest_lib).sources
70 endif
71 btest_pdb = $(btest_lib:.dll=.pdb)
72 btest_response = $(depsdir)/$(btest_lib).response
73 btest_makefrag = $(depsdir)/$(btest_lib).makefrag
74 btest_flags = -r:$(test_against) $(test_nunit_ref) $(TEST_MBAS_FLAGS)
75 library_CLEAN_FILES += $(LIBRARY:.dll=_btest*.dll) $(LIBRARY:.dll=_btest*.pdb) $(btest_response) $(btest_makefrag)
76
77 ifndef HAVE_CS_TESTS
78 HAVE_CS_TESTS := $(wildcard $(test_sourcefile))
79 endif
80 ifndef HAVE_VB_TESTS
81 HAVE_VB_TESTS := $(wildcard $(btest_sourcefile))
82 endif
83
84 endif
85
86 ifdef NO_INSTALL
87 GACUTIL = :
88 else
89 gacutil = $(topdir)/class/lib/net_1_1_bootstrap/gacutil.exe
90 GACUTIL = MONO_PATH="$(topdir)/class/lib/net_1_1_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(gacutil)
91 endif
92
93 ifdef NO_SIGN_ASSEMBLY
94 SN = :
95 else
96 sn = $(topdir)/class/lib/net_1_1_bootstrap/sn.exe
97 SN = MONO_PATH="$(topdir)/class/lib/net_1_1_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(sn)
98 SNFLAGS = -q -R
99 endif
100
101 ifeq ($(PLATFORM), win32)
102 GACDIR = `cygpath -w $(mono_libdir)`
103 GACROOT = `cygpath -w $(DESTDIR)$(mono_libdir)`
104 test_flags += -d:WINDOWS
105 else
106 GACDIR = $(mono_libdir)
107 GACROOT = $(DESTDIR)$(mono_libdir)
108 endif
109
110 all-local: $(the_lib)
111
112 install-local: all-local
113 test-local: all-local
114 uninstall-local:
115
116 ifdef NO_INSTALL
117 install-local uninstall-local:
118         @:
119
120 else
121
122 ifdef LIBRARY_INSTALL_DIR
123 install-local:
124         $(MKINSTALLDIRS) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
125         $(INSTALL_LIB) $(the_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
126         test ! -f $(the_lib).mdb || $(INSTALL_LIB) $(the_lib).mdb $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
127
128 uninstall-local:
129         -rm -f $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
130
131 else
132
133 # If RUNTIME_HAS_CONSISTENT_GACDIR is set, it implies that the internal GACDIR
134 # of the runtime is the same as the GACDIR we want.  So, we don't need to pass it
135 # to gacutil.  Note that the GACDIR we want may not be the same as the value of
136 # GACDIR set above, since the user could have overridden the value of $(prefix).
137 #
138 # This makes a difference only when we're building from the mono/ tree, since we
139 # have to ensure that the internal GACDIR of the in-tree runtime matches where we
140 # install the DLLs.
141
142 ifndef RUNTIME_HAS_CONSISTENT_GACDIR
143 gacdir_flag = /gacdir $(GACDIR)
144 endif
145
146 install-local: $(gacutil)
147         $(GACUTIL) /i $(the_lib) /f $(gacdir_flag) /root $(GACROOT) /package $(FRAMEWORK_VERSION)
148
149 uninstall-local: $(gacutil)
150         -$(GACUTIL) /u $(LIBRARY_NAME:.dll=) $(gacdir_flag) /root $(GACROOT) /package $(FRAMEWORK_VERSION)
151
152 endif
153 endif
154
155 clean-local:
156         -rm -f $(library_CLEAN_FILES) $(CLEAN_FILES)
157
158 test-local run-test-local run-test-ondotnet-local:
159         @:
160
161 ifndef NO_TEST
162 $(test_nunit_dep): $(topdir)/build/deps/nunit-$(PROFILE).stamp
163         @if test -f $@; then :; else rm -f $<; $(MAKE) $<; fi
164 $(topdir)/build/deps/nunit-$(PROFILE).stamp:
165         cd ${topdir}/nunit20 && $(MAKE)
166         echo "stamp" >$@
167 library_CLEAN_FILES += $(topdir)/build/deps/nunit-$(PROFILE).stamp
168 endif
169
170 test_assemblies :=
171
172 ifdef HAVE_CS_TESTS
173 test_assemblies += $(test_lib)
174 endif
175
176 ifdef HAVE_VB_TESTS
177 test_assemblies += $(btest_lib)
178 endif
179
180 ifdef test_assemblies
181 test-local: $(test_assemblies)
182 run-test-local: run-test-lib
183 run-test-ondotnet-local: run-test-ondotnet-lib
184
185 ## FIXME: i18n problem in the 'sed' command below
186 run-test-lib: test-local
187         ok=:; \
188         $(TEST_RUNTIME) $(TEST_HARNESS) $(TEST_HARNESS_FLAGS) $(LOCAL_TEST_HARNESS_FLAGS) /output:TestResult-$(PROFILE).log /exclude:NotWorking,ValueAdd,CAS,InetAccess /xml:TestResult-$(PROFILE).xml $(test_assemblies) || ok=false; \
189         sed '1,/^Tests run: /d' TestResult-$(PROFILE).log; \
190         $$ok
191
192 run-test-ondotnet-lib: test-local
193         ok=:; \
194         $(TEST_HARNESS) $(TEST_HARNESS_FLAGS) $(LOCAL_TEST_HARNESS_ONDOTNET_FLAGS) /exclude=NotDotNet,CAS /output:TestResult-ondotnet-$(PROFILE).log /xml:TestResult-ondotnet-$(PROFILE).xml $(test_assemblies) || ok=false; \
195         sed '1,/^Tests run: /d' TestResult-ondotnet-$(PROFILE).log; \
196         $$ok
197 endif
198
199 DISTFILES = $(sourcefile) $(EXTRA_DISTFILES)
200
201 TEST_FILES =
202
203 ifdef HAVE_CS_TESTS
204 TEST_FILES += `sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile)`
205 DISTFILES += $(test_sourcefile)
206 endif
207 ifdef HAVE_VB_TESTS
208 TEST_FILES += `sed -e '/^$$/d' -e 's,^,Test/,' $(btest_sourcefile)`
209 DISTFILES += $(btest_sourcefile)
210 endif
211
212 dist-local: dist-default
213         subs=' ' ; \
214         for f in `cat $(sourcefile)` $(TEST_FILES) ; do \
215           case $$f in \
216           ../*) : ;; \
217           *) dest=`dirname $$f` ; \
218              case $$subs in *" $$dest "*) : ;; *) subs=" $$dest$$subs" ; $(MKINSTALLDIRS) $(distdir)/$$dest ;; esac ; \
219              cp -p $$f $(distdir)/$$dest || exit 1 ;; \
220           esac ; done ; \
221         for d in . $$subs ; do \
222           case $$d in .) : ;; *) test ! -f $$d/ChangeLog || cp -p $$d/ChangeLog $(distdir)/$$d ;; esac ; done
223
224 ifdef LIBRARY_NEEDS_POSTPROCESSING
225 dist-local: dist-fixup
226 FIXUP_PROFILES = default net_2_0
227 dist-fixup:
228         $(MKINSTALLDIRS) $(distdir)/fixup $(FIXUP_PROFILES:%=$(distdir)/fixup/%)
229 endif
230
231 ifndef LIBRARY_COMPILE
232 LIBRARY_COMPILE = $(CSCOMPILE)
233 endif
234
235 ifndef TEST_COMPILE
236 TEST_COMPILE = $(CSCOMPILE)
237 endif
238
239 ifndef BTEST_COMPILE
240 BTEST_COMPILE = $(BASCOMPILE)
241 endif
242
243 ifndef LIBRARY_SNK
244 LIBRARY_SNK = $(topdir)/class/mono.snk
245 endif
246
247 ifdef gacutil
248 $(gacutil):
249         cd $(topdir) && $(MAKE) PROFILE=net_1_1_bootstrap
250 endif
251
252 ifdef sn
253 $(sn):
254         cd $(topdir) && $(MAKE) PROFILE=net_1_1_bootstrap
255 endif
256
257 ifdef BUILT_SOURCES
258 ifeq (cat, $(PLATFORM_CHANGE_SEPARATOR_CMD))
259 BUILT_SOURCES_cmdline = $(BUILT_SOURCES)
260 else
261 BUILT_SOURCES_cmdline = `echo $(BUILT_SOURCES) | $(PLATFORM_CHANGE_SEPARATOR_CMD)`
262 endif
263 endif
264
265 # The library
266
267 $(build_lib): $(response) $(sn) $(BUILT_SOURCES)
268 ifdef LIBRARY_USE_INTERMEDIATE_FILE
269         $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) -target:library -out:$(LIBRARY_NAME) $(BUILT_SOURCES_cmdline) @$(response)
270         $(SN) $(SNFLAGS) $(LIBRARY_NAME) $(LIBRARY_SNK)
271         mv $(LIBRARY_NAME) $@
272         test ! -f $(LIBRARY_NAME).mdb || mv $(LIBRARY_NAME).mdb $@.mdb
273 else
274         $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) -target:library -out:$@ $(BUILT_SOURCES_cmdline) @$(response)
275         $(SN) $(SNFLAGS) $@ $(LIBRARY_SNK)
276 endif
277
278 $(makefrag): $(sourcefile)
279         @echo Creating $@ ...
280         @sed 's,^,$(build_lib): ,' $< >$@
281
282 ifneq ($(response),$(sourcefile))
283 $(response): $(sourcefile) $(PLATFORM_excludes)
284         @echo Creating $@ ...
285         @sort $(sourcefile) $(PLATFORM_excludes) | uniq -u | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
286 endif
287
288 -include $(makefrag)
289
290 # for now, don't give any /lib flags or set MONO_PATH, since we
291 # give a full path to the assembly.
292
293 ifdef HAVE_CS_TESTS
294
295 $(test_lib): $(test_dep) $(test_response) $(test_nunit_dep)
296         $(TEST_COMPILE) -target:library -out:$@ $(test_flags) @$(test_response)
297
298 $(test_response): $(test_sourcefile)
299         @echo Creating $@ ...
300         @sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
301
302 $(test_makefrag): $(test_response)
303         @echo Creating $@ ...
304         @sed 's,^,$(test_lib): ,' $< >$@
305
306 -include $(test_makefrag)
307
308 endif
309
310 ifdef HAVE_VB_TESTS
311
312 $(btest_lib): $(test_dep) $(btest_response) $(test_nunit_dep)
313         $(BTEST_COMPILE) -target:library -out:$@ $(btest_flags) @$(btest_response)
314
315 $(btest_response): $(btest_sourcefile)
316         @echo Creating $@ ...
317         @sed -e '/^$$/d' -e 's,^,Test/,' $(btest_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
318
319 $(btest_makefrag): $(btest_response)
320         @echo Creating $@ ...
321         @sed 's,^,$(btest_lib): ,' $< >$@
322
323 -include $(btest_makefrag)
324
325 endif
326
327 all-local: $(makefrag) $(test_makefrag) $(btest_makefrag)
328 $(makefrag) $(test_makefrag) $(btest_makefrag): $(topdir)/build/library.make