cleol
[mcs.git] / build / rules.make
blob08bdc227483efca89eb25b519de2b92253c0a5fe
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)
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)))))
21 VERSION = 0.93
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 [$(PROFILE)] $(notdir $(@))";)
27 USE_MCS_FLAGS = /codepage:$(CODEPAGE) $(LOCAL_MCS_FLAGS) $(PLATFORM_MCS_FLAGS) $(PROFILE_MCS_FLAGS) $(MCS_FLAGS)
28 USE_MBAS_FLAGS = /codepage:$(CODEPAGE) $(LOCAL_MBAS_FLAGS) $(PLATFORM_MBAS_FLAGS) $(PROFILE_MBAS_FLAGS) $(MBAS_FLAGS)
29 USE_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS)
30 CSCOMPILE = $(Q_MCS) $(MCS) $(USE_MCS_FLAGS)
31 BASCOMPILE = $(MBAS) $(USE_MBAS_FLAGS)
32 CCOMPILE = $(CC) $(USE_CFLAGS)
33 BOOT_COMPILE = $(Q_MCS) $(BOOTSTRAP_MCS) $(USE_MCS_FLAGS)
34 INSTALL = $(SHELL) $(topdir)/../mono/install-sh
35 INSTALL_DATA = $(INSTALL) -c -m 644
36 INSTALL_BIN = $(INSTALL) -c -m 755
37 INSTALL_LIB = $(INSTALL_BIN)
38 MKINSTALLDIRS = $(SHELL) $(topdir)/mkinstalldirs
39 INTERNAL_MCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/mcs.exe
40 INTERNAL_MBAS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/mbas/mbas.exe
41 INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/mcs/gmcs.exe
42 INTERNAL_ILASM = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/ilasm.exe
43 corlib = mscorlib.dll
45 ifndef BUILD_TOOLS_PROFILE
46 BUILD_TOOLS_PROFILE = $(BOOTSTRAP_PROFILE)
47 endif
49 INTERNAL_RESGEN = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/resgen.exe
51 depsdir = $(topdir)/build/deps
53 # Make sure these propagate if set manually
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 TEST_HARNESS
64 export BOOTSTRAP_MCS
65 export DESTDIR
66 export RESGEN
68 # Get this so the platform.make platform-check rule doesn't become the
69 # default target
71 .DEFAULT: all
72 default: all
74 # Get initial configuration. pre-config is so that the builder can
75 # override PLATFORM or PROFILE
77 include $(topdir)/build/config-default.make
78 -include $(topdir)/build/pre-config.make
80 # Default PLATFORM and PROFILE if they're not already defined.
82 ifndef PLATFORM
83 ifeq ($(OS),Windows_NT)
84 PLATFORM = win32
85 else
86 PLATFORM = linux
87 endif
88 endif
90 # Platform config
92 include $(topdir)/build/platforms/$(PLATFORM).make
94 ifdef PLATFORM_CORLIB
95 corlib = $(PLATFORM_CORLIB)
96 endif
97 # Useful
99 ifeq ($(PLATFORM_RUNTIME),$(RUNTIME))
100 PLATFORM_MONO_NATIVE = yes
101 endif
103 # Rest of the configuration
105 ifndef PROFILE
106 PROFILE = net_2_0
107 endif
109 include $(topdir)/build/profiles/$(PROFILE).make
110 -include $(topdir)/build/config.make
112 ifdef OVERRIDE_TARGET_ALL
113 all: all.override
114 else
115 all: do-all
116 endif
118 ifdef NO_INSTALL
119 GACUTIL = :
120 else
121 gacutil = $(topdir)/class/lib/basic/gacutil.exe
122 GACUTIL = MONO_PATH="$(topdir)/class/lib/basic$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(gacutil)
123 endif
125 STD_TARGETS = test run-test run-test-ondotnet clean install uninstall doc-update
127 $(STD_TARGETS): %: do-%
129 do-run-test:
130 ok=:; $(MAKE) run-test-recursive || ok=false; $(MAKE) run-test-local || ok=false; $$ok
132 do-%: %-recursive
133 $(MAKE) $*-local
135 .PHONY: all-local $(STD_TARGETS:=-local)
136 all-local $(STD_TARGETS:=-local):
138 csproj: do-csproj
140 # The way this is set up, any profile-specific subdirs list should
141 # be listed _before_ including rules.make. However, the default
142 # SUBDIRS list can come after, so don't use the eager := syntax when
143 # using the defaults.
144 PROFILE_SUBDIRS := $($(PROFILE)_SUBDIRS)
145 ifndef PROFILE_SUBDIRS
146 PROFILE_SUBDIRS = $(SUBDIRS)
147 endif
149 ifndef FRAMEWORK_VERSION_MAJOR
150 FRAMEWORK_VERSION_MAJOR = $(basename $(FRAMEWORK_VERSION))
151 endif
153 %-recursive:
154 @set . $$MAKEFLAGS; final_exit=:; \
155 case $$2 in --unix) shift ;; esac; \
156 case $$2 in *=*) dk="exit 1" ;; *k*) dk=: ;; *) dk="exit 1" ;; esac; \
157 list='$(PROFILE_SUBDIRS)'; for d in $$list ; do \
158 (cd $$d && $(MAKE) $*) || { final_exit="exit 1"; $$dk; } ; \
159 done; \
160 $$final_exit
162 ifndef DIST_SUBDIRS
163 DIST_SUBDIRS = $(SUBDIRS) $(DIST_ONLY_SUBDIRS)
164 endif
165 dist-recursive: dist-local
166 @case '$(distdir)' in [\\/$$]* | ?:[\\/]* ) reldir='$(distdir)' ;; *) reldir='../$(distdir)' ;; esac ; \
167 list='$(DIST_SUBDIRS)'; for d in $$list ; do \
168 (cd $$d && $(MAKE) distdir=$$reldir/$$d $@) || exit 1 ; \
169 done
171 # The following target can be used like
173 # dist-local: dist-default
174 # ... additional commands ...
176 # Notes:
177 # 1. we invert the test here to not end in an error if ChangeLog doesn't exist.
178 # 2. we error out if we try to dist a nonexistant file.
179 # 3. we pick up Makefile, makefile, or GNUmakefile.
180 dist-default:
181 -mkdir -p $(distdir)
182 test '!' -f ChangeLog || cp ChangeLog $(distdir)
183 if test -f Makefile; then m=M; fi; \
184 if test -f makefile; then m=m; fi; \
185 if test -f GNUmakefile; then m=GNUm; fi; \
186 for f in $${m}akefile $(DISTFILES) ; do \
187 dest=`dirname "$(distdir)/$$f"` ; \
188 $(MKINSTALLDIRS) $$dest && cp -p "$$f" $$dest || exit 1 ; \
189 done
190 if test -d Documentation ; then \
191 find . -name '*.xml' > .files ; \
192 tar cTf .files - | (cd $(distdir); tar xf -) ; \
193 rm .files ; \
196 %/.stamp:
197 $(MKINSTALLDIRS) $(@D)
198 touch $@
200 # Useful
202 withmcs:
203 $(MAKE) MCS='$(INTERNAL_MCS)' BOOTSTRAP_MCS='$(INTERNAL_MCS)' all
205 ## Documentation stuff
207 Q_MDOC =$(if $(V),,@echo "MDOC [$(PROFILE)] $(notdir $(@))";)
208 MDOC =$(Q_MDOC) MONO_PATH="$(topdir)/class/lib/net_4_0$(PLATFORM_PATH_SEPARATOR)$(topdir)/class/lib/net_2_0$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" \
209 $(RUNTIME) $(topdir)/tools/mdoc/mdoc.exe