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