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