Add macOS archs/targets

This commit is contained in:
Davide De Rosa 2017-10-13 19:08:40 +02:00
parent d49bf7f61c
commit e455f1a1ae
6 changed files with 97 additions and 7 deletions

24
assets/MacOSX/Info.plist Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>openssl</string>
<key>CFBundleIdentifier</key>
<string>org.openssl.OpenSSL</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>openssl</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>MinimumOSVersion</key>
<string>10.11</string>
</dict>
</plist>

View File

@ -28,10 +28,11 @@ set -u
DEFAULTVERSION="1.0.2l" DEFAULTVERSION="1.0.2l"
# Default (=full) set of architectures (OpenSSL <= 1.0.2) or targets (OpenSSL >= 1.1.0) to build # 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" DEFAULTARCHS="x86_64 i386 arm64 armv7s 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" 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 # Minimum iOS/tvOS SDK version to build for
MACOS_MIN_SDK_VERSION="10.11"
IOS_MIN_SDK_VERSION="7.0" IOS_MIN_SDK_VERSION="7.0"
TVOS_MIN_SDK_VERSION="9.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 " --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 " --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 " -h, --help Print help (this message)"
echo " --macos-sdk=SDKVERSION Override macOS SDK version"
echo " --ios-sdk=SDKVERSION Override iOS SDK version" echo " --ios-sdk=SDKVERSION Override iOS SDK version"
echo " --noparallel Disable running make with parallel jobs (make -j)" echo " --noparallel Disable running make with parallel jobs (make -j)"
echo " --tvos-sdk=SDKVERSION Override tvOS SDK version" echo " --tvos-sdk=SDKVERSION Override tvOS SDK version"
@ -168,10 +170,14 @@ finish_build_loop()
LIBSSL_TVOS+=("${TARGETDIR}/lib/libssl.a") LIBSSL_TVOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_TVOS+=("${TARGETDIR}/lib/libcrypto.a") LIBCRYPTO_TVOS+=("${TARGETDIR}/lib/libcrypto.a")
OPENSSLCONF_SUFFIX="tvos_${ARCH}" OPENSSLCONF_SUFFIX="tvos_${ARCH}"
else elif [[ "${PLATFORM}" == iPhone* ]]; then
LIBSSL_IOS+=("${TARGETDIR}/lib/libssl.a") LIBSSL_IOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_IOS+=("${TARGETDIR}/lib/libcrypto.a") LIBCRYPTO_IOS+=("${TARGETDIR}/lib/libcrypto.a")
OPENSSLCONF_SUFFIX="ios_${ARCH}" OPENSSLCONF_SUFFIX="ios_${ARCH}"
else
LIBSSL_MACOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_MACOS+=("${TARGETDIR}/lib/libcrypto.a")
OPENSSLCONF_SUFFIX="macos_${ARCH}"
fi fi
# Copy opensslconf.h to bin directory and add to array # Copy opensslconf.h to bin directory and add to array
@ -192,6 +198,7 @@ CLEANUP=""
CONFIG_ENABLE_EC_NISTP_64_GCC_128="" CONFIG_ENABLE_EC_NISTP_64_GCC_128=""
CONFIG_DISABLE_BITCODE="" CONFIG_DISABLE_BITCODE=""
CONFIG_NO_DEPRECATED="" CONFIG_NO_DEPRECATED=""
MACOS_SDKVERSION=""
IOS_SDKVERSION="" IOS_SDKVERSION=""
LOG_VERBOSE="" LOG_VERBOSE=""
PARALLEL="" PARALLEL=""
@ -227,6 +234,10 @@ case $i in
echo_help echo_help
exit exit
;; ;;
--macos-sdk=*)
MACOS_SDKVERSION="${i#*=}"
shift
;;
--ios-sdk=*) --ios-sdk=*)
IOS_SDKVERSION="${i#*=}" IOS_SDKVERSION="${i#*=}"
shift shift
@ -327,6 +338,9 @@ else
fi fi
# Determine SDK versions # Determine SDK versions
if [ ! -n "${MACOS_SDKVERSION}" ]; then
MACOS_SDKVERSION=$(xcrun -sdk macosx --show-sdk-version)
fi
if [ ! -n "${IOS_SDKVERSION}" ]; then if [ ! -n "${IOS_SDKVERSION}" ]; then
IOS_SDKVERSION=$(xcrun -sdk iphoneos --show-sdk-version) IOS_SDKVERSION=$(xcrun -sdk iphoneos --show-sdk-version)
fi fi
@ -380,6 +394,7 @@ if [ "${BUILD_TYPE}" == "archs" ]; then
else else
echo " Targets: ${TARGETS}" echo " Targets: ${TARGETS}"
fi fi
echo " macOS SDK: ${MACOS_SDKVERSION}"
echo " iOS SDK: ${IOS_SDKVERSION}" echo " iOS SDK: ${IOS_SDKVERSION}"
echo " tvOS SDK: ${TVOS_SDKVERSION}" echo " tvOS SDK: ${TVOS_SDKVERSION}"
if [ "${CONFIG_DISABLE_BITCODE}" == "true" ]; then if [ "${CONFIG_DISABLE_BITCODE}" == "true" ]; then
@ -458,6 +473,8 @@ mkdir -p "${CURRENTPATH}/src"
# Init vars for library references # Init vars for library references
INCLUDE_DIR="" INCLUDE_DIR=""
OPENSSLCONF_ALL=() OPENSSLCONF_ALL=()
LIBSSL_MACOS=()
LIBCRYPTO_MACOS=()
LIBSSL_IOS=() LIBSSL_IOS=()
LIBCRYPTO_IOS=() LIBCRYPTO_IOS=()
LIBSSL_TVOS=() LIBSSL_TVOS=()
@ -470,6 +487,13 @@ else
source "${SCRIPTDIR}/scripts/build-loop-targets.sh" source "${SCRIPTDIR}/scripts/build-loop-targets.sh"
fi 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 # Build iOS library if selected for build
if [ ${#LIBSSL_IOS[@]} -gt 0 ]; then if [ ${#LIBSSL_IOS[@]} -gt 0 ]; then
echo "Build library for iOS..." echo "Build library for iOS..."
@ -505,6 +529,12 @@ if [ ${#OPENSSLCONF_ALL[@]} -gt 1 ]; then
# Determine define condition # Determine define condition
case "${OPENSSLCONF_CURRENT}" in 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) *_ios_x86_64.h)
DEFINE_CONDITION="TARGET_OS_IOS && TARGET_OS_SIMULATOR && TARGET_CPU_X86_64" DEFINE_CONDITION="TARGET_OS_IOS && TARGET_OS_SIMULATOR && TARGET_CPU_X86_64"
;; ;;

View File

@ -6,7 +6,7 @@
# Based on 10-main.conf: iphoneos-cross # Based on 10-main.conf: iphoneos-cross
# Add generic compiler flags # Add generic compiler flags
# Add embed-bitcode option if SDK version is 9 or higher # Add embed-bitcode option if SDK version is 9 or higher
"ios-tvos-cross-base" => { "all-base" => {
template => 1, template => 1,
cflags => combine('-isysroot $(CROSS_TOP)/SDKs/$(CROSS_SDK) -fno-common', 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}) 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 +16,7 @@
## Base settings for iOS ## Base settings for iOS
"ios-cross-base" => { "ios-cross-base" => {
inherit_from => [ "ios-tvos-cross-base" ], inherit_from => [ "all-base" ],
template => 1, template => 1,
cflags => add(sub { defined($ENV{'IOS_MIN_SDK_VERSION'}) ? '-mios-version-min=$(IOS_MIN_SDK_VERSION)' : '-mios-version-min=7.0'; }), cflags => add(sub { defined($ENV{'IOS_MIN_SDK_VERSION'}) ? '-mios-version-min=$(IOS_MIN_SDK_VERSION)' : '-mios-version-min=7.0'; }),
}, },
@ -24,12 +24,19 @@
## Base settings for tvOS ## Base settings for tvOS
# Defines to skip functionality that uses unsupported functions # Defines to skip functionality that uses unsupported functions
"tvos-cross-base" => { "tvos-cross-base" => {
inherit_from => [ "ios-tvos-cross-base" ], inherit_from => [ "all-base" ],
template => 1, template => 1,
cflags => add(sub { defined($ENV{'TVOS_MIN_SDK_VERSION'}) ? '-mtvos-version-min=$(TVOS_MIN_SDK_VERSION)' : '-mtvos-version-min=9.0'; }), 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" ], 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) ## Apple iOS simulator (x86_64)
# Based on 10-main.conf: iphoneos-cross / darwin64-x86_64-cc # Based on 10-main.conf: iphoneos-cross / darwin64-x86_64-cc
"ios-sim-cross-x86_64" => { "ios-sim-cross-x86_64" => {
@ -88,4 +95,16 @@
perlasm_scheme => "ios64", perlasm_scheme => "ios64",
sys_id => "tvOS", 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",
},
); );

View File

@ -21,7 +21,7 @@ if [ -d $FWROOT ]; then
rm -rf $FWROOT rm -rf $FWROOT
fi fi
ALL_SYSTEMS=("iPhone" "AppleTV") ALL_SYSTEMS=("iPhone" "AppleTV" "MacOSX")
function check_bitcode() { function check_bitcode() {
local FWDIR=$1 local FWDIR=$1
@ -64,6 +64,8 @@ if [ $FWTYPE == "dynamic" ]; then
if [[ $PLATFORM == "AppleTV"* ]]; then if [[ $PLATFORM == "AppleTV"* ]]; then
MIN_SDK="-tvos_version_min 9.0" MIN_SDK="-tvos_version_min 9.0"
elif [[ $PLATFORM == MacOSX* ]]; then
MIN_SDK="-macosx_version_min 10.11"
else else
MIN_SDK="-ios_version_min 8.0" MIN_SDK="-ios_version_min 8.0"
fi fi

View File

@ -24,6 +24,8 @@ do
# Determine relevant SDK version # Determine relevant SDK version
if [[ "$ARCH" == tv* ]]; then if [[ "$ARCH" == tv* ]]; then
SDKVERSION=${TVOS_SDKVERSION} SDKVERSION=${TVOS_SDKVERSION}
elif [[ "$ARCH" == mac* ]]; then
SDKVERSION=${MACOS_SDKVERSION}
else else
SDKVERSION=${IOS_SDKVERSION} SDKVERSION=${IOS_SDKVERSION}
fi fi
@ -37,6 +39,12 @@ do
elif [ "${ARCH}" == "tv_arm64" ]; then elif [ "${ARCH}" == "tv_arm64" ]; then
ARCH="arm64" ARCH="arm64"
PLATFORM="AppleTVOS" PLATFORM="AppleTVOS"
elif [ "${ARCH}" == "mac_x86_64" ]; then
ARCH="x86_64"
PLATFORM="MacOSX"
elif [ "${ARCH}" == "mac_i386" ]; then
ARCH="i386"
PLATFORM="MacOSX"
else else
PLATFORM="iPhoneOS" PLATFORM="iPhoneOS"
fi fi
@ -72,6 +80,8 @@ do
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -DHAVE_FORK=0 -mtvos-version-min=${TVOS_MIN_SDK_VERSION}" LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -DHAVE_FORK=0 -mtvos-version-min=${TVOS_MIN_SDK_VERSION}"
echo " Patching Configure..." echo " Patching Configure..."
LC_ALL=C sed -i -- 's/D\_REENTRANT\:iOS/D\_REENTRANT\:tvOS/' "./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 else
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -miphoneos-version-min=${IOS_MIN_SDK_VERSION}" LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -miphoneos-version-min=${IOS_MIN_SDK_VERSION}"
fi fi

View File

@ -24,12 +24,15 @@ do
# Determine relevant SDK version # Determine relevant SDK version
if [[ "${TARGET}" == tvos* ]]; then if [[ "${TARGET}" == tvos* ]]; then
SDKVERSION="${TVOS_SDKVERSION}" SDKVERSION="${TVOS_SDKVERSION}"
elif [[ "${TARGET}" == macos* ]]; then
SDKVERSION="${MACOS_SDKVERSION}"
else else
SDKVERSION="${IOS_SDKVERSION}" SDKVERSION="${IOS_SDKVERSION}"
fi fi
# These variables are used in the configuration file # These variables are used in the configuration file
export SDKVERSION export SDKVERSION
export MACOS_MIN_SDK_VERSION
export IOS_MIN_SDK_VERSION export IOS_MIN_SDK_VERSION
export TVOS_MIN_SDK_VERSION export TVOS_MIN_SDK_VERSION
export CONFIG_DISABLE_BITCODE export CONFIG_DISABLE_BITCODE
@ -41,6 +44,8 @@ do
PLATFORM="AppleTVSimulator" PLATFORM="AppleTVSimulator"
elif [[ "${TARGET}" == "tvos64-cross-"* ]]; then elif [[ "${TARGET}" == "tvos64-cross-"* ]]; then
PLATFORM="AppleTVOS" PLATFORM="AppleTVOS"
elif [[ "${TARGET}" == "macos"* ]]; then
PLATFORM="MacOSX"
else else
PLATFORM="iPhoneOS" PLATFORM="iPhoneOS"
fi fi