[bcl] Write newline-separated nunit/xunit excludes file for sdks archive (#14681)
[mono-project.git] / mcs / build / rules.make
blobb4c9df715754ae498984361e903418a8c819699a
1 # -*- makefile -*-
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.
10 empty :=
11 space := $(empty) $(empty)
12 comma := ,
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)))))
23 VERSION = 0.93
25 Q=$(if $(V),,@)
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
32 endif
34 ifeq ("$(ENABLE_COMPILER_SERVER)","1")
35 COMPILER_SERVER_ARGS=/shared:$(COMPILER_SERVER_PIPENAME)
36 CSC_LOCATION=$(SERVER_CSC_LOCATION)
37 else
38 COMPILER_SERVER_ARGS:=
39 CSC_LOCATION=$(STANDALONE_CSC_LOCATION)
40 endif
42 USE_MCS_FLAGS = $(COMPILER_SERVER_ARGS) /codepage:$(CODEPAGE) /nologo /noconfig /deterministic $(LOCAL_MCS_FLAGS) $(PLATFORM_MCS_FLAGS) $(PROFILE_MCS_FLAGS) $(MCS_FLAGS)
43 USE_MBAS_FLAGS = $(COMPILER_SERVER_ARGS) /codepage:$(CODEPAGE) $(LOCAL_MBAS_FLAGS) $(PLATFORM_MBAS_FLAGS) $(PROFILE_MBAS_FLAGS) $(MBAS_FLAGS)
44 USE_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS) $(CPPFLAGS)
45 CSCOMPILE = $(Q_MCS) $(MCS) $(USE_MCS_FLAGS)
46 CSC_RUNTIME_FLAGS = --aot-path=$(abspath $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)) --gc-params=nursery-size=64m
47 BASCOMPILE = $(MBAS) $(USE_MBAS_FLAGS)
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_MBAS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/mbas/mbas.exe
56 INTERNAL_CSC_LOCATION = $(CSC_LOCATION)
58 # Using CSC_SDK_PATH_DISABLED for sanity check that all references have path specified
59 INTERNAL_CSC = CSC_SDK_PATH_DISABLED= $(RUNTIME) $(RUNTIME_FLAGS) $(CSC_RUNTIME_FLAGS) $(INTERNAL_CSC_LOCATION)
61 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
62 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
63 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
64 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
66 depsdir = $(topdir)/build/deps
68 # Make sure these propagate if set manually
70 export PROFILE
71 export MCS
72 export MCS_FLAGS
73 export CC
74 export CFLAGS
75 export INSTALL
76 export MKINSTALLDIRS
77 export BOOTSTRAP_MCS
78 export DESTDIR
79 export RESGEN
81 # Get this so the platform.make platform-check rule doesn't become the
82 # default target
84 .DEFAULT: all
85 default: all
87 # Get initial configuration. pre-config is so that the builder can
88 # override BUILD_PLATFORM or PROFILE
90 include $(topdir)/build/config-default.make
91 -include $(topdir)/build/pre-config.make
92 -include $(topdir)/build/config.make
94 # Platform config
96 include $(topdir)/build/platforms/$(BUILD_PLATFORM).make
98 PROFILE_PLATFORM = $(if $(PLATFORMS),$(if $(filter $(PLATFORMS),$(HOST_PLATFORM)),$(HOST_PLATFORM),$(error Unknown platform "$(HOST_PLATFORM)" for profile "$(PROFILE)")))
99 PROFILE_DIRECTORY = $(PROFILE)$(if $(PROFILE_PLATFORM),-$(PROFILE_PLATFORM))
101 ifdef PLATFORM_CORLIB
102 corlib = $(PLATFORM_CORLIB)
103 endif
104 # Useful
106 ifeq ($(PLATFORM_RUNTIME),$(RUNTIME))
107 PLATFORM_MONO_NATIVE = yes
108 endif
110 # Rest of the configuration
112 ifndef PROFILE
113 PROFILE = $(DEFAULT_PROFILE)
114 endif
116 include $(topdir)/build/profiles/$(PROFILE).make
118 ifdef BCL_OPTIMIZE
119 PROFILE_MCS_FLAGS += -optimize
120 endif
122 ifdef MCS_MODE
123 INTERNAL_CSC_LOCATION = $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/mcs.exe
125 ifdef PLATFORM_DEBUG_FLAGS
126 PLATFORM_DEBUG_FLAGS = /debug:full
127 endif
129 endif
131 # Design:
132 # Problem: We want to be able to build aot
133 # assemblies as part of the build system.
135 # For this to be done safely, we really need two passes. This
136 # ensures that all of the .dlls are compiled before trying to
137 # aot them. Because we want this to be the
138 # default target for some profiles(testing_aot_full) we have a
139 # two-level build system. The do-all-aot target is what
140 # gets invoked at the top-level when someone tries to build with aot.
141 # It will invoke the do-all target, and will set TOP_LEVEL_DO for this
142 # recursive make call in order to prevent this recursive call from trying
143 # to build aot in each of the subdirs. After this is done, we will aot
144 # everything that our building produced by aoting everything in
145 # mcs/class/lib/$(PROFILE)/
146 ifndef TOP_LEVEL_DO
148 ifneq ($(or $(ALWAYS_AOT_BCL), $(ALWAYS_AOT_TESTS)),)
149 TOP_LEVEL_DO = do-all-aot
150 else
151 TOP_LEVEL_DO = do-all
152 endif
154 endif # !TOP_LEVEL_DO
156 ifdef OVERRIDE_TARGET_ALL
157 all: all.override
158 else
159 all: $(TOP_LEVEL_DO)
160 endif
162 ifdef NO_INSTALL
163 GACUTIL = :
164 else
165 gacutil = $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/gacutil.exe
166 GACUTIL = MONO_PATH="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(gacutil)
167 endif
169 STD_TARGETS = test xunit-test run-test run-xunit-test run-test-ondotnet clean install uninstall doc-update
171 $(STD_TARGETS): %: do-%
173 ifdef PLATFORM_AOT_SUFFIX
175 do-all-aot:
176 $(MAKE) do-all TOP_LEVEL_DO=do-all
177 $(MAKE) aot-all-profile
179 # When we recursively call $(MAKE) aot-all-profile
180 # we will have created this directory, and so will
181 # be able to evaluate the .dylibs to make
182 ifneq ("$(wildcard $(topdir)/class/lib/$(PROFILE))","")
184 ifdef ALWAYS_AOT_BCL
185 AOT_PROFILE_ASSEMBLIES := $(sort $(patsubst .//%,%,$(filter-out %.dll.dll %.exe.dll %bare% %plaincore% %secxml% %Facades% %ilasm%,$(filter %.dll %.exe,$(wildcard $(topdir)/class/lib/$(PROFILE)/*)))))
186 AOT_PROFILE_ASSEMBLIES_OUT := $(patsubst %,%$(PLATFORM_AOT_SUFFIX),$(AOT_PROFILE_ASSEMBLIES))
188 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/*)))))
189 AOT_PROFILE_FACADES_OUT := $(patsubst %,%$(PLATFORM_AOT_SUFFIX),$(AOT_PROFILE_FACADES))
190 endif
192 ifdef ALWAYS_AOT_TESTS
193 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/*)))))
194 AOT_PROFILE_TESTS_OUT := $(patsubst %,%$(PLATFORM_AOT_SUFFIX),$(AOT_PROFILE_TESTS))
195 endif
197 # This can run in parallel
198 .PHONY: aot-all-profile
199 ifdef AOT_BUILD_FLAGS
200 aot-all-profile: $(AOT_PROFILE_ASSEMBLIES_OUT) $(AOT_PROFILE_TESTS_OUT) $(AOT_PROFILE_FACADES_OUT)
201 else
202 aot-all-profile:
203 echo AOT_BUILD_FLAGS not set, skipping AOT.
204 endif
206 %.dll$(PLATFORM_AOT_SUFFIX): %.dll
207 @ mkdir -p $<_bitcode_tmp
208 $(Q_AOT) MONO_PATH="$(topdir)/class/lib/$(PROFILE)" $(RUNTIME) $(RUNTIME_FLAGS) $(AOT_BUILD_FLAGS),temp-path=$<_bitcode_tmp $<
209 @ rm -rf $<_bitcode_tmp
211 %.exe$(PLATFORM_AOT_SUFFIX): %.exe
212 @ mkdir -p $<_bitcode_tmp
213 $(Q_AOT) MONO_PATH="$(topdir)/class/lib/$(PROFILE)" $(RUNTIME) $(RUNTIME_FLAGS) $(AOT_BUILD_FLAGS),temp-path=$<_bitcode_tmp $<
214 @ rm -rf $<_bitcode_tmp
216 endif #ifneq ("$(wildcard $(topdir)/class/lib/$(PROFILE))","")
218 endif # PLATFORM_AOT_SUFFIX
220 do-run-test:
221 ok=:; $(MAKE) run-test-recursive || ok=false; $(MAKE) run-test-local || ok=false; $$ok
223 do-%: %-recursive
224 $(MAKE) $*-local
226 .PHONY: all-local $(STD_TARGETS:=-local)
227 all-local $(STD_TARGETS:=-local):
229 csproj: do-csproj
231 # The way this is set up, any profile-specific subdirs list should
232 # be listed _before_ including rules.make. However, the default
233 # SUBDIRS list can come after, so don't use the eager := syntax when
234 # using the defaults.
235 PROFILE_SUBDIRS = $(or $($(PROFILE)_SUBDIRS),$(SUBDIRS))
237 # These subdirs can be built in parallel
238 PROFILE_PARALLEL_SUBDIRS = $(or $($(PROFILE)_PARALLEL_SUBDIRS),$(PARALLEL_SUBDIRS))
240 ifndef FRAMEWORK_VERSION_MAJOR
241 FRAMEWORK_VERSION_MAJOR = $(basename $(FRAMEWORK_VERSION))
242 endif
244 %-recursive:
245 @set . $$MAKEFLAGS; \
246 case $$2 in --unix) shift ;; esac; \
247 case $$2 in *=*) dk="exit 1" ;; *k*) dk=: ;; *) dk="exit 1" ;; esac; \
248 final_exit=:; \
249 $(foreach subdir,$(PROFILE_SUBDIRS),$(MAKE) -C $(subdir) $* || { final_exit="exit 1"; $$dk; };) \
250 $(if $(PROFILE_PARALLEL_SUBDIRS), \
251 $(if $(filter $*,all), \
252 $(MAKE) $(PROFILE_PARALLEL_SUBDIRS) ENABLE_PARALLEL_SUBDIR_BUILD=1 || { final_exit="exit 1"; $$dk; };, \
253 $(foreach subdir,$(PROFILE_PARALLEL_SUBDIRS),$(MAKE) -C $(subdir) $* || { final_exit="exit 1"; $$dk; };))) \
254 $(if $(FACADES_FOLDER), \
255 $(MAKE) -C $(FACADES_FOLDER) $* || { final_exit="exit 1"; $$dk; }; \
257 $$final_exit
259 ifdef ENABLE_PARALLEL_SUBDIR_BUILD
260 .PHONY: $(PROFILE_PARALLEL_SUBDIRS)
261 $(PROFILE_PARALLEL_SUBDIRS):
262 @set . $$MAKEFLAGS; \
263 $(MAKE) -C $@ all
264 endif
267 # Parallel build support
269 # The variable $(PROFILE)_PARALLEL_SUBDIRS should be set to the list of directories
270 # which could be built in parallel. These directories are built after the directories in
271 # $(PROFILE)_SUBDIRS.
272 # Parallel building is currently only supported for the 'all' target.
274 # Each directory's Makefile may define DEP_LIBS and DEP_DIRS to specify the libraries and
275 # directories it depends on.
277 ifneq ($(PROFILE_PARALLEL_SUBDIRS),)
279 dep_dirs = .dep_dirs-$(PROFILE)
282 # This should track dependencies better but the variable can be defined in any
283 # Makefile dependency. On top of that we should also regenerate when any of the
284 # PROFILE_PARALLEL_SUBDIRS Makefile's are changed
286 $(dep_dirs): Makefile
287 $(if $(V),@echo "Creating $(abspath $@)...",)
288 list='$(PROFILE_PARALLEL_SUBDIRS)'; \
289 echo > $@; \
290 for d in $$list; do \
291 $(MAKE) -C $$d gen-deps DEPS_TARGET_DIR=$$d DEPS_FILE=$(abspath $@); \
292 done
294 -include $(dep_dirs)
296 endif
298 .PHONY: gen-deps
299 # The gen-deps target is in library.make/executable.make so it can pick up
300 # DEP_LIBS/DEP_DIRS
302 clean-dep-dir:
303 $(RM) $(dep_dirs)
305 clean-local: clean-dep-dir
307 ifndef DIST_SUBDIRS
308 DIST_SUBDIRS = $(SUBDIRS) $(DIST_ONLY_SUBDIRS)
309 endif
310 dist-recursive: dist-local
311 @case '$(distdir)' in [\\/$$]* | ?:[\\/]* ) reldir='$(distdir)' ;; *) reldir='../$(distdir)' ;; esac ; \
312 list='$(DIST_SUBDIRS)'; for d in $$list ; do \
313 (cd $$d && $(MAKE) distdir=$$reldir/$$d $@) || exit 1 ; \
314 done
316 # function to dist files in groups of 100 entries to make sure we don't exceed shell char limits
317 define distfilesingroups
318 for f in $(wordlist 1, 100, $(1)) ; do \
319 dest=`dirname "$(distdir)/$$f"` ; \
320 $(MKINSTALLDIRS) $$dest && cp -p "$$f" $$dest || exit 1 ; \
321 done
322 $(if $(word 101, $(1)), $(call distfilesingroups, $(wordlist 101, $(words $(1)), $(1))))
323 endef
325 # The following target can be used like
327 # dist-local: dist-default
328 # ... additional commands ...
330 # Notes:
331 # 1. we invert the test here to not end in an error if ChangeLog doesn't exist.
332 # 2. we error out if we try to dist a nonexistant file.
333 # 3. we pick up Makefile
334 dist-default:
335 -mkdir -p $(distdir)
336 test '!' -f ChangeLog || cp ChangeLog $(distdir)
337 $(call distfilesingroups, Makefile $(DISTFILES))
338 if test -d Documentation ; then \
339 find . -name '*.xml' > .files ; \
340 tar cTf .files - | (cd $(distdir); tar xf -) ; \
341 rm .files ; \
344 %/.stamp:
345 $(MKINSTALLDIRS) $(@D)
346 touch $@
348 ## Documentation stuff
350 Q_MDOC =$(if $(V),,@echo "MDOC [$(PROFILE_DIRECTORY)] $(notdir $(@))";)
351 MDOC =$(Q_MDOC) MONO_PATH="$(topdir)/class/lib/$(PROFILE_DIRECTORY)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(topdir)/class/lib/$(PROFILE_DIRECTORY)/mdoc.exe
353 Q_MDOC_UP=$(if $(V),,@echo "MDOC-UP [$(PROFILE_DIRECTORY)] $(notdir $(@))";)
354 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