Commit 43dbbd637586cdf00e3bfbb00f01c62c41e3a962

Sam Lantinga 2017-02-20T10:55:49

Updated iOS fat build

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
diff --git a/build-scripts/iosbuild.sh b/build-scripts/iosbuild.sh
index eeb5716..bb0e631 100755
--- a/build-scripts/iosbuild.sh
+++ b/build-scripts/iosbuild.sh
@@ -1,7 +1,6 @@
 #!/bin/sh
 #
 # Build a fat binary for iOS
-# Based on fatbuild.sh and code from the Ignifuga Game Engine
 
 # Number of CPUs (for make -j)
 NCPU=`sysctl -n hw.ncpu`
@@ -9,269 +8,181 @@ if test x$NJOB = x; then
     NJOB=$NCPU
 fi
 
-# SDK path
-XCODE_PATH=`xcode-select --print-path`
-if [ -z "$XCODE_PATH" ]; then
-    echo "Could not find XCode location (use xcode-select -switch to set the correct path)"
-    exit 1
+SRC_DIR=$(cd `dirname $0`/..; pwd)
+if [ "$PWD" = "$SRC_DIR" ]; then
+    PREFIX=$SRC_DIR/ios-build
+    mkdir $PREFIX
+else
+    PREFIX=$PWD
 fi
 
-prepare_environment() {
-    ARCH=$1
-    
-    if test x$SDK_VERSION = x; then
-      export SDK_VERSION=`xcodebuild -showsdks | grep iphoneos | sed "s|.*iphoneos||"`
-      if [ -z "$XCODE_PATH" ]; then
-          echo "Could not find a valid iOS SDK"
-          exit 1
-      fi  
-    fi
-    
-    case $ARCH in
-        armv6)
-            DEV_PATH="$XCODE_PATH/Platforms/iPhoneOS.platform/Developer"
-            SDK_PATH="$DEV_PATH/SDKs/iPhoneOS$SDK_VERSION.sdk"
-            ;;
-        armv7)
-            DEV_PATH="$XCODE_PATH/Platforms/iPhoneOS.platform/Developer"
-            SDK_PATH="$DEV_PATH/SDKs/iPhoneOS$SDK_VERSION.sdk"
-            ;;
-        i386)
-            DEV_PATH="$XCODE_PATH/Platforms/iPhoneSimulator.platform/Developer"
-            SDK_PATH="$DEV_PATH/SDKs/iPhoneSimulator$SDK_VERSION.sdk"
-            ;;
-        *)
-            echo "Unknown Architecture $ARCH"
-            exit 1
-            ;;
-    esac
+BUILD_I386_IOSSIM=YES
+BUILD_X86_64_IOSSIM=YES
 
-    if [ ! -d "$SDK_PATH" ]; then
-        echo "Could not find iOS SDK at $SDK_PATH"
-        exit 1
-    fi
+BUILD_IOS_ARMV7=YES
+BUILD_IOS_ARMV7S=YES
+BUILD_IOS_ARM64=YES
 
-    if test x$MIN_OS_VERSION = x; then
-        export MIN_OS_VERSION="3.0"
-    fi
-    
-    # Environment flags
-    CFLAGS="-g -O2 -pipe -no-cpp-precomp -isysroot $SDK_PATH \
-            -miphoneos-version-min=$MIN_OS_VERSION -I$SDK_PATH/usr/include/"
-    LDFLAGS="-L$SDK_PATH/usr/lib/ -isysroot $SDK_PATH \
-             -miphoneos-version-min=$MIN_OS_VERSION -static-libgcc"
-    export CXXFLAGS="$CFLAGS"
-    export CXXCPP="$DEV_PATH/usr/bin/llvm-cpp-4.2"
-    export CPP="$CXXCPP"
-    export CXX="$DEV_PATH/usr/bin/llvm-g++-4.2"
-    export CC="$DEV_PATH/usr/bin/llvm-gcc-4.2"
-    export LD="$DEV_PATH/usr/bin/ld"
-    export AR="$DEV_PATH/usr/bin/ar"
-    export AS="$DEV_PATH/usr/bin/ls"
-    export NM="$DEV_PATH/usr/bin/nm"
-    export RANLIB="$DEV_PATH/usr/bin/ranlib"
-    export STRIP="$DEV_PATH/usr/bin/strip"
-    
-    # We dynamically load X11, so using the system X11 headers is fine.
-    CONFIG_FLAGS="--disable-shared --enable-static"
-    
-    case $ARCH in
-        armv6)
-            export CONFIG_FLAGS="$CONFIG_FLAGS --host=armv6-apple-darwin"
-            export CFLAGS="$CFLAGS -arch armv6"
-            export LDFLAGS="$LDFLAGS -arch armv6"
-            ;;
-        armv7)
-            export CONFIG_FLAGS="$CONFIG_FLAGS --host=armv7-apple-darwin"
-            export CFLAGS="$CFLAGS -arch armv7"
-            export LDFLAGS="$LDFLAGS -arch armv7"
-            ;;
-        i386)
-            export CONFIG_FLAGS="$CONFIG_FLAGS --host=i386-apple-darwin"
-            export CFLAGS="$CFLAGS -arch i386"
-            export LDFLAGS="$LDFLAGS -arch i386"
-            ;;
-        *)
-            echo "Unknown Architecture $ARCH"
-            exit 1
-            ;;
-    esac
-}
+# 13.4.0 - Mavericks
+# 14.0.0 - Yosemite
+# 15.0.0 - El Capitan
+DARWIN=darwin15.0.0
 
