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 LIB_REFS_FULL
= $(call _FILTER_OUT
,=, $(LIB_REFS
)) $(DEFAULT_REFERENCES
)
18 LIB_REFS_ALIAS
= $(filter-out $(LIB_REFS_FULL
),$(LIB_REFS
))
20 # All dependent libs become dependent dirs for parallel builds
21 DEP_LIBS
= $(filter-out %=, $(subst =,= ,$(LIB_REFS
)))
23 ifdef TARGET_NET_REFERENCE
24 # System*, mscorlib references come from the TARGET_NET_REFERENCE dir, others from the profile dir
25 LIB_REFS_MONO_FULL
= $(call _FILTER_OUT
,System
,$(call _FILTER_OUT
,mscorlib
,$(LIB_REFS_FULL
)))
26 LIB_REFS_MONO_ALIAS
= $(call _FILTER_OUT
,System
,$(LIB_REFS_ALIAS
))
28 LIB_REFS_NET_FULL
= $(filter-out $(LIB_REFS_MONO_FULL
),$(LIB_REFS_FULL
))
29 LIB_REFS_NET_ALIAS
= $(filter-out $(LIB_REFS_MONO_ALIAS
),$(LIB_REFS_ALIAS
))
31 LIB_MCS_FLAGS
+= $(patsubst %,-r
:$(topdir
)/..
/external
/binary-reference-assemblies
/$(TARGET_NET_REFERENCE
)/%.dll
,$(LIB_REFS_NET_FULL
))
32 LIB_MCS_FLAGS
+= $(patsubst %,-r
:%.dll
, $(subst =,=$(topdir
)/..
/external
/binary-reference-assemblies
/$(TARGET_NET_REFERENCE
)/,$(LIB_REFS_NET_ALIAS
)))
34 LIB_MCS_FLAGS
+= $(patsubst %,-r
:$(topdir
)/class
/lib
/$(PROFILE_DIRECTORY
)/%.dll
,$(LIB_REFS_MONO_FULL
))
35 LIB_MCS_FLAGS
+= $(patsubst %,-r
:%.dll
, $(subst =,=$(topdir
)/class
/lib
/$(PROFILE_DIRECTORY
)/,$(LIB_REFS_MONO_ALIAS
)))
39 LIB_MCS_FLAGS
+= $(patsubst %,-r
:$(topdir
)/..
/external
/binary-reference-assemblies
/$(API_BIN_PROFILE
)/%.dll
,$(API_BIN_REFS
))
42 LIB_MCS_FLAGS
+= $(patsubst %,-r
:$(topdir
)/class
/lib
/$(PROFILE_DIRECTORY
)/%.dll
,$(LIB_REFS_FULL
))
43 LIB_MCS_FLAGS
+= $(patsubst %,-r
:%.dll
, $(subst =,=$(topdir
)/class
/lib
/$(PROFILE_DIRECTORY
)/,$(LIB_REFS_ALIAS
)))
47 KEYFILE_MCS_FLAGS
+= /keyfile
:$(KEYFILE
)
51 LIBRARY_NAME
= $(LIBRARY
)
60 the_libdir_base
= $(topdir
)/class
/$(lib_dir
)/$(PROFILE_DIRECTORY
)/$(if
$(LIBRARY_SUBDIR
),$(LIBRARY_SUBDIR
)/)
62 ifdef RESOURCE_STRINGS
63 RESOURCE_STRINGS_FILES
+= $(RESOURCE_STRINGS
:%=--resourcestrings
:%)
64 IL_REPLACE_FILES
+= $(IL_REPLACE
:%=--ilreplace
:%)
67 ifdef ENFORCE_LIBRARY_WARN_AS_ERROR
68 ifeq ($(LIBRARY_WARN_AS_ERROR
),yes
)
70 LIB_MCS_FLAGS
+= -warnaserror
75 # add sourcelink information if we're building a portable PDB
76 ifneq (, $(findstring debug
:portable
, $(PROFILE_MCS_FLAGS
)))
77 LIB_MCS_FLAGS
+= -sourcelink
:$(topdir
)/build
/common
/sourcelink.json
80 the_libdir
= $(the_libdir_base
)$(intermediate
)
82 ifdef LIBRARY_USE_INTERMEDIATE_FILE
83 build_libdir
= $(the_libdir
)tmp
/
85 build_libdir
= $(the_libdir
)
88 the_lib
= $(the_libdir
)$(LIBRARY_NAME
)
89 build_lib
= $(build_libdir
)$(LIBRARY_NAME
)
90 library_CLEAN_FILES
+= $(the_lib
) $(the_lib
).so
$(the_lib
).mdb
$(the_lib
:.dll
=.pdb
)
91 library_CLEAN_FILES
+= $(build_lib
) $(build_lib
).so
$(build_lib
).mdb
$(build_lib
:.dll
=.pdb
)
93 ifdef NO_SIGN_ASSEMBLY
97 sn
= $(topdir
)/class
/lib
/$(BUILD_TOOLS_PROFILE
)/sn.exe
98 SN
= MONO_PATH
="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME
) $(RUNTIME_FLAGS
) $(sn
) -q
102 ifeq ($(BUILD_PLATFORM
), win32
)
103 GACDIR
= `cygpath -w $(mono_libdir)`
104 GACROOT
= `cygpath -w $(DESTDIR)$(mono_libdir)`
105 test_flags
+= -d
:WINDOWS
107 GACDIR
= $(mono_libdir
)
108 GACROOT
= $(DESTDIR
)$(mono_libdir
)
112 all-local
: $(the_lib
) $(extra_targets
)
115 ifeq ($(LIBRARY_COMPILE
),$(BOOT_COMPILE
))
121 csproj-local
: csproj-library csproj-test
123 intermediate_clean
=$(subst /,-,$(intermediate
))
125 config_file
=`basename $(LIBRARY) .dll`-$(intermediate_clean
)$(PROFILE
).input
; \
126 case
"$(thisdir)" in
*"Facades"*) config_file
=Facades_
$$config_file;; *"legacy"*) config_file
=legacy_
$$config_file;; esac
; \
127 echo
$(thisdir
):$$config_file >> $(topdir
)/..
/msvc
/scripts
/order
; \
129 echo
$(USE_MCS_FLAGS
) $(LIBRARY_FLAGS
) $(LIB_MCS_FLAGS
) $(KEYFILE_MCS_FLAGS
); \
131 echo
$(LIBRARY_NAME
); \
132 echo
$(BUILT_SOURCES_cmdline
); \
134 echo
$(FRAMEWORK_VERSION
); \
136 echo
$(RESOURCE_DEFS
); \
137 echo
$(response
)) > $(topdir
)/..
/msvc
/scripts
/inputs
/$$config_file
141 install-local
: all-local
142 test-local
: all-local
146 install-local uninstall-local
:
151 aot_lib
= $(the_lib
)$(PLATFORM_AOT_SUFFIX
)
152 aot_libname
= $(LIBRARY_NAME
)$(PLATFORM_AOT_SUFFIX
)
154 ifdef LIBRARY_INSTALL_DIR
156 $(MKINSTALLDIRS
) $(DESTDIR
)$(LIBRARY_INSTALL_DIR
)
157 $(INSTALL_LIB
) $(the_lib
) $(DESTDIR
)$(LIBRARY_INSTALL_DIR
)/$(LIBRARY_NAME
)
158 test ! -f
$(the_lib
).mdb ||
$(INSTALL_LIB
) $(the_lib
).mdb
$(DESTDIR
)$(LIBRARY_INSTALL_DIR
)/$(LIBRARY_NAME
).mdb
159 test ! -f
$(the_lib
:.dll
=.pdb
) ||
$(INSTALL_LIB
) $(the_lib
:.dll
=.pdb
) $(DESTDIR
)$(LIBRARY_INSTALL_DIR
)/$(LIBRARY_NAME
:.dll
=.pdb
)
161 ifdef PLATFORM_AOT_SUFFIX
162 test ! -f
$(aot_lib
) ||
$(INSTALL_LIB
) $(aot_lib
) $(DESTDIR
)$(LIBRARY_INSTALL_DIR
)
166 -rm -f
$(DESTDIR
)$(LIBRARY_INSTALL_DIR
)/$(LIBRARY_NAME
) $(DESTDIR
)$(LIBRARY_INSTALL_DIR
)/$(LIBRARY_NAME
).mdb
$(DESTDIR
)$(LIBRARY_INSTALL_DIR
)/$(LIBRARY_NAME
:.dll
=.pdb
)
170 # If RUNTIME_HAS_CONSISTENT_GACDIR is set, it implies that the internal GACDIR
171 # of the runtime is the same as the GACDIR we want. So, we don't need to pass it
172 # to gacutil. Note that the GACDIR we want may not be the same as the value of
173 # GACDIR set above, since the user could have overridden the value of $(prefix).
175 # This makes a difference only when we're building from the mono/ tree, since we
176 # have to ensure that the internal GACDIR of the in-tree runtime matches where we
179 ifndef RUNTIME_HAS_CONSISTENT_GACDIR
180 gacdir_flag
= /gacdir
$(GACDIR
)
183 ifndef LIBRARY_PACKAGE
185 LIBRARY_PACKAGE
= compat-
$(FRAMEWORK_VERSION
)
187 LIBRARY_PACKAGE
= $(FRAMEWORK_VERSION
)
191 ifneq (none
, $(LIBRARY_PACKAGE
))
192 package_flag
= /package
$(LIBRARY_PACKAGE
)
195 install-local
: $(gacutil
)
196 $(GACUTIL
) /i
$(the_lib
) /f
$(gacdir_flag
) /root
$(GACROOT
) $(package_flag
)
198 uninstall-local
: $(gacutil
)
199 -$(GACUTIL
) /u
$(LIBRARY_NAME
:.dll
=) $(gacdir_flag
) /root
$(GACROOT
) $(package_flag
)
201 endif # LIBRARY_INSTALL_DIR
205 -rm -f
$(tests_CLEAN_FILES
) $(library_CLEAN_FILES
) $(CLEAN_FILES
)
207 test-local run-test-local run-test-ondotnet-local
:
211 # RESOURCES_DEFS is a list of ID,FILE pairs separated by spaces
212 # for each of those, generate a rule that produces ID.resource from
213 # FILE using the resgen tool, adds the generated file to CLENA_FILES and
214 # passes the resource to the compiler
217 define RESOURCE_template
219 $$(RESGEN
) "$$<" "$$@"
221 GEN_RESOURCE_DEPS
+= $(1).resources
222 GEN_RESOURCE_FLAGS
+= -resource
:$(1).resources
223 CLEAN_FILES
+= $(1).resources
224 DIST_LISTED_RESOURCES
+= $(2)
228 $(foreach pair
,$(RESOURCE_DEFS
), $(eval
$(call RESOURCE_template
,$(word 1, $(subst $(ccomma
), ,$(pair
))), $(word 2, $(subst $(ccomma
), ,$(pair
))))))
231 DISTFILES
= $(wildcard *.sources
) $(EXTRA_DISTFILES
) $(DIST_LISTED_RESOURCES
)
233 ASSEMBLY
= $(LIBRARY
)
235 the_assembly
= $(the_lib
)
237 include $(topdir
)/build
/tests.make
240 DISTFILES
+= $(test_sourcefile
)
243 config_file
=`basename $(LIBRARY) .dll`-tests-
$(PROFILE
).input
; \
244 echo
$(thisdir
):$$config_file >> $(topdir
)/..
/msvc
/scripts
/order
; \
246 echo
$(USE_MCS_FLAGS
) -r
:$(the_assembly
) $(TEST_MCS_FLAGS
); \
249 echo
$(BUILT_SOURCES_cmdline
); \
251 echo
$(FRAMEWORK_VERSION
); \
254 echo
$(test_response
)) > $(topdir
)/..
/msvc
/scripts
/inputs
/$$config_file
258 # make dist will collect files in .sources files from all profiles
259 dist-local
: dist-default
261 for f in
`$(topdir)/tools/removecomments.sh $(filter-out $(wildcard *_test.dll.sources) $(wildcard *_xtest.dll.sources) $(wildcard *exclude.sources),$(wildcard *.sources))` $(TEST_FILES
) ; do \
265 *) dest
=`dirname "$$f"` ; \
266 case
$$subs in
*" $$dest "*) : ;; *) subs
=" $$dest$$subs" ; $(MKINSTALLDIRS
) $(distdir
)/$$dest ;; esac
; \
267 cp
-p
"$$f" $(distdir
)/$$dest || exit
1 ;; \
269 for d in .
$$subs ; do \
270 case
$$d in .
) : ;; *) test ! -f
$$d/ChangeLog || cp
-p
$$d/ChangeLog
$(distdir
)/$$d ;; esac
; done
272 ifndef LIBRARY_COMPILE
273 LIBRARY_COMPILE
= $(CSCOMPILE
)
277 LIBRARY_SNK
= $(topdir
)/class
/mono.snk
281 library_CLEAN_FILES
+= $(BUILT_SOURCES
)
282 ifeq (cat
, $(PLATFORM_CHANGE_SEPARATOR_CMD
))
283 BUILT_SOURCES_cmdline
= $(BUILT_SOURCES
)
285 BUILT_SOURCES_cmdline
= `echo $(BUILT_SOURCES) | $(PLATFORM_CHANGE_SEPARATOR_CMD)`
291 # If the directory contains the per profile include file, generate list file.
292 # TODO: depend on all *.sources (except tests) for now and figure out how to list only needed files later
293 PROFILE_sources
= $(filter-out %test.dll.exclude.sources
%test.dll.sources
, $(wildcard *.sources
))
294 PROFILE_excludes
= $(filter-out %test.dll.exclude.sources
%test.dll.sources
, $(wildcard *.exclude.sources
))
296 sourcefile
= $(depsdir
)/$(PROFILE_PLATFORM
)_
$(PROFILE
)_
$(LIBRARY_SUBDIR
)_
$(LIBRARY
).sources
297 $(sourcefile
): $(PROFILE_sources
) $(PROFILE_excludes
) $(depsdir
)/.stamp
298 $(GENSOURCES
) --strict
--platformsdir
:$(topdir
)/build
"$@" "$(LIBRARY)" "$(PROFILE_PLATFORM)" "$(PROFILE)"
300 library_CLEAN_FILES
+= $(sourcefile
)
302 response
= $(depsdir
)/$(PROFILE_PLATFORM
)_
$(PROFILE
)_
$(LIBRARY_SUBDIR
)_
$(LIBRARY
).response
303 $(response
): $(sourcefile
) $(topdir
)/build
/library.make
$(depsdir
)/.stamp
304 $(PLATFORM_CHANGE_SEPARATOR_CMD
) <$(sourcefile
) >$@
306 library_CLEAN_FILES
+= $(response
)
308 makefrag
= $(depsdir
)/$(PROFILE_PLATFORM
)_
$(PROFILE
)_
$(LIBRARY_SUBDIR
)_
$(LIBRARY
).makefrag
309 $(makefrag
): $(sourcefile
) $(topdir
)/build
/library.make
$(depsdir
)/.stamp
310 # @echo Creating $@ ...
311 @sed
's,^,$(build_lib): ,' $< >$@
312 @if
test ! -f
$(sourcefile
).makefrag
; then
:; else \
313 cat
$(sourcefile
).makefrag
>> $@
; \
314 echo
'$@: $(sourcefile).makefrag' >> $@
; \
315 echo
'$(sourcefile).makefrag:' >> $@
; fi
317 library_CLEAN_FILES
+= $(makefrag
)
320 all-local
: $(makefrag
)
325 $(the_lib
): $(the_libdir
)/.stamp
$(if
$(PROFILE_PLATFORM
),$(if
$(filter $(HOST_PLATFORM
),$(BUILD_PLATFORM
)),$(topdir
)/class
/$(lib_dir
)/$(PROFILE
)/.stamp
))
327 ifdef PROFILE_PLATFORM
328 $(topdir
)/class
/$(lib_dir
)/$(PROFILE
)/.stamp
: |
$(topdir
)/class
/$(lib_dir
)/$(PROFILE
)-$(HOST_PLATFORM
)/.stamp
329 $(if
$(filter $(HOST_PLATFORM
),$(BUILD_PLATFORM
)),$(if
$(filter $(BUILD_PLATFORM
),win32
),CYGWIN
=winsymlinks
:nativestrict
) ln
-s
$(abspath
$(topdir
)/class
/$(lib_dir
)/$(PROFILE
)-$(BUILD_PLATFORM
)) $(abspath
$(topdir
)/class
/$(lib_dir
)/$(PROFILE
)))
334 $(build_lib
): $(response
) $(sn
) $(BUILT_SOURCES
) $(build_libdir
)/.stamp
$(GEN_RESOURCE_DEPS
) $(MODULE_DEPS
)
335 $(LIBRARY_COMPILE
) $(LIBRARY_FLAGS
) $(LIB_MCS_FLAGS
) $(KEYFILE_MCS_FLAGS
) $(GEN_RESOURCE_FLAGS
) -target
:library
-out
:$@
$(BUILT_SOURCES_cmdline
) @
$(response
)
336 ifdef RESOURCE_STRINGS_FILES
337 $(Q
) $(STRING_REPLACER
) $(RESOURCE_STRINGS_FILES
) $(IL_REPLACE_FILES
) $@
339 $(Q
) $(SN
) -R
$@
$(LIBRARY_SNK
)
341 ifdef LIBRARY_USE_INTERMEDIATE_FILE
342 $(the_lib
): $(build_lib
)
343 $(Q
) cp
$(build_lib
) $@
345 $(Q
) test ! -f
$(build_lib
).mdb || mv
$(build_lib
).mdb
$@.mdb
346 $(Q
) test ! -f
$(build_lib
:.dll
=.pdb
) || mv
$(build_lib
:.dll
=.pdb
) $(the_lib
:.dll
=.pdb
)
351 library_CLEAN_FILES
+= $(PROFILE
)_
$(LIBRARY_NAME
)_aot.log
353 ifdef PLATFORM_AOT_SUFFIX
354 $(the_lib
)$(PLATFORM_AOT_SUFFIX
): $(the_lib
)
355 $(Q_AOT
) MONO_PATH
='$(the_libdir_base)' $(RUNTIME
) $(AOT_BUILD_FLAGS
) --debug
$(the_lib
)
357 all-local-aot
: $(the_lib
)$(PLATFORM_AOT_SUFFIX
)
360 # for now, don't give any /lib flags or set MONO_PATH, since we
361 # give a full path to the assembly.
363 ## Include corcompare stuff
364 include $(topdir
)/build
/corcompare.make
367 all-local
: $(test_makefrag
) $(btest_makefrag
)
370 $(test_response
) $(test_makefrag
) $(btest_response
) $(btest_makefrag
): $(topdir
)/build
/library.make
$(depsdir
)/.stamp
372 ## Documentation stuff
374 doc-update-local
: $(the_libdir
)/.doc-stamp
376 $(the_libdir
)/.doc-stamp
: $(the_lib
)
377 $(MDOC_UP
) $(the_lib
)
378 @echo
"doc-stamp" > $@
380 # Need to be here so it comes after the definition of DEP_DIRS/DEP_LIBS
382 @echo
"$(DEPS_TARGET_DIR): $(DEP_DIRS) $(DEP_LIBS)" >> $(DEPS_FILE
)
384 update-corefx-sr-generic
:
385 ifneq ($(RESX_STRINGS
),)
386 MONO_PATH
="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME
) $(RUNTIME_FLAGS
) $(topdir
)/class
/lib
/$(BUILD_TOOLS_PROFILE
)/resx2sr.exe
$(RESX_EXTRA_ARGUMENTS
) $(RESX_STRINGS
) >$(SR_OUTPUT
)
389 update-corefx-sr
: $(RESX_RESOURCE_STRING
) $(XTEST_RESX_RESOURCE_STRING
)
390 $(MAKE
) SR_OUTPUT
=corefx
/SR.cs RESX_STRINGS
="$(RESX_RESOURCE_STRING)" RESX_EXTRA_ARGUMENTS
="$(RESX_EXTRA_ARGUMENTS)" update-corefx-sr-generic \
391 && $(MAKE
) SR_OUTPUT
=corefx
/SR.tests.cs RESX_STRINGS
=$(XTEST_RESX_RESOURCE_STRING
) update-corefx-sr-generic