d2df47166370561434776f2389d543646675729e
[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 core_sourcefile = $(LIBRARY).sources
12 PLATFORM_excludes := $(wildcard $(LIBRARY).$(PLATFORM)-excludes)
13
14 ifdef PLATFORM_excludes
15 sourcefile = $(depsdir)/$(LIBRARY).$(PLATFORM)-sources
16 $(sourcefile): $(core_sourcefile) $(PLATFORM_excludes)
17         cat $(core_sourcefile) $(PLATFORM_excludes) | sort | uniq -u >$@
18 else
19 sourcefile = $(core_sourcefile)
20 endif
21
22 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
23 response = $(depsdir)/$(PROFILE)_$(LIBRARY).response
24 else
25 response = $(sourcefile)
26 endif
27
28 ifndef LIBRARY_NAME
29 LIBRARY_NAME = $(LIBRARY)
30 endif
31
32 makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
33 the_lib = $(topdir)/class/lib/$(PROFILE)/$(LIBRARY_NAME)
34 the_pdb = $(patsubst %.dll,%.pdb,$(the_lib))
35
36 ifndef NO_TEST
37 test_nunitfw = $(topdir)/class/lib/$(PROFILE)/nunit.framework.dll 
38 test_nunitcore = $(topdir)/class/lib/$(PROFILE)/nunit.core.dll 
39 test_nunitutil = $(topdir)/class/lib/$(PROFILE)/nunit.util.dll 
40 test_nunit_dep = $(test_nunitfw) $(test_nunitcore) $(test_nunitutil)
41 test_nunit_ref = -r:$(test_nunitfw) -r:$(test_nunitcore) -r:$(test_nunitutil)
42
43 ifndef test_against
44 test_against = $(the_lib)
45 test_dep = $(the_lib)
46 endif
47
48 ifndef test_lib
49 test_lib = $(patsubst %.dll,%_test.dll,$(LIBRARY))
50 endif
51 test_pdb = $(patsubst %.dll,%.pdb,$(test_lib))
52 test_sourcefile = $(test_lib).sources
53 test_response = $(depsdir)/$(PROFILE)_$(test_lib).response
54 test_makefrag = $(depsdir)/$(PROFILE)_$(test_lib).makefrag
55 test_flags = /r:$(test_against) $(test_nunit_ref) $(TEST_MCS_FLAGS)
56
57 ifndef btest_lib
58 btest_lib = $(patsubst %.dll,%_btest.dll,$(LIBRARY))
59 endif
60 btest_pdb = $(patsubst %.dll,%.pdb,$(btest_lib))
61 btest_sourcefile = $(btest_lib).sources
62 btest_response = $(depsdir)/$(btest_lib).response
63 btest_makefrag = $(depsdir)/$(btest_lib).makefrag
64 btest_flags = /r:$(test_against) $(test_nunit_ref) $(TEST_MBAS_FLAGS)
65
66 ifndef HAVE_CS_TESTS
67 HAVE_CS_TESTS := $(wildcard $(btest_sourcefile))
68 endif
69 ifndef HAVE_VB_TESTS
70 HAVE_VB_TESTS := $(wildcard $(btest_sourcefile))
71 endif
72
73 endif
74
75 gacutil = $(topdir)/tools/gacutil/gacutil.exe
76 sn = $(topdir)/tools/security/sn.exe
77
78 PACKAGE = 1.0
79
80 ifeq ($(PROFILE), net_2_0)
81 PACKAGE = 2.0
82 endif
83
84 all-local: $(the_lib)
85
86 install-local: $(the_lib) maybe-sign-lib
87
88 ifdef LIBRARY_INSTALL_DIR
89 install-local:
90         $(MKINSTALLDIRS) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
91         $(INSTALL_LIB) $(the_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
92
93 uninstall-local:
94         -rm -f $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
95
96 else
97
98 install-local: $(gacutil)
99         $(RUNTIME) $(gacutil) /i $(the_lib) /f /root $(DESTDIR)$(prefix)/lib /package $(PACKAGE)
100
101 uninstall-local: $(gacutil)
102         $(RUNTIME) $(gacutil) /u `echo $(LIBRARY_NAME) | sed 's,.dll$,,'`
103
104 $(gacutil):
105         cd $(topdir)/tools/gacutil && $(MAKE)
106
107 endif
108
109 maybe-sign-lib:
110 ifndef NO_SIGN_ASSEMBLY
111 maybe-sign-lib: $(sn)
112         $(RUNTIME) $(sn) -q -R $(the_lib) $(topdir)/class/mono.snk
113 endif
114
115 $(sn):
116         cd $(topdir)/tools/security && $(MAKE) sn.exe
117
118 clean-local:
119         -rm -f $(the_lib) $(makefrag) $(test_lib) \
120                $(test_makefrag) $(test_response) \
121                $(the_pdb) $(test_pdb) $(CLEAN_FILES) \
122                TestResult.xml
123 ifdef PLATFORM_excludes
124         -rm -rf $(sourcefile)
125 endif
126 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
127         -rm -rf $(response)
128 endif
129
130
131 test-local: $(the_lib)
132         @:
133 run-test-local:
134         @:
135 run-test-ondotnet-local:
136         @:
137
138 ifndef NO_TEST
139 $(test_nunit_dep): $(topdir)/build/deps/nunit.stamp
140         @if test -f $@; then :; else rm -f $<; $(MAKE) $<; fi
141 $(topdir)/build/deps/nunit.stamp:
142         cd ${topdir}/nunit20 && $(MAKE)
143         echo "stamp" >$@
144 endif
145
146 ifdef HAVE_CS_TESTS
147
148 test-local: $(test_lib)
149
150 run-test-local: run-test-lib
151
152 run-test-lib: test-local
153         $(TEST_RUNTIME) $(TEST_HARNESS) $(test_lib)
154
155 run-test-ondotnet-local: run-test-ondotnet-lib
156
157 run-test-ondotnet-lib: test-local
158         $(TEST_HARNESS) $(test_lib)
159 endif
160
161 ifdef HAVE_VB_TESTS
162
163 test-local: $(btest_lib)
164
165 run-test-local: run-btest-lib
166
167 run-btest-lib: test-local
168         $(TEST_RUNTIME) $(TEST_HARNESS) $(btest_lib)
169
170 run-test-ondotnet-local: run-btest-ondotnet-lib
171
172 run-btest-ondotnet-lib: test-local
173         $(TEST_HARNESS) $(btest_lib)
174
175 endif
176
177 DISTFILES = $(core_sourcefile) $(test_sourcefile) $(EXTRA_DISTFILES)
178
179 TEST_FILES = 
180
181 ifdef HAVE_CS_TESTS
182 TEST_FILES += `sed 's,^,Test/,' $(test_sourcefile)`
183 endif
184 ifdef HAVE_VB_TESTS
185 TEST_FILES += `sed 's,^,Test/,' $(btest_sourcefile)`
186 endif
187
188 dist-local: dist-default
189         for f in `cat $(core_sourcefile)` $(TEST_FILES) ; do \
190             dest=`dirname $(distdir)/$$f` ; \
191             $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
192         done
193
194 ifndef LIBRARY_COMPILE
195 LIBRARY_COMPILE = $(CSCOMPILE)
196 endif
197
198 # Fun with dependency tracking
199
200 $(the_lib): $(makefrag) $(response)
201         $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$@ @$(response)
202
203 $(makefrag): $(sourcefile)
204         @echo Creating $@ ...
205         @sed 's,^,$(the_lib): ,' $< >$@
206
207 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
208 $(response): $(sourcefile)
209         @echo Creating $@ ...
210         @cat $(sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
211 endif
212
213 -include $(makefrag)
214
215 # for now, don't give any /lib flags or set MONO_PATH, since we
216 # give a full path to the assembly.
217
218 ifdef HAVE_CS_TESTS
219
220 $(test_lib): $(test_makefrag) $(test_dep) $(test_response) $(test_nunit_dep)
221         $(CSCOMPILE) /target:library /out:$@ $(test_flags) @$(test_response)
222
223 $(test_response): $(test_sourcefile)
224         @echo Creating $@ ...
225 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
226         @sed 's,^,Test/,' $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
227 else
228         @sed 's,^,Test/,' $< >$@
229 endif
230
231 $(test_makefrag): $(test_response)
232         @echo Creating $@ ...
233         @sed 's,^,$(test_lib): ,' $< >$@
234
235 -include $(test_makefrag)
236
237 endif
238
239 ifdef HAVE_VB_TESTS
240
241 $(btest_lib): $(btest_makefrag) $(test_dep) $(btest_response) $(test_nunit_dep)
242         $(BASCOMPILE) /target:library /out:$@ $(btest_flags) @$(btest_response)
243
244 $(btest_response): $(btest_sourcefile)
245         @echo Creating $@ ...
246 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
247         @sed 's,^,Test/,' $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
248 else
249         @sed 's,^,Test/,' $< >$@
250 endif
251
252 $(btest_makefrag): $(btest_response)
253         @echo Creating $@ ...
254         @sed 's,^,$(btest_lib): ,' $< >$@
255
256 -include $(btest_makefrag)
257
258 endif