2004-02-13 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / corlib / Makefile
1 thisdir = class/corlib
2 SUBDIRS =
3 include ../../build/rules.make
4
5 # corlib is crazy to build so we skip build/library.make and do stuff
6 # ourselves.
7 #
8 # Here, we define a bunch of variables.
9
10 ifdef PLATFORM_MONO_NATIVE
11 test_against = $(corlib)
12 else
13 test_against = $(reslib)
14 endif
15
16 LOCAL_MCS_FLAGS = /nowarn:649 /nowarn:169 -d:INSIDE_CORLIB
17
18 corlib = $(topdir)/class/lib/mscorlib.dll
19 testlib = corlib_test.dll
20 cmplib = $(topdir)/class/lib/corlib_cmp.dll
21 reslib = $(topdir)/class/lib/corlib_res.dll
22 plattestlib = corlib_plattest.dll
23
24 corpdb = $(patsubst %.dll,%.pdb,$(corlib))
25 testpdb = $(patsubst %.dll,%.pdb,$(testlib))
26 cmppdb = $(patsubst %.dll,%.pdb,$(cmplib))
27 respdb = $(patsubst %.dll,%.pdb,$(reslib))
28 plattestpdb = $(patsubst %.dll,%.pdb,$(plattestlib))
29
30 sourcefile = corlib.dll.sources
31 response = $(depsdir)/corlib.dll.response
32 makefrag = $(depsdir)/corlib.dll.makefrag
33 stampfile = $(depsdir)/corlib.dll.stamp
34 # disable, until people fix their code...
35 #corlib_flags = /unsafe /nostdlib /d:INSIDE_CORLIB
36 corlib_flags = /unsafe /nostdlib
37
38 test_sourcefile = corlib_test.dll.sources
39 test_response = $(depsdir)/$(testlib).response
40 test_makefrag = $(depsdir)/$(testlib).makefrag
41 test_stampfile = $(depsdir)/$(testlib).stamp
42 test_flags = /nowarn:0618 /nowarn:0672 /r:$(test_against) /r:$(topdir)/class/lib/NUnit.Framework.dll
43
44 cmp_response = $(depsdir)/corlib_cmp.dll.response
45 cmp_makefrag = $(depsdir)/corlib_cmp.dll.makefrag
46 cmp_stampfile = $(depsdir)/corlib_cmp.dll.stamp
47 cmp_flags = /r:$(PLATFORM_CORLIB) $(corlib_flags)
48
49 res_response = $(depsdir)/corlib_res.dll.response
50 res_makefrag = $(depsdir)/corlib_res.dll.makefrag
51 res_stampfile = $(depsdir)/corlib_res.dll.stamp
52 res_flags = /r:$(PLATFORM_CORLIB) $(corlib_flags)
53
54 plattest_excludes = corlib_plattest.dll.excludes
55 plattest_response = $(depsdir)/$(plattestlib).response
56 plattest_makefrag = $(depsdir)/$(plattestlib).makefrag
57 plattest_stampfile = $(depsdir)/$(plattestlib).stamp
58 plattest_flags = /debug+ /debug:full /nowarn:0618 /nowarn:0672 /r:$(PLATFORM_CORLIB) /r:$(topdir)/class/lib/NUnit.Framework.dll
59
60 # Here, we make all.
61
62 all-local: $(corlib)
63
64 install-local: $(corlib) $(makefrag)
65         $(MKINSTALLDIRS) $(DESTDIR)$(prefix)/lib
66         $(INSTALL_LIB) $(corlib) $(DESTDIR)$(prefix)/lib
67
68 uninstall-local:
69         -rm -f $(DESTDIR)$(prefix)/lib/corlib.dll
70
71 clean-local:
72         -rm -f $(corlib) $(cmplib) $(testlib) $(reslib) $(plattestlib) TestResult.xml \
73                $(response) $(makefrag) $(stampfile) \
74                $(test_response) $(test_makefrag) $(test_stampfile) \
75                $(cmp_response) $(cmp_makefrag) $(cmp_stampfile) \
76                $(res_response) $(res_makefrag) $(res_stampfile) \
77                $(plattest_response) $(plattest_makefrag) $(plattest_stampfile) \
78                $(corpdb) $(cmppdb) $(testpdb) $(respdb) $(plattestpdb)
79
80
81 # If building on a non mono-native platform, default
82 # to running the unit tests on its corlib, to see if
83 # our tests are complaint with their (hopefully bug-free)
84 # corlib. If on a mono-native platform, test our actual
85 # corlib.
86 #
87 # You can access either one on demand with either 'make
88 # run-monotest' or 'make run-plattest'.
89
90 ifdef PLATFORM_MONO_NATIVE
91 test-local: $(test_against) $(testlib)
92
93 run-test-local: run-monotest
94 else
95 test-local: $(plattestlib)
96
97 run-test-local: run-plattest
98 endif
99
100 run-monotest: $(test_against) $(testlib)
101         $(TEST_RUNTIME) $(TEST_HARNESS) $(testlib)
102
103 run-plattest: $(plattestlib)
104         $(TEST_RUNTIME) $(TEST_HARNESS) $(plattestlib)
105
106 # OK, that was the easy part. Now we get to the fun bits.
107 #
108 # first, make dist.
109
110 DISTFILES = $(sourcefile) $(test_sourcefile) \
111         corlib.dll.win32-excludes corlib_cmp.dll.excludes corlib_res.dll.excludes \
112         $(plattest_excludes) \
113         Test/ms_run_test.sh
114
115 # see $(topdir)/build/library.make for explanation of what's going on
116 # here.
117
118 dist-local: dist-default
119         for f in `cat $(sourcefile)` `cat $(test_sourcefile) |sed -e 's,^\(.\),Test/\1,'` ; do \
120             dest=`dirname $(distdir)/$$f` ; \
121             $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
122         done
123
124 # plain ol corlib
125
126 $(corlib): $(makefrag) $(response) $(stampfile)
127         $(BOOT_COMPILE) $(LIBRARY_FLAGS) $(corlib_flags) /target:library /out:$@ @$(response)
128
129 $(response): $(sourcefile)
130         @echo Creating $@ ...
131 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
132         @cat $< |$(PLATFORM_TWEAK_CORLIB_SOURCES) |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
133 else
134         @cat $< |$(PLATFORM_TWEAK_CORLIB_SOURCES) >$@
135 endif
136
137 # warning: embedded tab in the 'echo touch' line
138 $(makefrag): $(response)
139         @echo Creating $@ ...
140         @echo "HAVE_MAKEFRAG = yes" >$@.new
141         @echo "$(stampfile): \\" >>$@.new
142         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
143         @cat $@.new |sed -e '$$s, \\$$,,' >$@
144         @echo " touch \$$@" >>$@
145         @rm -rf $@.new
146
147 -include $(makefrag)
148
149 ifndef HAVE_MAKEFRAG
150 $(stampfile):
151         touch $@
152 endif
153
154 # corlib_cmp
155
156 $(cmplib): $(cmp_makefrag) $(cmp_response) $(cmp_stampfile)
157         $(BOOT_COMPILE) $(LIBRARY_FLAGS) $(cmp_flags) /target:library /out:$@ @$(cmp_response)
158
159 $(cmp_response): $(response) corlib_cmp.dll.excludes
160         @echo Creating $@ ...
161 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
162         @cat corlib_cmp.dll.excludes |$(PLATFORM_CHANGE_SEPARATOR_CMD) |cat - $< |sort |uniq -u >$@
163 else
164         @cat corlib_cmp.dll.excludes |cat - $< |sort |uniq -u >$@
165 endif
166
167 # warning: embedded tab in the 'echo touch' line
168 $(cmp_makefrag): $(cmp_response)
169         @echo Creating $@ ...
170         @echo "HAVE_CMP_MAKEFRAG = yes" >$@.new
171         @echo "$(cmp_stampfile): \\" >>$@.new
172         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
173         @cat $@.new |sed -e '$$s, \\$$,,' >$@
174         @echo " touch \$$@" >>$@
175         @rm -rf $@.new
176
177 # Since we make corlib_cmp on demand, there isn't a real need
178 # to have full dep tracking for it. Also, the generation of this
179 # file is busted on Win32 ('sort' seems to mess up line endings),
180 # leading to a broken build.
181 #
182 # -include $(cmp_makefrag)
183
184 ifndef HAVE_CMP_MAKEFRAG
185 $(cmp_stampfile):
186         touch $@
187 endif
188
189 # corlib_res
190
191 $(reslib): $(res_makefrag) $(res_response) $(res_stampfile)
192         $(BOOT_COMPILE) $(LIBRARY_FLAGS) $(res_flags) /target:library /out:$@ @$(res_response)
193
194 $(res_response): $(sourcefile) corlib_res.dll.excludes
195         @echo Creating $@ ...
196 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
197         @cat corlib_res.dll.excludes $(sourcefile) |sort |uniq -u |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
198 else
199         @cat corlib_res.dll.excludes $(sourcefile) |sort |uniq -u >$@
200 endif
201
202 # warning: embedded tab in the 'echo touch' line
203 $(res_makefrag): $(res_response)
204         @echo Creating $@ ...
205         @echo "HAVE_RES_MAKEFRAG = yes" >$@.new
206         @echo "$(res_stampfile): \\" >>$@.new
207         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
208         @cat $@.new |sed -e '$$s, \\$$,,' >$@
209         @echo " touch \$$@" >>$@
210         @rm -rf $@.new
211
212 -include $(res_makefrag)
213
214 ifndef HAVE_RES_MAKEFRAG
215 $(res_stampfile):
216         touch $@
217 endif
218
219 # corlib_test
220
221 $(testlib): $(test_makefrag) $(test_response) $(test_stampfile)
222         $(CSCOMPILE) $(test_flags) /target:library /out:$@ @$(test_response)
223
224 $(test_response): $(test_sourcefile)
225         @echo Creating $@ ...
226 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
227         @cat $< |sed -e 's,^\(.\),Test/\1,' |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
228 else
229         @cat $< |sed -e 's,^\(.\),Test/\1,' >$@
230 endif
231
232 # warning: embedded tab in the 'echo touch' line
233 $(test_makefrag): $(test_response)
234         @echo Creating $@ ...
235         @echo "HAVE_TEST_MAKEFRAG = yes" >$@.new
236         @echo "$(test_stampfile): \\" >>$@.new
237         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
238         @cat $@.new |sed -e '$$s, \\$$,,' >$@
239         @echo " touch \$$@" >>$@
240         @rm -rf $@.new
241
242 -include $(test_makefrag)
243
244 ifndef HAVE_TEST_MAKEFRAG
245 $(test_stampfile):
246         touch $@
247 endif
248
249 # corlib_plattest
250
251 $(plattestlib): $(plattest_makefrag) $(plattest_response) $(plattest_stampfile)
252         $(CSCOMPILE) $(plattest_flags) /target:library /out:$@ @$(plattest_response)
253
254 $(plattest_response): $(test_sourcefile) $(plattest_excludes)
255         @echo Creating $@ ...
256 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
257 ifdef PLATFORM_MONO_NATIVE
258         @cat $(plattest_excludes) $(test_sourcefile) |sort |uniq -u |sed -e 's,^\(.\),Test/\1,' |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
259 else
260         @cat $(test_sourcefile) |sort |uniq -u |sed -e 's,^\(.\),Test/\1,' |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
261 endif
262 else
263 ifdef PLATFORM_MONO_NATIVE
264         @cat $(plattest_excludes) $(test_sourcefile) |sort |uniq -u |sed -e 's,^\(.\),Test/\1,' >$@
265 else
266         @cat $(test_sourcefile) |sort |uniq -u |sed -e 's,^\(.\),Test/\1,' >$@
267 endif
268 endif
269
270 # warning: embedded tab in the 'echo touch' line
271 $(plattest_makefrag): $(plattest_response)
272         @echo Creating $@ ...
273         @echo "HAVE_PLATTEST_MAKEFRAG = yes" >$@.new
274         @echo "$(plattest_stampfile): \\" >>$@.new
275         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
276         @cat $@.new |sed -e '$$s, \\$$,,' >$@
277         @echo " touch \$$@" >>$@
278         @rm -rf $@.new
279
280 -include $(plattest_makefrag)
281
282 ifndef HAVE_PLATTEST_MAKEFRAG
283 $(plattest_stampfile):
284         touch $@
285 endif