3 # This is the makefile fragment with default rules
4 # for building things in MCS
6 # To customize the build, you should edit config.make.
7 # If you need to edit this file, that's a bug; email
8 # peter@newton.cx about it.
11 space
:= $(empty
) $(empty
)
13 _FILTER_OUT
= $(foreach x
,$(2),$(if
$(findstring $(1),$(x
)),,$(x
)))
15 # given $(thisdir), we compute the path to the top directory
17 # split_path = $(filter-out .,$(subst /,$(space),$(1)))
18 # make_path = ./$(subst $(space),/,$(1))
19 # dotdottify = $(patsubst %,..,$(1))
20 # topdir = $(call make_path,$(call dotdottify,$(call split_path,$(thisdir))))
21 topdir
:= .
/$(subst $(space
),/,$(patsubst %,..
,$(filter-out .
,$(subst /,$(space
),$(thisdir
)))))
26 # echo -e "\\t" does not work on some systems, so use 5 spaces
27 Q_MCS
=$(if
$(V
),,@echo
"$(if $(MCS_MODE),MCS,CSC) [$(intermediate)$(PROFILE_DIRECTORY)] $(notdir $(@))";)
28 Q_AOT
=$(if
$(V
),,@echo
"AOT [$(intermediate)$(PROFILE_DIRECTORY)] $(notdir $(@))";)
30 ifndef BUILD_TOOLS_PROFILE
31 BUILD_TOOLS_PROFILE
= build
34 # NOTE: We have to use conditional functions to branch on the state of ENABLE_COMPILER_SERVER
35 # because the value of this flag can change after rules.make is evaluated. If we use regular ifeq
36 # statements our builds will opt to use or not use the compiler server seemingly at random because
37 # we include rules.make many times and the last observed value from rules.make does not match the
38 # value used when actually executing csc. you can observe this by adding an $ ( info here and an
39 # echo above the csc invocation and printing the values.
40 COMPILER_SERVER_ENABLED_ARGS
= /shared
:$(COMPILER_SERVER_PIPENAME
)
41 COMPILER_SERVER_ARGS
= $(if
$(findstring 1,$(ENABLE_COMPILER_SERVER
)),$(COMPILER_SERVER_ENABLED_ARGS
),)
42 CSC_LOCATION
= $(if
$(findstring 1,$(ENABLE_COMPILER_SERVER
)),$(SERVER_CSC_LOCATION
),$(STANDALONE_CSC_LOCATION
))
44 USE_MCS_FLAGS
= $(COMPILER_SERVER_ARGS
) /codepage
:$(CODEPAGE
) /nologo
/noconfig
/deterministic
$(LOCAL_MCS_FLAGS
) $(PLATFORM_MCS_FLAGS
) $(PROFILE_MCS_FLAGS
) $(MCS_FLAGS
)
45 USE_CFLAGS
= $(LOCAL_CFLAGS
) $(CFLAGS
) $(CPPFLAGS
)
46 CSCOMPILE
= $(Q_MCS
) $(MCS
) $(USE_MCS_FLAGS
)
47 CSC_RUNTIME_FLAGS
= --aot-path
=$(abspath
$(topdir
)/class
/lib
/$(BUILD_TOOLS_PROFILE
)) --gc-params
=nursery-size
=64m
--clr-memory-model
48 CCOMPILE
= $(CC
) $(USE_CFLAGS
)
49 BOOT_COMPILE
= $(Q_MCS
) $(BOOTSTRAP_MCS
) $(USE_MCS_FLAGS
)
50 INSTALL
= $(SHELL
) $(topdir
)/..
/mono
/install-sh
51 INSTALL_DATA
= $(INSTALL
) -c
-m
644
52 INSTALL_BIN
= $(INSTALL
) -c
-m
755
53 INSTALL_LIB
= $(INSTALL_BIN
)
54 MKINSTALLDIRS
= $(SHELL
) $(topdir
)/mkinstalldirs
55 INTERNAL_CSC_LOCATION
= $(CSC_LOCATION
)
57 # Using CSC_SDK_PATH_DISABLED for sanity check that all references have path specified
58 INTERNAL_CSC
= CSC_SDK_PATH_DISABLED
= $(RUNTIME
) $(RUNTIME_FLAGS
) $(CSC_RUNTIME_FLAGS
) $(INTERNAL_CSC_LOCATION
)
60 RESGEN
= MONO_PATH
="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME
) $(RUNTIME_FLAGS
) $(topdir
)/class
/lib
/$(BUILD_TOOLS_PROFILE
)/resgen.exe
61 STRING_REPLACER
= MONO_PATH
="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME
) $(RUNTIME_FLAGS
) $(topdir
)/class
/lib
/$(BUILD_TOOLS_PROFILE
)/cil-stringreplacer.exe
62 ILASM
= MONO_PATH
="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME
) $(RUNTIME_FLAGS
) $(topdir
)/class
/lib
/$(BUILD_TOOLS_PROFILE
)/ilasm.exe
63 GENSOURCES
= MONO_PATH
="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME
) $(RUNTIME_FLAGS
) $(topdir
)/class
/lib
/$(BUILD_TOOLS_PROFILE
)/gensources.exe
65 depsdir
= $(topdir
)/build
/deps
67 # Make sure these propagate if set manually
80 # Get this so the platform.make platform-check rule doesn't become the
86 # Get initial configuration. pre-config is so that the builder can
87 # override BUILD_PLATFORM or PROFILE
89 include $(topdir
)/build
/config-default.make
90 -include $(topdir
)/build
/pre-config.make
91 -include $(topdir
)/build
/config.make
95 include $(topdir
)/build
/platforms
/$(BUILD_PLATFORM
).make
97 PROFILE_PLATFORM
= $(if
$(PLATFORMS
),$(if
$(filter $(PLATFORMS
),$(HOST_PLATFORM
)),$(HOST_PLATFORM
),$(error Unknown platform
"$(HOST_PLATFORM)" for profile
"$(PROFILE)")))
98 PROFILE_DIRECTORY
= $(PROFILE
)$(if
$(PROFILE_PLATFORM
),-$(PROFILE_PLATFORM
))
102 ifeq ($(PLATFORM_RUNTIME
),$(RUNTIME
))
103 PLATFORM_MONO_NATIVE
= yes
106 # Rest of the configuration
109 PROFILE
= $(DEFAULT_PROFILE
)
112 include $(topdir
)/build
/profiles
/$(PROFILE
).make
115 PROFILE_MCS_FLAGS
+= -optimize
119 INTERNAL_CSC_LOCATION
= $(topdir
)/class
/lib
/$(BOOTSTRAP_PROFILE
)/mcs.exe
121 ifdef PLATFORM_DEBUG_FLAGS
122 PLATFORM_DEBUG_FLAGS
= /debug
:full
128 # Problem: We want to be able to build aot
129 # assemblies as part of the build system.
131 # For this to be done safely, we really need two passes. This
132 # ensures that all of the .dlls are compiled before trying to
133 # aot them. Because we want this to be the
134 # default target for some profiles(testing_aot_full) we have a
135 # two-level build system. The do-all-aot target is what
136 # gets invoked at the top-level when someone tries to build with aot.
137 # It will invoke the do-all target, and will set TOP_LEVEL_DO for this
138 # recursive make call in order to prevent this recursive call from trying
139 # to build aot in each of the subdirs. After this is done, we will aot
140 # everything that our building produced by aoting everything in
141 # mcs/class/lib/$(PROFILE)/
144 ifneq ($(or
$(ALWAYS_AOT_BCL
), $(ALWAYS_AOT_TESTS
)),)
145 TOP_LEVEL_DO
= do-all-aot
147 TOP_LEVEL_DO
= do-all
150 endif # !TOP_LEVEL_DO
152 ifdef OVERRIDE_TARGET_ALL
161 gacutil
= $(topdir
)/class
/lib
/$(BUILD_TOOLS_PROFILE
)/gacutil.exe
162 GACUTIL
= MONO_PATH
="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME
) $(RUNTIME_FLAGS
) $(gacutil
)
165 STD_TARGETS
= test xunit-test run-test run-xunit-test run-test-ondotnet
clean install uninstall doc-update
167 $(STD_TARGETS
): %: do-
%
169 ifdef PLATFORM_AOT_SUFFIX
172 $(MAKE
) do-all TOP_LEVEL_DO
=do-all
173 $(MAKE
) aot-all-profile
175 # When we recursively call $(MAKE) aot-all-profile
176 # we will have created this directory, and so will
177 # be able to evaluate the .dylibs to make
178 ifneq ("$(wildcard $(topdir)/class/lib/$(PROFILE))","")
181 AOT_PROFILE_ASSEMBLIES
:= $(sort $(patsubst .
//%,%,$(filter-out %.dll.dll
%.exe.dll
%bare
% %plaincore
% %secxml
% %Facades
% %ilasm
%,$(filter %.dll
%.exe
,$(wildcard $(topdir
)/class
/lib
/$(PROFILE
)/*)))))
182 AOT_PROFILE_ASSEMBLIES_OUT
:= $(patsubst %,%$(PLATFORM_AOT_SUFFIX
),$(AOT_PROFILE_ASSEMBLIES
))
184 AOT_PROFILE_FACADES
:= $(sort $(patsubst .
//%,%,$(filter-out %.dll.dll
%.exe.dll
%bare
% %plaincore
% %secxml
% %Facades
% %ilasm
%,$(filter %.dll
%.exe
,$(wildcard $(topdir
)/class
/lib
/$(PROFILE
)/Facades
/*)))))
185 AOT_PROFILE_FACADES_OUT
:= $(patsubst %,%$(PLATFORM_AOT_SUFFIX
),$(AOT_PROFILE_FACADES
))
188 ifdef ALWAYS_AOT_TESTS
189 AOT_PROFILE_TESTS
:= $(sort $(patsubst .
//%,%,$(filter-out %.dll.dll
%.exe.dll
%bare
% %plaincore
% %secxml
% %Facades
% %ilasm
%,$(filter %.dll
%.exe
,$(wildcard $(topdir
)/class
/lib
/$(PROFILE
)/tests
/*)))))
190 AOT_PROFILE_TESTS_OUT
:= $(patsubst %,%$(PLATFORM_AOT_SUFFIX
),$(AOT_PROFILE_TESTS
))
193 # This can run in parallel
194 .PHONY
: aot-all-profile
195 ifdef AOT_BUILD_FLAGS
196 aot-all-profile
: $(AOT_PROFILE_ASSEMBLIES_OUT
) $(AOT_PROFILE_TESTS_OUT
) $(AOT_PROFILE_FACADES_OUT
)
199 echo AOT_BUILD_FLAGS not set
, skipping AOT.
202 %.dll
$(PLATFORM_AOT_SUFFIX
): %.dll
203 @ mkdir
-p
$<_bitcode_tmp
204 $(Q_AOT
) MONO_PATH
="$(topdir)/class/lib/$(PROFILE)" $(RUNTIME
) $(RUNTIME_FLAGS
) $(AOT_BUILD_FLAGS
),temp-path
=$<_bitcode_tmp
$<
205 @
rm -rf
$<_bitcode_tmp
207 %.exe
$(PLATFORM_AOT_SUFFIX
): %.exe
208 @ mkdir
-p
$<_bitcode_tmp
209 $(Q_AOT
) MONO_PATH
="$(topdir)/class/lib/$(PROFILE)" $(RUNTIME
) $(RUNTIME_FLAGS
) $(AOT_BUILD_FLAGS
),temp-path
=$<_bitcode_tmp
$<
210 @
rm -rf
$<_bitcode_tmp
212 endif #ifneq ("$(wildcard $(topdir)/class/lib/$(PROFILE))","")
214 endif # PLATFORM_AOT_SUFFIX
217 ok
=:; $(MAKE
) run-test-recursive || ok
=false
; $(MAKE
) run-test-local || ok
=false
; $$ok
222 .PHONY
: all-local
$(STD_TARGETS
:=-local
)
223 all-local
$(STD_TARGETS
:=-local
):
227 # The way this is set up, any profile-specific subdirs list should
228 # be listed _before_ including rules.make. However, the default
229 # SUBDIRS list can come after, so don't use the eager := syntax when
230 # using the defaults.
231 PROFILE_SUBDIRS
= $(or
$($(PROFILE
)_SUBDIRS
),$(SUBDIRS
))
233 # These subdirs can be built in parallel
234 PROFILE_PARALLEL_SUBDIRS
= $(or
$($(PROFILE
)_PARALLEL_SUBDIRS
),$(PARALLEL_SUBDIRS
))
236 ifndef FRAMEWORK_VERSION_MAJOR
237 FRAMEWORK_VERSION_MAJOR
= $(basename $(FRAMEWORK_VERSION
))
241 @set .
$$MAKEFLAGS; \
242 case
$$2 in
--unix
) shift
;; esac
; \
243 case
$$2 in
*=*) dk
="exit 1" ;; *k
*) dk
=: ;; *) dk
="exit 1" ;; esac
; \
245 $(foreach subdir
,$(PROFILE_SUBDIRS
),$(MAKE
) -C
$(subdir
) $* ||
{ final_exit
="exit 1"; $$dk; };) \
246 $(if
$(PROFILE_PARALLEL_SUBDIRS
), \
247 $(if
$(filter $*,all), \
248 $(MAKE
) $(PROFILE_PARALLEL_SUBDIRS
) ENABLE_PARALLEL_SUBDIR_BUILD
=1 ||
{ final_exit
="exit 1"; $$dk; };, \
249 $(foreach subdir
,$(PROFILE_PARALLEL_SUBDIRS
),$(MAKE
) -C
$(subdir
) $* ||
{ final_exit
="exit 1"; $$dk; };))) \
250 $(if
$(FACADES_FOLDER
), \
251 $(MAKE
) -C
$(FACADES_FOLDER
) $* ||
{ final_exit
="exit 1"; $$dk; }; \
255 ifdef ENABLE_PARALLEL_SUBDIR_BUILD
256 .PHONY
: $(PROFILE_PARALLEL_SUBDIRS
)
257 $(PROFILE_PARALLEL_SUBDIRS
):
258 @set .
$$MAKEFLAGS; \
263 # Parallel build support
265 # The variable $(PROFILE)_PARALLEL_SUBDIRS should be set to the list of directories
266 # which could be built in parallel. These directories are built after the directories in
267 # $(PROFILE)_SUBDIRS.
268 # Parallel building is currently only supported for the 'all' target.
270 # Each directory's Makefile may define DEP_LIBS and DEP_DIRS to specify the libraries and
271 # directories it depends on.
273 ifneq ($(PROFILE_PARALLEL_SUBDIRS
),)
275 dep_dirs
= .dep_dirs-
$(PROFILE
)
278 # This should track dependencies better but the variable can be defined in any
279 # Makefile dependency. On top of that we should also regenerate when any of the
280 # PROFILE_PARALLEL_SUBDIRS Makefile's are changed
282 $(dep_dirs
): Makefile
283 $(if
$(V
),@echo
"Creating $(abspath $@)...",)
284 list
='$(PROFILE_PARALLEL_SUBDIRS)'; \
286 for d in
$$list; do \
287 $(MAKE
) -C
$$d gen-deps DEPS_TARGET_DIR
=$$d DEPS_FILE
=$(abspath
$@
); \
295 # The gen-deps target is in library.make/executable.make so it can pick up
301 clean-local
: clean-dep-dir
304 DIST_SUBDIRS
= $(SUBDIRS
) $(DIST_ONLY_SUBDIRS
)
306 dist-recursive
: dist-local
307 @case
'$(distdir)' in
[\\/$$]* | ?
:[\\/]* ) reldir
='$(distdir)' ;; *) reldir
='../$(distdir)' ;; esac
; \
308 list
='$(DIST_SUBDIRS)'; for d in
$$list ; do \
309 (cd
$$d && $(MAKE
) distdir
=$$reldir/$$d $@
) || exit
1 ; \
312 # function to dist files in groups of 100 entries to make sure we don't exceed shell char limits
313 define distfilesingroups
314 for f in
$(wordlist
1, 100, $(1)) ; do \
315 dest
=`dirname "$(distdir)/$$f"` ; \
316 $(MKINSTALLDIRS
) $$dest && cp
-p
"$$f" $$dest || exit
1 ; \
318 $(if
$(word 101, $(1)), $(call distfilesingroups
, $(wordlist
101, $(words $(1)), $(1))))
321 # The following target can be used like
323 # dist-local: dist-default
324 # ... additional commands ...
327 # 1. we invert the test here to not end in an error if ChangeLog doesn't exist.
328 # 2. we error out if we try to dist a nonexistant file.
329 # 3. we pick up Makefile
332 test '!' -f ChangeLog || cp ChangeLog
$(distdir
)
333 $(call distfilesingroups
, Makefile
$(DISTFILES
))
334 if
test -d Documentation
; then \
335 find .
-name
'*.xml' > .files
; \
336 tar cTf .files
- |
(cd
$(distdir
); tar xf
-) ; \
341 $(MKINSTALLDIRS
) $(@D
)
344 ## Documentation stuff
346 Q_MDOC
=$(if
$(V
),,@echo
"MDOC [$(PROFILE_DIRECTORY)] $(notdir $(@))";)
347 MDOC
=$(Q_MDOC
) MONO_PATH
="$(topdir)/class/lib/$(PROFILE_DIRECTORY)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME
) $(topdir
)/class
/lib
/$(PROFILE_DIRECTORY
)/mdoc.exe
349 Q_MDOC_UP
=$(if
$(V
),,@echo
"MDOC-UP [$(PROFILE_DIRECTORY)] $(notdir $(@))";)
350 MDOC_UP
=$(Q_MDOC_UP
) MONO_PATH
="$(topdir)/class/lib/$(PROFILE_DIRECTORY)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME
) $(topdir
)/class
/lib
/$(PROFILE_DIRECTORY
)/mdoc.exe update
--delete
-o Documentation
/en