2013-01-22 00:25:49 -05:00
|
|
|
#! /bin/sh
|
2014-12-10 23:49:55 -05:00
|
|
|
#
|
|
|
|
# Step 1.
|
|
|
|
# Configure for base system so simulator is covered
|
|
|
|
#
|
|
|
|
# Step 2.
|
2015-04-19 05:18:08 -04:00
|
|
|
# Make for iOS and iOS simulator
|
2014-12-10 23:49:55 -05:00
|
|
|
#
|
|
|
|
# Step 3.
|
|
|
|
# Merge libs into final version for xcode import
|
|
|
|
|
|
|
|
export PREFIX="$(pwd)/libsodium-ios"
|
2015-04-18 05:50:27 -04:00
|
|
|
export IOS32_PREFIX="$PREFIX/tmp/ios32"
|
2017-04-07 10:16:44 -04:00
|
|
|
export IOS32s_PREFIX="$PREFIX/tmp/ios32s"
|
2015-04-18 05:50:27 -04:00
|
|
|
export IOS64_PREFIX="$PREFIX/tmp/ios64"
|
|
|
|
export SIMULATOR32_PREFIX="$PREFIX/tmp/simulator32"
|
|
|
|
export SIMULATOR64_PREFIX="$PREFIX/tmp/simulator64"
|
|
|
|
export XCODEDIR=$(xcode-select -p)
|
|
|
|
|
2016-09-18 04:46:59 -04:00
|
|
|
xcode_major=$(xcodebuild -version|egrep '^Xcode '|cut -d' ' -f2|cut -d. -f1)
|
|
|
|
if [ $xcode_major -ge 8 ]; then
|
2016-09-17 03:21:11 -04:00
|
|
|
export IOS_SIMULATOR_VERSION_MIN=${IOS_SIMULATOR_VERSION_MIN-"6.0.0"}
|
|
|
|
export IOS_VERSION_MIN=${IOS_VERSION_MIN-"6.0.0"}
|
2016-09-18 04:46:59 -04:00
|
|
|
else
|
|
|
|
export IOS_SIMULATOR_VERSION_MIN=${IOS_SIMULATOR_VERSION_MIN-"5.1.1"}
|
|
|
|
export IOS_VERSION_MIN=${IOS_VERSION_MIN-"5.1.1"}
|
2016-09-17 03:21:11 -04:00
|
|
|
fi
|
|
|
|
|
2017-04-07 10:16:44 -04:00
|
|
|
mkdir -p $SIMULATOR32_PREFIX $SIMULATOR64_PREFIX $IOS32_PREFIX $IOS32s_PREFIX $IOS64_PREFIX || exit 1
|
2015-04-18 05:50:27 -04: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 23:49:55 -05:00
|
|
|
|
2015-04-18 05:50:27 -04:00
|
|
|
## i386 simulator
|
2017-12-30 18:56:51 -05: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 05:50:27 -04:00
|
|
|
|
|
|
|
make distclean > /dev/null
|
2014-12-10 23:49:55 -05:00
|
|
|
|
2016-09-15 10:18:27 -04:00
|
|
|
./configure --host=i686-apple-darwin10 \
|
|
|
|
--disable-shared \
|
2014-12-11 00:21:15 -05:00
|
|
|
--enable-minimal \
|
2015-04-18 05:50:27 -04:00
|
|
|
--prefix="$SIMULATOR32_PREFIX" || exit 1
|
2014-12-11 00:21:15 -05:00
|
|
|
|
2015-04-18 05:50:27 -04:00
|
|
|
make -j3 install || exit 1
|
|
|
|
|
|
|
|
## x86_64 simulator
|
2017-12-30 18:56:51 -05:00
|
|
|
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}"
|
2014-12-10 23:49:55 -05:00
|
|
|
|
2014-12-11 00:27:10 -05:00
|
|
|
make distclean > /dev/null
|
2014-12-10 23:49:55 -05:00
|
|
|
|
2016-09-15 10:18:27 -04:00
|
|
|
./configure --host=x86_64-apple-darwin10 \
|
|
|
|
--disable-shared \
|
2014-12-12 03:43:55 -05:00
|
|
|
--enable-minimal \
|
2015-04-18 05:50:27 -04:00
|
|
|
--prefix="$SIMULATOR64_PREFIX"
|
2014-12-12 03:43:55 -05:00
|
|
|
|
2015-04-18 05:50:27 -04:00
|
|
|
make -j3 install || exit 1
|
2014-12-12 03:43:55 -05:00
|
|
|
|
2014-12-10 23:49:55 -05:00
|
|
|
# Build for iOS
|
2013-01-22 00:25:49 -05:00
|
|
|
export BASEDIR="${XCODEDIR}/Platforms/iPhoneOS.platform/Developer"
|
|
|
|
export PATH="${BASEDIR}/usr/bin:$BASEDIR/usr/sbin:$PATH"
|
2014-11-20 17:01:35 -05:00
|
|
|
export SDK="${BASEDIR}/SDKs/iPhoneOS.sdk"
|
2015-04-18 05:50:27 -04:00
|
|
|
|
|
|
|
## 32-bit iOS
|
2018-02-23 19:47:51 -05: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 05:50:27 -04:00
|
|
|
|
|
|
|
make distclean > /dev/null
|
|
|
|
|
|
|
|
./configure --host=arm-apple-darwin10 \
|
|
|
|
--disable-shared \
|
|
|
|
--enable-minimal \
|
|
|
|
--prefix="$IOS32_PREFIX" || exit 1
|
|
|
|
|
|
|
|
make -j3 install || exit 1
|
|
|
|
|
2017-04-07 10:16:44 -04:00
|
|
|
## 32-bit armv7s iOS
|
2018-02-23 19:47:51 -05: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 10:16:44 -04:00
|
|
|
|
|
|
|
make distclean > /dev/null
|
|
|
|
|
|
|
|
./configure --host=arm-apple-darwin10 \
|
|
|
|
--disable-shared \
|
|
|
|
--enable-minimal \
|
|
|
|
--prefix="$IOS32s_PREFIX" || exit 1
|
|
|
|
|
|
|
|
make -j3 install || exit 1
|
|
|
|
|
2015-04-18 05:50:27 -04:00
|
|
|
## 64-bit iOS
|
2018-02-23 19:47:51 -05:00
|
|
|
export CFLAGS="-fembed-bitcode -O2 -arch arm64 -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN} -fembed-bitcode"
|
|
|
|
export LDFLAGS="-fembed-bitcode -arch arm64 -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN} -fembed-bitcode"
|
2015-04-18 05:50:27 -04:00
|
|
|
|
|
|
|
make distclean > /dev/null
|
2013-01-22 00:25:49 -05:00
|
|
|
|
2013-05-31 01:56:18 -04:00
|
|
|
./configure --host=arm-apple-darwin10 \
|
|
|
|
--disable-shared \
|
2014-08-14 02:32:26 -04:00
|
|
|
--enable-minimal \
|
2015-04-18 05:50:27 -04:00
|
|
|
--prefix="$IOS64_PREFIX" || exit 1
|
2014-12-10 23:49:55 -05:00
|
|
|
|
2015-04-18 05:50:27 -04:00
|
|
|
make -j3 install || exit 1
|
2014-12-10 23:49:55 -05:00
|
|
|
|
|
|
|
# Create universal binary and include folder
|
2014-12-11 00:40:49 -05:00
|
|
|
rm -fr -- "$PREFIX/include" "$PREFIX/libsodium.a" 2> /dev/null
|
2015-07-18 11:44:45 -04:00
|
|
|
mkdir -p -- "$PREFIX/lib"
|
2015-04-18 05:50:27 -04:00
|
|
|
lipo -create \
|
|
|
|
"$SIMULATOR32_PREFIX/lib/libsodium.a" \
|
2015-04-18 12:41:48 -04:00
|
|
|
"$SIMULATOR64_PREFIX/lib/libsodium.a" \
|
2015-04-18 05:50:27 -04:00
|
|
|
"$IOS32_PREFIX/lib/libsodium.a" \
|
2017-04-07 10:16:44 -04:00
|
|
|
"$IOS32s_PREFIX/lib/libsodium.a" \
|
2015-04-18 05:50:27 -04:00
|
|
|
"$IOS64_PREFIX/lib/libsodium.a" \
|
2015-07-18 11:44:45 -04:00
|
|
|
-output "$PREFIX/lib/libsodium.a"
|
2015-04-18 05:50:27 -04:00
|
|
|
mv -f -- "$IOS32_PREFIX/include" "$PREFIX/"
|
2014-12-10 23:49:55 -05:00
|
|
|
|
2014-12-11 00:27:10 -05:00
|
|
|
echo
|
2014-12-11 00:23:24 -05:00
|
|
|
echo "libsodium has been installed into $PREFIX"
|
2014-12-11 00:27:10 -05:00
|
|
|
echo
|
2015-07-18 11:44:45 -04:00
|
|
|
file -- "$PREFIX/lib/libsodium.a"
|
2014-12-11 00:23:24 -05:00
|
|
|
|
2014-12-10 23:49:55 -05:00
|
|
|
# Cleanup
|
2014-12-11 00:40:49 -05:00
|
|
|
rm -rf -- "$PREFIX/tmp"
|
2014-12-11 00:27:10 -05:00
|
|
|
make distclean > /dev/null
|