Consts.cs.in: Removed RuntimeVersion as it should be the same as FxFileVersion. Use...
[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
13 # If the directory contains the per profile include file, generate list file.
14 PROFILE_sources = $(PROFILE)_$(LIBRARY).sources
15 ifeq ($(wildcard $(PROFILE_sources)), $(PROFILE_sources))
16 PROFILE_excludes = $(wildcard $(PROFILE)_$(LIBRARY).exclude.sources)
17 COMMON_sourcefile := $(sourcefile)
18 sourcefile = $(depsdir)/$(PROFILE)_$(LIBRARY).sources
19 $(sourcefile): $(PROFILE_sources) $(PROFILE_excludes) $(COMMON_sourcefile)
20         @echo Creating the per profile list $@ ...
21         $(topdir)/tools/gensources.sh $(PROFILE_sources) $(PROFILE_excludes) > $@
22 endif
23
24 PLATFORM_excludes := $(wildcard $(LIBRARY).$(PLATFORM)-excludes)
25
26 ifndef PLATFORM_excludes
27 ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
28 response = $(sourcefile)
29 endif
30 endif
31
32 ifndef response
33 response = $(depsdir)/$(PROFILE)_$(LIBRARY).response
34 library_CLEAN_FILES += $(response) $(LIBRARY).mdb $(BUILT_SOURCES)
35 endif
36
37 ifndef LIBRARY_NAME
38 LIBRARY_NAME = $(LIBRARY)
39 endif
40
41 ifdef LIBRARY_COMPAT
42 lib_dir = compat
43 else
44 lib_dir = lib
45 endif
46
47 makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
48 the_lib = $(topdir)/class/$(lib_dir)/$(PROFILE)/$(LIBRARY_NAME)
49 the_pdb = $(the_lib:.dll=.pdb)
50 the_mdb = $(the_lib).mdb
51 library_CLEAN_FILES += $(makefrag) $(the_lib) $(the_pdb) $(the_mdb)
52
53 ifdef LIBRARY_NEEDS_POSTPROCESSING
54 build_lib = fixup/$(PROFILE)/$(LIBRARY_NAME)
55 library_CLEAN_FILES += $(build_lib) $(build_lib:.dll=.pdb)
56 else
57 build_lib = $(the_lib)
58 endif
59
60 ifndef NO_TEST
61 test_nunit_lib = nunit.framework.dll nunit.core.dll nunit.util.dll
62 test_nunit_dep = $(test_nunit_lib:%=$(topdir)/class/lib/$(PROFILE)/%)
63 test_nunit_ref = $(test_nunit_dep:%=-r:%)
64 library_CLEAN_FILES += TestResult*.xml
65
66 test_lib = $(LIBRARY:.dll=_test_$(PROFILE).dll)
67 test_sourcefile = $(LIBRARY:.dll=_test.dll.sources)
68 test_pdb = $(test_lib:.dll=.pdb)
69 test_response = $(depsdir)/$(test_lib).response
70 test_makefrag = $(depsdir)/$(test_lib).makefrag
71 test_flags = -r:$(the_lib) $(test_nunit_ref) $(TEST_MCS_FLAGS)
72 library_CLEAN_FILES += $(LIBRARY:.dll=_test*.dll) $(LIBRARY:.dll=_test*.pdb) $(test_response) $(test_makefrag)
73
74 btest_lib = $(LIBRARY:.dll=_btest_$(PROFILE).dll)
75 btest_sourcefile = $(LIBRARY:.dll=_btest.dll.sources)
76 btest_pdb = $(btest_lib:.dll=.pdb)
77 btest_response = $(depsdir)/$(btest_lib).response
78 btest_makefrag = $(depsdir)/$(btest_lib).makefrag
79 btest_flags = -r:$(the_lib) $(test_nunit_ref) $(TEST_MBAS_FLAGS)
80 library_CLEAN_FILES += $(LIBRARY:.dll=_btest*.dll) $(LIBRARY:.dll=_btest*.pdb) $(btest_response) $(btest_makefrag)
81
82 ifndef HAVE_CS_TESTS
83 HAVE_CS_TESTS := $(wildcard $(test_sourcefile))
84 endif
85 ifndef HAVE_VB_TESTS
86 HAVE_VB_TESTS := $(wildcard $(btest_sourcefile))
87 endif
88
89 endif
90
91 ifdef NO_INSTALL
92 GACUTIL = :
93 else
94 gacutil = $(topdir)/class/lib/net_1_1_bootstrap/gacutil.exe
95 GACUTIL = MONO_PATH="$(topdir)/class/lib/net_1_1_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(gacutil)
96 endif
97
98 ifdef NO_SIGN_ASSEMBLY
99 SN = :
100 else
101 sn = $(topdir)/class/lib/net_1_1_bootstrap/sn.exe
102 SN = MONO_PATH="$(topdir)/class/lib/net_1_1_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(sn)
103 SNFLAGS = -q -R
104 endif
105
106 ifeq ($(PLATFORM), win32)
107 GACDIR = `cygpath -w $(mono_libdir)`
108 GACROOT = `cygpath -w $(DESTDIR)$(mono_libdir)`
109 test_flags += -d:WINDOWS
110 else
111 GACDIR = $(mono_libdir)
112 GACROOT = $(DESTDIR)$(mono_libdir)
113 endif
114
115 all-local: $(the_lib)
116
117 install-local: all-local
118 test-local: all-local
119 uninstall-local:
120
121 ifdef NO_INSTALL
122 install-local uninstall-local:
123         @:
124
125 else
126
127 ifdef LIBRARY_INSTALL_DIR
128 install-local:
129         $(MKINSTALLDIRS) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
130         $(INSTALL_LIB) $(the_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
131         test ! -f $(the_lib).mdb || $(INSTALL_LIB) $(the_lib).mdb $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
132
133 uninstall-local:
134         -rm -f $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
135
136 else
137
138 # If RUNTIME_HAS_CONSISTENT_GACDIR is set, it implies that the internal GACDIR
139 # of the runtime is the same as the GACDIR we want.  So, we don't need to pass it
140 # to gacutil.  Note that the GACDIR we want may not be the same as the value of
141 # GACDIR set above, since the user could have overridden the value of $(prefix).
142 #
143 # This makes a difference only when we're building from the mono/ tree, since we
144 # have to ensure that the internal GACDIR of the in-tree runtime matches where we
145 # install the DLLs.
146
147 ifndef RUNTIME_HAS_CONSISTENT_GACDIR
148 gacdir_flag = /gacdir $(GACDIR)
149 endif
150
151 ifndef LIBRARY_PACKAGE
152 ifdef LIBRARY_COMPAT
153 LIBRARY_PACKAGE = compat-$(FRAMEWORK_VERSION)
154 else
155 LIBRARY_PACKAGE = $(FRAMEWORK_VERSION)
156 endif
157 endif
158
159 install-local: $(gacutil)
160         $(GACUTIL) /i $(the_lib) /f $(gacdir_flag) /root $(GACROOT) /package $(LIBRARY_PACKAGE)
161
162 uninstall-local: $(gacutil)
163         -$(GACUTIL) /u $(LIBRARY_NAME:.dll=) $(gacdir_flag) /root $(GACROOT) /package $(LIBRARY_PACKAGE)
164
165 endif
166 endif
167
168 clean-local:
169         -rm -f $(library_CLEAN_FILES) $(CLEAN_FILES)
170
171 test-local run-test-local run-test-ondotnet-local:
172         @:
173
174 ifndef NO_TEST
175 $(test_nunit_dep): $(topdir)/build/deps/nunit-$(PROFILE).stamp
176         @if test -f $@; then :; else rm -f $<; $(MAKE) $<; fi
177 $(topdir)/build/deps/nunit-$(PROFILE).stamp:
178         cd ${topdir}/nunit20 && $(MAKE)
179         echo "stamp" >$@
180 library_CLEAN_FILES += $(topdir)/build/deps/nunit-$(PROFILE).stamp
181 endif
182
183 test_assemblies :=
184
185 ifdef HAVE_CS_TESTS
186 test_assemblies += $(test_lib)
187 endif
188
189 ifdef HAVE_VB_TESTS
190 test_assemblies += $(btest_lib)
191 endif
192
193 ifdef test_assemblies
194 test-local: $(test_assemblies)
195 run-test-local: run-test-lib
196 run-test-ondotnet-local: run-test-ondotnet-lib
197
198 ## FIXME: i18n problem in the 'sed' command below
199 run-test-lib: test-local
200         ok=:; \
201         $(TEST_RUNTIME) $(TEST_HARNESS) $(TEST_HARNESS_FLAGS) $(LOCAL_TEST_HARNESS_FLAGS) /output:TestResult-$(PROFILE).log /exclude:NotWorking,ValueAdd,CAS,InetAccess /xml:TestResult-$(PROFILE).xml $(test_assemblies) || ok=false; \
202         (echo ''; cat TestResult-$(PROFILE).log) | sed '1,/^Tests run: /d'; \
203         $$ok
204
205 run-test-ondotnet-lib: test-local
206         ok=:; \
207         $(TEST_HARNESS) $(TEST_HARNESS_FLAGS) $(LOCAL_TEST_HARNESS_ONDOTNET_FLAGS) /exclude=NotDotNet,CAS /output:TestResult-ondotnet-$(PROFILE).log /xml:TestResult-ondotnet-$(PROFILE).xml $(test_assemblies) || ok=false; \
208         (echo ''; cat TestResult-ondotnet-$(PROFILE).log) | sed '1,/^Tests run: /d'; \
209         $$ok
210 endif
211
212 DISTFILES = $(sourcefile) $(EXTRA_DISTFILES)
213
214 TEST_FILES =
215
216 ifdef HAVE_CS_TESTS
217 TEST_FILES += `sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile)`
218 DISTFILES += $(test_sourcefile)
219 endif
220 ifdef HAVE_VB_TESTS
221 TEST_FILES += `sed -e '/^$$/d' -e 's,^,Test/,' $(btest_sourcefile)`
222 DISTFILES += $(btest_sourcefile)
223 endif
224
225 dist-local: dist-default
226         subs=' ' ; \
227         for f in `cat $(sourcefile)` $(TEST_FILES) ; do \
228           case $$f in \
229           ../*) : ;; \
230           *) dest=`dirname $$f` ; \
231              case $$subs in *" $$dest "*) : ;; *) subs=" $$dest$$subs" ; $(MKINSTALLDIRS) $(distdir)/$$dest ;; esac ; \
232              cp -p $$f $(distdir)/$$dest || exit 1 ;; \
233           esac ; done ; \
234         for d in . $$subs ; do \
235           case $$d in .) : ;; *) test ! -f $$d/ChangeLog || cp -p $$d/ChangeLog $(distdir)/$$d ;; esac ; done
236
237 ifdef LIBRARY_NEEDS_POSTPROCESSING
238 dist-local: dist-fixup
239 FIXUP_PROFILES = default net_2_0
240 dist-fixup:
241         $(MKINSTALLDIRS) $(distdir)/fixup $(FIXUP_PROFILES:%=$(distdir)/fixup/%)
242 endif
243
244 ifndef LIBRARY_COMPILE
245 LIBRARY_COMPILE = $(CSCOMPILE)
246 endif
247
248 ifndef TEST_COMPILE
249 TEST_COMPILE = $(CSCOMPILE)
250 endif
251
252 ifndef BTEST_COMPILE
253 BTEST_COMPILE = $(BASCOMPILE)
254 endif
255
256 ifndef LIBRARY_SNK
257 LIBRARY_SNK = $(topdir)/class/mono.snk
258 endif
259
260 ifdef gacutil
261 $(gacutil):
262         cd $(topdir) && $(MAKE) PROFILE=net_1_1_bootstrap
263 endif
264
265 ifdef sn
266 $(sn):
267         cd $(topdir) && $(MAKE) PROFILE=net_1_1_bootstrap
268 endif
269
270 ifdef BUILT_SOURCES
271 ifeq (cat, $(PLATFORM_CHANGE_SEPARATOR_CMD))
272 BUILT_SOURCES_cmdline = $(BUILT_SOURCES)
273 else
274 BUILT_SOURCES_cmdline = `echo $(BUILT_SOURCES) | $(PLATFORM_CHANGE_SEPARATOR_CMD)`
275 endif
276 endif
277
278 # The library
279
280 $(build_lib): $(response) $(sn) $(BUILT_SOURCES)
281 ifdef LIBRARY_USE_INTERMEDIATE_FILE
282         $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) -target:library -out:$(LIBRARY_NAME) $(BUILT_SOURCES_cmdline) @$(response)
283         $(SN) $(SNFLAGS) $(LIBRARY_NAME) $(LIBRARY_SNK)
284         mv $(LIBRARY_NAME) $@
285         test ! -f $(LIBRARY_NAME).mdb || mv $(LIBRARY_NAME).mdb $@.mdb
286         test ! -f $(LIBRARY_NAME:.dll=.pdb) || mv $(LIBRARY_NAME:.dll=.pdb) $(dir $@)$(LIBRARY_NAME:.dll=.pdb)
287 else
288         $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) -target:library -out:$@ $(BUILT_SOURCES_cmdline) @$(response)
289         $(SN) $(SNFLAGS) $@ $(LIBRARY_SNK)
290 endif
291
292 $(makefrag): $(sourcefile)
293         @echo Creating $@ ...
294         @sed 's,^,$(build_lib): ,' $< >$@
295
296 ifneq ($(response),$(sourcefile))
297 $(response): $(sourcefile) $(PLATFORM_excludes)
298         @echo Creating $@ ...
299         @sort $(sourcefile) $(PLATFORM_excludes) | uniq -u | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
300 endif
301
302 -include $(makefrag)
303
304 # for now, don't give any /lib flags or set MONO_PATH, since we
305 # give a full path to the assembly.
306
307 ifdef HAVE_CS_TESTS
308
309 $(test_lib): $(the_lib) $(test_response) $(test_nunit_dep)
310         $(TEST_COMPILE) -target:library -out:$@ $(test_flags) @$(test_response)
311
312 $(test_response): $(test_sourcefile)
313         @echo Creating $@ ...
314         @sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
315
316 $(test_makefrag): $(test_response)
317         @echo Creating $@ ...
318         @sed 's,^,$(test_lib): ,' $< >$@
319
320 -include $(test_makefrag)
321
322 endif
323
324 ifdef HAVE_VB_TESTS
325
326 $(btest_lib): $(the_lib) $(btest_response) $(test_nunit_dep)
327         $(BTEST_COMPILE) -target:library -out:$@ $(btest_flags) @$(btest_response)
328
329 $(btest_response): $(btest_sourcefile)
330         @echo Creating $@ ...
331         @sed -e '/^$$/d' -e 's,^,Test/,' $(btest_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
332
333 $(btest_makefrag): $(btest_response)
334         @echo Creating $@ ...
335         @sed 's,^,$(btest_lib): ,' $< >$@
336
337 -include $(btest_makefrag)
338
339 endif
340
341 all-local: $(makefrag) $(test_makefrag) $(btest_makefrag)
342 $(makefrag) $(test_makefrag) $(btest_makefrag): $(topdir)/build/library.make