[mkbundle] Fix mapping length (#13061)
[mono-project.git] / sdks / builds / runtime.mk
blob61841b5690e7095c6773031d20253226e6cbc935
2 ##
3 # Parameters:
4 # $(1): product
5 # $(2): target
6 # $(3): host triple
8 # Flags:
9 # _$(1)-$(2)_AR
10 # _$(1)-$(2)_AS
11 # _$(1)-$(2)_CC
12 # _$(1)-$(2)_CPP
13 # _$(1)-$(2)_CXX
14 # _$(1)-$(2)_CXXCPP
15 # _$(1)-$(2)_DLLTOOL
16 # _$(1)-$(2)_LD
17 # _$(1)-$(2)_CMAKE
18 # _$(1)-$(2)_OBJDUMP
19 # _$(1)-$(2)_RANLIB
20 # _$(1)-$(2)_STRIP
21 # _$(1)-$(2)_CFLAGS
22 # _$(1)-$(2)_CXXFLAGS
23 # _$(1)-$(2)_CPPFLAGS
24 # _$(1)-$(2)_LDFLAGS
25 # _$(1)-$(2)_AC_VARS
26 # _$(1)-$(2)_CONFIGURE_FLAGS
27 # _$(1)-$(2)_PATH
28 define RuntimeTemplate
30 _runtime_$(1)-$(2)_BITNESS=$$(if $$(or $$(findstring i686,$(3)),$$(findstring i386,$(3))),-m32,$$(if $$(findstring x86_64,$(3)),-m64))
32 _runtime_$(1)-$(2)_CFLAGS=$(if $(RELEASE),-O2 -g,-O0 -ggdb3 -fno-omit-frame-pointer) $$(_$(1)-$(2)_CFLAGS) $$($(1)-$(2)_CFLAGS) $$(_runtime_$(1)-$(2)_BITNESS)
33 _runtime_$(1)-$(2)_CXXFLAGS=$(if $(RELEASE),-O2 -g,-O0 -ggdb3 -fno-omit-frame-pointer) $$(_$(1)-$(2)_CXXFLAGS) $$($(1)-$(2)_CXXFLAGS) $$(_runtime_$(1)-$(2)_BITNESS)
34 _runtime_$(1)-$(2)_CPPFLAGS=$(if $(RELEASE),-O2 -g,-O0 -ggdb3 -fno-omit-frame-pointer) $$(_$(1)-$(2)_CPPFLAGS) $$($(1)-$(2)_CPPFLAGS) $$(_runtime_$(1)-$(2)_BITNESS)
35 _runtime_$(1)-$(2)_CXXCPPFLAGS=$(if $(RELEASE),-O2 -g,-O0 -ggdb3 -fno-omit-frame-pointer) $$(_$(1)-$(2)_CXXCPPFLAGS) $$($(1)-$(2)_CXXCPPFLAGS) $$(_runtime_$(1)-$(2)_BITNESS)
36 _runtime_$(1)-$(2)_LDFLAGS=$$(_$(1)-$(2)_LDFLAGS) $$($(1)-$(2)_LDFLAGS)
38 _runtime_$(1)-$(2)_AC_VARS=$$(_$(1)-$(2)_AC_VARS) $$($(1)-$(2)_AC_VARS)
40 _runtime_$(1)-$(2)_CONFIGURE_ENVIRONMENT = \
41 $(if $$(_$(1)-$(2)_AR),AR="$$(_$(1)-$(2)_AR)") \
42 $(if $$(_$(1)-$(2)_AS),AS="$$(_$(1)-$(2)_AS)") \
43 $(if $$(_$(1)-$(2)_CC),CC="$$(_$(1)-$(2)_CC)") \
44 $(if $$(_$(1)-$(2)_CPP),CPP="$$(_$(1)-$(2)_CPP)") \
45 $(if $$(_$(1)-$(2)_CXX),CXX="$$(_$(1)-$(2)_CXX)") \
46 $(if $$(_$(1)-$(2)_CXXCPP),CXXCPP="$$(_$(1)-$(2)_CXXCPP)") \
47 $(if $$(_$(1)-$(2)_DLLTOOL),DLLTOOL="$$(_$(1)-$(2)_DLLTOOL)") \
48 $(if $$(_$(1)-$(2)_LD),LD="$$(_$(1)-$(2)_LD)") \
49 $(if $$(_$(1)-$(2)_OBJDUMP),OBJDUMP="$$(_$(1)-$(2)_OBJDUMP)") \
50 $(if $$(_$(1)-$(2)_RANLIB),RANLIB="$$(_$(1)-$(2)_RANLIB)") \
51 $(if $$(_$(1)-$(2)_CMAKE),CMAKE="$$(_$(1)-$(2)_CMAKE)") \
52 $(if $$(_$(1)-$(2)_STRIP),STRIP="$$(_$(1)-$(2)_STRIP)") \
53 CFLAGS="$$(_runtime_$(1)-$(2)_CFLAGS)" \
54 CXXFLAGS="$$(_runtime_$(1)-$(2)_CXXFLAGS)" \
55 CPPFLAGS="$$(_runtime_$(1)-$(2)_CPPFLAGS)" \
56 CXXCPPFLAGS="$$(_runtime_$(1)-$(2)_CXXCPPFLAGS)" \
57 LDFLAGS="$$(_runtime_$(1)-$(2)_LDFLAGS)" \
58 $$(_$(1)-$(2)_CONFIGURE_ENVIRONMENT) \
59 $$($(1)-$(2)_CONFIGURE_ENVIRONMENT)
61 _runtime_$(1)-$(2)_CONFIGURE_FLAGS= \
62 $$(if $(3),--host=$(3)) \
63 --cache-file=$$(TOP)/sdks/builds/$(1)-$(2)-$$(CONFIGURATION).config.cache \
64 --prefix=$$(TOP)/sdks/out/$(1)-$(2)-$$(CONFIGURATION) \
65 $$(if $$(ENABLE_CXX),--enable-cxx) \
66 $$(_cross-runtime_$(1)-$(2)_CONFIGURE_FLAGS) \
67 $$(_$(1)-$(2)_CONFIGURE_FLAGS) \
68 $$($(1)-$(2)_CONFIGURE_FLAGS)
70 .stamp-$(1)-$(2)-$$(CONFIGURATION)-configure: $$(TOP)/configure .stamp-$(1)-$(2)-toolchain
71 mkdir -p $$(TOP)/sdks/builds/$(1)-$(2)-$$(CONFIGURATION)
72 $(if $$(_$(1)-$(2)_PATH),PATH="$$$$PATH:$$(_$(1)-$(2)_PATH)") ./wrap-configure.sh $$(TOP)/sdks/builds/$(1)-$(2)-$$(CONFIGURATION) $$(abspath $$<) $$(_runtime_$(1)-$(2)_AC_VARS) $$(_runtime_$(1)-$(2)_CONFIGURE_ENVIRONMENT) $$(_runtime_$(1)-$(2)_CONFIGURE_FLAGS)
73 touch $$@
75 .stamp-$(1)-$(2)-configure: .stamp-$(1)-$(2)-$$(CONFIGURATION)-configure
76 touch $$@
78 .PHONY: build-custom-$(1)-$(2)
79 build-custom-$(1)-$(2):
80 $$(MAKE) -C $(1)-$(2)-$$(CONFIGURATION)
82 .PHONY: setup-custom-$(1)-$(2)
83 setup-custom-$(1)-$(2):
84 mkdir -p $$(TOP)/sdks/out/$(1)-$(2)-$$(CONFIGURATION)
86 .PHONY: package-$(1)-$(2)
87 package-$(1)-$(2):
88 $$(MAKE) -C $$(TOP)/sdks/builds/$(1)-$(2)-$$(CONFIGURATION)/mono install
89 $$(MAKE) -C $$(TOP)/sdks/builds/$(1)-$(2)-$$(CONFIGURATION)/support install
91 .PHONY: clean-$(1)-$(2)
92 clean-$(1)-$(2):
93 rm -rf .stamp-$(1)-$(2)-toolchain .stamp-$(1)-$(2)-$$(CONFIGURATION)-configure $$(TOP)/sdks/builds/toolchains/$(1)-$(2) $$(TOP)/sdks/builds/$(1)-$(2)-$$(CONFIGURATION) $$(TOP)/sdks/builds/$(1)-$(2)-$$(CONFIGURATION).config.cache $$(TOP)/sdks/out/$(1)-$(2)-$$(CONFIGURATION)
95 $$(eval $$(call TargetTemplate,$(1),$(2)))
97 .PHONY: configure-$(1)
98 configure-$(1): configure-$(1)-$(2)
100 .PHONY: build-$(1)
101 build-$(1): build-$(1)-$(2)
103 .PHONY: archive-$(1)
104 archive-$(1): package-$(1)-$(2)
106 $(1)_ARCHIVE += $(1)-$(2)-$$(CONFIGURATION)
108 endef
110 $(TOP)/tools/offsets-tool/MonoAotOffsetsDumper.exe: $(wildcard $(TOP)/tools/offsets-tool/*.cs)
111 $(MAKE) -C $(dir $@) MonoAotOffsetsDumper.exe
114 # Parameters:
115 # $(1): product
116 # $(2): target
117 # $(3): host triple
118 # $(4): target triple
119 # $(5): device target
120 # $(6): llvm
121 # $(7): offsets dumper abi
123 # Flags:
124 # _$(1)-$(2)_AR
125 # _$(1)-$(2)_AS
126 # _$(1)-$(2)_CC
127 # _$(1)-$(2)_CPP
128 # _$(1)-$(2)_CXX
129 # _$(1)-$(2)_CXXCPP
130 # _$(1)-$(2)_DLLTOOL
131 # _$(1)-$(2)_LD
132 # _$(1)-$(2)_OBJDUMP
133 # _$(1)-$(2)_RANLIB
134 # _$(1)-$(2)_STRIP
135 # _$(1)-$(2)_CFLAGS
136 # _$(1)-$(2)_CXXFLAGS
137 # _$(1)-$(2)_CPPFLAGS
138 # _$(1)-$(2)_LDFLAGS
139 # _$(1)-$(2)_AC_VARS
140 # _$(1)-$(2)_CONFIGURE_FLAGS
141 # _$(1)-$(2)_PATH
142 # _$(1)-$(2)_OFFSETS_DUMPER_ARGS
143 define CrossRuntimeTemplate
145 _cross-runtime_$(1)-$(2)_CONFIGURE_FLAGS= \
146 --target=$(4) \
147 --with-cross-offsets=$(4).h \
148 --with-llvm=$$(TOP)/sdks/out/$(6)
150 .stamp-$(1)-$(2)-toolchain:
151 touch $$@
153 .stamp-$(1)-$(2)-$$(CONFIGURATION)-configure: | $$(if $$(IGNORE_PROVISION_LLVM),,provision-$(6))
155 $$(TOP)/sdks/builds/$(1)-$(2)-$$(CONFIGURATION)/$(4).h: .stamp-$(1)-$(2)-$$(CONFIGURATION)-configure $$(TOP)/tools/offsets-tool/MonoAotOffsetsDumper.exe | configure-$(1)-$(5)
156 cd $$(TOP)/sdks/builds/$(1)-$(2)-$$(CONFIGURATION) && \
157 MONO_PATH=$$(TOP)/tools/offsets-tool/CppSharp/$$(if $$(filter $$(UNAME),Darwin),osx_32,$$(if $$(filter $$(UNAME),Linux),linux_64,$$(error "Unknown UNAME='$$(UNAME)'"))) \
158 mono $$(if $$(filter $$(UNAME),Darwin),--arch=32) --debug "$$(TOP)/tools/offsets-tool/MonoAotOffsetsDumper.exe" \
159 --abi $(7) --outfile "$$@" --mono "$$(TOP)" --targetdir "$$(TOP)/sdks/builds/$(1)-$(5)-$$(CONFIGURATION)" \
160 $$(_$(1)-$(2)_OFFSETS_DUMPER_ARGS)
162 build-$(1)-$(2): $$(TOP)/sdks/builds/$(1)-$(2)-$$(CONFIGURATION)/$(4).h
164 $$(eval $$(call RuntimeTemplate,$(1),$(2),$(3)))
166 .PHONY: archive-$(1)
167 archive-$(1): provision-$(6)
169 $(1)_ARCHIVE += $(6)
171 endef