2
0
MasterPassword/platform-darwin/Scripts/build_libjson-c-ios

91 lines
4.0 KiB
Plaintext
Raw Normal View History

#!/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-ios}/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-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}"
2017-08-13 19:52:08 +00:00
# Targets
(
## ARCH: i386
SDKROOT="$(xcrun --show-sdk-path --sdk iphonesimulator)"
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 $CFLAGS"
export LDFLAGS="-arch i386 -isysroot $SDKROOT -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} $LDFLAGS"
export CPPFLAGS="$CFLAGS $CPPFLAGS"
[[ -e Makefile ]] && make -s clean
./configure --host=i686-apple --disable-shared --prefix="$prefix_i386"
make -j3 install
)
(
## ARCH: x86_64
SDKROOT="$(xcrun --show-sdk-path --sdk iphonesimulator)"
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 $CFLAGS"
export LDFLAGS="-arch x86_64 -isysroot $SDKROOT -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} $LDFLAGS"
2017-08-13 19:52:08 +00:00
export CPPFLAGS="$CFLAGS $CPPFLAGS"
[[ -e Makefile ]] && make -s clean
2017-08-13 19:52:08 +00:00
./configure --host=x86_64-apple --disable-shared --prefix="$prefix_x86_64"
make -j3 install
)
(
## ARCH: armv7
SDKROOT="$(xcrun --show-sdk-path --sdk iphoneos)"
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 $CFLAGS"
export LDFLAGS="-mthumb -arch armv7 -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} $LDFLAGS"
2017-08-13 19:52:08 +00:00
export CPPFLAGS="$CFLAGS $CPPFLAGS"
[[ -e Makefile ]] && make -s clean
2017-08-13 19:52:08 +00:00
./configure --host=x86_64-apple --target=arm-apple --disable-shared --prefix="$prefix_armv7"
make -j3 install
)
(
## ARCH: armv7s
SDKROOT="$(xcrun --show-sdk-path --sdk iphoneos)"
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 $CFLAGS"
export LDFLAGS="-mthumb -arch armv7s -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} $LDFLAGS"
2017-08-13 19:52:08 +00:00
export CPPFLAGS="$CFLAGS $CPPFLAGS"
[[ -e Makefile ]] && make -s clean
2017-08-13 19:52:08 +00:00
./configure --host=x86_64-apple --target=arm-apple --disable-shared --prefix="$prefix_armv7s"
make -j3 install
)
(
## ARCH: arm64
SDKROOT="$(xcrun --show-sdk-path --sdk iphoneos)"
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 $CFLAGS"
export LDFLAGS="-mthumb -arch arm64 -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} $LDFLAGS"
2017-08-13 19:52:08 +00:00
export CPPFLAGS="$CFLAGS $CPPFLAGS"
[[ -e Makefile ]] && make -s clean
2017-08-13 19:52:08 +00:00
./configure --host=x86_64-apple --target=arm-apple --disable-shared --prefix="$prefix_arm64"
make -j3 install
)
# Merge Binaries
mv -f -- "$prefix_arm64/include" "$prefix/"
lipo -create \
2017-08-13 23:06:06 +00:00
"$prefix_i386/lib/libjson-c.a" \
"$prefix_x86_64/lib/libjson-c.a" \
"$prefix_armv7/lib/libjson-c.a" \
"$prefix_armv7s/lib/libjson-c.a" \
"$prefix_arm64/lib/libjson-c.a" \
-output "$prefix/lib/libjson-c.a"
# Cleanup
rm -rf -- "$prefix/tmp"
make -s really-clean