-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_mpfr.sh
executable file
·110 lines (79 loc) · 2.8 KB
/
build_mpfr.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
#!/bin/bash
# set -x
CURRENT=`pwd`
__pr="--print-path"
__name="xcode-select"
DEVELOPER=`${__name} ${__pr}`
MIN_IOS="9.0"
SDKVERSION=`xcrun -sdk iphoneos --show-sdk-version`
MPFR_VERSION="4.0.2"
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++`
downloadMPFR()
{
if [ ! -s ${CURRENT}/mpfr-${MPFR_VERSION}.tar.bz2 ]; then
echo "Downloading MPFR"
curl -L -o ${CURRENT}/mpfr-${MPFR_VERSION}.tar.bz2 http://www.mpfr.org/mpfr-current/mpfr-${MPFR_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 mpfrlib-${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} "
GMP_LIB_PATH="${CURRENT}/../gmp/gmplib-${ARCH}"
GMP_PATH="${CURRENT}/../gmp"
./configure --prefix="${CURRENT}/mpfrlib-${ARCH}" CC="${CLANG} ${CFLAGS}" CPP="${CLANG} -E" --with-gmp="${GMP_LIB_PATH}" \
--host=aarch64-apple-darwin --disable-assembly --enable-static --disable-shared ${ARGS}
echo "make in progress for ${ARCH}"
make -j `sysctl -n hw.logicalcpu_max` &> "${CURRENT}/mpfrlib-${ARCH}-build.log"
# if [ "${ARCH}" == "i386" ]; then
# echo "check in progress for ${ARCH}"
# make check &> "${CURRENT}/mpfrlib-${ARCH}-check.log"
# fi
echo "install in progress for ${ARCH}"
make install &> "${CURRENT}/mpfrlib-${ARCH}-install.log"
}
downloadMPFR
rm -rf mpfr
tar xfj "mpfr-${MPFR_VERSION}.tar.bz2"
mv mpfr-${MPFR_VERSION} mpfr
cd mpfr
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}/mpfrlib-x64_86/include include/
mkdir lib
echo "doing lipo"
lipo \
"${CURRENT}/mpfrlib-armv7/lib/libmpfr.a" \
"${CURRENT}/mpfrlib-arm64/lib/libmpfr.a" \
"${CURRENT}/mpfrlib-i386/lib/libmpfr.a" \
"${CURRENT}/mpfrlib-x64_86/lib/libmpfr.a" \
-create -output lib/libmpfr.a
echo "lib done"
echo "${CURRENT}/lib/libmpfr.a"
echo "${CURRENT}/include"