diff --git a/assets/MacOSX/Info.plist b/assets/MacOSX/Info.plist new file mode 100644 index 0000000..ad76608 --- /dev/null +++ b/assets/MacOSX/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + openssl + CFBundleIdentifier + org.openssl.OpenSSL + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + openssl + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + MinimumOSVersion + 10.11 + + diff --git a/build-libssl.sh b/build-libssl.sh index 5fb7bfa..2e2abdc 100755 --- a/build-libssl.sh +++ b/build-libssl.sh @@ -28,10 +28,11 @@ set -u DEFAULTVERSION="1.0.2l" # Default (=full) set of architectures (OpenSSL <= 1.0.2) or targets (OpenSSL >= 1.1.0) to build -DEFAULTARCHS="x86_64 i386 arm64 armv7s armv7 tv_x86_64 tv_arm64" -DEFAULTTARGETS="ios-sim-cross-x86_64 ios-sim-cross-i386 ios64-cross-arm64 ios-cross-armv7s ios-cross-armv7 tvos-sim-cross-x86_64 tvos64-cross-arm64" +DEFAULTARCHS="ios_x86_64 ios_i386 ios_arm64 ios_armv7s ios_armv7 tv_x86_64 tv_arm64 mac_x86_64 mac_i386" +DEFAULTTARGETS="ios-sim-cross-x86_64 ios-sim-cross-i386 ios64-cross-arm64 ios-cross-armv7s ios-cross-armv7 tvos-sim-cross-x86_64 tvos64-cross-arm64 macos64-x86_64 macos-i386" # Minimum iOS/tvOS SDK version to build for +MACOS_MIN_SDK_VERSION="10.11" IOS_MIN_SDK_VERSION="7.0" TVOS_MIN_SDK_VERSION="9.0" @@ -47,6 +48,7 @@ echo_help() 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 " --macos-sdk=SDKVERSION Override macOS SDK version" echo " --ios-sdk=SDKVERSION Override iOS SDK version" echo " --noparallel Disable running make with parallel jobs (make -j)" echo " --tvos-sdk=SDKVERSION Override tvOS SDK version" @@ -168,10 +170,14 @@ finish_build_loop() LIBSSL_TVOS+=("${TARGETDIR}/lib/libssl.a") LIBCRYPTO_TVOS+=("${TARGETDIR}/lib/libcrypto.a") OPENSSLCONF_SUFFIX="tvos_${ARCH}" - else + elif [[ "${PLATFORM}" == iPhone* ]]; then LIBSSL_IOS+=("${TARGETDIR}/lib/libssl.a") LIBCRYPTO_IOS+=("${TARGETDIR}/lib/libcrypto.a") OPENSSLCONF_SUFFIX="ios_${ARCH}" + else + LIBSSL_MACOS+=("${TARGETDIR}/lib/libssl.a") + LIBCRYPTO_MACOS+=("${TARGETDIR}/lib/libcrypto.a") + OPENSSLCONF_SUFFIX="macos_${ARCH}" fi # Copy opensslconf.h to bin directory and add to array @@ -192,6 +198,7 @@ CLEANUP="" CONFIG_ENABLE_EC_NISTP_64_GCC_128="" CONFIG_DISABLE_BITCODE="" CONFIG_NO_DEPRECATED="" +MACOS_SDKVERSION="" IOS_SDKVERSION="" LOG_VERBOSE="" PARALLEL="" @@ -227,6 +234,10 @@ case $i in echo_help exit ;; + --macos-sdk=*) + MACOS_SDKVERSION="${i#*=}" + shift + ;; --ios-sdk=*) IOS_SDKVERSION="${i#*=}" shift @@ -327,6 +338,9 @@ else fi # Determine SDK versions +if [ ! -n "${MACOS_SDKVERSION}" ]; then + MACOS_SDKVERSION=$(xcrun -sdk macosx --show-sdk-version) +fi if [ ! -n "${IOS_SDKVERSION}" ]; then IOS_SDKVERSION=$(xcrun -sdk iphoneos --show-sdk-version) fi @@ -380,6 +394,7 @@ if [ "${BUILD_TYPE}" == "archs" ]; then else echo " Targets: ${TARGETS}" fi +echo " macOS SDK: ${MACOS_SDKVERSION}" echo " iOS SDK: ${IOS_SDKVERSION}" echo " tvOS SDK: ${TVOS_SDKVERSION}" if [ "${CONFIG_DISABLE_BITCODE}" == "true" ]; then @@ -458,6 +473,8 @@ mkdir -p "${CURRENTPATH}/src" # Init vars for library references INCLUDE_DIR="" OPENSSLCONF_ALL=() +LIBSSL_MACOS=() +LIBCRYPTO_MACOS=() LIBSSL_IOS=() LIBCRYPTO_IOS=() LIBSSL_TVOS=() @@ -470,6 +487,13 @@ else source "${SCRIPTDIR}/scripts/build-loop-targets.sh" fi +# Build macOS library if selected for build +if [ ${#LIBSSL_MACOS[@]} -gt 0 ]; then + echo "Build library for macOS..." + lipo -create ${LIBSSL_MACOS[@]} -output "${CURRENTPATH}/lib/libssl-MacOSX.a" + lipo -create ${LIBCRYPTO_MACOS[@]} -output "${CURRENTPATH}/lib/libcrypto-MacOSX.a" +fi + # Build iOS library if selected for build if [ ${#LIBSSL_IOS[@]} -gt 0 ]; then echo "Build library for iOS..." @@ -505,6 +529,12 @@ if [ ${#OPENSSLCONF_ALL[@]} -gt 1 ]; then # Determine define condition case "${OPENSSLCONF_CURRENT}" in + *_macos_x86_64.h) + DEFINE_CONDITION="TARGET_OS_OSX && TARGET_CPU_X86_64" + ;; + *_macos_i386.h) + DEFINE_CONDITION="TARGET_OS_OSX && TARGET_CPU_X86" + ;; *_ios_x86_64.h) DEFINE_CONDITION="TARGET_OS_IOS && TARGET_OS_SIMULATOR && TARGET_CPU_X86_64" ;; diff --git a/config/20-ios-tvos-cross.conf b/config/20-all-platforms.conf similarity index 81% rename from config/20-ios-tvos-cross.conf rename to config/20-all-platforms.conf index f2654b5..81bbb09 100644 --- a/config/20-ios-tvos-cross.conf +++ b/config/20-all-platforms.conf @@ -1,12 +1,11 @@ ## -*- mode: perl; -*- -## iOS configuration targets %targets = ( - ## Base settings for iOS-tvOS cross-compile + ## Base settings for 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" => { + "all-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}) @@ -16,7 +15,7 @@ ## Base settings for iOS "ios-cross-base" => { - inherit_from => [ "ios-tvos-cross-base" ], + inherit_from => [ "all-base" ], template => 1, cflags => add(sub { defined($ENV{'IOS_MIN_SDK_VERSION'}) ? '-mios-version-min=$(IOS_MIN_SDK_VERSION)' : '-mios-version-min=7.0'; }), }, @@ -24,12 +23,19 @@ ## Base settings for tvOS # Defines to skip functionality that uses unsupported functions "tvos-cross-base" => { - inherit_from => [ "ios-tvos-cross-base" ], + inherit_from => [ "all-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 settings for macOS + "macos-base" => { + inherit_from => [ "all-base" ], + template => 1, + cflags => add(sub { defined($ENV{'MACOS_MIN_SDK_VERSION'}) ? '-mmacosx-version-min=$(MACOS_MIN_SDK_VERSION)' : '-mmacosx-version-min=10.11'; }), + }, + ## Apple iOS simulator (x86_64) # Based on 10-main.conf: iphoneos-cross / darwin64-x86_64-cc "ios-sim-cross-x86_64" => { @@ -88,4 +94,16 @@ perlasm_scheme => "ios64", sys_id => "tvOS", }, + + ## Apple macOS (x86_64) + "macos64-x86_64" => { + inherit_from => [ "darwin64-x86_64-cc", "macos-base" ], + sys_id => "macOS", + }, + + ## Apple macOS (i386) + "macos-i386" => { + inherit_from => [ "darwin-i386-cc", "macos-base" ], + sys_id => "macOS", + }, ); diff --git a/create-openssl-framework.sh b/create-openssl-framework.sh index a637761..c61862c 100755 --- a/create-openssl-framework.sh +++ b/create-openssl-framework.sh @@ -21,7 +21,7 @@ if [ -d $FWROOT ]; then rm -rf $FWROOT fi -ALL_SYSTEMS=("iPhone" "AppleTV") +ALL_SYSTEMS=("iPhone" "AppleTV" "MacOSX") function check_bitcode() { local FWDIR=$1 @@ -64,6 +64,8 @@ if [ $FWTYPE == "dynamic" ]; then if [[ $PLATFORM == "AppleTV"* ]]; then MIN_SDK="-tvos_version_min 9.0" + elif [[ $PLATFORM == MacOSX* ]]; then + MIN_SDK="-macosx_version_min 10.11" else MIN_SDK="-ios_version_min 8.0" fi diff --git a/scripts/build-loop-archs.sh b/scripts/build-loop-archs.sh index fe68301..9eca676 100755 --- a/scripts/build-loop-archs.sh +++ b/scripts/build-loop-archs.sh @@ -24,23 +24,28 @@ do # Determine relevant SDK version if [[ "$ARCH" == tv* ]]; then SDKVERSION=${TVOS_SDKVERSION} + elif [[ "$ARCH" == mac* ]]; then + SDKVERSION=${MACOS_SDKVERSION} else SDKVERSION=${IOS_SDKVERSION} fi # Determine platform, override arch for tvOS builds - if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; then + if [[ "${ARCH}" == "ios_x86_64" || "${ARCH}" == "ios_i386" ]]; then PLATFORM="iPhoneSimulator" elif [ "${ARCH}" == "tv_x86_64" ]; then - ARCH="x86_64" PLATFORM="AppleTVSimulator" elif [ "${ARCH}" == "tv_arm64" ]; then - ARCH="arm64" PLATFORM="AppleTVOS" + elif [[ "${ARCH}" == "mac_x86_64" || "${ARCH}" == "mac_i386" ]]; then + PLATFORM="MacOSX" else PLATFORM="iPhoneOS" fi + # Extract ARCH from pseudo ARCH (part after first underscore) + ARCH=$(echo "${ARCH}" | sed -E 's|^[^_]*_(.+)$|\1|g') + # Set env vars for Configure export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer" export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk" @@ -72,6 +77,8 @@ do LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -DHAVE_FORK=0 -mtvos-version-min=${TVOS_MIN_SDK_VERSION}" echo " Patching Configure..." LC_ALL=C sed -i -- 's/D\_REENTRANT\:iOS/D\_REENTRANT\:tvOS/' "./Configure" + elif [[ "${PLATFORM}" == MacOSX* ]]; then + LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -mmacosx-version-min=${MACOS_MIN_SDK_VERSION}" else LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -miphoneos-version-min=${IOS_MIN_SDK_VERSION}" fi diff --git a/scripts/build-loop-targets.sh b/scripts/build-loop-targets.sh index 9abb074..886e151 100755 --- a/scripts/build-loop-targets.sh +++ b/scripts/build-loop-targets.sh @@ -24,12 +24,15 @@ do # Determine relevant SDK version if [[ "${TARGET}" == tvos* ]]; then SDKVERSION="${TVOS_SDKVERSION}" + elif [[ "${TARGET}" == macos* ]]; then + SDKVERSION="${MACOS_SDKVERSION}" else SDKVERSION="${IOS_SDKVERSION}" fi # These variables are used in the configuration file export SDKVERSION + export MACOS_MIN_SDK_VERSION export IOS_MIN_SDK_VERSION export TVOS_MIN_SDK_VERSION export CONFIG_DISABLE_BITCODE @@ -41,6 +44,8 @@ do PLATFORM="AppleTVSimulator" elif [[ "${TARGET}" == "tvos64-cross-"* ]]; then PLATFORM="AppleTVOS" + elif [[ "${TARGET}" == "macos"* ]]; then + PLATFORM="MacOSX" else PLATFORM="iPhoneOS" fi