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
|
|
|
|
#
|
|
|
|
# Step 2.
|
|
|
|
# Make for iOS arm7 and arm64
|
|
|
|
#
|
|
|
|
# Step 3.
|
|
|
|
# Merge libs into final version for xcode import
|
|
|
|
|
|
|
|
export PREFIX="$(pwd)/libsodium-ios"
|
2014-12-12 01:35:38 -07:00
|
|
|
export IOS_PREFIX="$PREFIX/tmp/ios"
|
2014-12-12 01:43:55 -07:00
|
|
|
export OSX32_PREFIX="$PREFIX/tmp/osx32"
|
|
|
|
export OSX64_PREFIX="$PREFIX/tmp/osx64"
|
2014-12-10 21:49:55 -07:00
|
|
|
|
2014-12-12 01:43:55 -07:00
|
|
|
mkdir -p $IOS_PREFIX $OSX32_PREFIX $OSX64_PREFIX || exit 1
|
2014-12-10 21:49:55 -07:00
|
|
|
|
2014-12-12 01:43:55 -07:00
|
|
|
# Build for OSX32 First
|
|
|
|
export CFLAGS="-Oz -arch i386"
|
2014-12-10 22:21:15 -07:00
|
|
|
./configure --disable-shared \
|
|
|
|
--enable-minimal \
|
2014-12-12 01:43:55 -07:00
|
|
|
--prefix="$OSX32_PREFIX" || exit 1
|
2014-12-10 22:21:15 -07:00
|
|
|
|
2014-12-12 01:43:55 -07:00
|
|
|
make clean > /dev/null && make -j3 check && make -j3 install || exit 1
|
2014-12-10 21:49:55 -07:00
|
|
|
|
|
|
|
# Cleanup
|
2014-12-10 22:27:10 -07:00
|
|
|
make distclean > /dev/null
|
2014-12-10 21:49:55 -07:00
|
|
|
|
2014-12-12 01:43:55 -07:00
|
|
|
# Build for OSX64 Then
|
|
|
|
export CFLAGS="-Oz -arch x86_64"
|
|
|
|
./configure --disable-shared \
|
|
|
|
--enable-minimal \
|
|
|
|
--prefix="$OSX64_PREFIX"
|
|
|
|
|
|
|
|
make clean > /dev/null && make -j3 check && make -j3 install || exit 1
|
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
make distclean > /dev/null || exit 1
|
|
|
|
|
2014-12-10 21:49:55 -07:00
|
|
|
# Build for iOS
|
2013-11-18 15:59:25 -07:00
|
|
|
export XCODEDIR=$(xcode-select -p)
|
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"
|
|
|
|
export IPHONEOS_VERSION_MIN="5.1.1"
|
2014-12-10 21:49:55 -07:00
|
|
|
export CFLAGS="-Oz -mthumb -arch armv7 -arch arm64 -isysroot ${SDK} -miphoneos-version-min=${IPHONEOS_VERSION_MIN}"
|
|
|
|
export LDFLAGS="-mthumb -arch armv7 -arch arm64 -isysroot ${SDK} -miphoneos-version-min=${IPHONEOS_VERSION_MIN}"
|
2013-01-21 22:25:49 -07:00
|
|
|
|
2013-05-30 22:56:18 -07:00
|
|
|
./configure --host=arm-apple-darwin10 \
|
|
|
|
--disable-shared \
|
2014-08-13 23:32:26 -07:00
|
|
|
--enable-minimal \
|
2014-12-12 01:43:55 -07:00
|
|
|
--prefix="$IOS_PREFIX" || exit 1
|
2014-12-10 21:49:55 -07:00
|
|
|
|
2014-12-12 01:43:55 -07:00
|
|
|
make clean > /dev/null && make -j3 install || exit 1
|
2014-12-10 21:49:55 -07:00
|
|
|
|
|
|
|
# Create universal binary and include folder
|
2014-12-10 22:40:49 -07:00
|
|
|
rm -fr -- "$PREFIX/include" "$PREFIX/libsodium.a" 2> /dev/null
|
|
|
|
mkdir -p -- "$PREFIX"
|
2014-12-12 01:43:55 -07:00
|
|
|
lipo -create "$IOS_PREFIX/lib/libsodium.a" "$OSX32_PREFIX/lib/libsodium.a" "$OSX64_PREFIX/lib/libsodium.a" -output "$PREFIX/libsodium.a"
|
2014-12-10 22:40:49 -07:00
|
|
|
mv -f -- "$IOS_PREFIX/include" "$PREFIX/"
|
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
|
2014-12-10 22:43:55 -07:00
|
|
|
file -- "$PREFIX/libsodium.a"
|
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"
|
2014-12-10 22:27:10 -07:00
|
|
|
make distclean > /dev/null
|