Updated iOS fat build
authorSam Lantinga <slouken@libsdl.org>
Mon, 20 Feb 2017 10:55:49 -0800
changeset 109044dbd025c4eb9
parent 10903 875e0bb9646c
child 10905 9c6570c422c4
Updated iOS fat build
build-scripts/iosbuild.sh
configure
configure.in
     1.1 --- a/build-scripts/iosbuild.sh	Mon Feb 20 10:55:33 2017 -0800
     1.2 +++ b/build-scripts/iosbuild.sh	Mon Feb 20 10:55:49 2017 -0800
     1.3 @@ -1,7 +1,6 @@
     1.4  #!/bin/sh
     1.5  #
     1.6  # Build a fat binary for iOS
     1.7 -# Based on fatbuild.sh and code from the Ignifuga Game Engine
     1.8  
     1.9  # Number of CPUs (for make -j)
    1.10  NCPU=`sysctl -n hw.ncpu`
    1.11 @@ -9,269 +8,181 @@
    1.12      NJOB=$NCPU
    1.13  fi
    1.14  
    1.15 -# SDK path
    1.16 -XCODE_PATH=`xcode-select --print-path`
    1.17 -if [ -z "$XCODE_PATH" ]; then
    1.18 -    echo "Could not find XCode location (use xcode-select -switch to set the correct path)"
    1.19 -    exit 1
    1.20 +SRC_DIR=$(cd `dirname $0`/..; pwd)
    1.21 +if [ "$PWD" = "$SRC_DIR" ]; then
    1.22 +    PREFIX=$SRC_DIR/ios-build
    1.23 +    mkdir $PREFIX
    1.24 +else
    1.25 +    PREFIX=$PWD
    1.26  fi
    1.27  
    1.28 -prepare_environment() {
    1.29 -    ARCH=$1
    1.30 -    
    1.31 -    if test x$SDK_VERSION = x; then
    1.32 -      export SDK_VERSION=`xcodebuild -showsdks | grep iphoneos | sed "s|.*iphoneos||"`
    1.33 -      if [ -z "$XCODE_PATH" ]; then
    1.34 -          echo "Could not find a valid iOS SDK"
    1.35 -          exit 1
    1.36 -      fi  
    1.37 -    fi
    1.38 -    
    1.39 -    case $ARCH in
    1.40 -        armv6)
    1.41 -            DEV_PATH="$XCODE_PATH/Platforms/iPhoneOS.platform/Developer"
    1.42 -            SDK_PATH="$DEV_PATH/SDKs/iPhoneOS$SDK_VERSION.sdk"
    1.43 -            ;;
    1.44 -        armv7)
    1.45 -            DEV_PATH="$XCODE_PATH/Platforms/iPhoneOS.platform/Developer"
    1.46 -            SDK_PATH="$DEV_PATH/SDKs/iPhoneOS$SDK_VERSION.sdk"
    1.47 -            ;;
    1.48 -        i386)
    1.49 -            DEV_PATH="$XCODE_PATH/Platforms/iPhoneSimulator.platform/Developer"
    1.50 -            SDK_PATH="$DEV_PATH/SDKs/iPhoneSimulator$SDK_VERSION.sdk"
    1.51 -            ;;
    1.52 -        *)
    1.53 -            echo "Unknown Architecture $ARCH"
    1.54 -            exit 1
    1.55 -            ;;
    1.56 -    esac
    1.57 +BUILD_I386_IOSSIM=YES
    1.58 +BUILD_X86_64_IOSSIM=YES
    1.59  
    1.60 -    if [ ! -d "$SDK_PATH" ]; then
    1.61 -        echo "Could not find iOS SDK at $SDK_PATH"
    1.62 -        exit 1
    1.63 -    fi
    1.64 +BUILD_IOS_ARMV7=YES
    1.65 +BUILD_IOS_ARMV7S=YES
    1.66 +BUILD_IOS_ARM64=YES
    1.67  
    1.68 -    if test x$MIN_OS_VERSION = x; then
    1.69 -        export MIN_OS_VERSION="3.0"
    1.70 -    fi
    1.71 -    
    1.72 -    # Environment flags
    1.73 -    CFLAGS="-g -O2 -pipe -no-cpp-precomp -isysroot $SDK_PATH \
    1.74 -            -miphoneos-version-min=$MIN_OS_VERSION -I$SDK_PATH/usr/include/"
    1.75 -    LDFLAGS="-L$SDK_PATH/usr/lib/ -isysroot $SDK_PATH \
    1.76 -             -miphoneos-version-min=$MIN_OS_VERSION -static-libgcc"
    1.77 -    export CXXFLAGS="$CFLAGS"
    1.78 -    export CXXCPP="$DEV_PATH/usr/bin/llvm-cpp-4.2"
    1.79 -    export CPP="$CXXCPP"
    1.80 -    export CXX="$DEV_PATH/usr/bin/llvm-g++-4.2"
    1.81 -    export CC="$DEV_PATH/usr/bin/llvm-gcc-4.2"
    1.82 -    export LD="$DEV_PATH/usr/bin/ld"
    1.83 -    export AR="$DEV_PATH/usr/bin/ar"
    1.84 -    export AS="$DEV_PATH/usr/bin/ls"
    1.85 -    export NM="$DEV_PATH/usr/bin/nm"
    1.86 -    export RANLIB="$DEV_PATH/usr/bin/ranlib"
    1.87 -    export STRIP="$DEV_PATH/usr/bin/strip"
    1.88 -    
    1.89 -    # We dynamically load X11, so using the system X11 headers is fine.
    1.90 -    CONFIG_FLAGS="--disable-shared --enable-static"
    1.91 -    
    1.92 -    case $ARCH in
    1.93 -        armv6)
    1.94 -            export CONFIG_FLAGS="$CONFIG_FLAGS --host=armv6-apple-darwin"
    1.95 -            export CFLAGS="$CFLAGS -arch armv6"
    1.96 -            export LDFLAGS="$LDFLAGS -arch armv6"
    1.97 -            ;;
    1.98 -        armv7)
    1.99 -            export CONFIG_FLAGS="$CONFIG_FLAGS --host=armv7-apple-darwin"
   1.100 -            export CFLAGS="$CFLAGS -arch armv7"
   1.101 -            export LDFLAGS="$LDFLAGS -arch armv7"
   1.102 -            ;;
   1.103 -        i386)
   1.104 -            export CONFIG_FLAGS="$CONFIG_FLAGS --host=i386-apple-darwin"
   1.105 -            export CFLAGS="$CFLAGS -arch i386"
   1.106 -            export LDFLAGS="$LDFLAGS -arch i386"
   1.107 -            ;;
   1.108 -        *)
   1.109 -            echo "Unknown Architecture $ARCH"
   1.110 -            exit 1
   1.111 -            ;;
   1.112 -    esac
   1.113 -}
   1.114 +# 13.4.0 - Mavericks
   1.115 +# 14.0.0 - Yosemite
   1.116 +# 15.0.0 - El Capitan
   1.117 +DARWIN=darwin15.0.0
   1.118  
   1.119 -prepare_environment "armv6"
   1.120 -echo "Building with iOS SDK v$SDK_VERSION for iOS >= $MIN_OS_VERSION"
   1.121 +XCODEDIR=`xcode-select --print-path`
   1.122 +IOS_SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version`
   1.123 +MIN_SDK_VERSION=6.0
   1.124  
   1.125 -#
   1.126 -# Find the configure script
   1.127 -#
   1.128 -srcdir=`dirname $0`/..
   1.129 -srcdir=`cd $srcdir && pwd`
   1.130 -auxdir=$srcdir/build-scripts
   1.131 -cd $srcdir
   1.132 +IPHONEOS_PLATFORM=`xcrun --sdk iphoneos --show-sdk-platform-path`
   1.133 +IPHONEOS_SYSROOT=`xcrun --sdk iphoneos --show-sdk-path`
   1.134  
   1.135 -#
   1.136 -# Figure out which phase to build:
   1.137 -# all,
   1.138 -# configure, configure-armv6, configure-armv7, configure-i386
   1.139 -# make, make-armv6, make-armv7, make-i386, merge
   1.140 -# clean
   1.141 -if test x"$1" = x; then
   1.142 -    phase=all
   1.143 -else
   1.144 -    phase="$1"
   1.145 -fi
   1.146 -case $phase in
   1.147 -    all)
   1.148 -        configure_armv6="yes"
   1.149 -        configure_armv7="yes"
   1.150 -        configure_i386="yes"
   1.151 -        make_armv6="yes"
   1.152 -        make_armv7="yes"
   1.153 -        make_i386="yes"
   1.154 -        merge="yes"
   1.155 -        ;;
   1.156 -    configure)
   1.157 -        configure_armv6="yes"
   1.158 -        configure_armv7="yes"
   1.159 -        configure_i386="yes"
   1.160 -        ;;
   1.161 -    configure-armv6)
   1.162 -        configure_armv6="yes"
   1.163 -        ;;
   1.164 -    configure-armv7)
   1.165 -        configure_armv7="yes"
   1.166 -        ;;
   1.167 -    configure-i386)
   1.168 -        configure_i386="yes"
   1.169 -        ;;
   1.170 -    make)
   1.171 -        make_armv6="yes"
   1.172 -        make_armv7="yes"
   1.173 -        make_i386="yes"
   1.174 -        merge="yes"
   1.175 -        ;;
   1.176 -    make-armv6)
   1.177 -        make_armv6="yes"
   1.178 -        ;;
   1.179 -    make-armv7)
   1.180 -        make_armv7="yes"
   1.181 -        ;;
   1.182 -    make-i386)
   1.183 -        make_i386="yes"
   1.184 -        ;;
   1.185 -    merge)
   1.186 -        merge="yes"
   1.187 -        ;;
   1.188 -    clean)
   1.189 -        clean_armv6="yes"
   1.190 -        clean_armv7="yes"
   1.191 -        clean_i386="yes"
   1.192 -        ;;
   1.193 -    clean-armv6)
   1.194 -        clean_armv6="yes"
   1.195 -        ;;
   1.196 -    clean-armv7)
   1.197 -        clean_armv7="yes"
   1.198 -        ;;
   1.199 -    clean-i386)
   1.200 -        clean_i386="yes"
   1.201 -        ;;
   1.202 -    *)
   1.203 -        echo "Usage: $0 [all|configure[-armv6|-armv7|-i386]|make[-armv6|-armv7|-i386]|merge|clean[-armv6|-armv7|-i386]]"
   1.204 -        exit 1
   1.205 -        ;;
   1.206 -esac
   1.207 +IPHONESIMULATOR_PLATFORM=`xcrun --sdk iphonesimulator --show-sdk-platform-path`
   1.208 +IPHONESIMULATOR_SYSROOT=`xcrun --sdk iphonesimulator --show-sdk-path`
   1.209  
   1.210 -#
   1.211 -# Create the build directories
   1.212 -#
   1.213 -for dir in build build/armv6 build/armv7 build/i386; do
   1.214 -    if test -d $dir; then
   1.215 -        :
   1.216 -    else
   1.217 -        mkdir $dir || exit 1
   1.218 -    fi
   1.219 -done
   1.220 +# Uncomment if you want to see more information about each invocation
   1.221 +# of clang as the builds proceed.
   1.222 +# CLANG_VERBOSE="--verbose"
   1.223  
   1.224 -#
   1.225 -# Build the armv6 binary
   1.226 -#
   1.227 -prepare_environment "armv6"
   1.228 -if test x$configure_armv6 = xyes; then
   1.229 -    (cd build/armv6 && \
   1.230 -     sh ../../configure $CONFIG_FLAGS CC="$CC" CXX="$CXX" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS") || exit 2
   1.231 -     # configure is not yet fully ready for iOS, some manual patching is required
   1.232 -     cp include/* build/armv6/include
   1.233 -     cp include/SDL_config_iphoneos.h build/armv6/include/SDL_config.h || exit 2
   1.234 -     sed -i "" -e "s|^EXTRA_CFLAGS.*|EXTRA_CFLAGS=-I./include|g" build/armv6/Makefile || exit 2
   1.235 -     sed -i "" -e "s|^EXTRA_LDFLAGS.*|EXTRA_LDFLAGS=-lm|g" build/armv6/Makefile || exit 2
   1.236 -fi
   1.237 -if test x$make_armv6 = xyes; then
   1.238 -    (cd build/armv6 && make -j$NJOB) || exit 3
   1.239 -fi
   1.240 -#
   1.241 -# Build the armv7 binary
   1.242 -#
   1.243 -prepare_environment "armv7"
   1.244 -if test x$configure_armv7 = xyes; then
   1.245 -    (cd build/armv7 && \
   1.246 -     sh ../../configure $CONFIG_FLAGS CC="$CC" CXX="$CXX" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS") || exit 2
   1.247 -     # configure is not yet fully ready for iOS, some manual patching is required
   1.248 -     cp include/* build/armv7/include
   1.249 -     cp include/SDL_config_iphoneos.h build/armv7/include/SDL_config.h || exit 2
   1.250 -     sed -i "" -e "s|^EXTRA_CFLAGS.*|EXTRA_CFLAGS=-I./include|g" build/armv7/Makefile || exit 2
   1.251 -     sed -i "" -e "s|^EXTRA_LDFLAGS.*|EXTRA_LDFLAGS=-lm|g" build/armv7/Makefile || exit 2
   1.252 -fi
   1.253 -if test x$make_armv7 = xyes; then
   1.254 -    (cd build/armv7 && make -j$NJOB) || exit 3
   1.255 -fi
   1.256 -#
   1.257 -# Build the i386 binary
   1.258 -#
   1.259 -prepare_environment "i386"
   1.260 -if test x$configure_i386 = xyes; then
   1.261 -    (cd build/i386 && \
   1.262 -     sh ../../configure $CONFIG_FLAGS CC="$CC" CXX="$CXX" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS") || exit 2
   1.263 -     # configure is not yet fully ready for iOS, some manual patching is required
   1.264 -     cp include/* build/i386/include
   1.265 -     cp include/SDL_config_iphoneos.h build/i386/include/SDL_config.h || exit 2
   1.266 -     sed -i "" -e "s|^EXTRA_CFLAGS.*|EXTRA_CFLAGS=-I./include|g" build/i386/Makefile || exit 2
   1.267 -     sed -i "" -e "s|^EXTRA_LDFLAGS.*|EXTRA_LDFLAGS=-lm|g" build/i386/Makefile || exit 2
   1.268 -fi
   1.269 -if test x$make_i386 = xyes; then
   1.270 -    (cd build/i386 && make -j$NJOB) || exit 3
   1.271 +CC=clang
   1.272 +CXX=clang
   1.273 +
   1.274 +SILENCED_WARNINGS="-Wno-unused-local-typedef -Wno-unused-function"
   1.275 +
   1.276 +CFLAGS="${CLANG_VERBOSE} ${SILENCED_WARNINGS} -DNDEBUG -g -O0 -pipe -fPIC -fobjc-arc"
   1.277 +
   1.278 +echo "PREFIX ..................... ${PREFIX}"
   1.279 +echo "BUILD_MACOSX_X86_64 ........ ${BUILD_MACOSX_X86_64}"
   1.280 +echo "BUILD_I386_IOSSIM .......... ${BUILD_I386_IOSSIM}"
   1.281 +echo "BUILD_X86_64_IOSSIM ........ ${BUILD_X86_64_IOSSIM}"
   1.282 +echo "BUILD_IOS_ARMV7 ............ ${BUILD_IOS_ARMV7}"
   1.283 +echo "BUILD_IOS_ARMV7S ........... ${BUILD_IOS_ARMV7S}"
   1.284 +echo "BUILD_IOS_ARM64 ............ ${BUILD_IOS_ARM64}"
   1.285 +echo "DARWIN ..................... ${DARWIN}"
   1.286 +echo "XCODEDIR ................... ${XCODEDIR}"
   1.287 +echo "IOS_SDK_VERSION ............ ${IOS_SDK_VERSION}"
   1.288 +echo "MIN_SDK_VERSION ............ ${MIN_SDK_VERSION}"
   1.289 +echo "IPHONEOS_PLATFORM .......... ${IPHONEOS_PLATFORM}"
   1.290 +echo "IPHONEOS_SYSROOT ........... ${IPHONEOS_SYSROOT}"
   1.291 +echo "IPHONESIMULATOR_PLATFORM ... ${IPHONESIMULATOR_PLATFORM}"
   1.292 +echo "IPHONESIMULATOR_SYSROOT .... ${IPHONESIMULATOR_SYSROOT}"
   1.293 +echo "CC ......................... ${CC}"
   1.294 +echo "CFLAGS ..................... ${CFLAGS}"
   1.295 +echo "CXX ........................ ${CXX}"
   1.296 +echo "CXXFLAGS ................... ${CXXFLAGS}"
   1.297 +echo "LDFLAGS .................... ${LDFLAGS}"
   1.298 +
   1.299 +###################################################################
   1.300 +# This section contains the build commands for each of the 
   1.301 +# architectures that will be included in the universal binaries.
   1.302 +###################################################################
   1.303 +
   1.304 +echo "$(tput setaf 2)"
   1.305 +echo "###########################"
   1.306 +echo "# i386 for iPhone Simulator"
   1.307 +echo "###########################"
   1.308 +echo "$(tput sgr0)"
   1.309 +
   1.310 +if [ "${BUILD_I386_IOSSIM}" == "YES" ]
   1.311 +then
   1.312 +    (
   1.313 +        cd ${PREFIX}
   1.314 +        make clean
   1.315 +        ../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
   1.316 +	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
   1.317 +        make -j10 || exit 3
   1.318 +        make install
   1.319 +    ) || exit $?
   1.320  fi
   1.321  
   1.322 -#
   1.323 -# Combine into fat binary
   1.324 -#
   1.325 -if test x$merge = xyes; then
   1.326 -    output=ios/lib
   1.327 -    sh $auxdir/mkinstalldirs build/$output
   1.328 -    cd build
   1.329 -    target=`find . -mindepth 4 -maxdepth 4 -type f -name '*.dylib' | head -1 | sed 's|.*/||'`
   1.330 -    (lipo -create -o $output/libSDL2.a armv6/build/.libs/libSDL2.a armv7/build/.libs/libSDL2.a i386/build/.libs/libSDL2.a &&
   1.331 -     lipo -create -o $output/libSDL2main.a armv6/build/libSDL2main.a armv7/build/libSDL2main.a i386/build/libSDL2main.a &&
   1.332 -     cp -r armv6/include ios
   1.333 -     echo "Build complete!" &&
   1.334 -     echo "Files can be found under the build/ios directory.") || exit 4
   1.335 -    cd ..
   1.336 +echo "$(tput setaf 2)"
   1.337 +echo "#############################"
   1.338 +echo "# x86_64 for iPhone Simulator"
   1.339 +echo "#############################"
   1.340 +echo "$(tput sgr0)"
   1.341 +
   1.342 +if [ "${BUILD_X86_64_IOSSIM}" == "YES" ]
   1.343 +then
   1.344 +    (
   1.345 +        cd ${PREFIX}
   1.346 +        make clean
   1.347 +        ../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
   1.348 +	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
   1.349 +        make -j$NJOB || exit 3
   1.350 +        make install
   1.351 +    ) || exit $?
   1.352  fi
   1.353  
   1.354 -#
   1.355 -# Clean up
   1.356 -#
   1.357 -do_clean()
   1.358 -{
   1.359 -    echo $*
   1.360 -    $* || exit 6
   1.361 -}
   1.362 -if test x$clean_armv6 = xyes; then
   1.363 -    do_clean rm -r build/armv6
   1.364 +echo "$(tput setaf 2)"
   1.365 +echo "##################"
   1.366 +echo "# armv7 for iPhone"
   1.367 +echo "##################"
   1.368 +echo "$(tput sgr0)"
   1.369 +
   1.370 +if [ "${BUILD_IOS_ARMV7}" == "YES" ]
   1.371 +then
   1.372 +    (
   1.373 +        cd ${PREFIX}
   1.374 +        make clean
   1.375 +        ../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
   1.376 +	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
   1.377 +        make -j$NJOB || exit 3
   1.378 +        make install
   1.379 +    ) || exit $?
   1.380  fi
   1.381 -if test x$clean_armv7 = xyes; then
   1.382 -    do_clean rm -r build/armv7
   1.383 +
   1.384 +echo "$(tput setaf 2)"
   1.385 +echo "###################"
   1.386 +echo "# armv7s for iPhone"
   1.387 +echo "###################"
   1.388 +echo "$(tput sgr0)"
   1.389 +
   1.390 +if [ "${BUILD_IOS_ARMV7S}" == "YES" ]
   1.391 +then
   1.392 +    (
   1.393 +        cd ${PREFIX}
   1.394 +        make clean
   1.395 +        ../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
   1.396 +	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
   1.397 +        make -j$NJOB || exit 3
   1.398 +        make install
   1.399 +    ) || exit $?
   1.400  fi
   1.401 -if test x$clean_i386 = xyes; then
   1.402 -    do_clean rm -r build/i386
   1.403 +
   1.404 +echo "$(tput setaf 2)"
   1.405 +echo "##################"
   1.406 +echo "# arm64 for iPhone"
   1.407 +echo "##################"
   1.408 +echo "$(tput sgr0)"
   1.409 +
   1.410 +if [ "${BUILD_IOS_ARM64}" == "YES" ]
   1.411 +then
   1.412 +    (
   1.413 +        cd ${PREFIX}
   1.414 +        make clean
   1.415 +        ../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
   1.416 +	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
   1.417 +        make -j$NJOB || exit 3
   1.418 +        make install
   1.419 +    ) || exit $?
   1.420  fi
   1.421 +
   1.422 +echo "$(tput setaf 2)"
   1.423 +echo "###################################################################"
   1.424 +echo "# Create Universal Libraries and Finalize the packaging"
   1.425 +echo "###################################################################"
   1.426 +echo "$(tput sgr0)"
   1.427 +
   1.428 +(
   1.429 +    cd ${PREFIX}/platform
   1.430 +    mkdir -p universal
   1.431 +    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
   1.432 +)
   1.433 +
   1.434 +(
   1.435 +    cd ${PREFIX}
   1.436 +    mkdir -p lib
   1.437 +    cp -r platform/universal/* lib
   1.438 +    #rm -rf platform
   1.439 +    lipo -info lib/libSDL2.a
   1.440 +)
   1.441 +
   1.442 +echo Done!
     2.1 --- a/configure	Mon Feb 20 10:55:33 2017 -0800
     2.2 +++ b/configure	Mon Feb 20 10:55:49 2017 -0800
     2.3 @@ -23671,9 +23671,7 @@
     2.4          SOURCES="$srcdir/src/main/haiku/*.cc $SOURCES"
     2.5          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
     2.6          ;;
     2.7 -    arm*-apple-darwin*)
     2.8 -        # iOS - We are not writing anything to confdefs.h because you have to replace
     2.9 -        # SDL_config.h for SDL_config_iphoneos.h anyway
    2.10 +    arm*-apple-darwin*|*-ios-*)
    2.11          ARCH=ios
    2.12  
    2.13          CheckVisibilityHidden
    2.14 @@ -23682,18 +23680,22 @@
    2.15          CheckDiskAudio
    2.16          CheckDummyAudio
    2.17          CheckDLOPEN
    2.18 -        CheckCOCOA
    2.19          CheckPTHREAD
    2.20  
    2.21 -
    2.22          # Set up files for the audio library
    2.23          if test x$enable_audio = xyes; then
    2.24 +
    2.25 +$as_echo "#define SDL_AUDIO_DRIVER_COREAUDIO 1" >>confdefs.h
    2.26 +
    2.27              SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.m"
    2.28              SUMMARY_audio="${SUMMARY_audio} coreaudio"
    2.29              have_audio=yes
    2.30          fi
    2.31          # Set up files for the joystick library
    2.32          if test x$enable_joystick = xyes; then
    2.33 +
    2.34 +$as_echo "#define SDL_JOYSTICK_MFI 1" >>confdefs.h
    2.35 +
    2.36              SOURCES="$SOURCES $srcdir/src/joystick/iphoneos/*.m"
    2.37              have_joystick=yes
    2.38          fi
    2.39 @@ -23705,6 +23707,9 @@
    2.40          #fi
    2.41          # Set up files for the power library
    2.42          if test x$enable_power = xyes; then
    2.43 +
    2.44 +$as_echo "#define SDL_POWER_UIKIT 1" >>confdefs.h
    2.45 +
    2.46              SOURCES="$SOURCES $srcdir/src/power/uikit/*.m"
    2.47              have_power=yes
    2.48          fi
    2.49 @@ -23713,28 +23718,50 @@
    2.50              SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
    2.51              have_filesystem=yes
    2.52          fi
    2.53 +        # Set up additional files for the file library
    2.54 +        if test x$enable_file = xyes; then
    2.55 +
    2.56 +$as_echo "#define SDL_FILESYSTEM_COCOA 1" >>confdefs.h
    2.57 +
    2.58 +            SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
    2.59 +        fi
    2.60          # Set up files for the timer library
    2.61          if test x$enable_timers = xyes; then
    2.62 +
    2.63 +$as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
    2.64 +
    2.65              SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
    2.66              have_timers=yes
    2.67          fi
    2.68 -        # Set up additional files for the file library
    2.69 -        if test x$enable_file = xyes; then
    2.70 -            SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
    2.71 -        fi
    2.72          # The iOS platform requires special setup.
    2.73 +
    2.74 +$as_echo "#define SDL_VIDEO_DRIVER_UIKIT 1" >>confdefs.h
    2.75 +
    2.76 +
    2.77 +$as_echo "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h
    2.78 +
    2.79 +
    2.80 +$as_echo "#define SDL_VIDEO_OPENGL_ES 1" >>confdefs.h
    2.81 +
    2.82 +
    2.83 +$as_echo "#define SDL_VIDEO_RENDER_OGL_ES 1" >>confdefs.h
    2.84 +
    2.85 +
    2.86 +$as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
    2.87 +
    2.88          SOURCES="$SOURCES $srcdir/src/video/uikit/*.m"
    2.89          EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
    2.90          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm -liconv -lobjc"
    2.91 +        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AVFoundation"
    2.92 +        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox"
    2.93 +        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio"
    2.94 +        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreGraphics"
    2.95 +        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreMotion"
    2.96          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Foundation"
    2.97 -        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
    2.98 +        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,GameController"
    2.99          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
   2.100          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
   2.101 -        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio"
   2.102 -        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox"
   2.103 -        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreGraphics"
   2.104 -        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreMotion"
   2.105 -        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,GameController"
   2.106 +        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
   2.107          ;;
   2.108      *-*-darwin* )
   2.109          # This could be either full "Mac OS X", or plain "Darwin" which is
     3.1 --- a/configure.in	Mon Feb 20 10:55:33 2017 -0800
     3.2 +++ b/configure.in	Mon Feb 20 10:55:49 2017 -0800
     3.3 @@ -3346,9 +3346,7 @@
     3.4          SOURCES="$srcdir/src/main/haiku/*.cc $SOURCES"
     3.5          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
     3.6          ;;
     3.7 -    arm*-apple-darwin*)
     3.8 -        # iOS - We are not writing anything to confdefs.h because you have to replace
     3.9 -        # SDL_config.h for SDL_config_iphoneos.h anyway
    3.10 +    arm*-apple-darwin*|*-ios-*)
    3.11          ARCH=ios
    3.12  
    3.13          CheckVisibilityHidden
    3.14 @@ -3357,18 +3355,18 @@
    3.15          CheckDiskAudio
    3.16          CheckDummyAudio
    3.17          CheckDLOPEN
    3.18 -        CheckCOCOA
    3.19          CheckPTHREAD
    3.20  
    3.21 -
    3.22          # Set up files for the audio library
    3.23          if test x$enable_audio = xyes; then
    3.24 +            AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ])
    3.25              SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.m"
    3.26              SUMMARY_audio="${SUMMARY_audio} coreaudio"
    3.27              have_audio=yes
    3.28          fi
    3.29          # Set up files for the joystick library
    3.30          if test x$enable_joystick = xyes; then
    3.31 +            AC_DEFINE(SDL_JOYSTICK_MFI, 1, [ ])
    3.32              SOURCES="$SOURCES $srcdir/src/joystick/iphoneos/*.m"
    3.33              have_joystick=yes
    3.34          fi
    3.35 @@ -3380,6 +3378,7 @@
    3.36          #fi
    3.37          # Set up files for the power library
    3.38          if test x$enable_power = xyes; then
    3.39 +            AC_DEFINE(SDL_POWER_UIKIT, 1, [ ])
    3.40              SOURCES="$SOURCES $srcdir/src/power/uikit/*.m"
    3.41              have_power=yes
    3.42          fi
    3.43 @@ -3388,28 +3387,36 @@
    3.44              SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
    3.45              have_filesystem=yes
    3.46          fi
    3.47 +        # Set up additional files for the file library
    3.48 +        if test x$enable_file = xyes; then
    3.49 +            AC_DEFINE(SDL_FILESYSTEM_COCOA, 1, [ ])
    3.50 +            SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
    3.51 +        fi
    3.52          # Set up files for the timer library
    3.53          if test x$enable_timers = xyes; then
    3.54 +            AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
    3.55              SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
    3.56              have_timers=yes
    3.57          fi
    3.58 -        # Set up additional files for the file library
    3.59 -        if test x$enable_file = xyes; then
    3.60 -            SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
    3.61 -        fi
    3.62          # The iOS platform requires special setup.
    3.63 +        AC_DEFINE(SDL_VIDEO_DRIVER_UIKIT, 1, [ ])
    3.64 +        AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
    3.65 +        AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
    3.66 +        AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
    3.67 +        AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
    3.68          SOURCES="$SOURCES $srcdir/src/video/uikit/*.m"
    3.69          EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
    3.70          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm -liconv -lobjc"
    3.71 +        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AVFoundation"
    3.72 +        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox"
    3.73 +        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio"
    3.74 +        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreGraphics"
    3.75 +        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreMotion"
    3.76          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Foundation"
    3.77 -        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
    3.78 +        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,GameController"
    3.79          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
    3.80          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
    3.81 -        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio"
    3.82 -        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox"
    3.83 -        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreGraphics"
    3.84 -        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreMotion"
    3.85 -        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,GameController"
    3.86 +        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
    3.87          ;;
    3.88      *-*-darwin* )
    3.89          # This could be either full "Mac OS X", or plain "Darwin" which is