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 # given $(thisdir), we compute the path to the top directory
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)))))
24 # echo -e "\\t" does not work on some systems, so use 5 spaces
25 Q_MCS=$(if $(V),,@echo "MCS [$(intermediate)$(PROFILE)] $(notdir $(@))";)
27 ifndef BUILD_TOOLS_PROFILE
28 BUILD_TOOLS_PROFILE = build
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
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)
51 depsdir = $(topdir)/build/deps
53 # Make sure these propagate if set manually
67 # Get this so the platform.make platform-check rule doesn't become the
73 # Get initial configuration. pre-config is so that the builder can
74 # override PLATFORM or PROFILE
76 include $(topdir)/build/config-default.make
77 -include $(topdir)/build/pre-config.make
78 -include $(topdir)/build/config.make
80 # Default PLATFORM and PROFILE if they're not already defined.
83 ifeq ($(OS),Windows_NT)
85 $(info *** Assuming PLATFORM is 'win32'.)
90 $(info *** Assuming PLATFORM is 'linux'.)
98 include $(topdir)/build/platforms/$(PLATFORM).make
100 ifdef PLATFORM_CORLIB
101 corlib = $(PLATFORM_CORLIB)
105 ifeq ($(PLATFORM_RUNTIME),$(RUNTIME))
106 PLATFORM_MONO_NATIVE = yes
109 # Rest of the configuration
112 PROFILE = $(DEFAULT_PROFILE)
115 include $(topdir)/build/profiles/$(PROFILE).make
117 # If the profile is using nunit-lite, use it
119 TEST_HARNESS=$(topdir)/class/lib/$(PROFILE)/nunit-lite-console.exe
122 # Make sure propagates
125 # If the profile is using nunit-lite, use it
127 TEST_HARNESS=$(topdir)/class/lib/$(PROFILE)/nunit-lite-console.exe
130 # Make sure propagates
134 PROFILE_MCS_FLAGS += -optimize
137 ifdef OVERRIDE_TARGET_ALL
146 gacutil = $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/gacutil.exe
147 GACUTIL = MONO_PATH="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(gacutil)
150 STD_TARGETS = test run-test run-test-ondotnet clean install uninstall doc-update
152 $(STD_TARGETS): %: do-%
155 ok=:; $(MAKE) run-test-recursive || ok=false; $(MAKE) run-test-local || ok=false; $$ok
160 .PHONY: all-local $(STD_TARGETS:=-local)
161 all-local $(STD_TARGETS:=-local):
165 # The way this is set up, any profile-specific subdirs list should
166 # be listed _before_ including rules.make. However, the default
167 # SUBDIRS list can come after, so don't use the eager := syntax when
168 # using the defaults.
169 PROFILE_SUBDIRS := $($(PROFILE)_SUBDIRS)
170 ifndef PROFILE_SUBDIRS
171 PROFILE_SUBDIRS = $(SUBDIRS)
174 # These subdirs can be built in parallel
175 PROFILE_PARALLEL_SUBDIRS := $($(PROFILE)_PARALLEL_SUBDIRS)
176 ifndef PROFILE_PARALLEL_SUBDIRS
177 PROFILE_PARALLEL_SUBDIRS = $(PARALLEL_SUBDIRS)
180 ifndef FRAMEWORK_VERSION_MAJOR
181 FRAMEWORK_VERSION_MAJOR = $(basename $(FRAMEWORK_VERSION))
185 @set . $$MAKEFLAGS; final_exit=:; \
186 case $$2 in --unix) shift ;; esac; \
187 case $$2 in *=*) dk="exit 1" ;; *k*) dk=: ;; *) dk="exit 1" ;; esac; \
188 list='$(PROFILE_SUBDIRS)'; for d in $$list ; do \
189 (cd $$d && $(MAKE) $*) || { final_exit="exit 1"; $$dk; } ; \
191 if [ $* = "all" -a -n "$(PROFILE_PARALLEL_SUBDIRS)" ]; then \
192 $(MAKE) do-all-parallel ENABLE_PARALLEL_SUBDIR_BUILD=1 || { final_exit="exit 1"; $$dk; } ; \
194 list='$(PROFILE_PARALLEL_SUBDIRS)'; for d in $$list ; do \
195 (cd $$d && $(MAKE) $*) || { final_exit="exit 1"; $$dk; } ; \
201 # Parallel build support
203 # The variable $(PROFILE)_PARALLEL_SUBDIRS should be set to the list of directories
204 # which could be built in parallel. These directories are built after the directories in
205 # $(PROFILE)_SUBDIRS.
206 # Parallel building is currently only supported for the 'all' target.
208 # Each directory's Makefile may define DEP_LIBS and DEP_DIRS to specify the libraries and
209 # directories it depends on.
211 ifneq ($(PROFILE_PARALLEL_SUBDIRS),)
212 dep_dirs = .dep_dirs-$(PROFILE)
214 @echo "Creating $@..."
215 list='$(PROFILE_PARALLEL_SUBDIRS)'; \
217 for d in $$list; do \
218 $(MAKE) -C $$d gen-deps DEPS_TARGET_DIR=$$d DEPS_FILE=$(abspath $@); \
224 # The gen-deps target is in library.make/executable.make so it can pick up
230 clean-local: clean-dep-dir
232 ifdef ENABLE_PARALLEL_SUBDIR_BUILD
233 .PHONY: do-all-parallel $(PROFILE_PARALLEL_SUBDIRS)
235 do-all-parallel: $(PROFILE_PARALLEL_SUBDIRS)
237 $(PROFILE_PARALLEL_SUBDIRS):
238 @set . $$MAKEFLAGS; \
243 DIST_SUBDIRS = $(SUBDIRS) $(DIST_ONLY_SUBDIRS)
245 dist-recursive: dist-local
246 @case '$(distdir)' in [\\/$$]* | ?:[\\/]* ) reldir='$(distdir)' ;; *) reldir='../$(distdir)' ;; esac ; \
247 list='$(DIST_SUBDIRS)'; for d in $$list ; do \
248 (cd $$d && $(MAKE) distdir=$$reldir/$$d $@) || exit 1 ; \
251 # The following target can be used like
253 # dist-local: dist-default
254 # ... additional commands ...
257 # 1. we invert the test here to not end in an error if ChangeLog doesn't exist.
258 # 2. we error out if we try to dist a nonexistant file.
259 # 3. we pick up Makefile, makefile, or GNUmakefile.
262 test '!' -f ChangeLog || cp ChangeLog $(distdir)
263 if test -f Makefile; then m=M; fi; \
264 if test -f makefile; then m=m; fi; \
265 if test -f GNUmakefile; then m=GNUm; fi; \
266 for f in $${m}akefile $(DISTFILES) ; do \
267 dest=`dirname "$(distdir)/$$f"` ; \
268 $(MKINSTALLDIRS) $$dest && cp -p "$$f" $$dest || exit 1 ; \
270 if test -d Documentation ; then \
271 find . -name '*.xml' > .files ; \
272 tar cTf .files - | (cd $(distdir); tar xf -) ; \
277 $(MKINSTALLDIRS) $(@D)
280 ## Documentation stuff
282 Q_MDOC =$(if $(V),,@echo "MDOC [$(PROFILE)] $(notdir $(@))";)
283 MDOC =$(Q_MDOC) MONO_PATH="$(topdir)/class/lib/$(DEFAULT_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(topdir)/class/lib/$(DEFAULT_PROFILE)/mdoc.exe