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