[System.Native] Build a reduced library on Android and iOS
[mono-project.git] / sdks / builds / ios.mk
blobe5a7bb9fea0d4f0611669169230dd8f1e172ac88
2 include runtime.mk
5 # Targets:
6 # - build-ios-<target>
7 # Build <target>
8 # - package-ios-<target>
9 # Install target into ../out/<target>
10 # - clean-ios-<target>
11 # Clean target
12 # Where <target> is: target32, target32s, target64, sim32, sim64, cross32, cross64
15 PLATFORM_BIN=$(XCODE_DIR)/Toolchains/XcodeDefault.xctoolchain/usr/bin
17 ios_CPPFLAGS=-DMONOTOUCH=1
19 ios_LDFLAGS=
21 COMMON_LDFLAGS=-Wl,-no_weak_imports
23 BITCODE_CFLAGS=-fexceptions
24 BITCODE_LDFLAGS=-framework CoreFoundation -lobjc -lc++
25 BITCODE_CONFIGURE_FLAGS=--enable-llvm-runtime --with-bitcode=yes
28 # Device builds
30 # Parameters
31 # $(1): target (target32/target32s/target64)
32 # $(2): arch (armv7 or arm64)
33 # $(3): arch (arm or aarch64)
35 # Flags:
36 # ios-$(1)_AC_VARS
37 # ios-$(1)_SYSROOT
38 # ios-$(1)_CONFIGURE_FLAGS
39 # ios-$(1)_CFLAGS
40 # ios-$(1)_CPPFLAGS
41 # ios-$(1)_CXXFLAGS
42 # ios-$(1)_LDFLAGS
43 # ios-$(1)_BITCODE_MARKER
45 # This handles tvos/watchos as well.
47 define iOSDeviceTemplate
49 _ios-$(1)_CC=$$(CCACHE) $$(PLATFORM_BIN)/clang
50 _ios-$(1)_CXX=$$(CCACHE) $$(PLATFORM_BIN)/clang++
52 _ios-$(1)_AC_VARS= \
53 ac_cv_c_bigendian=no \
54 ac_cv_func_finite=no \
55 ac_cv_func_getpwuid_r=no \
56 ac_cv_func_posix_getpwuid_r=yes \
57 ac_cv_header_curses_h=no \
58 ac_cv_header_localcharset_h=no \
59 ac_cv_header_sys_user_h=no \
60 ac_cv_func_getentropy=no \
61 ac_cv_func_futimens=no \
62 ac_cv_func_utimensat=no \
63 ac_cv_func_shm_open_working_with_mmap=no \
64 mono_cv_sizeof_sunpath=104 \
65 mono_cv_uscore=yes \
66 $$(ios-$(1)_AC_VARS)
68 _ios-$(1)_CFLAGS= \
69 $$(ios-$(1)_SYSROOT) \
70 -arch $(2) \
71 -Wl,-application_extension \
72 -fexceptions \
73 $$(ios-$(1)_BITCODE_MARKER) \
74 $$(ios-$(1)_CFLAGS)
76 _ios-$(1)_CXXFLAGS= \
77 $$(ios-$(1)_SYSROOT) \
78 -arch $(2) \
79 -Wl,-application_extension \
80 $$(ios-$(1)_CXXFLAGS) \
81 $$(ios-$(1)_BITCODE_MARKER)
83 _ios-$(1)_CPPFLAGS= \
84 $$(ios_CPPFLAGS) \
85 $$(ios-$(1)_SYSROOT) \
86 -arch $(2) \
87 -DSMALL_CONFIG -DDISABLE_POLICY_EVIDENCE=1 -D_XOPEN_SOURCE -DHOST_IOS -DHAVE_LARGE_FILE_SUPPORT=1 \
88 $$(ios-$(1)_CPPFLAGS)
90 _ios-$(1)_LDFLAGS= \
91 $$(ios_LDFLAGS) \
92 -Wl,-no_weak_imports \
93 -arch $(2) \
94 -framework CoreFoundation \
95 -lobjc -lc++ \
96 $$(ios-$(1)_LDFLAGS)
98 _ios-$(1)_CONFIGURE_FLAGS = \
99 --build=i386-apple-darwin10 \
100 --host=$(3)-apple-darwin10 \
101 --cache-file=$(TOP)/sdks/builds/ios-$(1)-$$(CONFIGURATION).config.cache \
102 --prefix=$(TOP)/sdks/out/ios-$(1)-$$(CONFIGURATION) \
103 --disable-boehm \
104 --disable-btls \
105 --disable-executables \
106 --disable-icall-tables \
107 --disable-iconv \
108 --disable-mcs-build \
109 --disable-nls \
110 --disable-support-build \
111 --disable-visibility-hidden \
112 --enable-dtrace=no \
113 --enable-icall-export \
114 --enable-maintainer-mode \
115 --enable-minimal=ssa,com,interpreter,jit,reflection_emit_save,reflection_emit,portability,assembly_remapping,attach,verifier,full_messages,appdomains,security,sgen_remset,sgen_marksweep_par,sgen_marksweep_fixed,sgen_marksweep_fixed_par,sgen_copying,logging,remoting,shared_perfcounters \
116 --enable-monotouch \
117 --with-lazy-gc-thread-creation=yes \
118 --with-monotouch \
119 --with-tls=pthread \
120 --without-ikvm-native \
121 --without-sigaltstack \
122 --disable-cooperative-suspend \
123 --disable-hybrid-suspend \
124 $$(ios-$(1)_CONFIGURE_FLAGS)
126 .stamp-ios-$(1)-toolchain:
127 touch $$@
129 $$(eval $$(call RuntimeTemplate,ios-$(1)))
131 endef
133 ios_sysroot = -isysroot $(XCODE_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(IOS_VERSION).sdk -miphoneos-version-min=$(IOS_VERSION_MIN)
134 tvos_sysroot = -isysroot $(XCODE_DIR)/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS$(TVOS_VERSION).sdk -mtvos-version-min=$(TVOS_VERSION_MIN)
135 watchos_sysroot = -isysroot $(XCODE_DIR)/Platforms/WatchOS.platform/Developer/SDKs/WatchOS$(WATCH_VERSION).sdk -mwatchos-version-min=$(WATCHOS_VERSION_MIN)
137 # explicitly disable dtrace, since it requires inline assembly, which is disabled on AppleTV (and mono's configure.ac doesn't know that (yet at least))
138 ios-targettv_CONFIGURE_FLAGS = --enable-dtrace=no $(BITCODE_CONFIGURE_FLAGS) --with-monotouch-tv
139 ios-targetwatch_CONFIGURE_FLAGS = --enable-cooperative-suspend $(BITCODE_CONFIGURE_FLAGS) --with-monotouch-watch
141 ios-target32_SYSROOT = $(ios_sysroot)
142 ios-target32s_SYSROOT = $(ios_sysroot)
143 ios-target64_SYSROOT = $(ios_sysroot)
144 ios-targettv_SYSROOT = $(tvos_sysroot)
145 ios-targetwatch_SYSROOT = $(watchos_sysroot)
147 ios-target32_CPPFLAGS = -DHOST_IOS
148 ios-target32s_CPPFLAGS = -DHOST_IOS
149 ios-target64_CPPFLAGS = -DHOST_IOS
150 ios-targettv_CPPFLAGS = -DHOST_APPLETVOS -DTARGET_APPLETVOS
151 ios-targetwatch_CPPFLAGS = -DHOST_IOS -DHOST_WATCHOS
153 ios-targettv_CFLAGS = -fembed-bitcode -fno-gnu-inline-asm
154 ios-targettv_CXXFLAGS = -fembed-bitcode -fno-gnu-inline-asm
155 ios-targetwatch_CFLAGS = -fembed-bitcode -fno-gnu-inline-asm
156 ios-targetwatch_CXXFLAGS = -fembed-bitcode -fno-gnu-inline-asm
158 ios-targettv_LDFLAGS = -Wl,-bitcode_bundle $(BITCODE_LDFLAGS)
159 ios-targetwatch_LDFLAGS = -Wl,-bitcode_bundle $(BITCODE_LDFLAGS)
161 ios-targettv_AC_VARS = \
162 ac_cv_func_system=no \
163 ac_cv_func_pthread_kill=no \
164 ac_cv_func_kill=no \
165 ac_cv_func_sigaction=no \
166 ac_cv_func_fork=no \
167 ac_cv_func_execv=no \
168 ac_cv_func_execve=no \
169 ac_cv_func_execvp=no \
170 ac_cv_func_signal=no
171 ios-targetwatch_AC_VARS = $(ios-targettv_AC_VARS)
173 # ios-target32_BITCODE_MARKER=-fembed-bitcode-marker
174 $(eval $(call iOSDeviceTemplate,target32,armv7,arm))
175 $(eval $(call iOSDeviceTemplate,target32s,armv7s,arm))
176 # ios-target64_BITCODE_MARKER=-fembed-bitcode-marker
177 $(eval $(call iOSDeviceTemplate,target64,arm64,aarch64))
178 $(eval $(call iOSDeviceTemplate,targettv,arm64,aarch64))
179 $(eval $(call iOSDeviceTemplate,targetwatch,armv7k,armv7k))
182 # Simulator builds
184 # Parameters
185 # $(1): target (sim32 or sim64)
186 # $(2): arch (i386 or x86_64)
188 # Flags:
189 # ios-$(1)_SYSROOT
190 # ios-$(1)_AC_VARS
191 # ios-$(1)_CFLAGS
192 # ios-$(1)_CPPFLAGS
193 # ios-$(1)_CXXFLAGS
194 # ios-$(1)_LDFLAGS
196 # This handles tvos/watchos as well.
198 define iOSSimulatorTemplate
200 _ios-$(1)_CC=$$(CCACHE) $$(PLATFORM_BIN)/clang
201 _ios-$(1)_CXX=$$(CCACHE) $$(PLATFORM_BIN)/clang++
203 _ios-$(1)_AC_VARS= \
204 ac_cv_func_clock_nanosleep=no \
205 ac_cv_func_fstatat=no \
206 ac_cv_func_readlinkat=no \
207 ac_cv_func_system=no \
208 ac_cv_func_getentropy=no \
209 ac_cv_func_futimens=no \
210 ac_cv_func_utimensat=no \
211 ac_cv_func_shm_open_working_with_mmap=no \
212 mono_cv_uscore=yes \
213 $(ios-$(1)_AC_VARS)
215 _ios-$(1)_CFLAGS= \
216 $$(ios-$(1)_SYSROOT) \
217 -arch $(2) \
218 -Wl,-application_extension \
219 $$(ios-$(1)_CFLAGS)
221 _ios-$(1)_CPPFLAGS= \
222 $$(ios_CPPFLAGS) \
223 $$(ios-$(1)_SYSROOT) \
224 -arch $(2) \
225 -Wl,-application_extension \
226 $$(ios-$(1)_CPPFLAGS)
228 _ios-$(1)_CXXFLAGS= \
229 $$(ios-$(1)_SYSROOT) \
230 -arch $(2) \
231 -Wl,-application_extension\
232 $$(ios-$(1)_CXXFLAGS)
234 _ios-$(1)_LDFLAGS= \
235 $$(ios_LDFLAGS) \
236 $$(ios-$(1)_LDFLAGS)
238 _ios-$(1)_CONFIGURE_FLAGS= \
239 --host=$(2)-apple-darwin10 \
240 --cache-file=$$(TOP)/sdks/builds/ios-$(1)-$$(CONFIGURATION).config.cache \
241 --prefix=$$(TOP)/sdks/out/ios-$(1)-$$(CONFIGURATION) \
242 --disable-boehm \
243 --disable-btls \
244 --disable-executables \
245 --disable-iconv \
246 --disable-mcs-build \
247 --disable-nls \
248 --disable-visibility-hidden \
249 --enable-maintainer-mode \
250 --enable-minimal=com,remoting,shared_perfcounters \
251 --enable-monotouch \
252 --with-tls=pthread \
253 --without-ikvm-native \
254 --disable-cooperative-suspend \
255 --disable-hybrid-suspend \
256 $$(ios-$(1)_CONFIGURE_FLAGS)
258 # _ios-$(1)_CONFIGURE_FLAGS += --enable-extension-module=xamarin
260 .stamp-ios-$(1)-toolchain:
261 touch $$@
263 $$(eval $$(call RuntimeTemplate,ios-$(1)))
265 endef
267 ios_sim_sysroot = -isysroot $(XCODE_DIR)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$(IOS_VERSION).sdk -mios-simulator-version-min=$(IOS_VERSION_MIN)
268 tvos_sim_sysroot = -isysroot $(XCODE_DIR)/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator$(TVOS_VERSION).sdk -mtvos-simulator-version-min=$(TVOS_VERSION_MIN)
269 watchos_sim_sysroot = -isysroot $(XCODE_DIR)/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator$(WATCH_VERSION).sdk -mwatchos-simulator-version-min=$(WATCHOS_VERSION_MIN)
271 ios-sim32_SYSROOT = $(ios_sim_sysroot)
272 ios-sim64_SYSROOT = $(ios_sim_sysroot)
273 ios-simtv_SYSROOT = $(tvos_sim_sysroot)
274 ios-simwatch_SYSROOT = $(watchos_sim_sysroot)
276 ios-simwatch_CONFIGURE_FLAGS = --enable-cooperative-suspend
278 ios-sim32_CPPFLAGS = -DHOST_IOS
279 ios-sim64_CPPFLAGS = -DHOST_IOS
280 ios-simtv_CPPFLAGS = -DHOST_APPLETVOS -DTARGET_APPLETVOS
281 ios-simwatch_CPPFLAGS = -DHOST_IOS -DHOST_WATCHOS
283 ios-simtv_AC_VARS = \
284 ac_cv_func_pthread_kill=no \
285 ac_cv_func_kill=no \
286 ac_cv_func_sigaction=no \
287 ac_cv_func_fork=no \
288 ac_cv_func_execv=no \
289 ac_cv_func_execve=no \
290 ac_cv_func_execvp=no \
291 ac_cv_func_signal=no
292 ios-simwatch_AC_VARS = \
293 ac_cv_func_system=no \
294 ac_cv_func_pthread_kill=no \
295 ac_cv_func_kill=no \
296 ac_cv_func_sigaction=no \
297 ac_cv_func_fork=no \
298 ac_cv_func_execv=no \
299 ac_cv_func_execve=no \
300 ac_cv_func_execvp=no \
301 ac_cv_func_signal=no
303 $(eval $(call iOSSimulatorTemplate,sim32,i386))
304 $(eval $(call iOSSimulatorTemplate,sim64,x86_64))
305 $(eval $(call iOSSimulatorTemplate,simtv,x86_64))
306 $(eval $(call iOSSimulatorTemplate,simwatch,i386))
309 # Parameters:
310 # $(1): target (cross32 or cross64)
311 # $(2): arch (arm or aarch64)
312 # $(3): llvm (llvm32 or llvm64)
313 # $(4): configure target arch
314 # $(5): offsets tool --abi argument
316 # Flags:
317 # ios-$(1)_AC_VARS
318 # ios-$(1)_CFLAGS
319 # ios-$(1)_CXXFLAGS
320 # ios-$(1)_LDFLAGS
321 # ios-$(1)_CONFIGURE_FLAGS
322 define iOSCrossTemplate
324 _ios-$(1)_OFFSET_TOOL_ABI=$(5)
326 _ios-$(1)_CC=$$(CCACHE) $$(PLATFORM_BIN)/clang
327 _ios-$(1)_CXX=$$(CCACHE) $$(PLATFORM_BIN)/clang++
329 _ios-$(1)_AC_VARS= \
330 ac_cv_func_shm_open_working_with_mmap=no \
331 $$(ios-$(1)_AC_VARS)
333 _ios-$(1)_CFLAGS= \
334 -isysroot $$(XCODE_DIR)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$$(MACOS_VERSION).sdk -mmacosx-version-min=$$(MACOS_VERSION_MIN) \
335 -Qunused-arguments \
336 $$(ios-$(1)_CFLAGS)
338 _ios-$(1)_CXXFLAGS= \
339 -isysroot $$(XCODE_DIR)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$$(MACOS_VERSION).sdk -mmacosx-version-min=$$(MACOS_VERSION_MIN) \
340 -Qunused-arguments \
341 -stdlib=libc++ \
342 $$(ios-$(1)_CXXFLAGS)
344 _ios-$(1)_CPPFLAGS= \
345 -DMONOTOUCH=1 \
346 $$(ios-$(1)_CPPFLAGS)
348 _ios-$(1)_LDFLAGS= \
349 $$(ios_LDFLAGS) \
350 -stdlib=libc++ \
351 $$(ios-$(1)_LDFLAGS)
353 _ios-$(1)_CONFIGURE_FLAGS= \
354 $$(ios-$(1)_CONFIGURE_FLAGS) \
355 --target=$(4) \
356 --cache-file=$$(TOP)/sdks/builds/ios-$(1)-$$(CONFIGURATION).config.cache \
357 --prefix=$$(TOP)/sdks/out/ios-$(1)-$$(CONFIGURATION) \
358 --disable-boehm \
359 --disable-btls \
360 --disable-iconv \
361 --disable-libraries \
362 --disable-mcs-build \
363 --disable-nls \
364 --enable-dtrace=no \
365 --enable-icall-symbol-map \
366 --enable-minimal=com,remoting \
367 --with-cross-offsets=$(4).h \
368 --with-llvm=$$(TOP)/sdks/out/ios-$(3)
370 .stamp-ios-$(1)-toolchain:
371 touch $$@
373 .stamp-ios-$(1)-$$(CONFIGURATION)-configure: | $(if $(IGNORE_PACKAGE_LLVM),package-llvm-$(3),download-llvm-$(3))
375 $$(TOP)/sdks/builds/ios-$(1)-$$(CONFIGURATION)/$(4).h: .stamp-ios-$(1)-$$(CONFIGURATION)-configure $$(TOP)/tools/offsets-tool/MonoAotOffsetsDumper.exe
376 cd $$(TOP)/sdks/builds/ios-$(1)-$$(CONFIGURATION) && \
377 MONO_PATH=$(TOP)/tools/offsets-tool/CppSharp/osx_64 \
378 mono --debug $$(TOP)/tools/offsets-tool/MonoAotOffsetsDumper.exe \
379 --gen-ios --abi $$(_ios-$(1)_OFFSET_TOOL_ABI) --outfile $$@ --mono $$(TOP) --targetdir $$(TOP)/sdks/builds/ios-$(1)-$$(CONFIGURATION)
381 build-ios-$(1): $$(TOP)/sdks/builds/ios-$(1)-$$(CONFIGURATION)/$(4).h
383 $$(eval $$(call RuntimeTemplate,ios-$(1)))
385 endef
387 ios-cross32_CONFIGURE_FLAGS=--build=i386-apple-darwin10
388 ios-crosswatch_CONFIGURE_FLAGS=--build=i386-apple-darwin10 --enable-cooperative-suspend
389 $(eval $(call iOSCrossTemplate,cross32,arm,llvm36-32,arm-darwin,arm-apple-darwin10))
390 $(eval $(call iOSCrossTemplate,cross64,aarch64,llvm64,aarch64-darwin,aarch64-apple-darwin10))
391 $(eval $(call iOSCrossTemplate,crosswatch,armv7k,llvm36-32,armv7k-unknown-darwin,armv7k-apple-darwin))