[sdks] Use 7z format for the android/ios/mac archives (#14837)
[mono-project.git] / sdks / builds / Makefile
blobc00834dc2685e56cfbeefc7f84205d02af00ee7e
1 TOP=$(realpath $(CURDIR)/../..)
2 -include $(TOP)/sdks/Make.config
4 all: package
6 MAKEFLAGS += --no-builtin-rules
8 CONFIGURATION?=release
10 RELEASE=$(if $(filter $(CONFIGURATION),release),1)
12 lowercase=$(shell echo "$(1)" | tr '[:upper:]' '[:lower:]')
14 UNAME=$(shell uname)
16 ifneq (,$(findstring CYGWIN,$(UNAME)))
17 UNAME=Windows
18 endif
20 ifeq ($(UNAME),Linux)
21 UNAME_WSL_CHECK=$(shell uname -a)
22 ifneq (,$(findstring Microsoft,$(UNAME_WSL_CHECK)))
23 UNAME=Windows
24 endif
25 endif
27 ifneq ($(UNAME),Darwin)
28 ifneq ($(UNAME),Linux)
29 ifneq ($(UNAME),Windows)
30 $(error "Unsupported UNAME=$(UNAME)")
31 endif
32 endif
33 endif
35 ifeq ($(UNAME),Windows)
36 # x86_64 or i686
37 HOST_ARCH_MINGW32=$(shell uname -m)
38 endif
40 ifneq ($(UNAME),Darwin)
41 # iOS and Mac requires Xcode to be available, and Xcode is only available on macOS
42 DISABLE_IOS=1
43 DISABLE_MAC=1
44 endif
46 # On Windows, we will just trigger LLVM and Android builds using this Makefile.
47 ifeq ($(UNAME),Windows)
48 DISABLE_IOS=1
49 DISABLE_MAC=1
50 DISABLE_WASM=1
51 DISABLE_WASM_CROSS=1
52 DISABLE_DESKTOP=1
53 DISABLE_CCACHE=1
54 DISABLE_LIBTOOLIZE=1
55 IGNORE_PROVISION_MXE=1
56 endif
58 CCACHE:=$(if $(DISABLE_CCACHE),,$(shell which ccache))
59 NINJA:=$(shell which ninja)
61 include $(TOP)/sdks/versions.mk
62 include $(TOP)/sdks/paths.mk
64 ifndef DISABLE_LIBTOOLIZE
65 #brew's libtool is not compatible with some of the deps needed (I.E. V8) so in those systems we need to explicit add to the path
66 #this is due mono not being compatible with xcode's libtool, which is what's on path by default
67 ifeq (, $(shell which glibtoolize))
68 EXTRA_PATH=$(wildcard /usr/local/Cellar/libtool/*/bin/)
69 endif
70 endif
72 all: package
74 ## Common Mono targets
76 .PHONY: configure-mono
77 configure-mono: $(TOP)/configure
79 $(TOP)/configure: $(TOP)/configure.ac $(TOP)/autogen.sh
80 cd $(TOP) && PATH=$(EXTRA_PATH):$$PATH NOCONFIGURE=1 ./autogen.sh $(if $(wildcard $(TOP)/../mono-extensions),--enable-extension-module=xamarin --enable-extension-module)
82 ## Archive targets
84 ifndef DISABLE_ANDROID
85 android_ARCHIVE=
86 endif
88 ifndef DISABLE_IOS
89 ios_ARCHIVE=
90 endif
92 ifndef DISABLE_MAC
93 mac_ARCHIVE=
94 endif
96 ifndef DISABLE_WASM
97 wasm_ARCHIVE=
98 endif
101 # Parameters:
102 # $(1): target (android, ios, mac, wasm)
103 # $(2): compression format (7z, zip)
104 define ArchiveTemplate
105 _$(1)_HASH = $$(shell git -C $$(TOP) rev-parse HEAD)
106 _$(1)_PACKAGE = $(1)-$$(CONFIGURATION)-$$(UNAME)-$$(_$(1)_HASH).$(2)
108 ifeq ($(2),7z)
109 _$(1)_COMPRESSION_ARGS = -t7z -mx=9
110 endif
112 .PHONY: archive-$(1)
113 archive-$(1):
114 cd $$(TOP)/sdks/out && 7z a $$(_$(1)_COMPRESSION_ARGS) $$(TOP)/$$(_$(1)_PACKAGE) $$(sort $$($(1)_ARCHIVE))
115 endef
117 ifndef DISABLE_ANDROID
118 $(eval $(call ArchiveTemplate,android,7z))
119 endif
121 ifndef DISABLE_IOS
122 $(eval $(call ArchiveTemplate,ios,7z))
123 endif
125 ifndef DISABLE_MAC
126 $(eval $(call ArchiveTemplate,mac,7z))
127 endif
129 ifndef DISABLE_WASM
130 $(eval $(call ArchiveTemplate,wasm,zip))
131 endif
133 ## Targets
135 .PHONY: build-custom-%
136 build-custom-%:
137 $(MAKE) -C $*
139 .PHONY: setup-custom-%
140 setup-custom-%:
141 mkdir -p $(TOP)/sdks/out/$*
144 # Parameters:
145 # $(1): product
146 # $(2): target
147 define TargetTemplate
149 .PHONY: toolchain-$(1)-$(2)
150 toolchain-$(1)-$(2): .stamp-$(1)-$(2)-toolchain
152 .PHONY: toolchain
153 toolchain: toolchain-$(1)-$(2)
155 .stamp-$(1)-$(2)-configure: .stamp-$(1)-$(2)-toolchain
157 .PHONY: configure-$(1)-$(2)
158 configure-$(1)-$(2): .stamp-$(1)-$(2)-configure
160 .PHONY: configure
161 configure: configure-$(1)-$(2)
163 .PHONY: build-$(1)-$(2)
164 build-$(1)-$(2): .stamp-$(1)-$(2)-configure
165 $$(MAKE) build-custom-$(1)-$(2)
167 .PHONY: build
168 build: build-$(1)-$(2)
170 .PHONY: setup-$(1)-$(2)
171 setup-$(1)-$(2):
172 $$(MAKE) setup-custom-$(1)-$(2)
174 .PHONY: package-$(1)-$(2)
175 package-$(1)-$(2): setup-$(1)-$(2) build-$(1)-$(2)
177 .PHONY: package
178 package: package-$(1)-$(2)
180 .PHONY: clean-$(1)-$(2)
181 clean-$(1)-$(2):
183 .PHONY: clean
184 clean: clean-$(1)-$(2)
186 endef
188 ## Products
190 include runtime.mk
191 include bcl.mk
193 ## MXE targets
194 ifeq ($(and $(DISABLE_ANDROID),$(DISABLE_WASM_CROSS)),)
195 # FIXME add iOS support(?)
196 include mxe.mk
197 endif
199 ## LLVM targets
200 include llvm.mk
202 ## Android targets
203 ifndef DISABLE_ANDROID
204 include android.mk
205 endif
207 ## iOS targets
208 ifndef DISABLE_IOS
209 include ios.mk
210 endif
212 ## Mac targets
213 ifndef DISABLE_MAC
214 include mac.mk
215 endif
217 ## Desktop targets
218 ## To run host-side tests
219 ifndef DISABLE_DESKTOP
220 include desktop.mk
221 endif
223 ## WASM targets
224 ifndef DISABLE_WASM
225 include wasm.mk
226 endif