md.view.file
[tfs.git] / build / library.make
blob81a067470a5be970af68fb594408dde1b7ae9712
1 # -*- makefile -*-
3 # The rules for building our class libraries.
5 # The NO_TEST stuff is not too pleasant but whatcha
6 # gonna do.
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.
11 sourcefile = $(LIBRARY).sources
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 sourcefile = $(depsdir)/$(PROFILE)_$(LIBRARY).sources
18 $(sourcefile): $(PROFILE_sources) $(PROFILE_excludes)
19 @echo Creating the per profile list $@ ...
20 $(topdir)/tools/gensources.sh $(PROFILE_sources) $(PROFILE_excludes) > $@
21 endif
23 PLATFORM_excludes := $(wildcard $(LIBRARY).$(PLATFORM)-excludes)
25 ifndef PLATFORM_excludes
26 ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
27 response = $(sourcefile)
28 endif
29 endif
31 ifndef response
32 response = $(depsdir)/$(PROFILE)_$(LIBRARY).response
33 library_CLEAN_FILES += $(response) $(LIBRARY).mdb $(BUILT_SOURCES)
34 endif
36 ifndef LIBRARY_NAME
37 LIBRARY_NAME = $(LIBRARY)
38 endif
40 makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
41 the_lib = $(topdir)/class/lib/$(PROFILE)/$(LIBRARY_NAME)
42 the_pdb = $(the_lib:.dll=.pdb)
43 the_mdb = $(the_lib).mdb
44 the_csproj = $(LIBRARY_NAME:.dll=.csproj)
45 library_CLEAN_FILES += $(makefrag) $(the_lib) $(the_pdb) $(the_mdb) $(sourcefile)
47 ifdef LIBRARY_NEEDS_POSTPROCESSING
48 build_lib = fixup/$(PROFILE)/$(LIBRARY_NAME)
49 library_CLEAN_FILES += $(build_lib) $(build_lib:.dll=.pdb)
50 else
51 build_lib = $(the_lib)
52 endif
54 ifndef NO_TEST
55 test_nunit_ref = -pkg:nunit
56 library_CLEAN_FILES += TestResult*.xml
58 ifndef test_against
59 test_against = $(the_lib)
60 test_dep = $(the_lib)
61 endif
63 ifndef test_lib
64 test_lib = $(LIBRARY:.dll=_test_$(PROFILE).dll)
65 test_sourcefile = $(LIBRARY:.dll=_test.dll.sources)
66 else
67 test_sourcefile = $(test_lib).sources
68 endif
69 test_pdb = $(test_lib:.dll=.pdb)
70 test_response = $(depsdir)/$(test_lib).response
71 test_makefrag = $(depsdir)/$(test_lib).makefrag
72 test_flags = -r:$(test_against) $(test_nunit_ref) $(TEST_MCS_FLAGS)
73 library_CLEAN_FILES += $(LIBRARY:.dll=_test*.dll) $(LIBRARY:.dll=_test*.pdb) $(test_response) $(test_makefrag)
75 ifndef btest_lib
76 btest_lib = $(LIBRARY:.dll=_btest_$(PROFILE).dll)
77 btest_sourcefile = $(LIBRARY:.dll=_btest.dll.sources)
78 else
79 btest_sourcefile = $(btest_lib).sources
80 endif
81 btest_pdb = $(btest_lib:.dll=.pdb)
82 btest_response = $(depsdir)/$(btest_lib).response
83 btest_makefrag = $(depsdir)/$(btest_lib).makefrag
84 btest_flags = -r:$(test_against) $(test_nunit_ref) $(TEST_MBAS_FLAGS)
85 library_CLEAN_FILES += $(LIBRARY:.dll=_btest*.dll) $(LIBRARY:.dll=_btest*.pdb) $(btest_response) $(btest_makefrag)
87 ifndef HAVE_CS_TESTS
88 HAVE_CS_TESTS := $(wildcard $(test_sourcefile))
89 endif
90 ifndef HAVE_VB_TESTS
91 HAVE_VB_TESTS := $(wildcard $(btest_sourcefile))
92 endif
94 endif
96 ifdef NO_INSTALL
97 GACUTIL = :
98 else
99 GACUTIL = gacutil
100 endif
102 ifdef NO_SIGN_ASSEMBLY
103 SN = :
104 else
105 SN = sn
106 SNFLAGS = -q -R
107 endif
109 ifeq ($(PLATFORM), win32)
110 GACDIR = `cygpath -w $(mono_libdir)`
111 GACROOT = `cygpath -w $(DESTDIR)$(mono_libdir)`
112 test_flags += -d:WINDOWS
113 else
114 GACDIR = $(mono_libdir)
115 GACROOT = $(DESTDIR)$(mono_libdir)
116 endif
118 $(sourcefile): $(the_csproj)
119 xsltproc -o $@ $(topdir)/build/sources.xsl $<
120 echo $(EXTRA_SOURCES) >> $@
122 all-local: $(the_lib)
124 install-local: all-local
125 test-local: all-local
126 uninstall-local:
128 ifdef NO_INSTALL
129 install-local uninstall-local:
132 else
134 ifdef LIBRARY_INSTALL_DIR
135 install-local:
136 $(MKINSTALLDIRS) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
137 $(INSTALL_LIB) $(the_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
138 test ! -f $(the_lib).mdb || $(INSTALL_LIB) $(the_lib).mdb $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
140 uninstall-local:
141 -rm -f $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
143 else
145 # If RUNTIME_HAS_CONSISTENT_GACDIR is set, it implies that the internal GACDIR
146 # of the runtime is the same as the GACDIR we want. So, we don't need to pass it
147 # to gacutil. Note that the GACDIR we want may not be the same as the value of
148 # GACDIR set above, since the user could have overridden the value of $(prefix).
150 # This makes a difference only when we're building from the mono/ tree, since we
151 # have to ensure that the internal GACDIR of the in-tree runtime matches where we
152 # install the DLLs.
154 ifndef RUNTIME_HAS_CONSISTENT_GACDIR
155 gacdir_flag = /gacdir $(GACDIR)
156 endif
158 install-local:
159 $(GACUTIL) /i $(the_lib) /f $(gacdir_flag) /root $(GACROOT) /package $(FRAMEWORK_VERSION)
161 uninstall-local:
162 -$(GACUTIL) /u $(LIBRARY_NAME:.dll=) $(gacdir_flag) /root $(GACROOT) /package $(FRAMEWORK_VERSION)
164 endif
165 endif
167 clean-local:
168 -rm -f $(library_CLEAN_FILES) $(CLEAN_FILES)
170 test-local run-test-local run-test-ondotnet-local:
173 test_assemblies :=
175 ifdef HAVE_CS_TESTS
176 test_assemblies += $(test_lib)
177 endif
179 ifdef HAVE_VB_TESTS
180 test_assemblies += $(btest_lib)
181 endif
183 ifdef test_assemblies
184 test-local: $(test_assemblies)
185 run-test-local: run-test-lib
186 run-test-ondotnet-local: run-test-ondotnet-lib
188 ## FIXME: i18n problem in the 'sed' command below
189 run-test-lib: test-local
190 ok=:; \
191 $(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; \
192 sed '1,/^Tests run: /d' TestResult-$(PROFILE).log; \
193 $$ok
195 run-test-ondotnet-lib: test-local
196 ok=:; \
197 $(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; \
198 sed '1,/^Tests run: /d' TestResult-ondotnet-$(PROFILE).log; \
199 $$ok
200 endif
202 DISTFILES = $(sourcefile) $(EXTRA_DISTFILES)
204 TEST_FILES =
206 ifdef HAVE_CS_TESTS
207 TEST_FILES += `sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile)`
208 DISTFILES += $(test_sourcefile)
209 endif
210 ifdef HAVE_VB_TESTS
211 TEST_FILES += `sed -e '/^$$/d' -e 's,^,Test/,' $(btest_sourcefile)`
212 DISTFILES += $(btest_sourcefile)
213 endif
215 dist-local: dist-default
216 subs=' ' ; \
217 for f in `cat $(sourcefile)` $(TEST_FILES) ; do \
218 case $$f in \
219 ../*) : ;; \
220 *) dest=`dirname $$f` ; \
221 case $$subs in *" $$dest "*) : ;; *) subs=" $$dest$$subs" ; $(MKINSTALLDIRS) $(distdir)/$$dest ;; esac ; \
222 cp -p $$f $(distdir)/$$dest || exit 1 ;; \
223 esac ; done ; \
224 for d in . $$subs ; do \
225 case $$d in .) : ;; *) test ! -f $$d/ChangeLog || cp -p $$d/ChangeLog $(distdir)/$$d ;; esac ; done
227 ifdef LIBRARY_NEEDS_POSTPROCESSING
228 dist-local: dist-fixup
229 FIXUP_PROFILES = default net_2_0
230 dist-fixup:
231 $(MKINSTALLDIRS) $(distdir)/fixup $(FIXUP_PROFILES:%=$(distdir)/fixup/%)
232 endif
234 ifndef LIBRARY_COMPILE
235 LIBRARY_COMPILE = $(CSCOMPILE)
236 endif
238 ifndef TEST_COMPILE
239 TEST_COMPILE = $(CSCOMPILE)
240 endif
242 ifndef BTEST_COMPILE
243 BTEST_COMPILE = $(BASCOMPILE)
244 endif
246 ifndef LIBRARY_SNK
247 LIBRARY_SNK = $(topdir)/class/mono.snk
248 endif
251 ifdef BUILT_SOURCES
252 ifeq (cat, $(PLATFORM_CHANGE_SEPARATOR_CMD))
253 BUILT_SOURCES_cmdline = $(BUILT_SOURCES)
254 else
255 BUILT_SOURCES_cmdline = `echo $(BUILT_SOURCES) | $(PLATFORM_CHANGE_SEPARATOR_CMD)`
256 endif
257 endif
259 # The library
261 $(build_lib): $(response) $(BUILT_SOURCES)
262 ifdef LIBRARY_USE_INTERMEDIATE_FILE
263 $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) -target:library -out:$(LIBRARY_NAME) $(BUILT_SOURCES_cmdline) @$(response)
264 $(SN) $(SNFLAGS) $(LIBRARY_NAME) $(LIBRARY_SNK)
265 mv $(LIBRARY_NAME) $@
266 test ! -f $(LIBRARY_NAME).mdb || mv $(LIBRARY_NAME).mdb $@.mdb
267 else
268 # $(XBUILD) "/property:DelaySign=true;KeyOriginatorFile=../msfinal.pub;OutputPath=$(topdir)/class/lib/$(PROFILE)/" $(the_csproj)
269 $(LIBRARY_COMPILE) -delaysign+ -keyfile:../msfinal.pub $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) -target:library -out:$@ $(BUILT_SOURCES_cmdline) @$(response)
270 $(SN) $(SNFLAGS) $@ $(LIBRARY_SNK)
271 endif
273 $(makefrag): $(sourcefile)
274 @echo Creating $@ ...
275 @sed 's,^,$(build_lib): ,' $< >$@
277 ifneq ($(response),$(sourcefile))
278 $(response): $(sourcefile) $(PLATFORM_excludes)
279 @echo Creating $@ ...
280 @sort $(sourcefile) $(PLATFORM_excludes) | uniq -u | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
281 endif
283 -include $(makefrag)
285 # for now, don't give any /lib flags or set MONO_PATH, since we
286 # give a full path to the assembly.
288 ifdef HAVE_CS_TESTS
290 $(test_lib): $(test_dep) $(test_response)
291 $(TEST_COMPILE) -target:library -out:$@ $(test_flags) @$(test_response)
293 $(test_response): $(test_sourcefile)
294 @echo Creating $@ ...
295 @sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
297 $(test_makefrag): $(test_response)
298 @echo Creating $@ ...
299 @sed 's,^,$(test_lib): ,' $< >$@
301 -include $(test_makefrag)
303 endif
305 ifdef HAVE_VB_TESTS
307 $(btest_lib): $(test_dep) $(btest_response)
308 $(BTEST_COMPILE) -target:library -out:$@ $(btest_flags) @$(btest_response)
310 $(btest_response): $(btest_sourcefile)
311 @echo Creating $@ ...
312 @sed -e '/^$$/d' -e 's,^,Test/,' $(btest_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
314 $(btest_makefrag): $(btest_response)
315 @echo Creating $@ ...
316 @sed 's,^,$(btest_lib): ,' $< >$@
318 -include $(btest_makefrag)
320 endif
322 all-local: $(makefrag) $(test_makefrag) $(btest_makefrag)
323 $(makefrag) $(test_makefrag) $(btest_makefrag): $(topdir)/build/library.make
325 updated-dll-sources:
326 echo "../../build/common/Consts.cs" > $(LIBRARY).sources
327 echo "../../build/common/MonoTODOAttribute.cs" >> $(LIBRARY).sources
328 ls */*.cs >> $(LIBRARY).sources
329 cd Test; ls */*.cs > ../$(LIBRARY:.dll=_test.dll).sources; cd ..