New build system from Peter Williams (peter@newton.cx)
[mono.git] / mcs / class / corlib / Makefile
1 thisdir = class/corlib
2 SUBDIRS =
3 include ../../build/rules.make
4
5 real_corlib := $(corlib)
6
7 # corlib is crazy to build so we skip build/library.make and do stuff
8 # ourselves.
9 #
10 # Here, we define a bunch of variables.
11
12 corlib = $(topdir)/class/lib/corlib.dll
13 testlib = corlib_test.dll
14 cmplib = $(topdir)/class/lib/corlib_cmp.dll
15
16 sourcefile = corlib.dll.sources
17 response = $(depsdir)/corlib.dll.response
18 makefrag = $(depsdir)/corlib.dll.makefrag
19 stampfile = $(depsdir)/corlib.dll.stamp
20 corlib_flags = /unsafe /nostdlib
21
22 test_sourcefile = corlib_test.dll.sources
23 test_response = $(depsdir)/$(testlib).response
24 test_makefrag = $(depsdir)/$(testlib).makefrag
25 test_stampfile = $(depsdir)/$(testlib).stamp
26 test_flags = /nowarn:0618 /nowarn:0672 /r:$(corlib) /r:$(topdir)/class/lib/NUnit.Framework.dll
27
28 cmp_response = $(depsdir)/corlib_cmp.dll.response
29 cmp_makefrag = $(depsdir)/corlib_cmp.dll.makefrag
30 cmp_stampfile = $(depsdir)/corlib_cmp.dll.stamp
31 cmp_flags = /r:$(real_corlib) $(corlib_flags)
32
33 # Here, we make all.
34
35 ifdef PLATFORM_MAKE_CORLIB_CMP
36 build_cmplib = $(cmplib)
37 else
38 build_cmplib = 
39 endif
40
41 all-local: $(corlib) $(build_cmplib)
42
43 # should we install cmplib? sure!
44
45 install-local: $(corlib) $(build_cmplib)
46         $(MKINSTALLDIRS) $(DESTDIR)$(prefix)/lib
47         $(INSTALL_LIB) $(corlib) $(DESTDIR)$(prefix)/lib
48 ifdef PLATFORM_MAKE_CORLIB_CMP
49         $(INSTALL_LIB) $(cmplib) $(DESTDIR)$(prefix)/lib
50 endif
51
52 clean-local:
53         -rm -f $(corlib) $(cmplib) $(testlib) TestResult.xml \
54                $(response) $(makefrag) $(stampfile) \
55                $(test_response) $(test_makefrag) $(test_stampfile) \
56                $(cmp_response) $(cmp_makefrag) $(cmp_stampfile)
57
58
59 test-local: $(corlib) $(testlib)
60
61 run-test-local:
62         $(TEST_RUNTIME) $(TEST_HARNESS) $(testlib)
63
64 # OK, that was the easy part. Now we get to the fun bits.
65 #
66 # first, make dist.
67
68 DISTFILES = $(sourcefile) $(test_sourcefile) \
69         corlib.dll.win32-excludes corlib_cmp.dll.excludes Test/ms_run_test.sh
70
71 # see $(topdir)/build/library.make for explanation of what's going on
72 # here.
73
74 dist-local: dist-default $(test_response)
75         cat $(sourcefile) $(test_response) |xargs -n 20 \
76             $(SHELL) -c 'for f in $$* ; do \
77                 dest=`dirname $(distdir)/$$f` ; \
78                 $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
79             done' dollar0
80
81 # plain ol corlib
82
83 $(corlib): $(makefrag) $(response) $(stampfile)
84         $(CSCOMPILE) $(LIBRARY_FLAGS) $(corlib_flags) /target:library /out:$@ @$(response)
85
86 $(response): $(sourcefile)
87         @echo Creating $@ ...
88 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
89         @cat $< |$(PLATFORM_TWEAK_CORLIB_SOURCES) |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
90 else
91         @cat $< |$(PLATFORM_TWEAK_CORLIB_SOURCES) >$@
92 endif
93
94 $(makefrag): $(response)
95         @echo Creating $@ ...
96         @echo "HAVE_MAKEFRAG = yes" >$@.new
97         @echo "$(stampfile): \\" >>$@.new
98         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
99         @cat $@.new |sed -e '$$s, \\$$,,' >$@
100         @echo -e "\ttouch \$$@" >>$@
101         @rm -rf $@.new
102
103 -include $(makefrag)
104
105 ifndef HAVE_MAKEFRAG
106 $(stampfile):
107         touch $@
108 endif
109
110 # corlib_cmp
111
112 $(cmplib): $(cmp_makefrag) $(cmp_response) $(cmp_stampfile)
113         $(CSCOMPILE) $(LIBRARY_FLAGS) $(cmp_flags) /target:library /out:$@ @$(cmp_response)
114
115 $(cmp_response): $(response) corlib_cmp.dll.excludes
116         @echo Creating $@ ...
117 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
118         @cat corlib_cmp.dll.excludes |$(PLATFORM_CHANGE_SEPARATOR_CMD) |cat - $< |sort |uniq -u >$@
119 else
120         @cat corlib_cmp.dll.excludes |cat - $< |sort |uniq -u >$@
121 endif
122
123 $(cmp_makefrag): $(cmp_response)
124         @echo Creating $@ ...
125         @echo "HAVE_CMP_MAKEFRAG = yes" >$@.new
126         @echo "$(cmp_stampfile): \\" >>$@.new
127         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
128         @cat $@.new |sed -e '$$s, \\$$,,' >$@
129         @echo -e "\ttouch \$$@" >>$@
130         @rm -rf $@.new
131
132 -include $(cmp_makefrag)
133
134 ifndef HAVE_CMP_MAKEFRAG
135 $(cmp_stampfile):
136         touch $@
137 endif
138
139 # corlib_test
140
141 $(testlib): $(test_makefrag) $(test_response) $(test_stampfile)
142         $(CSCOMPILE) $(test_flags) /target:library /out:$@ @$(test_response)
143
144 $(test_response): $(test_sourcefile)
145         @echo Creating $@ ...
146 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
147         @cat $< |sed -e 's,^\(.\),Test/\1,' |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
148 else
149         @cat $< |sed -e 's,^\(.\),Test/\1,' >$@
150 endif
151
152 $(test_makefrag): $(test_response)
153         @echo Creating $@ ...
154         @echo "HAVE_TEST_MAKEFRAG = yes" >$@.new
155         @echo "$(test_stampfile): \\" >>$@.new
156         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
157         @cat $@.new |sed -e '$$s, \\$$,,' >$@
158         @echo -e "\ttouch \$$@" >>$@
159         @rm -rf $@.new
160
161 -include $(test_makefrag)
162
163 ifndef HAVE_TEST_MAKEFRAG
164 $(test_stampfile):
165         touch $@
166 endif