2
0
MasterPassword/platform-darwin/Scripts/build_libjson-c-osx
2018-02-10 20:51:50 -05:00

32 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
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; }
cd "${BASH_SOURCE%/*}/../External/libjson-c"
[[ -e "${prefix=$PWD/libjson-c-osx}/lib/libjson-c.a" ]] && exit
# Prepare
autoreconf -Iautoconf-archive/m4 --verbose --install --symlink 2> >(sed 's/^\([^:]*\):[0-9]\{1,\}: /\1: /')
rm -rf "${prefix=$PWD/libjson-c-osx}"
mkdir -p "$prefix"
# Targets
(
## ARCH: x86_64
SDKROOT="$(xcrun --show-sdk-path --sdk macosx)"
PATH="$(xcrun --show-sdk-platform-path --sdk macosx)/usr/bin:$PATH"
export CFLAGS="-arch x86_64 -isysroot $SDKROOT -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET:-10.8} -O2 -g $CFLAGS" # -flto
export LDFLAGS="-arch x86_64 -isysroot $SDKROOT -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET:-10.8} $LDFLAGS" # -flto
export CPPFLAGS="$CFLAGS $CPPFLAGS"
[[ -e Makefile ]] && make -s clean
./configure --disable-shared --prefix="$prefix"
make -j3 check
make -j3 install
)
# Cleanup
make -s really-clean