🛠️🐜 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.

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