[sgen] Scan pinned objects in nursery as part of concurrent mark
[mono.git] / mcs / build / rules.make
1 # -*- makefile -*-
2 #
3 # This is the makefile fragment with default rules
4 # for building things in MCS
5 #
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.
9
10 empty :=
11 space := $(empty) $(empty)
12
13 # given $(thisdir), we compute the path to the top directory
14 #
15 # split_path = $(filter-out .,$(subst /,$(space),$(1)))
16 # make_path = ./$(subst $(space),/,$(1))
17 # dotdottify = $(patsubst %,..,$(1))
18 # topdir = $(call make_path,$(call dotdottify,$(call split_path,$(thisdir))))
19 topdir := ./$(subst $(space),/,$(patsubst %,..,$(filter-out .,$(subst /,$(space),$(thisdir)))))
20
21 VERSION = 0.93
22
23 Q=$(if $(V),,@)
24 # echo -e "\\t" does not work on some systems, so use 5 spaces
25 Q_MCS=$(if $(V),,@echo "MCS     [$(intermediate)$(PROFILE)] $(notdir $(@))";)
26
27 ifndef BUILD_TOOLS_PROFILE
28 BUILD_TOOLS_PROFILE = build
29 endif
30
31 USE_MCS_FLAGS = /codepage:$(CODEPAGE) $(LOCAL_MCS_FLAGS) $(PLATFORM_MCS_FLAGS) $(PROFILE_MCS_FLAGS) $(MCS_FLAGS)
32 USE_MBAS_FLAGS = /codepage:$(CODEPAGE) $(LOCAL_MBAS_FLAGS) $(PLATFORM_MBAS_FLAGS) $(PROFILE_MBAS_FLAGS) $(MBAS_FLAGS)
33 USE_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS) $(CPPFLAGS)
34 CSCOMPILE = $(Q_MCS) $(MCS) $(USE_MCS_FLAGS)
35 BASCOMPILE = $(MBAS) $(USE_MBAS_FLAGS)
36 CCOMPILE = $(CC) $(USE_CFLAGS)
37 BOOT_COMPILE = $(Q_MCS) $(BOOTSTRAP_MCS) $(USE_MCS_FLAGS)
38 INSTALL = $(SHELL) $(topdir)/../mono/install-sh
39 INSTALL_DATA = $(INSTALL) -c -m 644
40 INSTALL_BIN = $(INSTALL) -c -m 755
41 INSTALL_LIB = $(INSTALL_BIN)
42 MKINSTALLDIRS = $(SHELL) $(topdir)/mkinstalldirs
43 INTERNAL_MBAS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/mbas/mbas.exe
44 INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/mcs.exe
45 INTERNAL_ILASM = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/ilasm.exe
46 corlib = mscorlib.dll
47
48 INTERNAL_RESGEN = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/resgen.exe
49 RESGEN = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_RESGEN)
50 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
51
52 depsdir = $(topdir)/build/deps
53
54 # Make sure these propagate if set manually
55
56 export PLATFORM
57 export PROFILE
58 export MCS
59 export MCS_FLAGS
60 export CC
61 export CFLAGS
62 export INSTALL
63 export MKINSTALLDIRS
64 export BOOTSTRAP_MCS
65 export DESTDIR
66 export RESGEN
67
68 # Get this so the platform.make platform-check rule doesn't become the
69 # default target
70
71 .DEFAULT: all
72 default: all
73
74 # Get initial configuration. pre-config is so that the builder can
75 # override PLATFORM or PROFILE
76
77 include $(topdir)/build/config-default.make
78 -include $(topdir)/build/pre-config.make
79 -include $(topdir)/build/config.make
80
81 # Default PLATFORM and PROFILE if they're not already defined.
82
83 ifndef PLATFORM
84 ifeq ($(OS),Windows_NT)
85 ifneq ($(V),)
86 $(info *** Assuming PLATFORM is 'win32'.)
87 endif
88 PLATFORM = win32
89 else
90 ifneq ($(V),)
91 $(info *** Assuming PLATFORM is 'linux'.)
92 endif
93 PLATFORM = linux
94 endif
95 endif
96
97 # Platform config
98
99 include $(topdir)/build/platforms/$(PLATFORM).make
100
101 ifdef PLATFORM_CORLIB
102 corlib = $(PLATFORM_CORLIB)
103 endif
104 # Useful
105
106 ifeq ($(PLATFORM_RUNTIME),$(RUNTIME))
107 PLATFORM_MONO_NATIVE = yes
108 endif
109
110 # Rest of the configuration
111
112 ifndef PROFILE
113 PROFILE = $(DEFAULT_PROFILE)
114 endif
115
116 include $(topdir)/build/profiles/$(PROFILE).make
117
118 # If the profile is using nunit-lite, use it
119 ifdef NUNIT_LITE
120 TEST_HARNESS=$(topdir)/class/lib/$(PROFILE)/nunit-lite-console.exe
121 endif
122
123 # Make sure propagates
124 export TEST_HARNESS
125
126 # If the profile is using nunit-lite, use it
127 ifdef NUNIT_LITE
128 TEST_HARNESS=$(topdir)/class/lib/$(PROFILE)/nunit-lite-console.exe
129 endif
130
131 # Make sure propagates
132 export TEST_HARNESS
133
134 # start aot config
135
136 # We set the prefix of the aot build flags
137 # in the profile. This determines the aot type,
138 # whether it be llvmonly or full. To this we append the
139 # options which do not change between them, the INVARIANT_AOT_OPTIONS
140 ifndef AOT_BUILD_FLAGS_PREFIX
141 AOT_BUILD_FLAGS_PREFIX = --aot=
142 endif
143
144 # Set the options for building and running AOT
145 # The trampoline numbers are provisional, they are what is required
146 # to run the corlib test suite. They should be considered a lower bound.
147 INVARIANT_AOT_OPTIONS=nimt-trampolines=900,ntrampolines=8000
148
149 ifndef MONO_DISABLE_GSHAREDVT
150 INVARIANT_AOT_OPTIONS:=$(INVARIANT_AOT_OPTIONS),ngsharedvt-trampolines=900
151 endif
152
153 AOT_BUILD_FLAGS = $(AOT_BUILD_FLAGS_PREFIX)$(INVARIANT_AOT_OPTIONS)
154
155 # end AOT config
156
157 ifdef BCL_OPTIMIZE
158 PROFILE_MCS_FLAGS += -optimize
159 endif
160
161 # Design:
162 # Problem: We want to be able to build aot
163 # assemblies as part of the build system. 
164 #
165 # For this to be done safely, we really need two passes. This
166 # ensures that all of the .dlls are compiled before trying to
167 # aot them. Because we want this to be the
168 # default target for some profiles(mobile_static) we have a
169 # two-level build system. The do-all-aot target is what
170 # gets invoked at the top-level when someone tries to build with aot.
171 # It will invoke the do-all target, and will set TOP_LEVEL_DO for this
172 # recursive make call in order to prevent this recursive call from trying
173 # to build aot in each of the subdirs. After this is done, we will aot
174 # everything that our building produced by aoting everything in
175 # mcs/class/lib/$(PROFILE)/
176 ifndef TOP_LEVEL_DO
177
178 ifdef ALWAYS_AOT
179 TOP_LEVEL_DO = do-all-aot
180 else
181 TOP_LEVEL_DO = do-all
182 endif # ALWAYS_AOT
183
184 endif # !TOP_LEVEL_DO
185
186 ifdef OVERRIDE_TARGET_ALL
187 all: all.override
188 else
189 all: $(TOP_LEVEL_DO)
190 endif
191
192 ifdef NO_INSTALL
193 GACUTIL = :
194 else
195 gacutil = $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/gacutil.exe
196 GACUTIL = MONO_PATH="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(gacutil)
197 endif
198
199 STD_TARGETS = test run-test run-test-ondotnet clean install uninstall doc-update
200
201 $(STD_TARGETS): %: do-%
202
203 ifdef PLATFORM_AOT_SUFFIX
204 Q_AOT=$(if $(V),,@echo "AOT     [$(PROFILE)] AOT All Assemblies";)
205 LIST_ALL_PROFILE_ASSEMBLIES = find . | grep -E '(dll|exe)$$' | grep -v -E 'bare|plaincore|secxml|Facades'
206 COMPILE_ALL_PROFILE_ASSEMBLIES = $(LIST_ALL_PROFILE_ASSEMBLIES) | MONO_PATH="./" xargs -I '{}' $(RUNTIME) $(RUNTIME_FLAGS) $(AOT_BUILD_FLAGS) '{}'
207
208 do-all-aot:
209         $(MAKE) do-all TOP_LEVEL_DO=do-all
210         $(MAKE) aot-all-profile
211
212 aot-all-profile:
213         $(Q_AOT) cd $(topdir)/class/lib/$(PROFILE)/ && $(COMPILE_ALL_PROFILE_ASSEMBLIES) &> $(PROFILE)-aot.log
214 endif
215
216 do-run-test:
217         ok=:; $(MAKE) run-test-recursive || ok=false; $(MAKE) run-test-local || ok=false; $$ok
218
219 do-%: %-recursive
220         $(MAKE) $*-local
221
222 .PHONY: all-local $(STD_TARGETS:=-local)
223 all-local $(STD_TARGETS:=-local):
224
225 csproj: do-csproj
226
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 := $($(PROFILE)_SUBDIRS)
232 ifndef PROFILE_SUBDIRS
233 PROFILE_SUBDIRS = $(SUBDIRS)
234 endif
235
236 # These subdirs can be built in parallel
237 PROFILE_PARALLEL_SUBDIRS := $($(PROFILE)_PARALLEL_SUBDIRS)
238 ifndef PROFILE_PARALLEL_SUBDIRS
239 PROFILE_PARALLEL_SUBDIRS = $(PARALLEL_SUBDIRS)
240 endif
241
242 ifndef FRAMEWORK_VERSION_MAJOR
243 FRAMEWORK_VERSION_MAJOR = $(basename $(FRAMEWORK_VERSION))
244 endif
245
246 %-recursive:
247         @set . $$MAKEFLAGS; final_exit=:; \
248         case $$2 in --unix) shift ;; esac; \
249         case $$2 in *=*) dk="exit 1" ;; *k*) dk=: ;; *) dk="exit 1" ;; esac; \
250         list='$(PROFILE_SUBDIRS)'; for d in $$list ; do \
251             (cd $$d && $(MAKE) $*) || { final_exit="exit 1"; $$dk; } ; \
252         done; \
253         if [ $* = "all" -a -n "$(PROFILE_PARALLEL_SUBDIRS)" ]; then \
254                 $(MAKE) do-all-parallel ENABLE_PARALLEL_SUBDIR_BUILD=1 || { final_exit="exit 1"; $$dk; } ; \
255         else \
256                 list='$(PROFILE_PARALLEL_SUBDIRS)'; for d in $$list ; do \
257                     (cd $$d && $(MAKE) $*) || { final_exit="exit 1"; $$dk; } ; \
258                 done; \
259         fi; \
260         $$final_exit
261
262 #
263 # Parallel build support
264 #
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.
269 #
270 # Each directory's Makefile may define DEP_LIBS and DEP_DIRS to specify the libraries and
271 # directories it depends on.
272 #
273 ifneq ($(PROFILE_PARALLEL_SUBDIRS),)
274 dep_dirs = .dep_dirs-$(PROFILE)
275 $(dep_dirs):
276         @echo "Creating $@..."
277         list='$(PROFILE_PARALLEL_SUBDIRS)'; \
278         echo > $@; \
279         for d in $$list; do \
280                 $(MAKE) -C $$d gen-deps DEPS_TARGET_DIR=$$d DEPS_FILE=$(abspath $@); \
281         done
282 -include $(dep_dirs)
283 endif
284
285 .PHONY: gen-deps
286 # The gen-deps target is in library.make/executable.make so it can pick up
287 # DEP_LIBS/DEP_DIRS
288
289 clean-dep-dir:
290         $(RM) $(dep_dirs)
291
292 clean-local: clean-dep-dir
293
294 ifdef ENABLE_PARALLEL_SUBDIR_BUILD
295 .PHONY: do-all-parallel $(PROFILE_PARALLEL_SUBDIRS)
296
297 do-all-parallel: $(PROFILE_PARALLEL_SUBDIRS)
298
299 $(PROFILE_PARALLEL_SUBDIRS):
300         @set . $$MAKEFLAGS; \
301         cd $@ && $(MAKE)
302 endif
303
304 ifndef DIST_SUBDIRS
305 DIST_SUBDIRS = $(SUBDIRS) $(DIST_ONLY_SUBDIRS)
306 endif
307 dist-recursive: dist-local
308         @case '$(distdir)' in [\\/$$]* | ?:[\\/]* ) reldir='$(distdir)' ;; *) reldir='../$(distdir)' ;; esac ; \
309         list='$(DIST_SUBDIRS)'; for d in $$list ; do \
310             (cd $$d && $(MAKE) distdir=$$reldir/$$d $@) || exit 1 ; \
311         done
312
313 # The following target can be used like
314 #
315 #   dist-local: dist-default
316 #       ... additional commands ...
317 #
318 # Notes:
319 #  1. we invert the test here to not end in an error if ChangeLog doesn't exist.
320 #  2. we error out if we try to dist a nonexistant file.
321 #  3. we pick up Makefile, makefile, or GNUmakefile.
322 dist-default:
323         -mkdir -p $(distdir)
324         test '!' -f ChangeLog || cp ChangeLog $(distdir)
325         if test -f Makefile; then m=M; fi; \
326         if test -f makefile; then m=m; fi; \
327         if test -f GNUmakefile; then m=GNUm; fi; \
328         for f in $${m}akefile $(DISTFILES) ; do \
329             dest=`dirname "$(distdir)/$$f"` ; \
330             $(MKINSTALLDIRS) $$dest && cp -p "$$f" $$dest || exit 1 ; \
331         done
332         if test -d Documentation ; then \
333                 find . -name '*.xml' > .files ; \
334                 tar cTf .files - | (cd $(distdir); tar xf -) ; \
335                 rm .files ; \
336         fi
337
338 %/.stamp:
339         $(MKINSTALLDIRS) $(@D)
340         touch $@
341
342 ## Documentation stuff
343
344 Q_MDOC =$(if $(V),,@echo "MDOC    [$(PROFILE)] $(notdir $(@))";)
345 MDOC   =$(Q_MDOC) MONO_PATH="$(topdir)/class/lib/$(DEFAULT_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(topdir)/class/lib/$(DEFAULT_PROFILE)/mdoc.exe
346