-prepare_environment "armv6"
-echo "Building with iOS SDK v$SDK_VERSION for iOS >= $MIN_OS_VERSION"
+XCODEDIR=`xcode-select --print-path`
+IOS_SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version`
+MIN_SDK_VERSION=6.0
 
-#
-# Find the configure script
-#
-srcdir=`dirname $0`/..
-srcdir=`cd $srcdir && pwd`
-auxdir=$srcdir/build-scripts
-cd $srcdir
+IPHONEOS_PLATFORM=`xcrun --sdk iphoneos --show-sdk-platform-path`
+IPHONEOS_SYSROOT=`xcrun --sdk iphoneos --show-sdk-path`
 
-#
-# Figure out which phase to build:
-# all,
-# configure, configure-armv6, configure-armv7, configure-i386
-# make, make-armv6, make-armv7, make-i386, merge
-# clean
-if test x"$1" = x; then
-    phase=all
-else
-    phase="$1"
-fi
-case $phase in
-    all)
-        configure_armv6="yes"
-        configure_armv7="yes"
-        configure_i386="yes"
-        make_armv6="yes"
-        make_armv7="yes"
-        make_i386="yes"
-        merge="yes"
-        ;;
-    configure)
-        configure_armv6="yes"
-        configure_armv7="yes"
-        configure_i386="yes"
-        ;;
-    configure-armv6)
-        configure_armv6="yes"
-        ;;
-    configure-armv7)
-        configure_armv7="yes"
-        ;;
-    configure-i386)
-        configure_i386="yes"
-        ;;
-    make)
-        make_armv6="yes"
-        make_armv7="yes"
-        make_i386="yes"
-        merge="yes"
-        ;;
-    make-armv6)
-        make_armv6="yes"
-        ;;
-    make-armv7)
-        make_armv7="yes"
-        ;;
-    make-i386)
-        make_i386="yes"
-        ;;
-    merge)
-        merge="yes"
-        ;;
-    clean)
-        clean_armv6="yes"
-        clean_armv7="yes"
-        clean_i386="yes"
-        ;;
-    clean-armv6)
-        clean_armv6="yes"
-        ;;
-    clean-armv7)
-        clean_armv7="yes"
-        ;;
-    clean-i386)
-        clean_i386="yes"
-        ;;
-    *)
-        echo "Usage: $0 [all|configure[-armv6|-armv7|-i386]|make[-armv6|-armv7|-i386]|merge|clean[-armv6|-armv7|-i386]]"
-        exit 1
-        ;;
-esac
+IPHONESIMULATOR_PLATFORM=`xcrun --sdk iphonesimulator --show-sdk-platform-path`
+IPHONESIMULATOR_SYSROOT=`xcrun --sdk iphonesimulator --show-sdk-path`
 
-#
-# Create the build directories
-#
-for dir in build build/armv6 build/armv7 build/i386; do
-    if test -d $dir; then
-        :
-    else
-        mkdir $dir || exit 1
-    fi
-done
+# Uncomment if you want to see more information about each invocation
+# of clang as the builds proceed.
+# CLANG_VERBOSE="--verbose"
 
-#
-# Build the armv6 binary
-#
-prepare_environment "armv6"
-if test x$configure_armv6 = xyes; then
-    (cd build/armv6 && \
-     sh ../../configure $CONFIG_FLAGS CC="$CC" CXX="$CXX" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS") || exit 2
-     # configure is not yet fully ready for iOS, some manual patching is required
-     cp include/* build/armv6/include
-     cp include/SDL_config_iphoneos.h build/armv6/include/SDL_config.h || exit 2
-     sed -i "" -e "s|^EXTRA_CFLAGS.*|EXTRA_CFLAGS=-I./include|g" build/armv6/Makefile || exit 2
-     sed -i "" -e "s|^EXTRA_LDFLAGS.*|EXTRA_LDFLAGS=-lm|g" build/armv6/Makefile || exit 2
-fi
-if test x$make_armv6 = xyes; then
-    (cd build/armv6 && make -j$NJOB) || exit 3
-fi
-#
-# Build the armv7 binary
-#
-prepare_environment "armv7"
-if test x$configure_armv7 = xyes; then
-    (cd build/armv7 && \
-     sh ../../configure $CONFIG_FLAGS CC="$CC" CXX="$CXX" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS") || exit 2
-     # configure is not yet fully ready for iOS, some manual patching is required
-     cp include/* build/armv7/include
-     cp include/SDL_config_iphoneos.h build/armv7/include/SDL_config.h || exit 2
-     sed -i "" -e "s|^EXTRA_CFLAGS.*|EXTRA_CFLAGS=-I./include|g" build/armv7/Makefile || exit 2
-     sed -i "" -e "s|^EXTRA_LDFLAGS.*|EXTRA_LDFLAGS=-lm|g" build/armv7/Makefile || exit 2
-fi
-if test x$make_armv7 = xyes; then
-    (cd build/armv7 && make -j$NJOB) || exit 3
-fi
-#
-# Build the i386 binary
-#
-prepare_environment "i386"
-if test x$configure_i386 = xyes; then
-    (cd build/i386 && \
-     sh ../../configure $CONFIG_FLAGS CC="$CC" CXX="$CXX" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS") || exit 2
-     # configure is not yet fully ready for iOS, some manual patching is required
-     cp include/* build/i386/include
-     cp include/SDL_config_iphoneos.h build/i386/include/SDL_config.h || exit 2
-     sed -i "" -e "s|^EXTRA_CFLAGS.*|EXTRA_CFLAGS=-I./include|g" build/i386/Makefile || exit 2
-     sed -i "" -e "s|^EXTRA_LDFLAGS.*|EXTRA_LDFLAGS=-lm|g" build/i386/Makefile || exit 2
-fi
-if test x$make_i386 = xyes; then
-    (cd build/i386 && make -j$NJOB) || exit 3
+CC=clang
+CXX=clang
+
+SILENCED_WARNINGS="-Wno-unused-local-typedef -Wno-unused-function"
+
+CFLAGS="${CLANG_VERBOSE} ${SILENCED_WARNINGS} -DNDEBUG -g -O0 -pipe -fPIC -fobjc-arc"
+
+echo "PREFIX ..................... ${PREFIX}"
+echo "BUILD_MACOSX_X86_64 ........ ${BUILD_MACOSX_X86_64}"
+echo "BUILD_I386_IOSSIM .......... ${BUILD_I386_IOSSIM}"
+echo "BUILD_X86_64_IOSSIM ........ ${BUILD_X86_64_IOSSIM}"
+echo "BUILD_IOS_ARMV7 ............ ${BUILD_IOS_ARMV7}"
+echo "BUILD_IOS_ARMV7S ........... ${BUILD_IOS_ARMV7S}"
+echo "BUILD_IOS_ARM64 ............ ${BUILD_IOS_ARM64}"
+echo "DARWIN ..................... ${DARWIN}"
+echo "XCODEDIR ................... ${XCODEDIR}"
+echo "IOS_SDK_VERSION ............ ${IOS_SDK_VERSION}"
+echo "MIN_SDK_VERSION ............ ${MIN_SDK_VERSION}"
+echo "IPHONEOS_PLATFORM .......... ${IPHONEOS_PLATFORM}"
+echo "IPHONEOS_SYSROOT ........... ${IPHONEOS_SYSROOT}"
+echo "IPHONESIMULATOR_PLATFORM ... ${IPHONESIMULATOR_PLATFORM}"
+echo "IPHONESIMULATOR_SYSROOT .... ${IPHONESIMULATOR_SYSROOT}"
+echo "CC ......................... ${CC}"
+echo "CFLAGS ..................... ${CFLAGS}"
+echo "CXX ........................ ${CXX}"
+echo "CXXFLAGS ................... ${CXXFLAGS}"
+echo "LDFLAGS .................... ${LDFLAGS}"
+
+###################################################################
+# This section contains the build commands for each of the 
+# architectures that will be included in the universal binaries.
+###################################################################
+
+echo "$(tput setaf 2)"
+echo "###########################"
+echo "# i386 for iPhone Simulator"
+echo "###########################"
+echo "$(tput sgr0)"
+
+if [ "${BUILD_I386_IOSSIM}" == "YES" ]
+then
+    (
+        cd ${PREFIX}
+        make clean
+        ../configure --build=x86_64-apple-${DARWIN} --host=i386-ios-${DARWIN} --disable-shared --prefix=${PREFIX}/platform/i386-sim "CC=${CC}" "CFLAGS=${CFLAGS} -mios-simulator-version-min=${MIN_SDK_VERSION} -arch i386 -isysroot ${IPHONESIMULATOR_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -mios-simulator-version-min=${MIN_SDK_VERSION} -arch i386 -isysroot ${IPHONESIMULATOR_SYSROOT}" LDFLAGS="-arch i386 -mios-simulator-version-min=${MIN_SDK_VERSION} ${LDFLAGS} -L${IPHONESIMULATOR_SYSROOT}/usr/lib/ -L${IPHONESIMULATOR_SYSROOT}/usr/lib/system" || exit 2
+	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
+        make -j10 || exit 3
+        make install
+    ) || exit $?
 fi
 
-#
-# Combine into fat binary
-#
-if test x$merge = xyes; then
-    output=ios/lib
-    sh $auxdir/mkinstalldirs build/$output
-    cd build
-    target=`find . -mindepth 4 -maxdepth 4 -type f -name '*.dylib' | head -1 | sed 's|.*/||'`
-    (lipo -create -o $output/libSDL2.a armv6/build/.libs/libSDL2.a armv7/build/.libs/libSDL2.a i386/build/.libs/libSDL2.a &&
-     lipo -create -o $output/libSDL2main.a armv6/build/libSDL2main.a armv7/build/libSDL2main.a i386/build/libSDL2main.a &&
-     cp -r armv6/include ios
-     echo "Build complete!" &&
-     echo "Files can be found under the build/ios directory.") || exit 4
-    cd ..
+echo "$(tput setaf 2)"
+echo "#############################"
+echo "# x86_64 for iPhone Simulator"
+echo "#############################"
+echo "$(tput sgr0)"
+
+if [ "${BUILD_X86_64_IOSSIM}" == "YES" ]
+then
+    (
+        cd ${PREFIX}
+        make clean
+        ../configure --build=x86_64-apple-${DARWIN} --host=x86_64-ios-${DARWIN} --disable-shared --prefix=${PREFIX}/platform/x86_64-sim "CC=${CC}" "CFLAGS=${CFLAGS} -mios-simulator-version-min=${MIN_SDK_VERSION} -arch x86_64 -isysroot ${IPHONESIMULATOR_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -mios-simulator-version-min=${MIN_SDK_VERSION} -arch x86_64 -isysroot ${IPHONESIMULATOR_SYSROOT}" LDFLAGS="-arch x86_64 -mios-simulator-version-min=${MIN_SDK_VERSION} ${LDFLAGS} -L${IPHONESIMULATOR_SYSROOT}/usr/lib/ -L${IPHONESIMULATOR_SYSROOT}/usr/lib/system" || exit 2
+	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
+        make -j$NJOB || exit 3
+        make install
+    ) || exit $?
 fi
 
-#
-# Clean up
-#
-do_clean()
-{
-    echo $*
-    $* || exit 6
-}
-if test x$clean_armv6 = xyes; then
-    do_clean rm -r build/armv6
+echo "$(tput setaf 2)"
+echo "##################"
+echo "# armv7 for iPhone"
+echo "##################"
+echo "$(tput sgr0)"
+
+if [ "${BUILD_IOS_ARMV7}" == "YES" ]
+then
+    (
+        cd ${PREFIX}
+        make clean
+        ../configure --build=x86_64-apple-${DARWIN} --host=armv7-ios-${DARWIN} --disable-shared --prefix=${PREFIX}/platform/armv7-ios "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch armv7 -isysroot ${IPHONEOS_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -arch armv7 -isysroot ${IPHONEOS_SYSROOT}" LDFLAGS="-arch armv7 -miphoneos-version-min=${MIN_SDK_VERSION} ${LDFLAGS}" || exit 2
+	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
+        make -j$NJOB || exit 3
+        make install
+    ) || exit $?
 fi
-if test x$clean_armv7 = xyes; then
-    do_clean rm -r build/armv7
+
+echo "$(tput setaf 2)"
+echo "###################"
+echo "# armv7s for iPhone"
+echo "###################"
+echo "$(tput sgr0)"
+
+if [ "${BUILD_IOS_ARMV7S}" == "YES" ]
+then
+    (
+        cd ${PREFIX}
+        make clean
+        ../configure --build=x86_64-apple-${DARWIN} --host=armv7s-ios-${DARWIN} --disable-shared --prefix=${PREFIX}/platform/armv7s-ios "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch armv7s -isysroot ${IPHONEOS_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch armv7s -isysroot ${IPHONEOS_SYSROOT}" LDFLAGS="-arch armv7s -miphoneos-version-min=${MIN_SDK_VERSION} ${LDFLAGS}" || exit 2
+	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
+        make -j$NJOB || exit 3
+        make install
+    ) || exit $?
 fi
-if test x$clean_i386 = xyes; then
-    do_clean rm -r build/i386
+
+echo "$(tput setaf 2)"
+echo "##################"
+echo "# arm64 for iPhone"
+echo "##################"
+echo "$(tput sgr0)"
+
+if [ "${BUILD_IOS_ARM64}" == "YES" ]
+then
+    (
+        cd ${PREFIX}
+        make clean
+        ../configure --build=x86_64-apple-${DARWIN} --host=arm-ios-${DARWIN} --disable-shared --prefix=${PREFIX}/platform/arm64-ios "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch arm64 -isysroot ${IPHONEOS_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch arm64 -isysroot ${IPHONEOS_SYSROOT}" LDFLAGS="-arch arm64 -miphoneos-version-min=${MIN_SDK_VERSION} ${LDFLAGS}" || exit 2
+	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
+        make -j$NJOB || exit 3
+        make install
+    ) || exit $?
 fi
+
+echo "$(tput setaf 2)"
+echo "###################################################################"
+echo "# Create Universal Libraries and Finalize the packaging"
+echo "###################################################################"
+echo "$(tput sgr0)"
+
+(
+    cd ${PREFIX}/platform
+    mkdir -p universal
+    lipo x86_64-sim/lib/libSDL2.a i386-sim/lib/libSDL2.a arm64-ios/lib/libSDL2.a armv7s-ios/lib/libSDL2.a armv7-ios/lib/libSDL2.a -create -output universal/libSDL2.a
+)
+
+(
+    cd ${PREFIX}
+    mkdir -p lib
+    cp -r platform/universal/* lib
+    #rm -rf platform
+    lipo -info lib/libSDL2.a
+)
+
+echo Done!
diff --git a/configure b/configure
index 5e60a44..a9a0f02 100755
--- a/configure
+++ b/configure
@@ -23671,9 +23671,7 @@ $as_echo "#define SDL_FILESYSTEM_HAIKU 1" >>confdefs.h
         SOURCES="$srcdir/src/main/haiku/*.cc $SOURCES"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
         ;;
-    arm*-apple-darwin*)
-        # iOS - We are not writing anything to confdefs.h because you have to replace
-        # SDL_config.h for SDL_config_iphoneos.h anyway
+    arm*-apple-darwin*|*-ios-*)
         ARCH=ios
 
         CheckVisibilityHidden
@@ -23682,18 +23680,22 @@ $as_echo "#define SDL_FILESYSTEM_HAIKU 1" >>confdefs.h
         CheckDiskAudio
         CheckDummyAudio
         CheckDLOPEN
-        CheckCOCOA
         CheckPTHREAD
 
-
         # Set up files for the audio library
         if test x$enable_audio = xyes; then
+
+$as_echo "#define SDL_AUDIO_DRIVER_COREAUDIO 1" >>confdefs.h
+
             SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.m"
             SUMMARY_audio="${SUMMARY_audio} coreaudio"
             have_audio=yes
         fi
         # Set up files for the joystick library
         if test x$enable_joystick = xyes; then
+
+$as_echo "#define SDL_JOYSTICK_MFI 1" >>confdefs.h
+
             SOURCES="$SOURCES $srcdir/src/joystick/iphoneos/*.m"
             have_joystick=yes
         fi
@@ -23705,6 +23707,9 @@ $as_echo "#define SDL_FILESYSTEM_HAIKU 1" >>confdefs.h
         #fi
         # Set up files for the power library
         if test x$enable_power = xyes; then
+
+$as_echo "#define SDL_POWER_UIKIT 1" >>confdefs.h
+
             SOURCES="$SOURCES $srcdir/src/power/uikit/*.m"
             have_power=yes
         fi
@@ -23713,28 +23718,50 @@ $as_echo "#define SDL_FILESYSTEM_HAIKU 1" >>confdefs.h
             SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
             have_filesystem=yes
         fi
+        # Set up additional files for the file library
+        if test x$enable_file = xyes; then
+
+$as_echo "#define SDL_FILESYSTEM_COCOA 1" >>confdefs.h
+
+            SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
+        fi
         # Set up files for the timer library
         if test x$enable_timers = xyes; then
+
+$as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
+
             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
             have_timers=yes
         fi
-        # Set up additional files for the file library
-        if test x$enable_file = xyes; then
-            SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
-        fi
         # The iOS platform requires special setup.
+
+$as_echo "#define SDL_VIDEO_DRIVER_UIKIT 1" >>confdefs.h
+
+
+$as_echo "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h
+
+
+$as_echo "#define SDL_VIDEO_OPENGL_ES 1" >>confdefs.h
+
+
+$as_echo "#define SDL_VIDEO_RENDER_OGL_ES 1" >>confdefs.h
+
+
+$as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
+
         SOURCES="$SOURCES $srcdir/src/video/uikit/*.m"
         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm -liconv -lobjc"
-        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Foundation"
-        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
-        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
-        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
-        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio"
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AVFoundation"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox"
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreGraphics"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreMotion"
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Foundation"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,GameController"
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
         ;;
     *-*-darwin* )
         # This could be either full "Mac OS X", or plain "Darwin" which is
diff --git a/configure.in b/configure.in
index f434d7e..6de8e25 100644
--- a/configure.in
+++ b/configure.in
@@ -3346,9 +3346,7 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
         SOURCES="$srcdir/src/main/haiku/*.cc $SOURCES"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
         ;;
-    arm*-apple-darwin*)
-        # iOS - We are not writing anything to confdefs.h because you have to replace
-        # SDL_config.h for SDL_config_iphoneos.h anyway
+    arm*-apple-darwin*|*-ios-*)
         ARCH=ios
 
         CheckVisibilityHidden
@@ -3357,18 +3355,18 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
         CheckDiskAudio
         CheckDummyAudio
         CheckDLOPEN
-        CheckCOCOA
         CheckPTHREAD
 
-
         # Set up files for the audio library
         if test x$enable_audio = xyes; then
+            AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ])
             SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.m"
             SUMMARY_audio="${SUMMARY_audio} coreaudio"
             have_audio=yes
         fi
         # Set up files for the joystick library
         if test x$enable_joystick = xyes; then
+            AC_DEFINE(SDL_JOYSTICK_MFI, 1, [ ])
             SOURCES="$SOURCES $srcdir/src/joystick/iphoneos/*.m"
             have_joystick=yes
         fi
@@ -3380,6 +3378,7 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
         #fi
         # Set up files for the power library
         if test x$enable_power = xyes; then
+            AC_DEFINE(SDL_POWER_UIKIT, 1, [ ])
             SOURCES="$SOURCES $srcdir/src/power/uikit/*.m"
             have_power=yes
         fi
@@ -3388,28 +3387,36 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
             SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
             have_filesystem=yes
         fi
+        # Set up additional files for the file library
+        if test x$enable_file = xyes; then
+            AC_DEFINE(SDL_FILESYSTEM_COCOA, 1, [ ])
+            SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
+        fi
         # Set up files for the timer library
         if test x$enable_timers = xyes; then
+            AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
             have_timers=yes
         fi
-        # Set up additional files for the file library
-        if test x$enable_file = xyes; then
-            SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
-        fi
         # The iOS platform requires special setup.
+        AC_DEFINE(SDL_VIDEO_DRIVER_UIKIT, 1, [ ])
+        AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
+        AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
+        AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
+        AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
         SOURCES="$SOURCES $srcdir/src/video/uikit/*.m"
         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm -liconv -lobjc"
-        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Foundation"
-        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
-        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
-        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
-        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio"
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AVFoundation"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox"
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreGraphics"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreMotion"
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Foundation"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,GameController"
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
         ;;
     *-*-darwin* )
         # This could be either full "Mac OS X", or plain "Darwin" which is