2013-01-21 22:25:49 -07:00
|
|
|
#! /bin/sh
|
2014-12-10 21:49:55 -07:00
|
|
|
#
|
|
|
|
# Step 1.
|
|
|
|
# Configure for base system so simulator is covered
|
2020-01-28 08:36:45 -07:00
|
|
|
#
|
2014-12-10 21:49:55 -07:00
|
|
|
# Step 2.
|
2020-07-03 10:44:01 -07:00
|
|
|
# Make for iOS, iOS simulator and Catalyst
|
2014-12-10 21:49:55 -07:00
|
|
|
#
|
|
|
|
# Step 3.
|
|
|
|
# Merge libs into final version for xcode import
|
|
|
|
|
|
|
|
export PREFIX="$(pwd)/libsodium-ios"
|
2015-04-18 02:50:27 -07:00
|
|
|
export IOS32_PREFIX="$PREFIX/tmp/ios32"
|
2017-04-07 07:16:44 -07:00
|
|
|
export IOS32s_PREFIX="$PREFIX/tmp/ios32s"
|
2015-04-18 02:50:27 -07:00
|
|
|
export IOS64_PREFIX="$PREFIX/tmp/ios64"
|
|
|
|
export SIMULATOR32_PREFIX="$PREFIX/tmp/simulator32"
|
2020-07-03 10:44:01 -07:00
|
|
|
export SIMULATOR64_PREFIX="$PREFIX/tmp/simulator64"
|
2020-01-28 08:36:45 -07:00
|
|
|
export CATALYST_PREFIX="$PREFIX/tmp/catalyst"
|
2020-07-03 10:44:01 -07:00
|
|
|
export XCODEDIR="$(xcode-select -p)"
|
2015-04-18 02:50:27 -07:00
|
|
|
|
2019-10-23 09:11:12 -07:00
|
|
|
export IOS_SIMULATOR_VERSION_MIN=${IOS_SIMULATOR_VERSION_MIN-"9.0.0"}
|
|
|
|
export IOS_VERSION_MIN=${IOS_VERSION_MIN-"9.0.0"}
|
2016-09-17 00:21:11 -07:00
|
|
|
|
2019-04-18 15:51:06 -07:00
|
|
|
echo
|
|
|
|
echo "Warnings related to headers being present but not usable are due to functions"
|
|
|
|
echo "that didn't exist in the specified minimum iOS version level."
|
|
|
|
echo "They can be safely ignored."
|
|
|
|
echo
|
|
|
|
|
2020-07-03 10:44:01 -07:00
|
|
|
mkdir -p $SIMULATOR32_PREFIX $SIMULATOR64_PREFIX $IOS32_PREFIX $IOS32s_PREFIX $IOS64_PREFIX $CATALYST_PREFIX || exit 1
|
2015-04-18 02:50:27 -07:00
|
|
|
|
|
|
|
# Build for the simulator
|
|
|
|
export BASEDIR="${XCODEDIR}/Platforms/iPhoneSimulator.platform/Developer"
|
|
|
|
export PATH="${BASEDIR}/usr/bin:$BASEDIR/usr/sbin:$PATH"
|
|
|
|
export SDK="${BASEDIR}/SDKs/iPhoneSimulator.sdk"
|
2014-12-10 21:49:55 -07:00
|
|
|
|
2015-04-18 02:50:27 -07:00
|
|
|
## i386 simulator
|
2017-12-30 16:56:51 -07:00
|
|
|
export CFLAGS="-O2 -arch i386 -isysroot ${SDK} -mios-simulator-version-min=${IOS_SIMULATOR_VERSION_MIN}"
|
|
|
|
export LDFLAGS="-arch i386 -isysroot ${SDK} -mios-simulator-version-min=${IOS_SIMULATOR_VERSION_MIN}"
|
2015-04-18 02:50:27 -07:00
|
|
|
|
2020-07-03 10:44:01 -07:00
|
|
|
make distclean >/dev/null
|
2014-12-10 21:49:55 -07:00
|
|
|
|
2018-03-06 13:10:05 -07:00
|
|
|
if [ -z "$LIBSODIUM_FULL_BUILD" ]; then
|
2018-03-06 12:36:39 -07:00
|
|
|
export LIBSODIUM_ENABLE_MINIMAL_FLAG="--enable-minimal"
|
2018-03-06 13:20:17 -07:00
|
|
|
else
|
|
|
|
export LIBSODIUM_ENABLE_MINIMAL_FLAG=""
|
2018-03-06 12:36:39 -07:00
|
|
|
fi
|
|
|
|
|
2016-09-15 07:18:27 -07:00
|
|
|
./configure --host=i686-apple-darwin10 \
|
2020-07-03 10:44:01 -07:00
|
|
|
${LIBSODIUM_ENABLE_MINIMAL_FLAG} \
|
|
|
|
--prefix="$SIMULATOR32_PREFIX" || exit 1
|
2018-03-07 00:15:01 -07:00
|
|
|
|
2018-03-07 02:14:01 -07:00
|
|
|
NPROCESSORS=$(getconf NPROCESSORS_ONLN 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null)
|
2018-03-07 00:15:01 -07:00
|
|
|
PROCESSORS=${NPROCESSORS:-3}
|
|
|
|
|
|
|
|
make -j${PROCESSORS} install || exit 1
|
2015-04-18 02:50:27 -07:00
|
|
|
|
2020-07-03 10:44:01 -07:00
|
|
|
## x86_64 simulator
|
|
|
|
export CFLAGS="-O2 -arch x86_64 -isysroot ${SDK} -mios-simulator-version-min=${IOS_SIMULATOR_VERSION_MIN}"
|
|
|
|
export LDFLAGS="-arch x86_64 -isysroot ${SDK} -mios-simulator-version-min=${IOS_SIMULATOR_VERSION_MIN}"
|
|
|
|
|
|
|
|
make distclean >/dev/null
|
|
|
|
|
|
|
|
./configure --host=x86_64-apple-darwin10 \
|
|
|
|
${LIBSODIUM_ENABLE_MINIMAL_FLAG} \
|
|
|
|
--prefix="$SIMULATOR64_PREFIX"
|
|
|
|
|
|
|
|
make -j${PROCESSORS} install || exit 1
|
|
|
|
|
|
|
|
# Build for x86_64 macOS (Catalyst)
|
2020-01-28 08:36:45 -07:00
|
|
|
export BASEDIR="${XCODEDIR}/Platforms/MacOSX.platform/Developer"
|
|
|
|
export PATH="${BASEDIR}/usr/bin:$BASEDIR/usr/sbin:$PATH"
|
2020-07-03 10:44:01 -07:00
|
|
|
export SDK="${BASEDIR}/SDKs/MacOSX.sdk"
|
2020-01-28 08:36:45 -07:00
|
|
|
|
|
|
|
export CFLAGS="-fembed-bitcode -O2 -arch x86_64 -target x86_64-apple-ios13.0-macabi -isysroot ${SDK}"
|
|
|
|
export LDFLAGS="-fembed-bitcode -arch x86_64 -target x86_64-apple-ios13.0-macabi -isysroot ${SDK}"
|
2014-12-10 21:49:55 -07:00
|
|
|
|
2020-07-03 10:44:01 -07:00
|
|
|
make distclean >/dev/null
|
2014-12-10 21:49:55 -07:00
|
|
|
|
2016-09-15 07:18:27 -07:00
|
|
|
./configure --host=x86_64-apple-darwin10 \
|
2020-07-03 10:44:01 -07:00
|
|
|
${LIBSODIUM_ENABLE_MINIMAL_FLAG} \
|
|
|
|
--prefix="$CATALYST_PREFIX" || exit 1
|
2014-12-12 01:43:55 -07:00
|
|
|
|
2018-03-07 00:15:01 -07:00
|
|
|
make -j${PROCESSORS} install || exit 1
|
2014-12-12 01:43:55 -07:00
|
|
|
|
2014-12-10 21:49:55 -07:00
|
|
|
# Build for iOS
|
2013-01-21 22:25:49 -07:00
|
|
|
export BASEDIR="${XCODEDIR}/Platforms/iPhoneOS.platform/Developer"
|
|
|
|
export PATH="${BASEDIR}/usr/bin:$BASEDIR/usr/sbin:$PATH"
|
2014-11-20 15:01:35 -07:00
|
|
|
export SDK="${BASEDIR}/SDKs/iPhoneOS.sdk"
|
2015-04-18 02:50:27 -07:00
|
|
|
|
|
|
|
## 32-bit iOS
|
2018-02-23 17:47:51 -07:00
|
|
|
export CFLAGS="-fembed-bitcode -O2 -mthumb -arch armv7 -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN}"
|
|
|
|
export LDFLAGS="-fembed-bitcode -mthumb -arch armv7 -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN}"
|
2015-04-18 02:50:27 -07:00
|
|
|
|
2020-07-03 10:44:01 -07:00
|
|
|
make distclean >/dev/null
|
2015-04-18 02:50:27 -07:00
|
|
|
|
|
|
|
./configure --host=arm-apple-darwin10 \
|
2020-07-03 10:44:01 -07:00
|
|
|
${LIBSODIUM_ENABLE_MINIMAL_FLAG} \
|
|
|
|
--prefix="$IOS32_PREFIX" || exit 1
|
2015-04-18 02:50:27 -07:00
|
|
|
|
2018-03-07 00:15:01 -07:00
|
|
|
make -j${PROCESSORS} install || exit 1
|
2015-04-18 02:50:27 -07:00
|
|
|
|
2017-04-07 07:16:44 -07:00
|
|
|
## 32-bit armv7s iOS
|
2018-02-23 17:47:51 -07:00
|
|
|
export CFLAGS="-fembed-bitcode -O2 -mthumb -arch armv7s -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN}"
|
|
|
|
export LDFLAGS="-fembed-bitcode -mthumb -arch armv7s -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN}"
|
2017-04-07 07:16:44 -07:00
|
|
|
|
2020-07-03 10:44:01 -07:00
|
|
|
make distclean >/dev/null
|
2017-04-07 07:16:44 -07:00
|
|
|
|
|
|
|
./configure --host=arm-apple-darwin10 \
|
2020-07-03 10:44:01 -07:00
|
|
|
${LIBSODIUM_ENABLE_MINIMAL_FLAG} \
|
|
|
|
--prefix="$IOS32s_PREFIX" || exit 1
|
2017-04-07 07:16:44 -07:00
|
|
|
|
2018-03-07 00:15:01 -07:00
|
|
|
make -j${PROCESSORS} install || exit 1
|
2017-04-07 07:16:44 -07:00
|
|
|
|
2015-04-18 02:50:27 -07:00
|
|
|
## 64-bit iOS
|
2020-01-28 05:43:05 -07:00
|
|
|
export CFLAGS="-fembed-bitcode -O2 -arch arm64 -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN}"
|
|
|
|
export LDFLAGS="-fembed-bitcode -arch arm64 -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN}"
|
2015-04-18 02:50:27 -07:00
|
|
|
|
2020-07-03 10:44:01 -07:00
|
|
|
make distclean >/dev/null
|
2013-01-21 22:25:49 -07:00
|
|
|
|
2013-05-30 22:56:18 -07:00
|
|
|
./configure --host=arm-apple-darwin10 \
|
2020-07-03 10:44:01 -07:00
|
|
|
${LIBSODIUM_ENABLE_MINIMAL_FLAG} \
|
|
|
|
--prefix="$IOS64_PREFIX" || exit 1
|
2014-12-10 21:49:55 -07:00
|
|
|
|
2018-03-07 00:15:01 -07:00
|
|
|
make -j${PROCESSORS} install || exit 1
|
2014-12-10 21:49:55 -07:00
|
|
|
|
2020-07-03 10:44:01 -07:00
|
|
|
# Create fat libraries for iOS and simulators
|
|
|
|
rm -fr -- "$PREFIX/include" "$PREFIX/libsodium.a" 2>/dev/null
|
2015-07-18 08:44:45 -07:00
|
|
|
mkdir -p -- "$PREFIX/lib"
|
2015-04-18 02:50:27 -07:00
|
|
|
lipo -create \
|
|
|
|
"$SIMULATOR32_PREFIX/lib/libsodium.a" \
|
2020-01-28 08:36:45 -07:00
|
|
|
"$CATALYST_PREFIX/lib/libsodium.a" \
|
2015-04-18 02:50:27 -07:00
|
|
|
"$IOS32_PREFIX/lib/libsodium.a" \
|
2017-04-07 07:16:44 -07:00
|
|
|
"$IOS32s_PREFIX/lib/libsodium.a" \
|
2015-04-18 02:50:27 -07:00
|
|
|
"$IOS64_PREFIX/lib/libsodium.a" \
|
2015-07-18 08:44:45 -07:00
|
|
|
-output "$PREFIX/lib/libsodium.a"
|
2020-01-28 08:36:45 -07:00
|
|
|
|
2019-09-08 19:25:59 -07:00
|
|
|
lipo -create \
|
|
|
|
"$SIMULATOR32_PREFIX/lib/libsodium.dylib" \
|
2020-01-28 08:36:45 -07:00
|
|
|
"$CATALYST_PREFIX/lib/libsodium.dylib" \
|
2019-09-08 19:25:59 -07:00
|
|
|
"$IOS32_PREFIX/lib/libsodium.dylib" \
|
|
|
|
"$IOS32s_PREFIX/lib/libsodium.dylib" \
|
|
|
|
"$IOS64_PREFIX/lib/libsodium.dylib" \
|
|
|
|
-output "$PREFIX/lib/libsodium.dylib"
|
2020-01-28 08:36:45 -07:00
|
|
|
|
2015-04-18 02:50:27 -07:00
|
|
|
mv -f -- "$IOS32_PREFIX/include" "$PREFIX/"
|
2019-09-08 19:25:59 -07:00
|
|
|
install_name_tool -id "@rpath/SODIUM.framework/libsodium.dylib" "$PREFIX/lib/libsodium.dylib"
|
2014-12-10 21:49:55 -07:00
|
|
|
|
2014-12-10 22:27:10 -07:00
|
|
|
echo
|
2014-12-10 22:23:24 -07:00
|
|
|
echo "libsodium has been installed into $PREFIX"
|
2014-12-10 22:27:10 -07:00
|
|
|
echo
|
2015-07-18 08:44:45 -07:00
|
|
|
file -- "$PREFIX/lib/libsodium.a"
|
2019-09-08 19:25:59 -07:00
|
|
|
file -- "$PREFIX/lib/libsodium.dylib"
|
2014-12-10 22:23:24 -07:00
|
|
|
|
2014-12-10 21:49:55 -07:00
|
|
|
# Cleanup
|
2014-12-10 22:40:49 -07:00
|
|
|
rm -rf -- "$PREFIX/tmp"
|
2020-07-03 10:44:01 -07:00
|
|
|
make distclean >/dev/null
|