2017-08-11 05:40:37 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
|
2018-02-11 01:51:50 +00:00
|
|
|
hash automake || { echo >&2 "Missing automake."; exit 1; }
|
|
|
|
hash autoreconf || { echo >&2 "Missing autoconf."; exit 1; }
|
|
|
|
hash libtool || hash glibtool || { echo >&2 "Missing libtool."; exit 1; }
|
|
|
|
|
2017-08-11 05:40:37 +00:00
|
|
|
cd "${BASH_SOURCE%/*}/../External/libsodium"
|
2017-09-01 15:16:09 +00:00
|
|
|
[[ -e "${prefix=$PWD/libsodium-osx}/lib/libsodium.a" ]] && exit
|
2017-08-11 05:40:37 +00:00
|
|
|
|
|
|
|
# Inspired by libsodium/dist-build/osx.sh
|
|
|
|
# Prepare
|
2018-02-11 01:51:50 +00:00
|
|
|
autoreconf --verbose --install --symlink 2> >(sed 's/^\([^:]*\):[0-9]\{1,\}: /\1: /')
|
2017-08-11 05:40:37 +00:00
|
|
|
rm -rf "${prefix=$PWD/libsodium-osx}"
|
|
|
|
mkdir -p "$prefix"
|
|
|
|
|
2017-08-31 19:14:08 +00:00
|
|
|
# Targets
|
2017-08-11 05:40:37 +00:00
|
|
|
(
|
|
|
|
## ARCH: x86_64
|
2018-02-11 01:51:50 +00:00
|
|
|
SDKROOT="$(xcrun --show-sdk-path --sdk macosx)"
|
|
|
|
PATH="$(xcrun --show-sdk-platform-path --sdk macosx)/usr/bin:$PATH"
|
2017-08-31 19:14:08 +00:00
|
|
|
export CFLAGS="-arch x86_64 -isysroot $SDKROOT -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET:-10.8} -O2 -g -flto $CFLAGS"
|
|
|
|
export LDFLAGS="-arch x86_64 -isysroot $SDKROOT -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET:-10.8} -flto $LDFLAGS"
|
|
|
|
export CPPFLAGS="$CFLAGS $CPPFLAGS"
|
2017-08-11 05:40:37 +00:00
|
|
|
[[ -e Makefile ]] && make -s distclean
|
2017-09-24 00:14:53 +00:00
|
|
|
./configure --disable-shared --enable-minimal --prefix="$prefix"
|
2017-08-11 05:40:37 +00:00
|
|
|
make -j3 check
|
|
|
|
make -j3 install
|
|
|
|
)
|
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
make -s distclean
|