87 lines
4.0 KiB
Bash
Executable File
87 lines
4.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
cd "${BASH_SOURCE%/*}/../External/libsodium"
|
|
[[ -e "${prefix=$PWD/libsodium-ios}/lib/libsodium.a" ]] && exit
|
|
|
|
# Prepare
|
|
autoreconf --verbose --install --symlink 2>&1 | sed 's/^\([^:]*\):[0-9]\{1,\}: /\1: /'
|
|
rm -rf "${prefix=$PWD/libsodium-ios}"
|
|
mkdir -p "$prefix/lib" \
|
|
"${prefix_i386=$prefix/tmp/i386}" \
|
|
"${prefix_x86_64=$prefix/tmp/x86_64}" \
|
|
"${prefix_armv7=$prefix/tmp/armv7}" \
|
|
"${prefix_armv7s=$prefix/tmp/armv7s}" \
|
|
"${prefix_arm64=$prefix/tmp/arm64}"
|
|
|
|
# Targets
|
|
(
|
|
## ARCH: i386
|
|
export SDKROOT="$(xcrun --show-sdk-path --sdk iphonesimulator)"
|
|
export PATH="$(xcrun --show-sdk-platform-path --sdk iphonesimulator)/usr/bin:$PATH"
|
|
export CFLAGS="-arch i386 -isysroot $SDKROOT -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS"
|
|
export LDFLAGS="-arch i386 -isysroot $SDKROOT -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS"
|
|
export CPPFLAGS="$CFLAGS $CPPFLAGS"
|
|
[[ -e Makefile ]] && make -s distclean
|
|
./configure --host=i686-apple --disable-shared --enable-minimal --prefix="$prefix_i386"
|
|
make -j3 install
|
|
)
|
|
(
|
|
## ARCH: x86_64
|
|
export SDKROOT="$(xcrun --show-sdk-path --sdk iphonesimulator)"
|
|
export PATH="$(xcrun --show-sdk-platform-path --sdk iphonesimulator)/usr/bin:$PATH"
|
|
export CFLAGS="-arch x86_64 -isysroot $SDKROOT -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS"
|
|
export LDFLAGS="-arch x86_64 -isysroot $SDKROOT -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS"
|
|
export CPPFLAGS="$CFLAGS $CPPFLAGS"
|
|
[[ -e Makefile ]] && make -s distclean
|
|
./configure --host=x86_64-apple --disable-shared --enable-minimal --prefix="$prefix_x86_64"
|
|
make -j3 install
|
|
)
|
|
(
|
|
## ARCH: armv7
|
|
export SDKROOT="$(xcrun --show-sdk-path --sdk iphoneos)"
|
|
export PATH="$(xcrun --show-sdk-platform-path --sdk iphoneos)/usr/bin:$PATH"
|
|
export CFLAGS="-mthumb -arch armv7 -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS"
|
|
export LDFLAGS="-mthumb -arch armv7 -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS"
|
|
export CPPFLAGS="$CFLAGS $CPPFLAGS"
|
|
[[ -e Makefile ]] && make -s distclean
|
|
./configure --host=x86_64-apple --target=arm-apple --disable-shared --enable-minimal --prefix="$prefix_armv7"
|
|
make -j3 install
|
|
)
|
|
(
|
|
## ARCH: armv7s
|
|
export SDKROOT="$(xcrun --show-sdk-path --sdk iphoneos)"
|
|
export PATH="$(xcrun --show-sdk-platform-path --sdk iphoneos)/usr/bin:$PATH"
|
|
export CFLAGS="-mthumb -arch armv7s -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS"
|
|
export LDFLAGS="-mthumb -arch armv7s -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS"
|
|
export CPPFLAGS="$CFLAGS $CPPFLAGS"
|
|
[[ -e Makefile ]] && make -s distclean
|
|
./configure --host=x86_64-apple --target=arm-apple --disable-shared --enable-minimal --prefix="$prefix_armv7s"
|
|
make -j3 install
|
|
)
|
|
(
|
|
## ARCH: arm64
|
|
export SDKROOT="$(xcrun --show-sdk-path --sdk iphoneos)"
|
|
export PATH="$(xcrun --show-sdk-platform-path --sdk iphoneos)/usr/bin:$PATH"
|
|
export CFLAGS="-mthumb -arch arm64 -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -O2 -g -flto $CFLAGS"
|
|
export LDFLAGS="-mthumb -arch arm64 -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} -flto $LDFLAGS"
|
|
export CPPFLAGS="$CFLAGS $CPPFLAGS"
|
|
[[ -e Makefile ]] && make -s distclean
|
|
./configure --host=x86_64-apple --target=arm-apple --disable-shared --enable-minimal --prefix="$prefix_arm64"
|
|
make -j3 install
|
|
)
|
|
|
|
# Merge Binaries
|
|
mv -f -- "$prefix_arm64/include" "$prefix/"
|
|
lipo -create \
|
|
"$prefix_i386/lib/libsodium.a" \
|
|
"$prefix_x86_64/lib/libsodium.a" \
|
|
"$prefix_armv7/lib/libsodium.a" \
|
|
"$prefix_armv7s/lib/libsodium.a" \
|
|
"$prefix_arm64/lib/libsodium.a" \
|
|
-output "$prefix/lib/libsodium.a"
|
|
|
|
# Cleanup
|
|
rm -rf -- "$prefix/tmp"
|
|
make -s distclean
|