From 372cf34224df6a925171df121b12771ff0160d20 Mon Sep 17 00:00:00 2001 From: Drew Wells Date: Thu, 23 Apr 2020 22:26:45 -0500 Subject: [PATCH 1/6] update openssl-for-iphone --- openssl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openssl b/openssl index 173110e..6c665e2 160000 --- a/openssl +++ b/openssl @@ -1 +1 @@ -Subproject commit 173110e9b414d7a8c2f62e20e94e876b6beb632d +Subproject commit 6c665e2a15ba7e834875eecaf4eb93c11605dd9a From f71a2138368ca2c203ca82c38ce10084ddb36301 Mon Sep 17 00:00:00 2001 From: Drew Wells Date: Thu, 23 Apr 2020 23:14:48 -0500 Subject: [PATCH 2/6] make repeatable steps and add dependencies --- .gitignore | 7 ++++--- README.md | 2 ++ build-all.sh | 5 +++-- build-libssh2.sh | 20 ++++++++++---------- makefile | 8 ++++++++ with-libgcrypt-prefix.patch | 6 +++--- 6 files changed, 30 insertions(+), 18 deletions(-) create mode 100644 makefile diff --git a/.gitignore b/.gitignore index 956643d..356329c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,10 @@ -bin -src +bin/ +build/ +src/ *.gz libssh2-for-iOS.xcodeproj/project.xcworkspace/xcuserdata libssh2-for-iOS.xcodeproj/xcuserdata -lib +lib/ *.xccheckout openssl.framework include/ diff --git a/README.md b/README.md index 74a98b9..6814694 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ You can build the libssh2 library with openssl or with libgcrypt! - Xcode 7.1 - Xcode Command Line Tools + brew install automake autoconf + ## Readme ### Checkout the submodules: ```bash diff --git a/build-all.sh b/build-all.sh index 3309377..b630020 100755 --- a/build-all.sh +++ b/build-all.sh @@ -1,6 +1,6 @@ -#!/bin/bash +#!/bin/bash -e -# Automatic build script for libssh2 +# Automatic build script for libssh2 # for iPhoneOS and iPhoneSimulator # # Created by Felix Schulze on 01.02.11. @@ -36,6 +36,7 @@ then lipo -create -output openssl.framework/openssl build/Debug-iphonesimulator/openssl.framework/openssl build/Debug-iphoneos/openssl.framework/openssl # if you don't need bitcode, use this line instead: # ./openssl/create-openssl-framework.sh dynamic + echo "Build libssh2:" ./build-libssh2.sh openssl # Make dynamic framework, with embed-bitcode, iOS + Simulator: diff --git a/build-libssh2.sh b/build-libssh2.sh index fb45b8e..5498c58 100755 --- a/build-libssh2.sh +++ b/build-libssh2.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Automatic build script for libssh2 +# Automatic build script for libssh2 # for iPhoneOS and iPhoneSimulator # # Created by Felix Schulze on 02.02.11. @@ -21,12 +21,12 @@ ########################################################################### # Change values here # -VERSION="1.8.0" +VERSION="1.9.0" # ########################################################################### # # Don't change anything here -SDKVERSION=`xcrun -sdk iphoneos --show-sdk-version` +SDKVERSION=`xcrun -sdk iphoneos --show-sdk-version` CURRENTPATH=`pwd` ARCHS="i386 x86_64 armv7 armv7s arm64" DEVELOPER=`xcode-select -print-path` @@ -64,7 +64,7 @@ do echo "Building libssh2 for ${PLATFORM} ${SDKVERSION} ${ARCH}" echo "Please stand by..." tar zxf libssh2-${VERSION}.tar.gz -C src - cd src/libssh2-${VERSION} + cd src/libssh2 PATCHFILE=`find ../.. | grep with-libgcrypt-prefix.patch` patch -p2 < $PATCHFILE @@ -87,14 +87,14 @@ do LOG="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/build-libssh2-${VERSION}.log" echo ${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk - - + + HOST="${ARCH}" if [ "${ARCH}" == "arm64" ]; then HOST="aarch64" fi - + autoconf if [ "$1" == "openssl" ]; @@ -103,16 +103,16 @@ do else ./configure --host=${HOST}-apple-darwin --prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" --with-libgcrypt --with-libgcrypt-prefix=${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk --disable-shared --enable-static >> "${LOG}" 2>&1 fi - + make >> "${LOG}" 2>&1 make install >> "${LOG}" 2>&1 cd ${CURRENTPATH} rm -rf src/libssh2-${VERSION} - + done echo "Build library..." -# +# lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/lib/libssh2.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/lib/libssh2.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/lib/libssh2.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/lib/libssh2.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/lib/libssh2.a -output ${CURRENTPATH}/lib/libssh2.a mkdir -p ${CURRENTPATH}/include/libssh2 cp -R ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/include/libssh2* ${CURRENTPATH}/include/libssh2/ diff --git a/makefile b/makefile new file mode 100644 index 0000000..af12ceb --- /dev/null +++ b/makefile @@ -0,0 +1,8 @@ +.PHONY: build +build: + ./build-all.sh openssl + xcrun -sdk iphoneos lipo -info libssh2.framework/libssh2 + xcrun -sdk iphoneos lipo -info openssl.framework/openssl + +clean: + rm -rf bin lib src *.gz include/ diff --git a/with-libgcrypt-prefix.patch b/with-libgcrypt-prefix.patch index b5a21a4..631ae79 100644 --- a/with-libgcrypt-prefix.patch +++ b/with-libgcrypt-prefix.patch @@ -1,7 +1,7 @@ ---- src/libssh2-1.8.0.orig/acinclude.m4 2016-09-27 16:06:35.000000000 +1000 -+++ src/libssh2-1.8.0/acinclude.m4 2017-07-11 15:34:35.000000000 +1000 +--- src/libssh2.orig/acinclude.m4 2016-09-27 16:06:35.000000000 +1000 ++++ src/libssh2/acinclude.m4 2017-07-11 15:34:35.000000000 +1000 @@ -412,9 +412,9 @@ - + old_LDFLAGS=$LDFLAGS old_CFLAGS=$CFLAGS - if test -n "$use_libgcrypt" && test "$use_libgcrypt" != "no"; then From d5ed24fad7ca8599a2722513485dd2190189f685 Mon Sep 17 00:00:00 2001 From: Drew Wells Date: Sun, 26 Apr 2020 19:13:24 -0500 Subject: [PATCH 3/6] xcode updates --- build-libssh2.sh | 2 +- libssh2-for-iOS.xcodeproj/project.pbxproj | 86 ++++++++++++++++--- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++ .../xcschemes/libssh2-for-iOS.xcscheme | 10 +-- .../AppIcon.appiconset/Contents.json | 73 +++++++++------- 5 files changed, 130 insertions(+), 49 deletions(-) create mode 100644 libssh2-for-iOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/build-libssh2.sh b/build-libssh2.sh index 5498c58..a2cee62 100755 --- a/build-libssh2.sh +++ b/build-libssh2.sh @@ -41,7 +41,7 @@ fi echo "Checking file: libssh2-${VERSION}.tar.gz" md5=`md5 -q libssh2-${VERSION}.tar.gz` -if [ $md5 != "3d1147cae66e2959ea5441b183de1b1c" ] +if [ $md5 != "7d5214b06f08dc9ec13a901782981c9b" ] then echo "File corrupt, please download again." exit 1 diff --git a/libssh2-for-iOS.xcodeproj/project.pbxproj b/libssh2-for-iOS.xcodeproj/project.pbxproj index f280bce..c808aea 100755 --- a/libssh2-for-iOS.xcodeproj/project.pbxproj +++ b/libssh2-for-iOS.xcodeproj/project.pbxproj @@ -260,7 +260,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0710; - LastUpgradeCheck = 0710; + LastUpgradeCheck = 1140; TargetAttributes = { 22BCB307202E32330041F00E = { CreatedOnToolsVersion = 9.3; @@ -274,13 +274,14 @@ }; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "libssh2-for-iOS" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 1; knownRegions = ( - English, - Japanese, - French, - German, + ja, + en, + fr, + Base, + de, ); mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; projectDirPath = ""; @@ -365,6 +366,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "libssh2-for-iOS/libssh2_for_iOS_Prefix.pch"; INFOPLIST_FILE = "libssh2-for-iOS/libssh2_for_iOS-Info.plist"; + INSTALL_PATH = "~/Applications"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -374,6 +376,7 @@ PRODUCT_NAME = "libssh2-for-iOS"; SWIFT_OBJC_BRIDGING_HEADER = "libssh2-for-iOS/libssh2-for-iOS-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -392,6 +395,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "libssh2-for-iOS/libssh2_for_iOS_Prefix.pch"; INFOPLIST_FILE = "libssh2-for-iOS/libssh2_for_iOS-Info.plist"; + INSTALL_PATH = "~/Applications"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -400,6 +404,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "de.x2on.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "libssh2-for-iOS"; SWIFT_OBJC_BRIDGING_HEADER = "libssh2-for-iOS/libssh2-for-iOS-Bridging-Header.h"; + TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; name = Release; @@ -436,7 +441,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Manual; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; @@ -513,7 +518,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Manual; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; @@ -585,7 +590,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Manual; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; @@ -615,7 +620,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; INFOPLIST_FILE = libssh2_Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -628,6 +633,7 @@ PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = NO; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -666,7 +672,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Manual; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; @@ -691,7 +697,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; INFOPLIST_FILE = libssh2_Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -703,6 +709,7 @@ PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = NO; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -713,27 +720,82 @@ C01FCF4F08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = c99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = "include/**"; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; + SWIFT_VERSION = 5.0; }; name = Debug; }; C01FCF5008A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = c99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = "include/**"; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; + ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/libssh2-for-iOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/libssh2-for-iOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/libssh2-for-iOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/libssh2-for-iOS.xcodeproj/xcshareddata/xcschemes/libssh2-for-iOS.xcscheme b/libssh2-for-iOS.xcodeproj/xcshareddata/xcschemes/libssh2-for-iOS.xcscheme index bc5ab70..011a092 100644 --- a/libssh2-for-iOS.xcodeproj/xcshareddata/xcschemes/libssh2-for-iOS.xcscheme +++ b/libssh2-for-iOS.xcodeproj/xcshareddata/xcschemes/libssh2-for-iOS.xcscheme @@ -1,6 +1,6 @@ - - - - + + - - Date: Sun, 26 Apr 2020 19:35:07 -0500 Subject: [PATCH 4/6] changes for xcode 11.4 --- .travis.yml | 12 ++++++------ README.md | 14 +++++++++++++- build-all.sh | 8 ++++---- build-libssh2.sh | 22 +++++++++------------- with-libgcrypt-prefix.patch | 15 --------------- 5 files changed, 32 insertions(+), 39 deletions(-) delete mode 100644 with-libgcrypt-prefix.patch diff --git a/.travis.yml b/.travis.yml index 75ce4b8..ff98db1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ -osx_image: xcode9.2 +osx_image: xcode11.3 language: objective-c -before_install: +before_install: -script: - - ./build-all.sh openssl - - xcrun -sdk iphoneos lipo -info libssh2.framework/libssh2 - - xcrun -sdk iphoneos lipo -info openssl.framework/openssl +script: + - ./build-all.sh openssl + - xcrun -sdk iphoneos lipo -info libssh2.framework/libssh2 + - xcrun -sdk iphoneos lipo -info openssl.framework/openssl diff --git a/README.md b/README.md index 6814694..c8549e2 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,19 @@ You can build the libssh2 library with openssl or with libgcrypt! - Xcode 7.1 - Xcode Command Line Tools - brew install automake autoconf + brew install automake autoconf libssh2 + +Be sure to include libssh2 headers. Brew recommends steps to do so: + +If you need to have openssl@1.1 first in your PATH run: + + echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc + +For compilers to find openssl@1.1 you may need to set: + + export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib" + export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include" + ## Readme ### Checkout the submodules: diff --git a/build-all.sh b/build-all.sh index b630020..ca75f9a 100755 --- a/build-all.sh +++ b/build-all.sh @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash -x -e # Automatic build script for libssh2 # for iPhoneOS and iPhoneSimulator @@ -20,7 +20,7 @@ # if [ "$1" == "openssl" ]; then - echo "Building openssl:" + echo "Building openssl: $2" # ./openssl/build-libssl.sh --version=1.1.0j --deprecated $2 ./openssl/build-libssl.sh $2 # Make dynamic framework, with embed-bitcode, iOS + Simulator: @@ -29,7 +29,7 @@ then xcodebuild -project libssh2-for-iOS.xcodeproj -target openssl -sdk iphoneos -configuration Debug mkdir -p build/Debug-iphoneos/openssl.framework/Headers/ cp include/openssl/* build/Debug-iphoneos/openssl.framework/Headers/ - xcodebuild -project libssh2-for-iOS.xcodeproj -target openssl -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=10.0' -arch x86_64 -arch i386 -configuration Debug + xcodebuild -project libssh2-for-iOS.xcodeproj -target openssl -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=13.4' -arch x86_64 -arch i386 -configuration Debug mkdir -p build/Debug-iphonesimulator/openssl.framework/Headers/ cp include/openssl/* build/Debug-iphonesimulator/openssl.framework/Headers/ cp -r build/Debug-iphoneos/openssl.framework . @@ -44,7 +44,7 @@ then xcodebuild -project libssh2-for-iOS.xcodeproj -target libssh2 -sdk iphoneos -configuration Debug mkdir -p build/Debug-iphoneos/libssh2.framework/Headers/ cp include/libssh2/* build/Debug-iphoneos/libssh2.framework/Headers/ - xcodebuild -project libssh2-for-iOS.xcodeproj -target libssh2 -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=10.0' -arch x86_64 -arch i386 -configuration Debug + xcodebuild -project libssh2-for-iOS.xcodeproj -target libssh2 -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=13.4' -arch x86_64 -arch i386 -configuration Debug mkdir -p build/Debug-iphonesimulator/libssh2.framework/Headers/ cp include/libssh2/* build/Debug-iphonesimulator/libssh2.framework/Headers/ cp -r build/Debug-iphoneos/libssh2.framework . diff --git a/build-libssh2.sh b/build-libssh2.sh index a2cee62..2768823 100755 --- a/build-libssh2.sh +++ b/build-libssh2.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -x -e # Automatic build script for libssh2 # for iPhoneOS and iPhoneSimulator @@ -34,14 +34,14 @@ DEVELOPER=`xcode-select -print-path` set -e if [ ! -e libssh2-${VERSION}.tar.gz ]; then echo "Downloading libssh2-${VERSION}.tar.gz" - curl -O https://www.libssh2.org/download/libssh2-${VERSION}.tar.gz + curl --fail -O https://www.libssh2.org/download/libssh2-${VERSION}.tar.gz else echo "Using libssh2-${VERSION}.tar.gz" fi echo "Checking file: libssh2-${VERSION}.tar.gz" md5=`md5 -q libssh2-${VERSION}.tar.gz` -if [ $md5 != "7d5214b06f08dc9ec13a901782981c9b" ] +if [ $md5 != "1beefafe8963982adc84b408b2959927" ] then echo "File corrupt, please download again." exit 1 @@ -53,6 +53,9 @@ mkdir -p bin mkdir -p lib mkdir -p src +tar zxf libssh2-${VERSION}.tar.gz -C src +cd src/libssh2-${VERSION} + for ARCH in ${ARCHS} do if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; @@ -62,12 +65,7 @@ do PLATFORM="iPhoneOS" fi echo "Building libssh2 for ${PLATFORM} ${SDKVERSION} ${ARCH}" - echo "Please stand by..." - tar zxf libssh2-${VERSION}.tar.gz -C src - cd src/libssh2 - - PATCHFILE=`find ../.. | grep with-libgcrypt-prefix.patch` - patch -p2 < $PATCHFILE + echo "Please stand by...!" export M4="${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/gm4" export DEVROOT="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer" @@ -88,7 +86,6 @@ do LOG="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/build-libssh2-${VERSION}.log" echo ${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk - HOST="${ARCH}" if [ "${ARCH}" == "arm64" ]; then @@ -96,12 +93,11 @@ do fi autoconf - if [ "$1" == "openssl" ]; then - ./configure --host=${HOST}-apple-darwin --prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" --with-openssl --with-libssl-prefix=${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk --disable-shared --enable-static >> "${LOG}" 2>&1 + ./configure --host=${HOST}-apple-darwin --prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" --with-crypto=openssl --with-libssl-prefix=${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk --disable-shared --enable-static >> "${LOG}" 2>&1 else - ./configure --host=${HOST}-apple-darwin --prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" --with-libgcrypt --with-libgcrypt-prefix=${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk --disable-shared --enable-static >> "${LOG}" 2>&1 + ./configure --host=${HOST}-apple-darwin --prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" --with-crypto=libgcrypt --with-libgcrypt-prefix=${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk --disable-shared --enable-static >> "${LOG}" 2>&1 fi make >> "${LOG}" 2>&1 diff --git a/with-libgcrypt-prefix.patch b/with-libgcrypt-prefix.patch deleted file mode 100644 index 631ae79..0000000 --- a/with-libgcrypt-prefix.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- src/libssh2.orig/acinclude.m4 2016-09-27 16:06:35.000000000 +1000 -+++ src/libssh2/acinclude.m4 2017-07-11 15:34:35.000000000 +1000 -@@ -412,9 +412,9 @@ - - old_LDFLAGS=$LDFLAGS - old_CFLAGS=$CFLAGS -- if test -n "$use_libgcrypt" && test "$use_libgcrypt" != "no"; then -- LDFLAGS="$LDFLAGS -L$use_libgcrypt/lib" -- CFLAGS="$CFLAGS -I$use_libgcrypt/include" -+ if test -n "$with_libgcrypt_prefix" && test "$use_libgcrypt" != "no"; then -+ LDFLAGS="$LDFLAGS -L$with_libgcrypt_prefix/lib" -+ CFLAGS="$CFLAGS -I$with_libgcrypt_prefix/include" - fi - AC_LIB_HAVE_LINKFLAGS([gcrypt], [], [ - #include From d440d013c6e918f4f437525d02c21832da93eb41 Mon Sep 17 00:00:00 2001 From: Drew Wells Date: Sun, 26 Apr 2020 23:53:26 -0500 Subject: [PATCH 5/6] brought in openssl build scripts for arm64 processing --- .gitignore | 1 + build-all.sh | 11 +- build-libssh2.sh | 18 +- build-libssl.sh | 547 ++++++++++++++++++++++++++++++++++ config/20-ios-tvos-cross.conf | 109 +++++++ openssl | 2 +- scripts/build-loop-targets.sh | 93 ++++++ 7 files changed, 765 insertions(+), 16 deletions(-) create mode 100755 build-libssl.sh create mode 100644 config/20-ios-tvos-cross.conf create mode 100755 scripts/build-loop-targets.sh diff --git a/.gitignore b/.gitignore index 356329c..7112fcf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ bin/ build/ src/ *.gz +libssh2-*/ libssh2-for-iOS.xcodeproj/project.xcworkspace/xcuserdata libssh2-for-iOS.xcodeproj/xcuserdata lib/ diff --git a/build-all.sh b/build-all.sh index ca75f9a..712104d 100755 --- a/build-all.sh +++ b/build-all.sh @@ -21,15 +21,14 @@ if [ "$1" == "openssl" ]; then echo "Building openssl: $2" - # ./openssl/build-libssl.sh --version=1.1.0j --deprecated $2 - ./openssl/build-libssl.sh $2 + ./build-libssl.sh --archs="x86_64 arm64" --targets="ios-sim-cross-x86_64 ios64-sim-cross-arm64 ios64-cross-arm64" $2 # Make dynamic framework, with embed-bitcode, iOS + Simulator: rm -rf build rm -rf openssl.framework - xcodebuild -project libssh2-for-iOS.xcodeproj -target openssl -sdk iphoneos -configuration Debug + xcodebuild -project libssh2-for-iOS.xcodeproj -UseModernBuildSystem=NO -target openssl -sdk iphoneos -configuration Debug mkdir -p build/Debug-iphoneos/openssl.framework/Headers/ cp include/openssl/* build/Debug-iphoneos/openssl.framework/Headers/ - xcodebuild -project libssh2-for-iOS.xcodeproj -target openssl -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=13.4' -arch x86_64 -arch i386 -configuration Debug + xcodebuild -project libssh2-for-iOS.xcodeproj -UseModernBuildSystem=NO -target openssl -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=13.4' -arch x86_64 -arch arm64 -configuration Debug mkdir -p build/Debug-iphonesimulator/openssl.framework/Headers/ cp include/openssl/* build/Debug-iphonesimulator/openssl.framework/Headers/ cp -r build/Debug-iphoneos/openssl.framework . @@ -41,10 +40,10 @@ then ./build-libssh2.sh openssl # Make dynamic framework, with embed-bitcode, iOS + Simulator: rm -rf libssh2.framework - xcodebuild -project libssh2-for-iOS.xcodeproj -target libssh2 -sdk iphoneos -configuration Debug + xcodebuild -UseModernBuildSystem=NO -project libssh2-for-iOS.xcodeproj -target libssh2 -sdk iphoneos -configuration Debug mkdir -p build/Debug-iphoneos/libssh2.framework/Headers/ cp include/libssh2/* build/Debug-iphoneos/libssh2.framework/Headers/ - xcodebuild -project libssh2-for-iOS.xcodeproj -target libssh2 -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=13.4' -arch x86_64 -arch i386 -configuration Debug + xcodebuild -UseModernBuildSystem=NO -project libssh2-for-iOS.xcodeproj -target libssh2 -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=13.4' -arch x86_64 -arch i386 -configuration Debug mkdir -p build/Debug-iphonesimulator/libssh2.framework/Headers/ cp include/libssh2/* build/Debug-iphonesimulator/libssh2.framework/Headers/ cp -r build/Debug-iphoneos/libssh2.framework . diff --git a/build-libssh2.sh b/build-libssh2.sh index 2768823..2389e0b 100755 --- a/build-libssh2.sh +++ b/build-libssh2.sh @@ -28,7 +28,7 @@ VERSION="1.9.0" # Don't change anything here SDKVERSION=`xcrun -sdk iphoneos --show-sdk-version` CURRENTPATH=`pwd` -ARCHS="i386 x86_64 armv7 armv7s arm64" +ARCHS="x86_64 arm64" DEVELOPER=`xcode-select -print-path` ########## set -e @@ -55,6 +55,7 @@ mkdir -p src tar zxf libssh2-${VERSION}.tar.gz -C src cd src/libssh2-${VERSION} +./buildconf for ARCH in ${ARCHS} do @@ -67,6 +68,7 @@ do echo "Building libssh2 for ${PLATFORM} ${SDKVERSION} ${ARCH}" echo "Please stand by...!" + export M4="${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/gm4" export DEVROOT="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer" export SDKROOT="${DEVROOT}/SDKs/${PLATFORM}${SDKVERSION}.sdk" @@ -92,24 +94,22 @@ do HOST="aarch64" fi - autoconf if [ "$1" == "openssl" ]; then - ./configure --host=${HOST}-apple-darwin --prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" --with-crypto=openssl --with-libssl-prefix=${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk --disable-shared --enable-static >> "${LOG}" 2>&1 + ./configure --host=${HOST}-apple-darwin --prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" --with-crypto=openssl --with-libssl-prefix=${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk --disable-shared --enable-static >> "${LOG}" else - ./configure --host=${HOST}-apple-darwin --prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" --with-crypto=libgcrypt --with-libgcrypt-prefix=${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk --disable-shared --enable-static >> "${LOG}" 2>&1 + ./configure --host=${HOST}-apple-darwin --prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" --with-crypto=libgcrypt --with-libgcrypt-prefix=${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk --disable-shared --enable-static >> "${LOG}" fi make >> "${LOG}" 2>&1 make install >> "${LOG}" 2>&1 - cd ${CURRENTPATH} - rm -rf src/libssh2-${VERSION} done echo "Build library..." -# -lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/lib/libssh2.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/lib/libssh2.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/lib/libssh2.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/lib/libssh2.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/lib/libssh2.a -output ${CURRENTPATH}/lib/libssh2.a + +lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/lib/libssh2.a -output ${CURRENTPATH}/lib/libssh2-x86_64.a +lipo -create ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/lib/libssh2.a -output ${CURRENTPATH}/lib/libssh2.a mkdir -p ${CURRENTPATH}/include/libssh2 -cp -R ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/include/libssh2* ${CURRENTPATH}/include/libssh2/ +#cp -vR ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-arm64.sdk/include/libssh2* ${CURRENTPATH}/include/libssh2/ echo "Building done." diff --git a/build-libssl.sh b/build-libssl.sh new file mode 100755 index 0000000..7b01179 --- /dev/null +++ b/build-libssl.sh @@ -0,0 +1,547 @@ +#!/bin/sh + +# Automatic build script for libssl and libcrypto +# for iPhoneOS and iPhoneSimulator +# +# Created by Felix Schulze on 16.12.10. +# Copyright 2010-2019 Felix Schulze. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# -u Attempt to use undefined variable outputs error message, and forces an exit +set -u + +# SCRIPT DEFAULTS + +# Default version in case no version is specified +DEFAULTVERSION="1.1.0l" + +# Default (=full) set of targets to build +DEFAULTTARGETS="ios-sim-cross-x86_64 ios64-cross-arm64 tvos-sim-cross-x86_64 tvos64-cross-arm64" # mac-catalyst-x86_64 is a valid target that is not in the DEFAULTTARGETS because it's incompatible with "ios-sim-cross-x86_64" + +# Minimum iOS/tvOS SDK version to build for +IOS_MIN_SDK_VERSION="12.0" +TVOS_MIN_SDK_VERSION="12.0" +MACOSX_MIN_SDK_VERSION="10.15" + +# Init optional env variables (use available variable or default to empty string) +CURL_OPTIONS="${CURL_OPTIONS:-}" +CONFIG_OPTIONS="${CONFIG_OPTIONS:-}" + +echo_help() +{ + echo "Usage: $0 [options...]" + echo "Generic options" + echo " --branch=BRANCH Select OpenSSL branch to build. The script will determine and download the latest release for that branch" + echo " --cleanup Clean up build directories (bin, include/openssl, lib, src) before starting build" + echo " --ec-nistp-64-gcc-128 Enable configure option enable-ec_nistp_64_gcc_128 for 64 bit builds" + echo " -h, --help Print help (this message)" + echo " --ios-sdk=SDKVERSION Override iOS SDK version" + echo " --macosx-sdk=SDKVERSION Override MacOSX SDK version" + echo " --noparallel Disable running make with parallel jobs (make -j)" + echo " --tvos-sdk=SDKVERSION Override tvOS SDK version" + echo " --disable-bitcode Disable embedding Bitcode" + echo " -v, --verbose Enable verbose logging" + echo " --verbose-on-error Dump last 500 lines from log file if an error occurs (for Travis builds)" + echo " --version=VERSION OpenSSL version to build (defaults to ${DEFAULTVERSION})" + echo " --deprecated Exclude no-deprecated configure option and build with deprecated methods" + echo " --targets=\"TARGET TARGET ...\" Space-separated list of build targets" + echo " Options: ${DEFAULTTARGETS} mac-catalyst-x86_64" + echo + echo "For custom configure options, set variable CONFIG_OPTIONS" + echo "For custom cURL options, set variable CURL_OPTIONS" + echo " Example: CURL_OPTIONS=\"--proxy 192.168.1.1:8080\" ./build-libssl.sh" +} + +spinner() +{ + local pid=$! + local delay=0.75 + local spinstr='|/-\' + while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do + local temp=${spinstr#?} + printf " [%c]" "$spinstr" + local spinstr=$temp${spinstr%"$temp"} + sleep $delay + printf "\b\b\b\b\b" + done + + wait $pid + return $? +} + +# Prepare target and source dir in build loop +prepare_target_source_dirs() +{ + # Prepare target dir + TARGETDIR="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" + mkdir -p "${TARGETDIR}" + LOG="${TARGETDIR}/build-openssl-${VERSION}.log" + + echo "Building openssl-${VERSION} for ${PLATFORM} ${SDKVERSION} ${ARCH}..." + echo " Logfile: ${LOG}" + + # Prepare source dir + SOURCEDIR="${CURRENTPATH}/src/${PLATFORM}-${ARCH}" + mkdir -p "${SOURCEDIR}" + tar zxf "${CURRENTPATH}/${OPENSSL_ARCHIVE_FILE_NAME}" -C "${SOURCEDIR}" + cd "${SOURCEDIR}/${OPENSSL_ARCHIVE_BASE_NAME}" + chmod u+x ./Configure +} + +# Check for error status +check_status() +{ + local STATUS=$1 + local COMMAND=$2 + + if [ "${STATUS}" != 0 ]; then + if [[ "${LOG_VERBOSE}" != "verbose"* ]]; then + echo "Problem during ${COMMAND} - Please check ${LOG}" + fi + + # Dump last 500 lines from log file for verbose-on-error + if [ "${LOG_VERBOSE}" == "verbose-on-error" ]; then + echo "Problem during ${COMMAND} - Dumping last 500 lines from log file" + echo + tail -n 500 "${LOG}" + fi + + exit 1 + fi +} + +# Run Configure in build loop +run_configure() +{ + echo " Configure..." + set +e + if [ "${LOG_VERBOSE}" == "verbose" ]; then + ./Configure ${LOCAL_CONFIG_OPTIONS} | tee "${LOG}" + else + (./Configure ${LOCAL_CONFIG_OPTIONS} > "${LOG}" 2>&1) & spinner + fi + + # Check for error status + check_status $? "Configure" +} + +# Run make in build loop +run_make() +{ + echo " Make (using ${BUILD_THREADS} thread(s))..." + if [ "${LOG_VERBOSE}" == "verbose" ]; then + make -j "${BUILD_THREADS}" | tee -a "${LOG}" + else + (make -j "${BUILD_THREADS}" >> "${LOG}" 2>&1) & spinner + fi + + # Check for error status + check_status $? "make" +} + +# Cleanup and bookkeeping at end of build loop +finish_build_loop() +{ + # Return to ${CURRENTPATH} and remove source dir + cd "${CURRENTPATH}" + rm -r "${SOURCEDIR}" + + # Add references to library files to relevant arrays + if [[ "${PLATFORM}" == AppleTV* ]]; then + LIBSSL_TVOS+=("${TARGETDIR}/lib/libssl.a") + LIBCRYPTO_TVOS+=("${TARGETDIR}/lib/libcrypto.a") + OPENSSLCONF_SUFFIX="tvos_${ARCH}" + else + LIBSSL_IOS+=("${TARGETDIR}/lib/libssl.a") + LIBCRYPTO_IOS+=("${TARGETDIR}/lib/libcrypto.a") + if [[ "${PLATFORM}" != MacOSX* ]]; then + OPENSSLCONF_SUFFIX="ios_${ARCH}" + else + OPENSSLCONF_SUFFIX="catalyst_${ARCH}" + fi + fi + + # Copy opensslconf.h to bin directory and add to array + OPENSSLCONF="opensslconf_${OPENSSLCONF_SUFFIX}.h" + cp "${TARGETDIR}/include/openssl/opensslconf.h" "${CURRENTPATH}/bin/${OPENSSLCONF}" + OPENSSLCONF_ALL+=("${OPENSSLCONF}") + + # Keep reference to first build target for include file + if [ -z "${INCLUDE_DIR}" ]; then + INCLUDE_DIR="${TARGETDIR}/include/openssl" + fi +} + +# Init optional command line vars +ARCHS="" +BRANCH="" +CLEANUP="" +CONFIG_ENABLE_EC_NISTP_64_GCC_128="" +CONFIG_DISABLE_BITCODE="" +CONFIG_NO_DEPRECATED="" +IOS_SDKVERSION="" +MACOSX_SDKVERSION="" +LOG_VERBOSE="" +PARALLEL="" +TARGETS="" +TVOS_SDKVERSION="" +VERSION="" + +# Process command line arguments +for i in "$@" +do +case $i in + --archs=*) + ARCHS="${i#*=}" + shift + ;; + --branch=*) + BRANCH="${i#*=}" + shift + ;; + --cleanup) + CLEANUP="true" + ;; + --deprecated) + CONFIG_NO_DEPRECATED="false" + ;; + --ec-nistp-64-gcc-128) + CONFIG_ENABLE_EC_NISTP_64_GCC_128="true" + ;; + --disable-bitcode) + CONFIG_DISABLE_BITCODE="true" + ;; + -h|--help) + echo_help + exit + ;; + --ios-sdk=*) + IOS_SDKVERSION="${i#*=}" + shift + ;; + --macosx-sdk=*) + MACOSX_SDKVERSION="${i#*=}" + shift + ;; + --noparallel) + PARALLEL="false" + ;; + --targets=*) + TARGETS="${i#*=}" + shift + ;; + --tvos-sdk=*) + TVOS_SDKVERSION="${i#*=}" + shift + ;; + -v|--verbose) + LOG_VERBOSE="verbose" + ;; + --verbose-on-error) + LOG_VERBOSE="verbose-on-error" + ;; + --version=*) + VERSION="${i#*=}" + shift + ;; + *) + echo "Unknown argument: ${i}" + ;; +esac +done + +# Don't mix version and branch +if [[ -n "${VERSION}" && -n "${BRANCH}" ]]; then + echo "Either select a branch (the script will determine and build the latest version) or select a specific version, but not both." + exit 1 + +# Specific version: Verify version number format. Expected: dot notation +elif [[ -n "${VERSION}" && ! "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+[a-z]*$ ]]; then + echo "Unknown version number format. Examples: 1.1.0, 1.1.0l" + exit 1 + +# Specific branch +elif [ -n "${BRANCH}" ]; then + # Verify version number format. Expected: dot notation + if [[ ! "${BRANCH}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Unknown branch version number format. Examples: 1.1.0, 1.2.0" + exit 1 + + # Valid version number, determine latest version + else + echo "Checking latest version of ${BRANCH} branch on openssl.org..." + # Get directory content listing of /source/ (only contains latest version per branch), limit list to archives (so one archive per branch), + # filter for the requested branch, sort the list and get the last item (last two steps to ensure there is always 1 result) + VERSION=$(curl ${CURL_OPTIONS} -s https://ftp.openssl.org/source/ | grep -Eo '>openssl-[0-9]\.[0-9]\.[0-9][a-z]*\.tar\.gz<' | grep -Eo "${BRANCH//./\.}[a-z]*" | sort | tail -1) + + # Verify result + if [ -z "${VERSION}" ]; then + echo "Could not determine latest version, please check https://www.openssl.org/source/ and use --version option" + exit 1 + fi + fi + +# Script default +elif [ -z "${VERSION}" ]; then + VERSION="${DEFAULTVERSION}" +fi + +BUILD_TYPE="targets" + +# Set default for TARGETS if not specified +if [ ! -n "${TARGETS}" ]; then + TARGETS="${DEFAULTTARGETS}" +fi + +# Add no-deprecated config option (if not overwritten) +if [ "${CONFIG_NO_DEPRECATED}" != "false" ]; then + CONFIG_OPTIONS="${CONFIG_OPTIONS} no-deprecated" +fi + +# Determine SDK versions +if [ ! -n "${IOS_SDKVERSION}" ]; then + IOS_SDKVERSION=$(xcrun -sdk iphoneos --show-sdk-version) +fi +if [ ! -n "${MACOSX_SDKVERSION}" ]; then + MACOSX_SDKVERSION=$(xcrun -sdk macosx --show-sdk-version) +fi +if [ ! -n "${TVOS_SDKVERSION}" ]; then + TVOS_SDKVERSION=$(xcrun -sdk appletvos --show-sdk-version) +fi + +# Determine number of cores for (parallel) build +BUILD_THREADS=1 +if [ "${PARALLEL}" != "false" ]; then + BUILD_THREADS=$(sysctl hw.ncpu | awk '{print $2}') +fi + +# Determine script directory +SCRIPTDIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) + +# Write files relative to current location and validate directory +CURRENTPATH=$(pwd) +case "${CURRENTPATH}" in + *\ * ) + echo "Your path contains whitespaces, which is not supported by 'make install'." + exit 1 + ;; +esac +cd "${CURRENTPATH}" + +# Validate Xcode Developer path +DEVELOPER=$(xcode-select -print-path) +if [ ! -d "${DEVELOPER}" ]; then + echo "Xcode path is not set correctly ${DEVELOPER} does not exist" + echo "run" + echo "sudo xcode-select -switch " + echo "for default installation:" + echo "sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer" + exit 1 +fi + +case "${DEVELOPER}" in + *\ * ) + echo "Your Xcode path contains whitespaces, which is not supported." + exit 1 + ;; +esac + +# Show build options +echo +echo "Build options" +echo " OpenSSL version: ${VERSION}" +echo " Targets: ${TARGETS}" +echo " iOS SDK: ${IOS_SDKVERSION}" +echo " tvOS SDK: ${TVOS_SDKVERSION}" +if [ "${CONFIG_DISABLE_BITCODE}" == "true" ]; then + echo " Bitcode embedding disabled" +fi +echo " Number of make threads: ${BUILD_THREADS}" +if [ -n "${CONFIG_OPTIONS}" ]; then + echo " Configure options: ${CONFIG_OPTIONS}" +fi +echo " Build location: ${CURRENTPATH}" +echo + +# Download OpenSSL when not present +OPENSSL_ARCHIVE_BASE_NAME="openssl-${VERSION}" +OPENSSL_ARCHIVE_FILE_NAME="${OPENSSL_ARCHIVE_BASE_NAME}.tar.gz" +if [ ! -e ${OPENSSL_ARCHIVE_FILE_NAME} ]; then + echo "Downloading ${OPENSSL_ARCHIVE_FILE_NAME}..." + OPENSSL_ARCHIVE_URL="https://www.openssl.org/source/${OPENSSL_ARCHIVE_FILE_NAME}" + + # Check whether file exists here (this is the location of the latest version for each branch) + # -s be silent, -f return non-zero exit status on failure, -I get header (do not download) + curl ${CURL_OPTIONS} -sfI "${OPENSSL_ARCHIVE_URL}" > /dev/null + + # If unsuccessful, try the archive + if [ $? -ne 0 ]; then + BRANCH=$(echo "${VERSION}" | grep -Eo '^[0-9]\.[0-9]\.[0-9]') + OPENSSL_ARCHIVE_URL="https://www.openssl.org/source/old/${BRANCH}/${OPENSSL_ARCHIVE_FILE_NAME}" + + curl ${CURL_OPTIONS} -sfI "${OPENSSL_ARCHIVE_URL}" > /dev/null + fi + + # Both attempts failed, so report the error + if [ $? -ne 0 ]; then + echo "An error occurred trying to find OpenSSL ${VERSION} on ${OPENSSL_ARCHIVE_URL}" + echo "Please verify that the version you are trying to build exists, check cURL's error message and/or your network connection." + exit 1 + fi + + # Archive was found, so proceed with download. + # -O Use server-specified filename for download + curl ${CURL_OPTIONS} -O "${OPENSSL_ARCHIVE_URL}" + +else + echo "Using ${OPENSSL_ARCHIVE_FILE_NAME}" +fi + +# Set reference to custom configuration (OpenSSL 1.1.0) +# See: https://github.com/openssl/openssl/commit/afce395cba521e395e6eecdaf9589105f61e4411 +export OPENSSL_LOCAL_CONFIG_DIR="${SCRIPTDIR}/config" + +# -e Abort script at first error, when a command exits with non-zero status (except in until or while loops, if-tests, list constructs) +# -o pipefail Causes a pipeline to return the exit status of the last command in the pipe that returned a non-zero return value +set -eo pipefail + +# Clean up target directories if requested and present +if [ "${CLEANUP}" == "true" ]; then + if [ -d "${CURRENTPATH}/bin" ]; then + rm -r "${CURRENTPATH}/bin" + fi + if [ -d "${CURRENTPATH}/include/openssl" ]; then + rm -r "${CURRENTPATH}/include/openssl" + fi + if [ -d "${CURRENTPATH}/lib" ]; then + rm -r "${CURRENTPATH}/lib" + fi + if [ -d "${CURRENTPATH}/src" ]; then + rm -r "${CURRENTPATH}/src" + fi +fi + +# (Re-)create target directories +mkdir -p "${CURRENTPATH}/bin" +mkdir -p "${CURRENTPATH}/lib" +mkdir -p "${CURRENTPATH}/src" + +# Init vars for library references +INCLUDE_DIR="" +OPENSSLCONF_ALL=() +LIBSSL_IOS=() +LIBCRYPTO_IOS=() +LIBSSL_TVOS=() +LIBCRYPTO_TVOS=() + +# Run relevant build loop +source "${SCRIPTDIR}/scripts/build-loop-targets.sh" +set -x + +# Build iOS library if selected for build +if [ ${#LIBSSL_IOS[@]} -gt 0 ]; then + echo "Build library for iOS..." + #lipo -create ${LIBSSL_IOS[@]} -output "${CURRENTPATH}/lib/libssl.a" + #lipo -create ${LIBCRYPTO_IOS[@]} -output "${CURRENTPATH}/lib/libcrypto.a" + + echo "\n=====>iOS SSL and Crypto lib files:" + echo "${CURRENTPATH}/lib/libssl.a" + echo "${CURRENTPATH}/lib/libcrypto.a" +fi + +# Build tvOS library if selected for build +if [ ${#LIBSSL_TVOS[@]} -gt 0 ]; then + echo "Build library for tvOS..." + lipo -create ${LIBSSL_TVOS[@]} -output "${CURRENTPATH}/lib/libssl-tvOS.a" + lipo -create ${LIBCRYPTO_TVOS[@]} -output "${CURRENTPATH}/lib/libcrypto-tvOS.a" + echo "\n=====>tvOS SSL and Crypto lib files:" + echo "${CURRENTPATH}/lib/libssl-tvOS.a" + echo "${CURRENTPATH}/lib/libcrypto-tvOS.a" +fi + +set +x +# Copy include directory +cp -R "${INCLUDE_DIR}" "${CURRENTPATH}/include/" + +echo "\n=====>Include directory:" +echo "${CURRENTPATH}/include/" + +# Only create intermediate file when building for multiple targets +# For a single target, opensslconf.h is still present in $INCLUDE_DIR (and has just been copied to the target include dir) +if [ ${#OPENSSLCONF_ALL[@]} -gt 1 ]; then + + # Prepare intermediate header file + # This overwrites opensslconf.h that was copied from $INCLUDE_DIR + OPENSSLCONF_INTERMEDIATE="${CURRENTPATH}/include/openssl/opensslconf.h" + cp "${CURRENTPATH}/include/opensslconf-template.h" "${OPENSSLCONF_INTERMEDIATE}" + + # Loop all header files + LOOPCOUNT=0 + for OPENSSLCONF_CURRENT in "${OPENSSLCONF_ALL[@]}" ; do + + # Copy specific opensslconf file to include dir + cp "${CURRENTPATH}/bin/${OPENSSLCONF_CURRENT}" "${CURRENTPATH}/include/openssl" + + # Determine define condition + case "${OPENSSLCONF_CURRENT}" in + *_ios_x86_64.h) + DEFINE_CONDITION="TARGET_OS_IOS && TARGET_OS_SIMULATOR && TARGET_CPU_X86_64" + ;; + *_ios_i386.h) + DEFINE_CONDITION="TARGET_OS_IOS && TARGET_OS_SIMULATOR && TARGET_CPU_X86" + ;; + *_ios_arm64.h) + DEFINE_CONDITION="TARGET_OS_IOS && TARGET_OS_EMBEDDED && TARGET_CPU_ARM64" + ;; + *_ios_armv7s.h) + DEFINE_CONDITION="TARGET_OS_IOS && TARGET_OS_EMBEDDED && TARGET_CPU_ARM && defined(__ARM_ARCH_7S__)" + ;; + *_ios_armv7.h) + DEFINE_CONDITION="TARGET_OS_IOS && TARGET_OS_EMBEDDED && TARGET_CPU_ARM && !defined(__ARM_ARCH_7S__)" + ;; + *_catalyst_x86_64.h) + DEFINE_CONDITION="(TARGET_OS_MACCATALYST || (TARGET_OS_IOS && TARGET_OS_SIMULATOR)) && TARGET_CPU_X86_64" + ;; + *_tvos_x86_64.h) + DEFINE_CONDITION="TARGET_OS_TV && TARGET_OS_SIMULATOR && TARGET_CPU_X86_64" + ;; + *_tvos_arm64.h) + DEFINE_CONDITION="TARGET_OS_TV && TARGET_OS_EMBEDDED && TARGET_CPU_ARM64" + ;; + *) + # Don't run into unexpected cases by setting the default condition to false + DEFINE_CONDITION="0" + ;; + esac + + # Determine loopcount; start with if and continue with elif + LOOPCOUNT=$((LOOPCOUNT + 1)) + if [ ${LOOPCOUNT} -eq 1 ]; then + echo "#if ${DEFINE_CONDITION}" >> "${OPENSSLCONF_INTERMEDIATE}" + else + echo "#elif ${DEFINE_CONDITION}" >> "${OPENSSLCONF_INTERMEDIATE}" + fi + + # Add include + echo "# include " >> "${OPENSSLCONF_INTERMEDIATE}" + done + + # Finish + echo "#else" >> "${OPENSSLCONF_INTERMEDIATE}" + echo '# error Unable to determine target or target not included in OpenSSL build' >> "${OPENSSLCONF_INTERMEDIATE}" + echo "#endif" >> "${OPENSSLCONF_INTERMEDIATE}" +fi + +echo "Done." diff --git a/config/20-ios-tvos-cross.conf b/config/20-ios-tvos-cross.conf new file mode 100644 index 0000000..6242a92 --- /dev/null +++ b/config/20-ios-tvos-cross.conf @@ -0,0 +1,109 @@ +## -*- mode: perl; -*- +## iOS configuration targets + +%targets = ( + ## Base settings for iOS-tvOS cross-compile + # Based on 10-main.conf: iphoneos-cross + # Add generic compiler flags + # Add embed-bitcode option if SDK version is 9 or higher + "ios-tvos-cross-base" => { + template => 1, + cflags => combine('-isysroot $(CROSS_TOP)/SDKs/$(CROSS_SDK) -fno-common', + sub { ((!defined($ENV{'CONFIG_DISABLE_BITCODE'}) || $ENV{'CONFIG_DISABLE_BITCODE'} ne 'true') && defined($ENV{'SDKVERSION'}) && $ENV{'SDKVERSION'} =~ /^(9|[1-9][0-9]+)\./ && $disabled{shared}) + ? '-fembed-bitcode' : (); }, + ), + }, + + ## Base settings for iOS + "ios-cross-base" => { + inherit_from => [ "ios-tvos-cross-base" ], + template => 1, + cflags => add(sub { defined($ENV{'IOS_MIN_SDK_VERSION'}) ? '-mios-version-min=$(IOS_MIN_SDK_VERSION)' : '-mios-version-min=7.0'; }), + }, + + ## Base settings for tvOS + # Defines to skip functionality that uses unsupported functions + "tvos-cross-base" => { + inherit_from => [ "ios-tvos-cross-base" ], + template => 1, + cflags => add(sub { defined($ENV{'TVOS_MIN_SDK_VERSION'}) ? '-mtvos-version-min=$(TVOS_MIN_SDK_VERSION)' : '-mtvos-version-min=9.0'; }), + defines => [ "HAVE_FORK=0" ], + }, + + ## Base for Catalyst + "mac-catalyst-base" => { + inherit_from => [ "ios-tvos-cross-base" ], + template => 1, + cflags => add(sub { defined($ENV{'MACOSX_MIN_SDK_VERSION'}) ? '-mios-version-min=$(MACOSX_MIN_SDK_VERSION)' : '-mmacosx-version-min=10.15'; }), + }, + + ## Catalyst (armv7s) + # Based on 10-main.conf: ios-cross + "mac-catalyst-x86_64" => { + inherit_from => [ "darwin64-x86_64-cc", "mac-catalyst-base" ], + cflags => add("-target x86_64-apple-ios13.0-macabi"), + sys_id => "MacOSX", + }, + + ## Apple iOS simulator (x86_64) + # Based on 10-main.conf: iphoneos-cross / darwin64-x86_64-cc + "ios-sim-cross-x86_64" => { + inherit_from => [ "darwin64-x86_64-cc", "ios-cross-base" ], + sys_id => "iOS", + }, + + ## Apple iOS simulator (arm64) + # Based on 10-main.conf: iphoneos-cross / darwin-arm64 + "ios64-sim-cross-arm64" => { + inherit_from => [ "darwin-common", "ios-cross-base", asm("aarch64_asm") ], + cflags => add("-arch arm64"), + bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR", + perlasm_scheme => "ios64", + sys_id => "iOS", + }, + + ## Apple iOS (arm64) + # Based on 10-main.conf: ios64-cross + "ios64-cross-arm64" => { + inherit_from => [ "darwin-common", "ios-cross-base", asm("aarch64_asm") ], + cflags => add("-arch arm64"), + bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR", + perlasm_scheme => "ios64", + sys_id => "iOS", + }, + + ## Apple iOS (armv7s) + # Based on 10-main.conf: ios-cross + "ios-cross-armv7s" => { + inherit_from => [ "darwin-common", "ios-cross-base", asm("armv4_asm") ], + cflags => add("-arch armv7s"), + perlasm_scheme => "ios32", + sys_id => "iOS", + }, + + ## Apple iOS (armv7) + # Based on 10-main.conf: ios-cross + "ios-cross-armv7" => { + inherit_from => [ "darwin-common", "ios-cross-base", asm("armv4_asm") ], + cflags => add("-arch armv7"), + perlasm_scheme => "ios32", + sys_id => "iOS", + }, + + ## Apple tvOS simulator (x86_64) + # Based on 10-main.conf: iphoneos-cross / darwin64-x86_64-cc + "tvos-sim-cross-x86_64" => { + inherit_from => [ "darwin64-x86_64-cc", "tvos-cross-base" ], + sys_id => "tvOS", + }, + + ## Apple tvOS (arm64) + # Based on 10-main.conf: ios64-cross + "tvos64-cross-arm64" => { + inherit_from => [ "darwin-common", "tvos-cross-base", asm("aarch64_asm") ], + cflags => add("-arch arm64"), + bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR", + perlasm_scheme => "ios64", + sys_id => "tvOS", + }, +); diff --git a/openssl b/openssl index 6c665e2..059b45f 160000 --- a/openssl +++ b/openssl @@ -1 +1 @@ -Subproject commit 6c665e2a15ba7e834875eecaf4eb93c11605dd9a +Subproject commit 059b45ff1ee582a2a3e92c82c62c7e5bb01a1941 diff --git a/scripts/build-loop-targets.sh b/scripts/build-loop-targets.sh new file mode 100755 index 0000000..e04ffca --- /dev/null +++ b/scripts/build-loop-targets.sh @@ -0,0 +1,93 @@ +#!/bin/sh + +# Automatic build script for libssl and libcrypto +# for iPhoneOS and iPhoneSimulator +# +# Created by Felix Schulze on 16.12.10. +# Copyright 2010-2016 Felix Schulze. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +for TARGET in ${TARGETS} +do + # Determine relevant SDK version + if [[ "${TARGET}" == tvos* ]]; then + SDKVERSION="${TVOS_SDKVERSION}" + elif [[ "${TARGET}" == "mac-catalyst"* ]]; then + SDKVERSION="${MACOSX_SDKVERSION}" + else + SDKVERSION="${IOS_SDKVERSION}" + fi + + # These variables are used in the configuration file + export SDKVERSION + export IOS_MIN_SDK_VERSION + export TVOS_MIN_SDK_VERSION + export CONFIG_DISABLE_BITCODE + + # Determine platform + if [[ "${TARGET}" == "ios-sim-cross-"* ]]; then + PLATFORM="iPhoneSimulator" + elif [[ "${TARGET}" == "ios64-sim-cross-"* ]]; then + PLATFORM="iPhoneSimulator" + elif [[ "${TARGET}" == "tvos-sim-cross-"* ]]; then + PLATFORM="AppleTVSimulator" + elif [[ "${TARGET}" == "tvos64-cross-"* ]]; then + PLATFORM="AppleTVOS" + elif [[ "${TARGET}" == "mac-catalyst-"* ]]; then + PLATFORM="MacOSX" + else + PLATFORM="iPhoneOS" + fi + + # Extract ARCH from TARGET (part after last dash) + ARCH=$(echo "${TARGET}" | sed -E 's|^.*\-([^\-]+)$|\1|g') + + # Cross compile references, see Configurations/10-main.conf + export CROSS_COMPILE="${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/" + export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer" + export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk" + + # Prepare TARGETDIR and SOURCEDIR + prepare_target_source_dirs + + ## Determine config options + # Add build target, --prefix and prevent async (references to getcontext(), + # setcontext() and makecontext() result in App Store rejections) and creation + # of shared libraries (default since 1.1.0) + LOCAL_CONFIG_OPTIONS="${TARGET} --prefix=${TARGETDIR} ${CONFIG_OPTIONS} no-async no-shared" + + # Only relevant for 64 bit builds + if [[ "${CONFIG_ENABLE_EC_NISTP_64_GCC_128}" == "true" && "${ARCH}" == *64 ]]; then + LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} enable-ec_nistp_64_gcc_128" + fi + + # Run Configure + run_configure + + # Run make + run_make + + # Run make install + set -e + if [ "${LOG_VERBOSE}" == "verbose" ]; then + make install_dev | tee -a "${LOG}" + else + make install_dev >> "${LOG}" 2>&1 + fi + + # Remove source dir, add references to library files to relevant arrays + # Keep reference to first build target for include file + finish_build_loop +done From 4674b97e2ac0b4aa6d7175a1851fa245a96534ab Mon Sep 17 00:00:00 2001 From: Drew Wells Date: Tue, 5 May 2020 21:03:17 -0500 Subject: [PATCH 6/6] openssl is building fine. libssh still needs work --- build-all.sh | 2 +- build-libssh2.sh | 5 +-- build-libssl.sh | 21 +++++++++--- config/20-ios-tvos-cross.conf | 10 ------ hello.c | 1 + makefile | 64 +++++++++++++++++++++++++++++++++++ 6 files changed, 83 insertions(+), 20 deletions(-) create mode 100644 hello.c diff --git a/build-all.sh b/build-all.sh index 712104d..cd1ce46 100755 --- a/build-all.sh +++ b/build-all.sh @@ -21,7 +21,7 @@ if [ "$1" == "openssl" ]; then echo "Building openssl: $2" - ./build-libssl.sh --archs="x86_64 arm64" --targets="ios-sim-cross-x86_64 ios64-sim-cross-arm64 ios64-cross-arm64" $2 + ./build-libssl.sh --archs="x86_64 arm64" --targets="ios-sim-cross-x86_64 ios64-cross-arm64" $2 # Make dynamic framework, with embed-bitcode, iOS + Simulator: rm -rf build rm -rf openssl.framework diff --git a/build-libssh2.sh b/build-libssh2.sh index 2389e0b..4f5c1b2 100755 --- a/build-libssh2.sh +++ b/build-libssh2.sh @@ -53,10 +53,6 @@ mkdir -p bin mkdir -p lib mkdir -p src -tar zxf libssh2-${VERSION}.tar.gz -C src -cd src/libssh2-${VERSION} -./buildconf - for ARCH in ${ARCHS} do if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; @@ -96,6 +92,7 @@ do if [ "$1" == "openssl" ]; then + pwd ./configure --host=${HOST}-apple-darwin --prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" --with-crypto=openssl --with-libssl-prefix=${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk --disable-shared --enable-static >> "${LOG}" else ./configure --host=${HOST}-apple-darwin --prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" --with-crypto=libgcrypt --with-libgcrypt-prefix=${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk --disable-shared --enable-static >> "${LOG}" diff --git a/build-libssl.sh b/build-libssl.sh index 7b01179..5016933 100755 --- a/build-libssl.sh +++ b/build-libssl.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -x # Automatic build script for libssl and libcrypto # for iPhoneOS and iPhoneSimulator @@ -26,13 +26,14 @@ set -u # Default version in case no version is specified DEFAULTVERSION="1.1.0l" +DEVELOPER=`xcode-select -print-path` # Default (=full) set of targets to build DEFAULTTARGETS="ios-sim-cross-x86_64 ios64-cross-arm64 tvos-sim-cross-x86_64 tvos64-cross-arm64" # mac-catalyst-x86_64 is a valid target that is not in the DEFAULTTARGETS because it's incompatible with "ios-sim-cross-x86_64" # Minimum iOS/tvOS SDK version to build for -IOS_MIN_SDK_VERSION="12.0" -TVOS_MIN_SDK_VERSION="12.0" +IOS_MIN_SDK_VERSION="13.0" +TVOS_MIN_SDK_VERSION="13.0" MACOSX_MIN_SDK_VERSION="10.15" # Init optional env variables (use available variable or default to empty string) @@ -66,6 +67,9 @@ echo_help() spinner() { + # spinner is incompatible with set -x + old_setting=${-//[^x]/} + set +x local pid=$! local delay=0.75 local spinstr='|/-\' @@ -76,7 +80,7 @@ spinner() sleep $delay printf "\b\b\b\b\b" done - + if [[ -n "$old_setting" ]]; then set -x; else set +x; fi wait $pid return $? } @@ -85,7 +89,10 @@ spinner() prepare_target_source_dirs() { # Prepare target dir - TARGETDIR="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" + if [ -z "$TARGETDIR" ]; then + TARGETDIR="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" + fi + mkdir -p "${TARGETDIR}" LOG="${TARGETDIR}/build-openssl-${VERSION}.log" @@ -231,6 +238,10 @@ case $i in IOS_SDKVERSION="${i#*=}" shift ;; + --prefix=*) + TARGETDIR="${i#*=}" + shift + ;; --macosx-sdk=*) MACOSX_SDKVERSION="${i#*=}" shift diff --git a/config/20-ios-tvos-cross.conf b/config/20-ios-tvos-cross.conf index 6242a92..2ff1be4 100644 --- a/config/20-ios-tvos-cross.conf +++ b/config/20-ios-tvos-cross.conf @@ -52,16 +52,6 @@ sys_id => "iOS", }, - ## Apple iOS simulator (arm64) - # Based on 10-main.conf: iphoneos-cross / darwin-arm64 - "ios64-sim-cross-arm64" => { - inherit_from => [ "darwin-common", "ios-cross-base", asm("aarch64_asm") ], - cflags => add("-arch arm64"), - bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR", - perlasm_scheme => "ios64", - sys_id => "iOS", - }, - ## Apple iOS (arm64) # Based on 10-main.conf: ios64-cross "ios64-cross-arm64" => { diff --git a/hello.c b/hello.c new file mode 100644 index 0000000..53c5fdf --- /dev/null +++ b/hello.c @@ -0,0 +1 @@ +#include diff --git a/makefile b/makefile index af12ceb..3875eda 100644 --- a/makefile +++ b/makefile @@ -1,3 +1,12 @@ +ARCHS ?=ios64-cross-arm64 ios-sim-cross-x86_64 +SDKVERSION ?=13.4 +OPENSSLVERSION ?=1.1.0l +LIBSSH2VERSION ?=1.9.0 +OPENSSLVERSION_ :=$(shell echo ${OPENSSLVERSION} | sed 's/\./_/g') + +demo: + echo ${OPENSSLVERSION_} + .PHONY: build build: ./build-all.sh openssl @@ -6,3 +15,58 @@ build: clean: rm -rf bin lib src *.gz include/ + +openssl-${OPENSSLVERSION}.tar.gz: + curl -Lo openssl_${OPENSSLVERSION}.tar.gz https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSLVERSION_}.tar.gz + touch $@ + +openssl: src/openssl-${OPENSSLVERSION}/config + +src/openssl-${OPENSSLVERSION}/config: openssl-${OPENSSLVERSION}.tar.gz + tar -zxvf openssl-${OPENSSLVERSION}.tar.gz --directory src + touch $@ + +# bin/iPhoneSimulator13.4-x86_64.sdk/lib/libssl.a +# bin/iPhoneOS13.4-cross.sdk/lib/libssl.a +# bin/iPhoneOS13.4-arm64.sdk/lib/libssl.a + +libssh: +# libssh2 assumes it is running in the libssh2 directory + cd src/libssh2-${LIBSSH2VERSION} \ + ./build-libssh2.sh openssl + rm -rf libssh2.framework + xcodebuild -UseModernBuildSystem=NO -project libssh2-for-iOS.xcodeproj -target libssh2 -sdk iphoneos -configuration Debug + mkdir -p build/Debug-iphoneos/libssh2.framework/Headers/ + cp include/libssh2/* build/Debug-iphoneos/libssh2.framework/Headers/ + xcodebuild -UseModernBuildSystem=NO -project libssh2-for-iOS.xcodeproj -target libssh2 -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=13.4' -arch x86_64 -arch i386 -configuration Debug + mkdir -p build/Debug-iphonesimulator/libssh2.framework/Headers/ + cp include/libssh2/* build/Debug-iphonesimulator/libssh2.framework/Headers/ + cp -r build/Debug-iphoneos/libssh2.framework . + lipo -create -output libssh2.framework/libssh2 build/Debug-iphonesimulator/libssh2.framework/libssh2 build/Debug-iphoneos/libssh2.framework/libssh2 + +libssl: build/13.4/ios64-cross-arm64/1.1.0l/lib/libssl.a + rm -rf build + rm -rf openssl.framework + xcodebuild -project libssh2-for-iOS.xcodeproj -UseModernBuildSystem=NO -target openssl -sdk iphoneos -configuration Debug + mkdir -p build/Debug-iphoneos/openssl.framework/Headers/ + cp include/openssl/* build/Debug-iphoneos/openssl.framework/Headers/ + xcodebuild -project libssh2-for-iOS.xcodeproj -UseModernBuildSystem=NO -target openssl -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=13.4' -arch x86_64 -arch arm64 -configuration Debug + mkdir -p build/Debug-iphonesimulator/openssl.framework/Headers/ + cp include/openssl/* build/Debug-iphonesimulator/openssl.framework/Headers/ + cp -r build/Debug-iphoneos/openssl.framework . + lipo -create -output openssl.framework/openssl build/Debug-iphonesimulator/openssl.framework/openssl build/Debug-iphoneos/openssl.framework/openssl + +TARGETS := $(foreach arch,$(ARCHS),build/${SDKVERSION}/$(arch)/${OPENSSLVERSION}/lib/libssl.a) + +# Build opeenssl for a specific architecture +$(TARGETS): ARCH=$(shell echo $@ | awk -F'/' '{print $$3}') +$(TARGETS): PREFIX=${PWD}/$(shell dirname $(shell dirname $@)) +$(TARGETS): openssl + @echo "Building $PREFIX" + @echo "SDKVersion: ${SDKVERSION}" + @echo "Arch: ${ARCH}" + @echo "OpenSSL: ${OPENSSLVERSION}" + ./build-libssl.sh --targets=${ARCH} \ + --version=${OPENSSLVERSION} \ + --ios-sdk=${SDKVERSION} \ + --prefix=${PREFIX}