BUGFIX: when deleting directories, delete any files within them
[tfs.git] / build / library.make
blobfee5f93d9b0c2180dcc1c89046cfe4b334d75480
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 library_CLEAN_FILES += $(makefrag) $(the_lib) $(the_pdb) $(the_mdb)
46 ifdef LIBRARY_NEEDS_POSTPROCESSING
47 build_lib = fixup/$(PROFILE)/$(LIBRARY_NAME)
48 library_CLEAN_FILES += $(build_lib) $(build_lib:.dll=.pdb)
49 else
50 build_lib = $(the_lib)
51 endif
53 ifndef NO_TEST
54 test_nunit_lib = nunit.framework.dll nunit.core.dll nunit.util.dll
55 test_nunit_dep = $(test_nunit_lib:%=$(topdir)/class/lib/$(PROFILE)/%)
56 test_nunit_ref = $(test_nunit_dep:%=-r:%)
57 library_CLEAN_FILES += TestResult*.xml
59 ifndef test_against
60 test_against = $(the_lib)
61 test_dep = $(the_lib)
62 endif
64 ifndef test_lib
65 test_lib = $(LIBRARY:.dll=_test_$(PROFILE).dll)
66 test_sourcefile = $(LIBRARY:.dll=_test.dll.sources)
67 else
68 test_sourcefile = $(test_lib).sources
69 endif
70 test_pdb = $(test_lib:.dll=.pdb)
71 test_response = $(depsdir)/$(test_lib).response
72 test_makefrag = $(depsdir)/$(test_lib).makefrag
73 test_flags = -r:$(test_against) $(test_nunit_ref) $(TEST_MCS_FLAGS)
74 library_CLEAN_FILES += $(LIBRARY:.dll=_test*.dll) $(LIBRARY:.dll=_test*.pdb) $(test_response) $(test_makefrag)
76 ifndef btest_lib
77 btest_lib = $(LIBRARY:.dll=_btest_$(PROFILE).dll)
78 btest_sourcefile = $(LIBRARY:.dll=_btest.dll.sources)
79 else
80 btest_sourcefile = $(btest_lib).sources
81 endif
82 btest_pdb = $(btest_lib:.dll=.pdb)
83 btest_response = $(depsdir)/$(btest_lib).response
84 btest_makefrag = $(depsdir)/$(btest_lib).makefrag
85 btest_flags = -r:$(test_against) $(test_nunit_ref) $(TEST_MBAS_FLAGS)
86 library_CLEAN_FILES += $(LIBRARY:.dll=_btest*.dll) $(LIBRARY:.dll=_btest*.pdb) $(btest_response) $(btest_makefrag)
88 ifndef HAVE_CS_TESTS
89 HAVE_CS_TESTS := $(wildcard $(test_sourcefile))
90 endif
91 ifndef HAVE_VB_TESTS
92 HAVE_VB_TESTS := $(wildcard $(btest_sourcefile))
93 endif
95 endif
97 ifdef NO_INSTALL
98 GACUTIL = :
99 else
100 GACUTIL = gacutil
101 endif
103 ifdef NO_SIGN_ASSEMBLY
104 SN = :
105 else
106 SN = sn
107 SNFLAGS = -q -R
108 endif
110 ifeq ($(PLATFORM), win32)
111 GACDIR = `cygpath -w $(mono_libdir)`
112 GACROOT = `cygpath -w $(DESTDIR)$(mono_libdir)`
113 test_flags += -d:WINDOWS
114 else
115 GACDIR = $(mono_libdir)
116 GACROOT = $(DESTDIR)$(mono_libdir)
117 endif
119 all-local: $(the_lib)
121 install-local: all-local
122 test-local: all-local
123 uninstall-local:
125 ifdef NO_INSTALL
126 install-local uninstall-local:
129 else
131 ifdef LIBRARY_INSTALL_DIR
132 install-local:
133 $(MKINSTALLDIRS) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
134 $(INSTALL_LIB) $(the_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
135 test ! -f $(the_lib).mdb || $(INSTALL_LIB) $(the_lib).mdb $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
137 uninstall-local:
138 -rm -f $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
140 else
142 # If RUNTIME_HAS_CONSISTENT_GACDIR is set, it implies that the internal GACDIR
143 # of the runtime is the same as the GACDIR we want. So, we don't need to pass it
144 # to gacutil. Note that the GACDIR we want may not be the same as the value of
145 # GACDIR set above, since the user could have overridden the value of $(prefix).
147 # This makes a difference only when we're building from the mono/ tree, since we
148 # have to ensure that the internal GACDIR of the in-tree runtime matches where we
149 # install the DLLs.
151 ifndef RUNTIME_HAS_CONSISTENT_GACDIR
152 gacdir_flag = /gacdir $(GACDIR)
153 endif
155 install-local:
156 $(GACUTIL) /i $(the_lib) /f $(gacdir_flag) /root $(GACROOT) /package $(FRAMEWORK_VERSION)
158 uninstall-local:
159 -$(GACUTIL) /u $(LIBRARY_NAME:.dll=) $(gacdir_flag) /root $(GACROOT) /package $(FRAMEWORK_VERSION)
161 endif
162 endif
164 clean-local:
165 -rm -f $(library_CLEAN_FILES) $(CLEAN_FILES)
167 test-local run-test-local run-test-ondotnet-local:
170 ifndef NO_TEST
171 $(test_nunit_dep): $(topdir)/build/deps/nunit-$(PROFILE).stamp
172 @if test -f $@; then :; else rm -f $<; $(MAKE) $<; fi
173 $(topdir)/build/deps/nunit-$(PROFILE).stamp:
174 cd ${topdir}/nunit20 && $(MAKE)
175 echo "stamp" >$@
176 library_CLEAN_FILES += $(topdir)/build/deps/nunit-$(PROFILE).stamp
177 endif
179 test_assemblies :=
181 ifdef HAVE_CS_TESTS
182 test_assemblies += $(test_lib)
183 endif
185 ifdef HAVE_VB_TESTS
186 test_assemblies += $(btest_lib)
187 endif
189 ifdef test_assemblies
190 test-local: $(test_assemblies)
191 run-test-local: run-test-lib
192 run-test-ondotnet-local: run-test-ondotnet-lib
194 ## FIXME: i18n problem in the 'sed' command below
195 run-test-lib: test-local
196 ok=:; \
197 $(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; \
198 sed '1,/^Tests run: /d' TestResult-$(PROFILE).log; \
199 $$ok
201 run-test-ondotnet-lib: test-local
202 ok=:; \
203 $(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; \
204 sed '1,/^Tests run: /d' TestResult-ondotnet-$(PROFILE).log; \
205 $$ok
206 endif
208 DISTFILES = $(sourcefile) $(EXTRA_DISTFILES)
210 TEST_FILES =
212 ifdef HAVE_CS_TESTS
213 TEST_FILES += `sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile)`
214 DISTFILES += $(test_sourcefile)
215 endif
216 ifdef HAVE_VB_TESTS
217 TEST_FILES += `sed -e '/^$$/d' -e 's,^,Test/,' $(btest_sourcefile)`
218 DISTFILES += $(btest_sourcefile)
219 endif
221 dist-local: dist-default
222 subs=' ' ; \
223 for f in `cat $(sourcefile)` $(TEST_FILES) ; do \
224 case $$f in \
225 ../*) : ;; \
226 *) dest=`dirname $$f` ; \
227 case $$subs in *" $$dest "*) : ;; *) subs=" $$dest$$subs" ; $(MKINSTALLDIRS) $(distdir)/$$dest ;; esac ; \
228 cp -p $$f $(distdir)/$$dest || exit 1 ;; \
229 esac ; done ; \
230 for d in . $$subs ; do \
231 case $$d in .) : ;; *) test ! -f $$d/ChangeLog || cp -p $$d/ChangeLog $(distdir)/$$d ;; esac ; done
233 ifdef LIBRARY_NEEDS_POSTPROCESSING
234 dist-local: dist-fixup
235 FIXUP_PROFILES = default net_2_0
236 dist-fixup:
237 $(MKINSTALLDIRS) $(distdir)/fixup $(FIXUP_PROFILES:%=$(distdir)/fixup/%)
238 endif
240 ifndef LIBRARY_COMPILE
241 LIBRARY_COMPILE = $(CSCOMPILE)
242 endif
244 ifndef TEST_COMPILE
245 TEST_COMPILE = $(CSCOMPILE)
246 endif
248 ifndef BTEST_COMPILE
249 BTEST_COMPILE = $(BASCOMPILE)
250 endif
252 ifndef LIBRARY_SNK
253 LIBRARY_SNK = $(topdir)/class/mono.snk
254 endif
257 ifdef BUILT_SOURCES
258 ifeq (cat, $(PLATFORM_CHANGE_SEPARATOR_CMD))
259 BUILT_SOURCES_cmdline = $(BUILT_SOURCES)
260 else
261 BUILT_SOURCES_cmdline = `echo $(BUILT_SOURCES) | $(PLATFORM_CHANGE_SEPARATOR_CMD)`
262 endif
263 endif
265 # The library
267 $(build_lib): $(response) $(BUILT_SOURCES)
268 ifdef LIBRARY_USE_INTERMEDIATE_FILE
269 $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) -target:library -out:$(LIBRARY_NAME) $(BUILT_SOURCES_cmdline) @$(response)
270 $(SN) $(SNFLAGS) $(LIBRARY_NAME) $(LIBRARY_SNK)
271 mv $(LIBRARY_NAME) $@
272 test ! -f $(LIBRARY_NAME).mdb || mv $(LIBRARY_NAME).mdb $@.mdb
273 else
274 $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) -target:library -out:$@ $(BUILT_SOURCES_cmdline) @$(response)
275 $(SN) $(SNFLAGS) $@ $(LIBRARY_SNK)
276 endif
278 $(makefrag): $(sourcefile)
279 @echo Creating $@ ...
280 @sed 's,^,$(build_lib): ,' $< >$@
282 ifneq ($(response),$(sourcefile))
283 $(response): $(sourcefile) $(PLATFORM_excludes)
284 @echo Creating $@ ...
285 @sort $(sourcefile) $(PLATFORM_excludes) | uniq -u | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
286 endif
288 -include $(makefrag)
290 # for now, don't give any /lib flags or set MONO_PATH, since we
291 # give a full path to the assembly.
293 ifdef HAVE_CS_TESTS
295 $(test_lib): $(test_dep) $(test_response) $(test_nunit_dep)
296 $(TEST_COMPILE) -target:library -out:$@ $(test_flags) @$(test_response)
298 $(test_response): $(test_sourcefile)
299 @echo Creating $@ ...
300 @sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
302 $(test_makefrag): $(test_response)
303 @echo Creating $@ ...
304 @sed 's,^,$(test_lib): ,' $< >$@
306 -include $(test_makefrag)
308 endif
310 ifdef HAVE_VB_TESTS
312 $(btest_lib): $(test_dep) $(btest_response) $(test_nunit_dep)
313 $(BTEST_COMPILE) -target:library -out:$@ $(btest_flags) @$(btest_response)
315 $(btest_response): $(btest_sourcefile)
316 @echo Creating $@ ...
317 @sed -e '/^$$/d' -e 's,^,Test/,' $(btest_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
319 $(btest_makefrag): $(btest_response)
320 @echo Creating $@ ...
321 @sed 's,^,$(btest_lib): ,' $< >$@
323 -include $(btest_makefrag)
325 endif
327 all-local: $(makefrag) $(test_makefrag) $(btest_makefrag)
328 $(makefrag) $(test_makefrag) $(btest_makefrag): $(topdir)/build/library.make
330 updated-dll-sources:
331 echo "../../build/common/Consts.cs" > $(LIBRARY).sources
332 echo "../../build/common/MonoTODOAttribute.cs" >> $(LIBRARY).sources
333 ls */*.cs >> $(LIBRARY).sources
334 cd Test; ls */*.cs > ../$(LIBRARY:.dll=_test.dll).sources; cd ..