forked from GetoXs/GnuTLS-GMP-Nettle-for-iOS
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-gmp.sh
112 lines (90 loc) · 3.7 KB
/
build-gmp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh
# Automatic build script for GNU MP Bignum Library (GMP)
# for i386 (iPhoneSimulator) and armv7(iPhoneOS)
#
# Created by Mateusz Przybylek
# Created on 2014-01-07
# Copyright 2014 Mateusz Przybylek. All rights reserved.
#
# You can change values here
#=================================================================================
# Library version
VERSION="5.1.3"
# Architectures array
ARCHS=("i386" "armv7")
# Platforms array
PLATFORMS=("iPhoneSimulator" "iPhoneOS")
# SDK versions array
SDKVERSIONS=("6.1" "7.0")
#=================================================================================
#
# You don't need to change values here
#=================================================================================
CURRENTPATH=${PWD}
mkdir -p "${CURRENTPATH}/build"
mkdir -p "${CURRENTPATH}/include"
mkdir -p "${CURRENTPATH}/lib"
mkdir -p "${CURRENTPATH}/src"
mkdir -p "${CURRENTPATH}/tar"
mkdir -p "${CURRENTPATH}/usr"
cd "${CURRENTPATH}/tar"
if [ ! -e gmp-${VERSION}.tar.bz2 ]; then
echo "Downloading gmp-${VERSION}.tar.bz2"
curl -O ftp://ftp.gnu.org/gnu/gmp/gmp-${VERSION}.tar.bz2
else
echo "Using gmp-${VERSION}.tar.bz2"
fi
echo "Extracting files..."
tar zxf gmp-${VERSION}.tar.bz2 -C ${CURRENTPATH}/src/
for ((i=0; i<${#ARCHS[*]}; i++))
do
ARCH=${ARCHS[i]}
PLATFORM=${PLATFORMS[i]}
SDKVERSION=${SDKVERSIONS[i]}
OUTPUTPATH=${CURRENTPATH}/usr/${PLATFORM}${SDKVERSION}-${ARCH}.sdk
mkdir -p "${OUTPUTPATH}"
export PREFIX=${OUTPUTPATH}
export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk
#common toolchains for all platforms
export DEVROOT=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr
export CC=$DEVROOT/bin/cc
export LD=$DEVROOT/bin/ld
export CXX=$DEVROOT/bin/c++
# alias
export AS=$DEVROOT/bin/as
# alt
# export AS=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/as/x86_64/as
export AR=$DEVROOT/bin/ar
# alias
export NM=$DEVROOT/bin/nm
# alt
# export NM="$DEVROOT/bin/nm -arch ${ARCH}"
#export CPP=$DEVROOT/bin/cpp
export CPP="$DEVROOT/bin/clang -E"
#export CXXCPP=$DEVROOT/bin/cpp
export CXXCPP="$DEVROOT/bin/clang -E"
# alias as libtool
export RANLIB=$DEVROOT/bin/ranlib
export CC_FOR_BUILD="/usr/bin/clang -isysroot / -I/usr/include"
export LDFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -L${PREFIX}/lib"
export CCASFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -I${PREFIX}/include"
export CFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -I${PREFIX}/include"
export CXXFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -I${PREFIX}/include"
export M4FLAGS="-I${PREFIX}/include"
export CPPFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -I${PREFIX}/include"
mkdir -p "${CURRENTPATH}/build/gmp-${ARCH}"
cd ${CURRENTPATH}/build/gmp-${ARCH}
echo "Configure..."
${CURRENTPATH}/src/gmp-${VERSION}/configure --prefix=${PREFIX} --host=${ARCH}-apple-darwin --disable-assembly
echo "Build..."
make
make install
cd ${CURRENTPATH}
done
cd ${CURRENTPATH}
echo "Build library..."
lipo -create ${CURRENTPATH}/usr/${PLATFORMS[0]}${SDKVERSIONS[0]}-${ARCHS[0]}.sdk/lib/libgmp.a ${CURRENTPATH}/usr/${PLATFORMS[1]}${SDKVERSIONS[1]}-${ARCHS[1]}.sdk/lib/libgmp.a -output ${CURRENTPATH}/lib/libgmp.a
lipo -create ${CURRENTPATH}/usr/${PLATFORMS[0]}${SDKVERSIONS[0]}-${ARCHS[0]}.sdk/lib/libgmp.dylib ${CURRENTPATH}/usr/${PLATFORMS[1]}${SDKVERSIONS[1]}-${ARCHS[1]}.sdk/lib/libgmp.dylib -output ${CURRENTPATH}/lib/libgmp.dylib
echo "Copy headers..."
cp -r ${CURRENTPATH}/usr/${PLATFORMS[0]}${SDKVERSIONS[0]}-${ARCHS[0]}.sdk/include/* include
echo "Done"