-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_gmp.sh
executable file
·117 lines (85 loc) · 3.02 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
113
114
115
116
117
#!/bin/bash
# set -x
CURRENT=`pwd`
__pr="--print-path"
__name="xcode-select"
DEVELOPER=`${__name} ${__pr}`
GMP_VERSION="6.1.2"
SDKVERSION=`xcrun -sdk iphoneos --show-sdk-version`
MIN_IOS="9.0"
BITCODE="-fembed-bitcode"
if [ "${SDKVERSION}" == "9.0" ]; then
BITCODE=""
fi
OSX_PLATFORM=`xcrun --sdk macosx --show-sdk-platform-path`
OSX_SDK=`xcrun --sdk macosx --show-sdk-path`
IPHONEOS_PLATFORM=`xcrun --sdk iphoneos --show-sdk-platform-path`
IPHONEOS_SDK=`xcrun --sdk iphoneos --show-sdk-path`
IPHONESIMULATOR_PLATFORM=`xcrun --sdk iphonesimulator --show-sdk-platform-path`
IPHONESIMULATOR_SDK=`xcrun --sdk iphonesimulator --show-sdk-path`
CLANG=`xcrun --sdk iphoneos --find clang`
CLANGPP=`xcrun --sdk iphoneos --find clang++`
downloadGMP()
{
if [ ! -s ${CURRENT}/gmp-${GMP_VERSION}.tar.bz2 ]; then
echo "Downloading GMP"
curl -L -o ${CURRENT}/gmp-${GMP_VERSION}.tar.bz2 ftp://ftp.gmplib.org/pub/gmp/gmp-${GMP_VERSION}.tar.bz2
fi
}
build()
{
ARCH=$1
SDK=$2
PLATFORM=$3
ARGS=$4
make clean
make distclean
export PATH="${PLATFORM}/Developer/usr/bin:${DEVELOPER}/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
mkdir gmplib-${ARCH}
EXTRAS=""
if [ "${ARCH}" != "x64_86" ]; then
EXTRAS="-miphoneos-version-min=${MIN_IOS} -no-integrated-as -arch ${ARCH} -target ${ARCH}-apple-darwin"
fi
CFLAGS="${BITCODE} -isysroot ${SDK} -Wno-error -Wno-implicit-function-declaration ${EXTRAS}"
./configure --prefix="${CURRENT}/gmplib-${ARCH}" CC="${CLANG} ${CFLAGS}" CPP="${CLANG} -E" CPPFLAGS="${CFLAGS}" \
--host=aarch64-apple-darwin --disable-assembly --enable-static --disable-shared --enable-cxx ${ARGS}
# &> "${CURRENT}/gmplib-${ARCH}-configure.log"
echo "make in progress for ${ARCH}"
make -j `sysctl -n hw.logicalcpu_max` &> "${CURRENT}/gmplib-${ARCH}-build.log"
# if [ "${ARCH}" == "i386" ]; then
# echo "check in progress for ${ARCH}"
# make check &> "${CURRENT}/gmplib-${ARCH}-check.log"
# fi
echo "install in progress for ${ARCH}"
make install &> "${CURRENT}/gmplib-${ARCH}-install.log"
}
downloadGMP
rm -rf gmp
tar xfj "gmp-${GMP_VERSION}.tar.bz2"
mv gmp-${GMP_VERSION} gmp
cd gmp
CURRENT=`pwd`
build "armv7" "${IPHONEOS_SDK}" "${IPHONEOS_PLATFORM}"
build "arm64" "${IPHONEOS_SDK}" "${IPHONEOS_PLATFORM}"
build "i386" "${IPHONESIMULATOR_SDK}" "${IPHONESIMULATOR_PLATFORM}"
build "x64_86" "${OSX_SDK}" "${OSX_PLATFORM}"
mkdir include
cp -r ${CURRENT}/gmplib-x64_86/include include/
mkdir lib
echo "doing lipo"
lipo \
"${CURRENT}/gmplib-armv7/lib/libgmp.a" \
"${CURRENT}/gmplib-arm64/lib/libgmp.a" \
"${CURRENT}/gmplib-i386/lib/libgmp.a" \
"${CURRENT}/gmplib-x64_86/lib/libgmp.a" \
-create -output lib/libgmp.a
lipo \
"${CURRENT}/gmplib-armv7/lib/libgmpxx.a" \
"${CURRENT}/gmplib-arm64/lib/libgmpxx.a" \
"${CURRENT}/gmplib-i386/lib/libgmpxx.a" \
"${CURRENT}/gmplib-x64_86/lib/libgmpxx.a" \
-create -output lib/libgmpxx.a
echo "lib done"
echo "${CURRENT}/lib/libgmp.a"
echo "${CURRENT}/lib/libgmpxx.a"
echo "${CURRENT}/include"