Fix for -mminimal-toc detection, enable BTLS on FreeBSD PowerPC (#18578)
[mono-project.git] / sdks / builds / Makefile
blob35dfe845c50fd326302d1db46735a23fd3bec438
1 TOP=$(realpath $(CURDIR)/../..)
2 -include $(TOP)/sdks/Make.config
4 MAKEFLAGS += --no-builtin-rules
6 CONFIGURATION?=release
8 RELEASE=$(if $(filter $(CONFIGURATION),release),1)
10 lowercase=$(shell echo "$(1)" | tr '[:upper:]' '[:lower:]')
12 UNAME=$(shell uname)
14 ifneq (,$(findstring CYGWIN,$(UNAME)))
15 UNAME=Windows
16 endif
18 ifeq ($(UNAME),Linux)
19 UNAME_WSL_CHECK=$(shell uname -a)
20 ifneq (,$(findstring Microsoft,$(UNAME_WSL_CHECK)))
21 UNAME=Windows
22 endif
23 endif
25 ifneq ($(UNAME),Darwin)
26 ifneq ($(UNAME),Linux)
27 ifneq ($(UNAME),Windows)
28 $(error "Unsupported UNAME=$(UNAME)")
29 endif
30 endif
31 endif
33 ifeq ($(UNAME),Windows)
34 # x86_64 or i686
35 HOST_ARCH_MINGW32=$(shell uname -m)
36 endif
38 ifneq ($(UNAME),Darwin)
39 # iOS and Mac requires Xcode to be available, and Xcode is only available on macOS
40 ENABLE_IOS=
41 ENABLE_MAC=
42 endif
44 # On Windows, we will just trigger LLVM and Android builds using this Makefile.
45 ifeq ($(UNAME),Windows)
46 ENABLE_IOS=
47 ENABLE_MAC=
48 ENABLE_WASM=
49 ENABLE_WASM_CROSS=
50 ENABLE_DESKTOP=
51 DISABLE_CCACHE=1
52 DISABLE_LIBTOOLIZE=1
53 IGNORE_PROVISION_MXE=1
54 endif
56 CCACHE:=$(if $(DISABLE_CCACHE),,$(shell which ccache))
57 NINJA:=$(shell which ninja)
59 include $(TOP)/sdks/versions.mk
60 include $(TOP)/sdks/paths.mk
62 ifndef DISABLE_LIBTOOLIZE
63 #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
64 #this is due mono not being compatible with xcode's libtool, which is what's on path by default
65 ifeq (, $(shell which glibtoolize))
66 EXTRA_PATH=$(wildcard /usr/local/Cellar/libtool/*/bin/)
67 endif
68 endif
70 .PHONY: all
71 all:
73 ## Common Mono targets
75 .PHONY: configure-mono
76 configure-mono: $(TOP)/configure
79 ifeq ($(UNAME),Darwin)
80 .stamp-ulimit-check:
81 @if [ $$(ulimit -n) -lt 1024 ] ; then \
82 echo "Error: Increase ulimit -n to at least 1024"; \
83 exit 1; \
85 touch $@
86 else
87 .stamp-ulimit-check:
88 touch $@
89 endif
91 $(TOP)/configure: $(TOP)/configure.ac $(TOP)/autogen.sh .stamp-ulimit-check
92 cd $(TOP) && PATH=$(EXTRA_PATH):$$PATH NOCONFIGURE=1 ./autogen.sh $(if $(wildcard $(TOP)/../mono-extensions),--enable-extension-module=xamarin --enable-extension-module)
94 ## Archive targets
96 ifdef ENABLE_ANDROID
97 android_ARCHIVE=
98 endif
100 ifdef ENABLE_IOS
101 ios_ARCHIVE=
102 endif
104 ifdef ENABLE_MAC
105 mac_ARCHIVE=
106 endif
108 ifdef ENABLE_WASM
109 wasm_ARCHIVE=
110 endif
113 # Parameters:
114 # $(1): target (android, ios, mac, wasm)
115 # $(2): compression format (7z, zip)
116 define ArchiveTemplate
117 _$(1)_HASH = $$(shell git -C $$(TOP) rev-parse HEAD)
118 _$(1)_PACKAGE = $(1)-$$(CONFIGURATION)-$$(UNAME)-$$(_$(1)_HASH).$(2)
120 ifeq ($(2),7z)
121 _$(1)_COMPRESSION_ARGS = -t7z -mx=9
122 endif
124 .PHONY: archive-$(1)
125 archive-$(1):
126 cd $$(TOP)/sdks/out && 7z a $$(_$(1)_COMPRESSION_ARGS) $$(TOP)/$$(_$(1)_PACKAGE) $$(sort $$($(1)_ARCHIVE))
127 endef
129 ifdef ENABLE_ANDROID
130 $(eval $(call ArchiveTemplate,android,7z))
131 endif
133 ifdef ENABLE_IOS
134 $(eval $(call ArchiveTemplate,ios,7z))
135 endif
137 ifdef ENABLE_MAC
138 $(eval $(call ArchiveTemplate,mac,7z))
139 endif
141 ifdef ENABLE_WASM
142 $(eval $(call ArchiveTemplate,wasm,zip))
143 endif
145 ## Targets
147 .PHONY: build-custom-%
148 build-custom-%:
149 $(MAKE) -C $*
151 .PHONY: setup-custom-%
152 setup-custom-%:
153 mkdir -p $(TOP)/sdks/out/$*
156 # Parameters:
157 # $(1): product
158 # $(2): target
159 define TargetTemplate
161 .PHONY: toolchain-$(1)-$(2)
162 toolchain-$(1)-$(2): .stamp-$(1)-$(2)-toolchain
164 .PHONY: toolchain
165 toolchain: toolchain-$(1)-$(2)
167 .stamp-$(1)-$(2)-configure: .stamp-$(1)-$(2)-toolchain
169 .PHONY: configure-$(1)-$(2)
170 configure-$(1)-$(2): .stamp-$(1)-$(2)-configure
172 .PHONY: configure
173 configure: configure-$(1)-$(2)
175 .PHONY: build-$(1)-$(2)
176 build-$(1)-$(2): .stamp-$(1)-$(2)-configure
177 $$(MAKE) build-custom-$(1)-$(2)
179 .PHONY: build
180 build: build-$(1)-$(2)
182 .PHONY: setup-$(1)-$(2)
183 setup-$(1)-$(2):
184 $$(MAKE) setup-custom-$(1)-$(2)
186 .PHONY: package-$(1)-$(2)
187 package-$(1)-$(2): setup-$(1)-$(2) build-$(1)-$(2)
189 .PHONY: clean-$(1)-$(2)
190 clean-$(1)-$(2):
192 .PHONY: clean
193 clean: clean-$(1)-$(2)
195 endef
197 ## Products
199 include runtime.mk
200 include bcl.mk
202 ## MXE targets
203 ifeq ($(and $(DISABLE_ANDROID),$(DISABLE_WASM_CROSS)),)
204 # FIXME add iOS support(?)
205 include mxe.mk
206 endif
208 ## LLVM targets
209 include llvm.mk
211 ## Android targets
212 ifdef ENABLE_ANDROID
213 include android.mk
214 endif
216 ## iOS targets
217 ifdef ENABLE_IOS
218 include ios.mk
219 endif
221 ## Mac targets
222 ifdef ENABLE_MAC
223 include mac.mk
224 endif
226 ## Desktop targets
227 ## To run host-side tests
228 ifdef ENABLE_DESKTOP
229 include desktop.mk
230 endif
232 ## WASM targets
233 include wasm.mk