2004-05-30 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / corlib / Makefile
1 thisdir = class/corlib
2 SUBDIRS =
3 include ../../build/rules.make
4 export __SECURITY_BOOTSTRAP_DB=$(topdir)/class/corlib
5
6 # corlib is crazy to build so we skip build/library.make and do stuff
7 # ourselves.
8 #
9 # Here, we define a bunch of variables.
10
11 ifdef PLATFORM_MONO_NATIVE
12 test_against = $(corlib)
13 else
14 test_against = $(reslib)
15 endif
16
17 LOCAL_MCS_FLAGS = /nowarn:649 /nowarn:169 -d:INSIDE_CORLIB
18
19 gmcs = $(topdir)/gmcs/gmcs.exe
20
21 corlib = $(topdir)/class/lib/$(PROFILE)/mscorlib.dll
22 testlib = corlib_test.dll
23 cmplib = $(topdir)/class/lib/$(PROFILE)/corlib_cmp.dll
24 reslib = $(topdir)/class/lib/$(PROFILE)/corlib_res.dll
25 plattestlib = corlib_plattest.dll
26
27 corpdb = $(patsubst %.dll,%.pdb,$(corlib))
28 testpdb = $(patsubst %.dll,%.pdb,$(testlib))
29 cmppdb = $(patsubst %.dll,%.pdb,$(cmplib))
30 respdb = $(patsubst %.dll,%.pdb,$(reslib))
31 plattestpdb = $(patsubst %.dll,%.pdb,$(plattestlib))
32
33 sourcefile = corlib.dll.sources
34 response = $(depsdir)/$(PROFILE)_corlib.dll.response
35 makefrag = $(depsdir)/$(PROFILE)_corlib.dll.makefrag
36 stampfile = $(depsdir)/$(PROFILE)_corlib.dll.stamp
37 # disable, until people fix their code...
38 #corlib_flags = /unsafe /nostdlib /d:INSIDE_CORLIB
39 corlib_flags = /unsafe /nostdlib
40
41 net_2_0_bootstrap_response = $(depsdir)/corlib_net_2_0_bootstrap.dll.response
42 net_2_0_bootstrap_makefrag = $(depsdir)/corlib_net_2_0_bootstrap.dll.makefrag
43 net_2_0_bootstrap_stampfile = $(depsdir)/corlib_net_2_0_bootstrap.dll.stamp
44
45 net_2_0_response = $(depsdir)/corlib_net_2_0.dll.response
46 net_2_0_makefrag = $(depsdir)/corlib_net_2_0.dll.makefrag
47 net_2_0_stampfile = $(depsdir)/corlib_net_2_0.dll.stamp
48
49 test_sourcefile = corlib_test.dll.sources
50 test_response = $(depsdir)/$(PROFILE)_$(testlib).response
51 test_makefrag = $(depsdir)/$(PROFILE)_$(testlib).makefrag
52 test_stampfile = $(depsdir)/$(PROFILE)_$(testlib).stamp
53 test_nunitfw = $(topdir)/class/lib/$(PROFILE)/nunit.framework.dll
54 test_flags = /nowarn:0618 /nowarn:0672 /unsafe /r:$(test_against) /r:$(test_nunitfw)
55
56 cmp_response = $(depsdir)/$(PROFILE)_corlib_cmp.dll.response
57 cmp_makefrag = $(depsdir)/$(PROFILE)_corlib_cmp.dll.makefrag
58 cmp_stampfile = $(depsdir)/$(PROFILE)_corlib_cmp.dll.stamp
59 cmp_flags = /r:$(PLATFORM_CORLIB) $(corlib_flags)
60
61 res_response = $(depsdir)/$(PROFILE)_corlib_res.dll.response
62 res_makefrag = $(depsdir)/$(PROFILE)_corlib_res.dll.makefrag
63 res_stampfile = $(depsdir)/$(PROFILE)_corlib_res.dll.stamp
64 res_flags = /r:$(PLATFORM_CORLIB) $(corlib_flags)
65
66 plattest_excludes = corlib_plattest.dll.excludes
67 plattest_response = $(depsdir)/$(PROFILE)_$(plattestlib).response
68 plattest_makefrag = $(depsdir)/$(PROFILE)_$(plattestlib).makefrag
69 plattest_stampfile = $(depsdir)/$(PROFILE)_$(plattestlib).stamp
70 plattest_flags = /debug+ /debug:full /nowarn:0618 /nowarn:0672 /unsafe /r:$(PLATFORM_CORLIB) /r:$(test_nunitfw)
71
72 # Here, we make all.
73
74 all-local: $(corlib)
75
76 install-local: $(corlib) $(makefrag)
77         @if test $(PROFILE) = "net_2_0" ; then \
78                 echo $(MKINSTALLDIRS) $(DESTDIR)$(prefix)/lib/net_2_0 ; \
79                 $(MKINSTALLDIRS) $(DESTDIR)$(prefix)/lib/net_2_0 ; \
80                 echo $(INSTALL_LIB) $(corlib) $(DESTDIR)$(prefix)/lib/net_2_0 ; \
81                 $(INSTALL_LIB) $(corlib) $(DESTDIR)$(prefix)/lib/net_2_0 ; \
82         else \
83                 echo $(MKINSTALLDIRS) $(DESTDIR)$(prefix)/lib ; \
84                 $(MKINSTALLDIRS) $(DESTDIR)$(prefix)/lib ; \
85                 echo $(INSTALL_LIB) $(corlib) $(DESTDIR)$(prefix)/lib ; \
86                 $(INSTALL_LIB) $(corlib) $(DESTDIR)$(prefix)/lib ; \
87         fi
88
89 uninstall-local:
90         @if test $(PROFILE) = "net_2_0" ; then \
91                 -rm -f $(DESTDIR)$(prefix)/lib/net_2_0/corlib.dll
92         else \
93                 -rm -f $(DESTDIR)$(prefix)/lib/corlib.dll
94         fi
95
96 clean-local:
97         -rm -f $(corlib) $(cmplib) $(testlib) $(reslib) $(plattestlib) TestResult.xml \
98                $(response) $(makefrag) $(stampfile) \
99                $(net_2_0_bootstrap_response) $(net_2_0_bootstrap_makefrag) $(net_2_0_bootstrap_stampfile) \
100                $(net_2_0_response) $(net_2_0_makefrag) $(net_2_0_stampfile) \
101                $(test_response) $(test_makefrag) $(test_stampfile) \
102                $(cmp_response) $(cmp_makefrag) $(cmp_stampfile) \
103                $(res_response) $(res_makefrag) $(res_stampfile) \
104                $(plattest_response) $(plattest_makefrag) $(plattest_stampfile) \
105                $(corpdb) $(cmppdb) $(testpdb) $(respdb) $(plattestpdb)
106
107
108 # If building on a non mono-native platform, default
109 # to running the unit tests on its corlib, to see if
110 # our tests are complaint with their (hopefully bug-free)
111 # corlib. If on a mono-native platform, test our actual
112 # corlib.
113 #
114 # You can access either one on demand with either 'make
115 # run-monotest' or 'make run-plattest'.
116
117 $(test_nunitfw):
118         (cd ${topdir}/nunit20 && make)
119
120 ifdef PLATFORM_MONO_NATIVE
121 test-local: $(test_nunitfw) $(test_against) $(testlib)
122
123 run-test-local: run-monotest
124 else
125 test-local: $(test_nunitfw) $(plattestlib)
126
127 run-test-local: run-plattest
128 endif
129
130 run-monotest: $(test_against) $(testlib)
131         $(TEST_RUNTIME) $(TEST_HARNESS) $(testlib)
132
133 run-plattest: $(plattestlib)
134         $(TEST_RUNTIME) $(TEST_HARNESS) $(plattestlib)
135
136 # OK, that was the easy part. Now we get to the fun bits.
137 #
138 # first, make dist.
139
140 DISTFILES = $(sourcefile) $(test_sourcefile) \
141         corlib.dll.win32-excludes corlib_cmp.dll.excludes corlib_res.dll.excludes \
142         $(plattest_excludes) \
143         Test/ms_run_test.sh
144
145 # see $(topdir)/build/library.make for explanation of what's going on
146 # here.
147
148 dist-local: dist-default
149         for f in `cat $(sourcefile)` `cat $(test_sourcefile) |sed -e 's,^\(.\),Test/\1,'` ; do \
150             dest=`dirname $(distdir)/$$f` ; \
151             $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
152         done
153
154 # plain ol corlib
155
156 $(corlib): $(makefrag) $(response) $(stampfile) 
157         @if test $(PROFILE) = "net_2_0" ; then \
158                 $(MAKE) corlib_net_2_0 || exit 1 ; \
159         else \
160                 $(MAKE) corlib_compile || exit 1 ; \
161         fi
162
163 corlib_compile: $(makefrag) $(response) $(stampfile) 
164         $(BOOT_COMPILE) $(LIBRARY_FLAGS) $(corlib_flags) /target:library /out:../lib/default/mscorlib.dll @$(response)
165
166 # A bootstrap corlib 2.0 needs to be built so gmcs can be built and the full net 2.0 corlib can be built
167 # here we go,....
168
169 corlib_net_2_0: corlib_net_2_0_compile
170
171 corlib_net_2_0_compile: corlib_net_2_0_bootstrap $(net_2_0_makefrag) $(net_2_0_response) $(net_2_0_stampfile) $(gmcs)
172         MONO_PATH="../lib/net_2_0_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(gmcs) $(USE_MCS_FLAGS) $(LIBRARY_FLAGS) $(corlib_flags) /define:NET_1_1 /define:NET_2_0 /target:library /out:../lib/net_2_0/mscorlib.dll @$(net_2_0_response)
173
174 corlib_net_2_0_bootstrap: $(net_2_0_bootstrap_response) $(net_2_0_bootstrap_stampfile)
175         $(BOOTSTRAP_MCS) /nowarn:649 /nowarn:169 /define:INSIDE_CORLIB /define:NET_1_1 /define:BOOTSTRAP_NET_2_0 $(corlib_flags) /target:library /out:../lib/net_2_0_bootstrap/mscorlib.dll @$(net_2_0_bootstrap_response)
176
177 # make sure that $(gmcs) is up-to-date
178 FORCE:
179 $(gmcs): FORCE
180         cd $(topdir)/gmcs && $(MAKE) ;
181
182 $(response): $(sourcefile)
183         @echo Creating $@ ...
184 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
185         @cat $< |$(PLATFORM_TWEAK_CORLIB_SOURCES) |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
186 else
187         @cat $< |$(PLATFORM_TWEAK_CORLIB_SOURCES) >$@
188 endif
189
190 # warning: embedded tab in the 'echo touch' line
191 $(makefrag): $(response)
192         @echo Creating $@ ...
193         @echo "HAVE_MAKEFRAG = yes" >$@.new
194         @echo "$(stampfile): \\" >>$@.new
195         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
196         @cat $@.new |sed -e '$$s, \\$$,,' >$@
197         @echo " touch \$$@" >>$@
198         @rm -rf $@.new
199
200 -include $(makefrag)
201
202 ifndef HAVE_MAKEFRAG
203 $(stampfile):
204         touch $@
205 endif
206
207 # corlib_cmp
208
209 $(cmplib): $(cmp_makefrag) $(cmp_response) $(cmp_stampfile)
210         $(BOOT_COMPILE) $(LIBRARY_FLAGS) $(cmp_flags) /target:library /out:$@ @$(cmp_response)
211
212 $(cmp_response): $(response) corlib_cmp.dll.excludes
213         @echo Creating $@ ...
214 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
215         @cat corlib_cmp.dll.excludes |$(PLATFORM_CHANGE_SEPARATOR_CMD) |cat - $< |sort |uniq -u >$@
216 else
217         @cat corlib_cmp.dll.excludes |cat - $< |sort |uniq -u >$@
218 endif
219
220 # warning: embedded tab in the 'echo touch' line
221 $(cmp_makefrag): $(cmp_response)
222         @echo Creating $@ ...
223         @echo "HAVE_CMP_MAKEFRAG = yes" >$@.new
224         @echo "$(cmp_stampfile): \\" >>$@.new
225         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
226         @cat $@.new |sed -e '$$s, \\$$,,' >$@
227         @echo " touch \$$@" >>$@
228         @rm -rf $@.new
229
230 # Since we make corlib_cmp on demand, there isn't a real need
231 # to have full dep tracking for it. Also, the generation of this
232 # file is busted on Win32 ('sort' seems to mess up line endings),
233 # leading to a broken build.
234 #
235 # -include $(cmp_makefrag)
236
237 ifndef HAVE_CMP_MAKEFRAG
238 $(cmp_stampfile):
239         touch $@
240 endif
241
242 # corlib_res
243
244 $(reslib): $(res_makefrag) $(res_response) $(res_stampfile)
245         $(BOOT_COMPILE) $(LIBRARY_FLAGS) $(res_flags) /target:library /out:$@ @$(res_response)
246
247 $(res_response): $(sourcefile) corlib_res.dll.excludes
248         @echo Creating $@ ...
249 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
250         @cat corlib_res.dll.excludes $(sourcefile) |sort |uniq -u |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
251 else
252         @cat corlib_res.dll.excludes $(sourcefile) |sort |uniq -u >$@
253 endif
254
255 # warning: embedded tab in the 'echo touch' line
256 $(res_makefrag): $(res_response)
257         @echo Creating $@ ...
258         @echo "HAVE_RES_MAKEFRAG = yes" >$@.new
259         @echo "$(res_stampfile): \\" >>$@.new
260         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
261         @cat $@.new |sed -e '$$s, \\$$,,' >$@
262         @echo " touch \$$@" >>$@
263         @rm -rf $@.new
264
265 -include $(res_makefrag)
266
267 ifndef HAVE_RES_MAKEFRAG
268 $(res_stampfile):
269         touch $@
270 endif
271
272 # corlib_test
273
274 $(testlib): $(test_makefrag) $(test_response) $(test_stampfile)
275         $(CSCOMPILE) $(test_flags) /target:library /out:$@ @$(test_response)
276
277 $(test_response): $(test_sourcefile)
278         @echo Creating $@ ...
279 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
280         @cat $< |sed -e 's,^\(.\),Test/\1,' |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
281 else
282         @cat $< |sed -e 's,^\(.\),Test/\1,' >$@
283 endif
284
285 # warning: embedded tab in the 'echo touch' line
286 $(test_makefrag): $(test_response)
287         @echo Creating $@ ...
288         @echo "HAVE_TEST_MAKEFRAG = yes" >$@.new
289         @echo "$(test_stampfile): \\" >>$@.new
290         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
291         @cat $@.new |sed -e '$$s, \\$$,,' >$@
292         @echo " touch \$$@" >>$@
293         @rm -rf $@.new
294
295 -include $(test_makefrag)
296
297 ifndef HAVE_TEST_MAKEFRAG
298 $(test_stampfile):
299         touch $@
300 endif
301
302 # corlib_plattest
303
304 $(plattestlib): $(plattest_makefrag) $(plattest_response) $(plattest_stampfile)
305         $(INTERNAL_MCS) $(plattest_flags) /target:library /out:$@ @$(plattest_response)
306         #$(CSCOMPILE) $(plattest_flags) /target:library /out:$@ @$(plattest_response)
307
308 $(plattest_response): $(test_sourcefile) $(plattest_excludes)
309         @echo Creating $@ ...
310 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
311 ifdef PLATFORM_MONO_NATIVE
312         @cat $(plattest_excludes) $(test_sourcefile) |sort |uniq -u |sed -e 's,^\(.\),Test/\1,' |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
313 else
314         @cat $(test_sourcefile) |sort |uniq -u |sed -e 's,^\(.\),Test/\1,' |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
315 endif
316 else
317 ifdef PLATFORM_MONO_NATIVE
318         @cat $(plattest_excludes) $(test_sourcefile) |sort |uniq -u |sed -e 's,^\(.\),Test/\1,' >$@
319 else
320         @cat $(test_sourcefile) |sort |uniq -u |sed -e 's,^\(.\),Test/\1,' >$@
321 endif
322 endif
323
324 # warning: embedded tab in the 'echo touch' line
325 $(plattest_makefrag): $(plattest_response)
326         @echo Creating $@ ...
327         @echo "HAVE_PLATTEST_MAKEFRAG = yes" >$@.new
328         @echo "$(plattest_stampfile): \\" >>$@.new
329         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
330         @cat $@.new |sed -e '$$s, \\$$,,' >$@
331         @echo " touch \$$@" >>$@
332         @rm -rf $@.new
333
334 -include $(plattest_makefrag)
335
336 ifndef HAVE_PLATTEST_MAKEFRAG
337 $(plattest_stampfile):
338         touch $@
339 endif
340
341 #net_2_0_bootstrap
342
343 $(net_2_0_bootstrap_response): $(sourcefile)
344         @echo Creating $@ ...
345 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
346         @cat $< |$(PLATFORM_TWEAK_CORLIB_SOURCES) |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
347 else
348         @cat $< |$(PLATFORM_TWEAK_CORLIB_SOURCES) >$@
349 endif
350
351 # warning: embedded tab in the 'echo touch' line
352 $(net_2_0_boostrap_makefrag): $(net_2_0_boostrap_response)
353         @echo Creating $@ ...
354         @echo "HAVE_NET_2_0_BOOTSTRAP_MAKEFRAG = yes" >$@.new
355         @echo "$(net_2_0_bootstrap_stampfile): \\" >>$@.new
356         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
357         @cat $@.new |sed -e '$$s, \\$$,,' >$@
358         @echo " touch \$$@" >>$@
359         @rm -rf $@.new
360
361 -include $(net_2_0_bootstrap_makefrag)
362
363 ifndef HAVE_NET_2_0_BOOTSTRAP_MAKEFRAG
364 $(net_2_0_bootstrap_stampfile):
365         touch $@
366 endif
367
368 #net_2_0
369
370 $(net_2_0_response): $(sourcefile)
371         @echo Creating $@ ...
372 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
373         @cat $< |$(PLATFORM_TWEAK_CORLIB_SOURCES) |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
374 else
375         @cat $< |$(PLATFORM_TWEAK_CORLIB_SOURCES) >$@
376 endif
377
378 # warning: embedded tab in the 'echo touch' line
379 $(net_2_0_makefrag): $(net_2_0_response)
380         @echo Creating $@ ...
381         @echo "HAVE_NET_2_0_MAKEFRAG = yes" >$@.new
382         @echo "$(net_2_0_stampfile): \\" >>$@.new
383         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
384         @cat $@.new |sed -e '$$s, \\$$,,' >$@
385         @echo " touch \$$@" >>$@
386         @rm -rf $@.new
387
388 -include $(net_2_0_makefrag)
389
390 ifndef HAVE_NET_2_0_MAKEFRAG
391 $(net_2_0_stampfile):
392         touch $@
393 endif
394