🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

190 lines
7.3 KiB

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