build-scripts/iosbuild.sh
author Manuel Alfayate Corchete
Thu, 22 Oct 2020 19:51:57 +0200
changeset 14191 7bb6793cd70f
parent 13861 fe24019c4791
permissions -rwxr-xr-x
kmsdrm: Add comment about KMSDRM_VideoQuit() changes.
     1 #!/bin/sh
     2 #
     3 # Build a fat binary for iOS
     4 
     5 # Number of CPUs (for make -j)
     6 NCPU=`sysctl -n hw.ncpu`
     7 if test x$NJOB = x; then
     8     NJOB=$NCPU
     9 fi
    10 
    11 SRC_DIR=$(cd `dirname $0`/..; pwd)
    12 if [ "$PWD" = "$SRC_DIR" ]; then
    13     PREFIX=$SRC_DIR/ios-build
    14     if [ ! -d "$PREFIX" ]; then
    15         mkdir $PREFIX
    16     fi
    17 else
    18     PREFIX=$PWD
    19 fi
    20 
    21 BUILD_I386_IOSSIM=YES
    22 BUILD_X86_64_IOSSIM=YES
    23 
    24 BUILD_IOS_ARMV7=YES
    25 BUILD_IOS_ARMV7S=YES
    26 BUILD_IOS_ARM64=YES
    27 
    28 # 13.4.0 - Mavericks
    29 # 14.0.0 - Yosemite
    30 # 15.0.0 - El Capitan
    31 DARWIN=darwin15.0.0
    32 
    33 XCODEDIR=`xcode-select --print-path`
    34 IOS_SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version`
    35 MIN_SDK_VERSION=6.0
    36 
    37 IPHONEOS_PLATFORM=`xcrun --sdk iphoneos --show-sdk-platform-path`
    38 IPHONEOS_SYSROOT=`xcrun --sdk iphoneos --show-sdk-path`
    39 
    40 IPHONESIMULATOR_PLATFORM=`xcrun --sdk iphonesimulator --show-sdk-platform-path`
    41 IPHONESIMULATOR_SYSROOT=`xcrun --sdk iphonesimulator --show-sdk-path`
    42 
    43 # Uncomment if you want to see more information about each invocation
    44 # of clang as the builds proceed.
    45 # CLANG_VERBOSE="--verbose"
    46 
    47 CC=clang
    48 CXX=clang
    49 
    50 SILENCED_WARNINGS="-Wno-unused-local-typedef -Wno-unused-function"
    51 
    52 CFLAGS="${CLANG_VERBOSE} ${SILENCED_WARNINGS} -DNDEBUG -g -O0 -pipe -fPIC -fobjc-arc"
    53 
    54 echo "PREFIX ..................... ${PREFIX}"
    55 echo "BUILD_MACOSX_X86_64 ........ ${BUILD_MACOSX_X86_64}"
    56 echo "BUILD_I386_IOSSIM .......... ${BUILD_I386_IOSSIM}"
    57 echo "BUILD_X86_64_IOSSIM ........ ${BUILD_X86_64_IOSSIM}"
    58 echo "BUILD_IOS_ARMV7 ............ ${BUILD_IOS_ARMV7}"
    59 echo "BUILD_IOS_ARMV7S ........... ${BUILD_IOS_ARMV7S}"
    60 echo "BUILD_IOS_ARM64 ............ ${BUILD_IOS_ARM64}"
    61 echo "DARWIN ..................... ${DARWIN}"
    62 echo "XCODEDIR ................... ${XCODEDIR}"
    63 echo "IOS_SDK_VERSION ............ ${IOS_SDK_VERSION}"
    64 echo "MIN_SDK_VERSION ............ ${MIN_SDK_VERSION}"
    65 echo "IPHONEOS_PLATFORM .......... ${IPHONEOS_PLATFORM}"
    66 echo "IPHONEOS_SYSROOT ........... ${IPHONEOS_SYSROOT}"
    67 echo "IPHONESIMULATOR_PLATFORM ... ${IPHONESIMULATOR_PLATFORM}"
    68 echo "IPHONESIMULATOR_SYSROOT .... ${IPHONESIMULATOR_SYSROOT}"
    69 echo "CC ......................... ${CC}"
    70 echo "CFLAGS ..................... ${CFLAGS}"
    71 echo "CXX ........................ ${CXX}"
    72 echo "CXXFLAGS ................... ${CXXFLAGS}"
    73 echo "LDFLAGS .................... ${LDFLAGS}"
    74 
    75 ###################################################################
    76 # This section contains the build commands for each of the 
    77 # architectures that will be included in the universal binaries.
    78 ###################################################################
    79 
    80 echo "$(tput setaf 2)"
    81 echo "###########################"
    82 echo "# i386 for iPhone Simulator"
    83 echo "###########################"
    84 echo "$(tput sgr0)"
    85 
    86 if [ "${BUILD_I386_IOSSIM}" == "YES" ]
    87 then
    88     (
    89         cd ${PREFIX}
    90         make clean
    91         ../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
    92         cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
    93         make -j10 || exit 3
    94         make install
    95     ) || exit $?
    96 fi
    97 
    98 echo "$(tput setaf 2)"
    99 echo "#############################"
   100 echo "# x86_64 for iPhone Simulator"
   101 echo "#############################"
   102 echo "$(tput sgr0)"
   103 
   104 if [ "${BUILD_X86_64_IOSSIM}" == "YES" ]
   105 then
   106     (
   107         cd ${PREFIX}
   108         make clean
   109         ../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
   110         cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
   111         make -j$NJOB || exit 3
   112         make install
   113     ) || exit $?
   114 fi
   115 
   116 echo "$(tput setaf 2)"
   117 echo "##################"
   118 echo "# armv7 for iPhone"
   119 echo "##################"
   120 echo "$(tput sgr0)"
   121 
   122 if [ "${BUILD_IOS_ARMV7}" == "YES" ]
   123 then
   124     (
   125         cd ${PREFIX}
   126         make clean
   127         ../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
   128         cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
   129         make -j$NJOB || exit 3
   130         make install
   131     ) || exit $?
   132 fi
   133 
   134 echo "$(tput setaf 2)"
   135 echo "###################"
   136 echo "# armv7s for iPhone"
   137 echo "###################"
   138 echo "$(tput sgr0)"
   139 
   140 if [ "${BUILD_IOS_ARMV7S}" == "YES" ]
   141 then
   142     (
   143         cd ${PREFIX}
   144         make clean
   145         ../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
   146         cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
   147         make -j$NJOB || exit 3
   148         make install
   149     ) || exit $?
   150 fi
   151 
   152 echo "$(tput setaf 2)"
   153 echo "##################"
   154 echo "# arm64 for iPhone"
   155 echo "##################"
   156 echo "$(tput sgr0)"
   157 
   158 if [ "${BUILD_IOS_ARM64}" == "YES" ]
   159 then
   160     (
   161         cd ${PREFIX}
   162         make clean
   163         ../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
   164         cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
   165         make -j$NJOB || exit 3
   166         make install
   167     ) || exit $?
   168 fi
   169 
   170 echo "$(tput setaf 2)"
   171 echo "###################################################################"
   172 echo "# Create Universal Libraries and Finalize the packaging"
   173 echo "###################################################################"
   174 echo "$(tput sgr0)"
   175 
   176 (
   177     cd ${PREFIX}/platform
   178     mkdir -p universal
   179     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
   180 )
   181 
   182 (
   183     cd ${PREFIX}
   184     mkdir -p lib
   185     cp -r platform/universal/* lib
   186     #rm -rf platform
   187     lipo -info lib/libSDL2.a
   188 )
   189 
   190 echo Done!