Merge pull request #3965 from akoeplinger/ppc-disable-tests
[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 Q_AOT=$(if $(V),,@echo "AOT     [$(intermediate)$(PROFILE)] $(notdir $(@))";)
27
28 ifndef BUILD_TOOLS_PROFILE
29 BUILD_TOOLS_PROFILE = build
30 endif
31
32 USE_MCS_FLAGS = /codepage:$(CODEPAGE) $(LOCAL_MCS_FLAGS) $(PLATFORM_MCS_FLAGS) $(PROFILE_MCS_FLAGS) $(MCS_FLAGS)
33 USE_MBAS_FLAGS = /codepage:$(CODEPAGE) $(LOCAL_MBAS_FLAGS) $(PLATFORM_MBAS_FLAGS) $(PROFILE_MBAS_FLAGS) $(MBAS_FLAGS)
34 USE_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS) $(CPPFLAGS)
35 CSCOMPILE = $(Q_MCS) $(MCS) $(USE_MCS_FLAGS)
36 BASCOMPILE = $(MBAS) $(USE_MBAS_FLAGS)
37 CCOMPILE = $(CC) $(USE_CFLAGS)
38 BOOT_COMPILE = $(Q_MCS) $(BOOTSTRAP_MCS) $(USE_MCS_FLAGS)
39 INSTALL = $(SHELL) $(topdir)/../mono/install-sh
40 INSTALL_DATA = $(INSTALL) -c -m 644
41 INSTALL_BIN = $(INSTALL) -c -m 755
42 INSTALL_LIB = $(INSTALL_BIN)
43 MKINSTALLDIRS = $(SHELL) $(topdir)/mkinstalldirs
44 INTERNAL_MBAS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/mbas/mbas.exe
45 INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/mcs.exe
46 INTERNAL_ILASM = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/ilasm.exe
47 INTERNAL_CSC = $(RUNTIME) $(RUNTIME_FLAGS) $(CSC_LOCATION)
48
49 RESGEN_EXE = $(topdir)/class/lib/$(PROFILE)/$(PARENT_PROFILE)resgen.exe
50 INTERNAL_RESGEN = $(RUNTIME) $(RUNTIME_FLAGS) $(RESGEN_EXE)
51 RESGEN = MONO_PATH="$(topdir)/class/lib/$(PROFILE)/$(PARENT_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_RESGEN)
52 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
53
54 depsdir = $(topdir)/build/deps
55
56 # Make sure these propagate if set manually
57
58 export PLATFORM
59 export PROFILE
60 export MCS
61 export MCS_FLAGS
62 export CC
63 export CFLAGS
64 export INSTALL
65 export MKINSTALLDIRS
66 export BOOTSTRAP_MCS
67 export DESTDIR
68 export RESGEN
69
70 # Get this so the platform.make platform-check rule doesn't become the
71 # default target
72
73 .DEFAULT: all
74 default: all
75
76 # Get initial configuration. pre-config is so that the builder can
77 # override PLATFORM or PROFILE
78
79 include $(topdir)/build/config-default.make
80 -include $(topdir)/build/pre-config.make
81 -include $(topdir)/build/config.make
82
83 # Default PLATFORM and PROFILE if they're not already defined.
84
85 ifndef PLATFORM
86 ifeq ($(OS),Windows_NT)
87 ifneq ($(V),)
88 $(info *** Assuming PLATFORM is 'win32'.)
89 endif
90 PLATFORM = win32
91 else
92 ifneq ($(V),)
93 $(info *** Assuming PLATFORM is 'linux'.)
94 endif
95 PLATFORM = linux
96 endif
97 endif
98
99 # Platform config
100
101 include $(topdir)/build/platforms/$(PLATFORM).make
102
103 ifdef PLATFORM_CORLIB
104 corlib = $(PLATFORM_CORLIB)
105 endif
106 # Useful
107
108 ifeq ($(PLATFORM_RUNTIME),$(RUNTIME))
109 PLATFORM_MONO_NATIVE = yes
110 endif
111
112 # Rest of the configuration
113
114 ifndef PROFILE
115 PROFILE = $(DEFAULT_PROFILE)
116 endif
117
118 include $(topdir)/build/profiles/$(PROFILE).make
119
120 ifdef BCL_OPTIMIZE
121 PROFILE_MCS_FLAGS += -optimize
122 endif
123
124 # Design:
125 # Problem: We want to be able to build aot
126 # assemblies as part of the build system. 
127 #
128 # For this to be done safely, we really need two passes. This
129 # ensures that all of the .dlls are compiled before trying to
130 # aot them. Because we want this to be the
131 # default target for some profiles(mobile_static) we have a
132 # two-level build system. The do-all-aot target is what
133 # gets invoked at the top-level when someone tries to build with aot.
134 # It will invoke the do-all target, and will set TOP_LEVEL_DO for this
135 # recursive make call in order to prevent this recursive call from trying
136 # to build aot in each of the subdirs. After this is done, we will aot
137 # everything that our building produced by aoting everything in
138 # mcs/class/lib/$(PROFILE)/
139 ifndef TOP_LEVEL_DO
140
141 ifdef ALWAYS_AOT
142 TOP_LEVEL_DO = do-all-aot
143 else
144 TOP_LEVEL_DO = do-all
145 endif # ALWAYS_AOT
146
147 endif # !TOP_LEVEL_DO
148
149 ifdef OVERRIDE_TARGET_ALL
150 all: all.override
151 else
152 all: $(TOP_LEVEL_DO)
153 endif
154
155 ifdef NO_INSTALL
156 GACUTIL = :
157 else
158 gacutil = $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/gacutil.exe
159 GACUTIL = MONO_PATH="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(gacutil)
160 endif
161
162 STD_TARGETS = test run-test run-test-ondotnet clean install uninstall doc-update
163
164 $(STD_TARGETS): %: do-%
165
166 ifdef PLATFORM_AOT_SUFFIX
167
168 do-all-aot:
169         $(MAKE) do-all TOP_LEVEL_DO=do-all
170         $(MAKE) aot-all-profile
171
172 # When we recursively call $(MAKE) aot-all-profile
173 # we will have created this directory, and so will
174 # be able to evaluate the .dylibs to make
175 ifneq ("$(wildcard $(topdir)/class/lib/$(PROFILE))","")
176
177 AOT_PROFILE_ASSEMBLIES := $(sort $(patsubst .//%,%,$(filter-out %bare% %plaincore% %secxml% %Facades% %ilasm%,$(filter %.dll %.exe,$(wildcard $(topdir)/class/lib/$(PROFILE)/*)))))
178
179 # This can run in parallel
180 .PHONY: aot-all-profile
181 aot-all-profile: $(patsubst %,%$(PLATFORM_AOT_SUFFIX),$(AOT_PROFILE_ASSEMBLIES))
182
183 %$(PLATFORM_AOT_SUFFIX): %
184         @ mkdir -p $*_bitcode_tmp
185         $(Q_AOT) MONO_PATH="$(dir $*)" $(RUNTIME) $(RUNTIME_FLAGS) $(AOT_BUILD_FLAGS),temp-path=$*_bitcode_tmp --verbose $* > $@.aot-log
186         @ rm -rf $*_bitcode_tmp
187
188 endif #ifneq ("$(wildcard $(topdir)/class/lib/$(PROFILE))","")
189
190 endif # PLATFORM_AOT_SUFFIX
191
192 do-run-test:
193         ok=:; $(MAKE) run-test-recursive || ok=false; $(MAKE) run-test-local || ok=false; $$ok
194
195 do-%: %-recursive
196         $(MAKE) $*-local
197
198 .PHONY: all-local $(STD_TARGETS:=-local)
199 all-local $(STD_TARGETS:=-local):
200
201 csproj: do-csproj
202
203 # The way this is set up, any profile-specific subdirs list should
204 # be listed _before_ including rules.make.  However, the default
205 # SUBDIRS list can come after, so don't use the eager := syntax when
206 # using the defaults.
207 PROFILE_SUBDIRS := $($(PROFILE)_SUBDIRS)
208 ifndef PROFILE_SUBDIRS
209 PROFILE_SUBDIRS = $(SUBDIRS)
210 endif
211
212 # These subdirs can be built in parallel
213 PROFILE_PARALLEL_SUBDIRS := $($(PROFILE)_PARALLEL_SUBDIRS)
214 ifndef PROFILE_PARALLEL_SUBDIRS
215 PROFILE_PARALLEL_SUBDIRS = $(PARALLEL_SUBDIRS)
216 endif
217
218 ifndef FRAMEWORK_VERSION_MAJOR
219 FRAMEWORK_VERSION_MAJOR = $(basename $(FRAMEWORK_VERSION))
220 endif
221
222 %-recursive:
223         @set . $$MAKEFLAGS; final_exit=:; \
224         case $$2 in --unix) shift ;; esac; \
225         case $$2 in *=*) dk="exit 1" ;; *k*) dk=: ;; *) dk="exit 1" ;; esac; \
226         list='$(PROFILE_SUBDIRS)'; for d in $$list ; do \
227             (cd $$d && $(MAKE) $*) || { final_exit="exit 1"; $$dk; } ; \
228         done; \
229         if [ $* = "all" -a -n "$(PROFILE_PARALLEL_SUBDIRS)" ]; then \
230                 $(MAKE) do-all-parallel ENABLE_PARALLEL_SUBDIR_BUILD=1 || { final_exit="exit 1"; $$dk; } ; \
231         else \
232                 list='$(PROFILE_PARALLEL_SUBDIRS)'; for d in $$list ; do \
233                     (cd $$d && $(MAKE) $*) || { final_exit="exit 1"; $$dk; } ; \
234                 done; \
235         fi; \
236         $$final_exit
237
238 #
239 # Parallel build support
240 #
241 # The variable $(PROFILE)_PARALLEL_SUBDIRS should be set to the list of directories
242 # which could be built in parallel. These directories are built after the directories in
243 # $(PROFILE)_SUBDIRS.
244 # Parallel building is currently only supported for the 'all' target.
245 #
246 # Each directory's Makefile may define DEP_LIBS and DEP_DIRS to specify the libraries and
247 # directories it depends on.
248 #
249 ifneq ($(PROFILE_PARALLEL_SUBDIRS),)
250 dep_dirs = .dep_dirs-$(PROFILE)
251 $(dep_dirs):
252         @echo "Creating $@..."
253         list='$(PROFILE_PARALLEL_SUBDIRS)'; \
254         echo > $@; \
255         for d in $$list; do \
256                 $(MAKE) -C $$d gen-deps DEPS_TARGET_DIR=$$d DEPS_FILE=$(abspath $@); \
257         done
258 -include $(dep_dirs)
259 endif
260
261 .PHONY: gen-deps
262 # The gen-deps target is in library.make/executable.make so it can pick up
263 # DEP_LIBS/DEP_DIRS
264
265 clean-dep-dir:
266         $(RM) $(dep_dirs)
267
268 clean-local: clean-dep-dir
269
270 ifdef ENABLE_PARALLEL_SUBDIR_BUILD
271 .PHONY: do-all-parallel $(PROFILE_PARALLEL_SUBDIRS)
272
273 do-all-parallel: $(PROFILE_PARALLEL_SUBDIRS)
274
275 $(PROFILE_PARALLEL_SUBDIRS):
276         @set . $$MAKEFLAGS; \
277         cd $@ && $(MAKE)
278 endif
279
280 ifndef DIST_SUBDIRS
281 DIST_SUBDIRS = $(SUBDIRS) $(DIST_ONLY_SUBDIRS)
282 endif
283 dist-recursive: dist-local
284         @case '$(distdir)' in [\\/$$]* | ?:[\\/]* ) reldir='$(distdir)' ;; *) reldir='../$(distdir)' ;; esac ; \
285         list='$(DIST_SUBDIRS)'; for d in $$list ; do \
286             (cd $$d && $(MAKE) distdir=$$reldir/$$d $@) || exit 1 ; \
287         done
288
289 # The following target can be used like
290 #
291 #   dist-local: dist-default
292 #       ... additional commands ...
293 #
294 # Notes:
295 #  1. we invert the test here to not end in an error if ChangeLog doesn't exist.
296 #  2. we error out if we try to dist a nonexistant file.
297 #  3. we pick up Makefile, makefile, or GNUmakefile.
298 dist-default:
299         -mkdir -p $(distdir)
300         test '!' -f ChangeLog || cp ChangeLog $(distdir)
301         if test -f Makefile; then m=M; fi; \
302         if test -f makefile; then m=m; fi; \
303         if test -f GNUmakefile; then m=GNUm; fi; \
304         for f in $${m}akefile $(DISTFILES) ; do \
305             dest=`dirname "$(distdir)/$$f"` ; \
306             $(MKINSTALLDIRS) $$dest && cp -p "$$f" $$dest || exit 1 ; \
307         done
308         if test -d Documentation ; then \
309                 find . -name '*.xml' > .files ; \
310                 tar cTf .files - | (cd $(distdir); tar xf -) ; \
311                 rm .files ; \
312         fi
313
314 %/.stamp:
315         $(MKINSTALLDIRS) $(@D)
316         touch $@
317
318 ## Documentation stuff
319
320 Q_MDOC =$(if $(V),,@echo "MDOC    [$(PROFILE)] $(notdir $(@))";)
321 MDOC   =$(Q_MDOC) MONO_PATH="$(topdir)/class/lib/$(DEFAULT_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(topdir)/class/lib/$(DEFAULT_PROFILE)/mdoc.exe
322