mac编译iOS版openssl


版权声明:本文为CSDN博主「hongge372」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u010029439/article/details/78530607


#!/bin/bash # This script builds the iOS and Mac openSSL libraries # Download openssl http://www.openssl.org/source/ and place the tarball next to this script # Credits: # https://github.com/st3fan/ios-openssl # https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh set -e INSTALL_PATH="/tmp/openssl" usage () { echo "usage: $0 [minimum iOS SDK version (default 8.2)]" exit 127 } if [ $1 -e "-h" ]; then usage fi if [ -z $1 ]; then SDK_VERSION="8.4" else SDK_VERSION=$1 fi OPENSSL_VERSION="openssl-1.0.2d" DEVELOPER=`xcode-select -print-path` buildMac1() { echo buildMac ----- } buildMac() { ARCH=$1 echo "Building ${OPENSSL_VERSION} for ${ARCH}" TARGET="darwin-i386-cc" if [[ $ARCH == "x86_64" ]]; then TARGET="darwin64-x86_64-cc" fi pushd . > /dev/null cd "${OPENSSL_VERSION}" ./Configure ${TARGET} --openssldir="$INSTALL_PATH/${OPENSSL_VERSION}-${ARCH}" make make install make clean popd > /dev/null } buildIOS1() { echo build-ios-1----- } buildIOS() { ARCH=$1 pushd . > /dev/null cd "${OPENSSL_VERSION}" if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; then PLATFORM="iPhoneSimulator" else PLATFORM="iPhoneOS" sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" "crypto/ui/ui_openssl.c" fi export $PLATFORM export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer" export CROSS_SDK="${PLATFORM}${SDK_VERSION}.sdk" export BUILD_TOOLS="${DEVELOPER}" export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}" echo "Building ${OPENSSL_VERSION} for ${PLATFORM} ${SDK_VERSION} ${ARCH}" if [[ "${ARCH}" == "x86_64" ]]; then echo "Configure darwin64-x86_64-cc" # ./Configure darwin64-x86_64-cc --openssldir="$INSTALL_PATH/${OPENSSL_VERSION}-iOS-${ARCH}" else echo "Configure iphoneos-cross" # ./Configure iphoneos-cross --openssldir="$INSTALL_PATH/${OPENSSL_VERSION}-iOS-${ARCH}" fi # add -isysroot to CC= sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=${SDK_VERSION} !" "Makefile" # make # make install make clean popd > /dev/null } echo "Cleaning up" rm -rf include/openssl/* lib/* mkdir -p lib/iOS mkdir -p lib/Mac mkdir -p include/openssl/ rm -rf "$INSTALL_PATH/${OPENSSL_VERSION}-*" rm -rf "$INSTALL_PATH/${OPENSSL_VERSION}-*.log" function download_unrar_openssl { if [ ! -e ${OPENSSL_VERSION}.tar.gz ]; then echo "Downloading ${OPENSSL_VERSION}.tar.gz" curl -O https://www.openssl.org/source/${OPENSSL_VERSION}.tar.gz else echo "cur version is exit, Using ${OPENSSL_VERSION}.tar.gz" fi echo "unrar ${OPENSSL_VERSION}.tar.gz" tar xfz "${OPENSSL_VERSION}.tar.gz" } #rm -rf "${OPENSSL_VERSION}" if [ ! -d ${OPENSSL_VERSION} ];then download_unrar_openssl fi echo "check and prepare openssl end" buildIOS "armv7" buildIOS "armv7s" buildIOS "arm64" buildIOS "x86_64" buildIOS "i386" echo "Building iOS libraries" lipo \ "$INSTALL_PATH/${OPENSSL_VERSION}-iOS-armv7/lib/libcrypto.a" \ "$INSTALL_PATH/${OPENSSL_VERSION}-iOS-armv7s/lib/libcrypto.a" \ "$INSTALL_PATH/${OPENSSL_VERSION}-iOS-arm64/lib/libcrypto.a" \ "$INSTALL_PATH/${OPENSSL_VERSION}-iOS-i386/lib/libcrypto.a" \ "$INSTALL_PATH/${OPENSSL_VERSION}-iOS-x86_64/lib/libcrypto.a" \ -create -output lib/iOS/libcrypto.a lipo \ "$INSTALL_PATH/${OPENSSL_VERSION}-iOS-armv7/lib/libssl.a" \ "$INSTALL_PATH/${OPENSSL_VERSION}-iOS-armv7s/lib/libssl.a" \ "$INSTALL_PATH/${OPENSSL_VERSION}-iOS-arm64/lib/libssl.a" \ "$INSTALL_PATH/${OPENSSL_VERSION}-iOS-i386/lib/libssl.a" \ "$INSTALL_PATH/${OPENSSL_VERSION}-iOS-x86_64/lib/libssl.a" \ -create -output lib/iOS/libssl.a echo "Cleaning up" rm -rf $INSTALL_PATH/${OPENSSL_VERSION}-* #rm -rf ${OPENSSL_VERSION} echo "Done" ———————————————— 版权声明:本文为CSDN博主「hongge372」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/u010029439/article/details/78530607

 

posted @ 2021-04-08 15:00  YZFHKMS-X  阅读(185)  评论(0编辑  收藏  举报