3 # The rules for building our class libraries.
5 # The NO_TEST stuff is not too pleasant but whatcha
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 # The including makefile can set the following variables:
12 # LIB_MCS_FLAGS - Command line flags passed to mcs.
13 # LIB_REFS - This should be a space separated list of assembly names which are added to the mcs
17 # All dependent libs become dependent dirs for parallel builds
18 # Have to rename to handle differences between assembly/directory names
19 DEP_LIBS=$(patsubst System.Xml,System.XML,$(LIB_REFS))
21 LIB_MCS_FLAGS += $(patsubst %,-r:%,$(LIB_REFS))
23 sourcefile = $(LIBRARY).sources
25 # If the directory contains the per profile include file, generate list file.
26 PROFILE_sources := $(wildcard $(PROFILE)_$(LIBRARY).sources)
28 PROFILE_excludes = $(wildcard $(PROFILE)_$(LIBRARY).exclude.sources)
29 sourcefile = $(depsdir)/$(PROFILE)_$(LIBRARY).sources
30 library_CLEAN_FILES += $(sourcefile)
32 ifdef EXTENSION_MODULE
33 EXTENSION_include = $(wildcard $(topdir)/../../mono-extensions/mcs/$(thisdir)/$(PROFILE)_$(LIBRARY).sources)
35 EXTENSION_include = $(wildcard $(PROFILE)_opt_$(LIBRARY).sources)
39 ifdef EXTENSION_MODULE
40 EXTENSION_exclude = $(wildcard $(topdir)/../../mono-extensions/mcs/$(thisdir)/$(PROFILE)_$(LIBRARY).exclude.sources)
42 EXTENSION_exclude = $(wildcard $(PROFILE)_opt_$(LIBRARY).exclude.sources)
45 # Note, gensources.sh can create a $(sourcefile).makefrag if it sees any '#include's
46 # We don't include it in the dependencies since it isn't always created
47 $(sourcefile): $(PROFILE_sources) $(PROFILE_excludes) $(topdir)/build/gensources.sh $(EXTENSION_include)
48 @echo Creating the per profile list $@ ...
49 $(SHELL) $(topdir)/build/gensources.sh $@ '$(PROFILE_sources)' '$(PROFILE_excludes)' '$(EXTENSION_include)' '$(EXTENSION_exclude)'
52 PLATFORM_excludes := $(wildcard $(LIBRARY).$(PLATFORM)-excludes)
54 ifndef PLATFORM_excludes
55 ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
56 response = $(sourcefile)
61 response = $(depsdir)/$(PROFILE)_$(LIBRARY_SUBDIR)_$(LIBRARY).response
62 library_CLEAN_FILES += $(response)
66 LIBRARY_NAME = $(LIBRARY)
76 the_libdir_base = $(topdir)/class/$(lib_dir)/$(PROFILE)/$(LIBRARY_SUBDIR)/
78 the_libdir_base = $(topdir)/class/$(lib_dir)/$(PROFILE)/
81 ifdef RESOURCE_STRINGS
82 ifdef BOOTSTRAP_PROFILE
83 MCS_FLAGS_RESOURCE_STRINGS += $(RESOURCE_STRINGS:%=--getresourcestrings:%)
88 # The bare directory contains the plain versions of System and System.Xml
90 bare_libdir = $(the_libdir_base)bare
93 # The secxml directory contains the System version that depends on
94 # System.Xml and Mono.Security
96 secxml_libdir = $(the_libdir_base)secxml
98 the_libdir = $(the_libdir_base)$(intermediate)
100 ifdef LIBRARY_USE_INTERMEDIATE_FILE
101 build_libdir = $(the_libdir)tmp/
103 build_libdir = $(the_libdir)
106 the_lib = $(the_libdir)$(LIBRARY_NAME)
107 build_lib = $(build_libdir)$(LIBRARY_NAME)
108 library_CLEAN_FILES += $(the_lib) $(the_lib).so $(the_lib).mdb $(the_lib:.dll=.pdb)
109 library_CLEAN_FILES += $(build_lib) $(build_lib).so $(build_lib).mdb $(build_lib:.dll=.pdb)
111 ifdef NO_SIGN_ASSEMBLY
115 sn = $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/sn.exe
116 SN = MONO_PATH="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(sn) -q
120 ifeq ($(PLATFORM), win32)
121 GACDIR = `cygpath -w $(mono_libdir)`
122 GACROOT = `cygpath -w $(DESTDIR)$(mono_libdir)`
123 test_flags += -d:WINDOWS
125 GACDIR = $(mono_libdir)
126 GACROOT = $(DESTDIR)$(mono_libdir)
130 all-local: $(the_lib) $(extra_targets)
133 ifeq ($(LIBRARY_COMPILE),$(BOOT_COMPILE))
139 csproj-local: csproj-library csproj-test
141 intermediate_clean=$(subst /,-,$(intermediate))
143 config_file=`basename $(LIBRARY) .dll`-$(intermediate_clean)$(PROFILE).input; \
144 [[ $(thisdir) == *"Facades"* ]] && config_file=Facades_$$config_file; \
145 echo $(thisdir):$$config_file >> $(topdir)/../msvc/scripts/order; \
147 echo $(USE_MCS_FLAGS) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS); \
148 echo $(LIBRARY_NAME); \
149 echo $(BUILT_SOURCES_cmdline); \
151 echo $(FRAMEWORK_VERSION); \
153 echo $(response)) > $(topdir)/../msvc/scripts/inputs/$$config_file
157 install-local: all-local
158 test-local: all-local
162 install-local uninstall-local:
167 aot_lib = $(the_lib)$(PLATFORM_AOT_SUFFIX)
168 aot_libname = $(LIBRARY_NAME)$(PLATFORM_AOT_SUFFIX)
170 ifdef LIBRARY_INSTALL_DIR
172 $(MKINSTALLDIRS) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
173 $(INSTALL_LIB) $(the_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
174 test ! -f $(the_lib).mdb || $(INSTALL_LIB) $(the_lib).mdb $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
175 ifdef PLATFORM_AOT_SUFFIX
176 test ! -f $(aot_lib) || $(INSTALL_LIB) $(aot_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
180 -rm -f $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
184 # If RUNTIME_HAS_CONSISTENT_GACDIR is set, it implies that the internal GACDIR
185 # of the runtime is the same as the GACDIR we want. So, we don't need to pass it
186 # to gacutil. Note that the GACDIR we want may not be the same as the value of
187 # GACDIR set above, since the user could have overridden the value of $(prefix).
189 # This makes a difference only when we're building from the mono/ tree, since we
190 # have to ensure that the internal GACDIR of the in-tree runtime matches where we
193 ifndef RUNTIME_HAS_CONSISTENT_GACDIR
194 gacdir_flag = /gacdir $(GACDIR)
197 ifndef LIBRARY_PACKAGE
199 LIBRARY_PACKAGE = compat-$(FRAMEWORK_VERSION)
201 LIBRARY_PACKAGE = $(FRAMEWORK_VERSION)
205 ifneq (none, $(LIBRARY_PACKAGE))
206 package_flag = /package $(LIBRARY_PACKAGE)
209 install-local: $(gacutil)
210 $(GACUTIL) /i $(the_lib) /f $(gacdir_flag) /root $(GACROOT) $(package_flag)
212 uninstall-local: $(gacutil)
213 -$(GACUTIL) /u $(LIBRARY_NAME:.dll=) $(gacdir_flag) /root $(GACROOT) $(package_flag)
215 endif # LIBRARY_INSTALL_DIR
219 -rm -f $(tests_CLEAN_FILES) $(library_CLEAN_FILES) $(CLEAN_FILES)
221 test-local run-test-local run-test-ondotnet-local:
224 DISTFILES = $(wildcard *$(LIBRARY)*.sources) $(EXTRA_DISTFILES)
226 ASSEMBLY = $(LIBRARY)
228 the_assembly = $(the_lib)
229 include $(topdir)/build/tests.make
232 DISTFILES += $(test_sourcefile)
235 config_file=`basename $(LIBRARY) .dll`-tests-$(PROFILE).input; \
236 echo $(thisdir):$$config_file >> $(topdir)/../msvc/scripts/order; \
238 echo $(USE_MCS_FLAGS) -r:$(the_assembly) $(TEST_MCS_FLAGS); \
240 echo $(BUILT_SOURCES_cmdline); \
242 echo $(FRAMEWORK_VERSION); \
244 echo $(test_response)) > $(topdir)/../msvc/scripts/inputs/$$config_file
248 # make dist will collect files in .sources files from all profiles
249 dist-local: dist-default
251 for f in `$(topdir)/tools/removecomments.sh $(wildcard *$(LIBRARY).sources)` $(TEST_FILES) ; do \
254 *) dest=`dirname "$$f"` ; \
255 case $$subs in *" $$dest "*) : ;; *) subs=" $$dest$$subs" ; $(MKINSTALLDIRS) $(distdir)/$$dest ;; esac ; \
256 cp -p "$$f" $(distdir)/$$dest || exit 1 ;; \
258 for d in . $$subs ; do \
259 case $$d in .) : ;; *) test ! -f $$d/ChangeLog || cp -p $$d/ChangeLog $(distdir)/$$d ;; esac ; done
261 ifndef LIBRARY_COMPILE
262 LIBRARY_COMPILE = $(CSCOMPILE)
266 LIBRARY_SNK = $(topdir)/class/mono.snk
270 library_CLEAN_FILES += $(BUILT_SOURCES)
271 ifeq (cat, $(PLATFORM_CHANGE_SEPARATOR_CMD))
272 BUILT_SOURCES_cmdline = $(BUILT_SOURCES)
274 BUILT_SOURCES_cmdline = `echo $(BUILT_SOURCES) | $(PLATFORM_CHANGE_SEPARATOR_CMD)`
280 $(the_lib): $(the_libdir)/.stamp
282 $(build_lib): $(response) $(sn) $(BUILT_SOURCES) $(build_libdir:=/.stamp)
283 $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) $(MCS_FLAGS_RESOURCE_STRINGS) -target:library -out:$@ $(BUILT_SOURCES_cmdline) @$(response)
284 $(Q) $(SN) -R $@ $(LIBRARY_SNK)
286 ifdef LIBRARY_USE_INTERMEDIATE_FILE
287 $(the_lib): $(build_lib)
288 $(Q) cp $(build_lib) $@
290 $(Q) test ! -f $(build_lib).mdb || mv $(build_lib).mdb $@.mdb
291 $(Q) test ! -f $(build_lib:.dll=.pdb) || mv $(build_lib:.dll=.pdb) $(the_lib:.dll=.pdb)
294 library_CLEAN_FILES += $(PROFILE)_aot.log
296 ifdef PLATFORM_AOT_SUFFIX
297 Q_AOT=$(if $(V),,@echo "AOT [$(PROFILE)] $(notdir $(@))";)
298 $(the_lib)$(PLATFORM_AOT_SUFFIX): $(the_lib)
299 $(Q_AOT) MONO_PATH='$(the_libdir)' > $(PROFILE)_aot.log 2>&1 $(RUNTIME) --aot=bind-to-runtime-version --debug $(the_lib)
303 ifneq (,$(filter $(AOT_IN_PROFILES), $(PROFILE)))
305 all-local: $(the_lib)$(PLATFORM_AOT_SUFFIX)
310 makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY_SUBDIR)_$(LIBRARY).makefrag
311 library_CLEAN_FILES += $(makefrag)
312 $(makefrag): $(sourcefile)
313 # @echo Creating $@ ...
314 @sed 's,^,$(build_lib): ,' $< >$@
315 @if test ! -f $(sourcefile).makefrag; then :; else \
316 cat $(sourcefile).makefrag >> $@ ; \
317 echo '$@: $(sourcefile).makefrag' >> $@; \
318 echo '$(sourcefile).makefrag:' >> $@; fi
320 ifneq ($(response),$(sourcefile))
322 ifdef PLATFORM_excludes
323 $(response): $(sourcefile) $(PLATFORM_excludes)
324 @echo Filtering $(sourcefile) to $@ ...
325 @sort $(sourcefile) $(PLATFORM_excludes) | uniq -u | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
327 $(response): $(sourcefile)
328 @echo Converting $(sourcefile) to $@ ...
329 @cat $(sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
336 # for now, don't give any /lib flags or set MONO_PATH, since we
337 # give a full path to the assembly.
339 ## Include corcompare stuff
340 include $(topdir)/build/corcompare.make
342 all-local: $(makefrag) $(test_makefrag) $(btest_makefrag)
343 ifneq ($(response),$(sourcefile))
344 $(response): $(topdir)/build/library.make $(depsdir)/.stamp
346 $(makefrag) $(test_response) $(test_makefrag) $(btest_response) $(btest_makefrag): $(topdir)/build/library.make $(depsdir)/.stamp
348 ## Documentation stuff
350 Q_MDOC_UP=$(if $(V),,@echo "MDOC-UP [$(PROFILE)] $(notdir $(@))";)
351 MDOC_UP =$(Q_MDOC_UP) \
352 MONO_PATH="$(topdir)/class/lib/$(DEFAULT_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(topdir)/class/lib/$(DEFAULT_PROFILE)/mdoc.exe \
353 update --delete -o Documentation/en $(the_lib)
355 doc-update-local: $(the_libdir)/.doc-stamp
357 $(the_libdir)/.doc-stamp: $(the_lib)
359 @echo "doc-stamp" > $@
361 # Need to be here so it comes after the definition of DEP_DIRS/DEP_LIBS
363 @echo "$(DEPS_TARGET_DIR): $(DEP_DIRS) $(DEP_LIBS)" >> $(DEPS_FILE)