-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_curl.sh
executable file
·97 lines (79 loc) · 2.44 KB
/
build_curl.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
#!/bin/bash
checkExitCode() {
if [ $1 -ne 0 ]; then
echo "Error building zlib library"
cd $BASE_PATH
exit $1
fi
}
safeMakeDir() {
if [ ! -x "$1" ]; then
mkdir -p "$1"
fi
}
compile() {
cd $CRUL_PATH
ABI=$1
TOOLCHAIN=$2
TOOL=$3
ARCH_FLAGS=$4
# echo '------ABI------'$ABI
# echo '------TOOLCHAIN------'$TOOLCHAIN
# echo '------TOOL------'$TOOL
# echo '------ARCH_FLAGS------'$ARCH_FLAGS
export TOOLCHAIN=$TOOLCHAIN
# export AR=$TOOLCHAIN/bin/llvm-ar
echo 'AR---'$AR
export PKG_CONFIG_LIBDIR=$TOOLCHAIN/lib/pkgconfig
export CROSS_SYSROOT=$TOOLCHAIN/sysroot
# export PATH=$TOOLCHAIN/bin:$PATH
export CC=$TOOLCHAIN/bin/${TOOL}-clang
export CXX=$TOOLCHAIN/bin/${TOOL}-clang++
echo 'CXX---'$CXX
export LINK=${CXX}
export LD=$TOOLCHAIN/bin/${TOOL}-ld
export AS=$TOOLCHAIN/bin/${TOOL}-clang
export RANLIB=$TOOLCHAIN/bin/${TOOL}-ranlib
export STRIP=$TOOLCHAIN/bin/${TOOL}-strip
export ARCH_FLAGS=$ARCH_FLAGS
CFLAGS="${ARCH_FLAGS} -fPIE -fPIC -ffunction-sections -funwind-tables -fno-stack-protector -fno-strict-aliasing"
export CXXFLAGS="${CFLAGS} -frtti -fexceptions -fdata-sections -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -Wno-unused-function -Wno-narrowing"
export LDFLAGS="-pie"
export CFLAGS="-I$TOOLCHAIN/sysroot/usr/include --sysroot=$TOOLCHAIN/sysroot $CFLAGS"
export AR=$TOOLCHAIN/bin/${TOOL}-ar
# zlib configure
export CROSS_PREFIX="$TOOLCHAIN/arm-linux-androideabi-"
# config
safeMakeDir $CRUL_PATH/$ABI
./configure --prefix=$CRUL_PATH/$ABI --enable-static --enable-shared --host=$TOOL \
--with-ssl=$BASE_PATH/source/openssl/$ABI --with-nghttp2=$BASE_PATH/source/nghttp2/$ABI
# # make
make -j4
# checkExitCode $?
# install
make install
# checkExitCode $?
make clean
# checkExitCode $?
cd $BASE_PATH
}
BASE_PATH=$(
cd "$(dirname $0)"
pwd
)
CRUL_PATH=${BASE_PATH}"/source/curl"
TOOLCHAIN_PATH=$BASE_PATH'/toolchain/'$1
echo '---TOOLCHAIN_PATH---'$TOOLCHAIN_PATH
if [[ $1 == 'arm' ]]; then
#statements
compile $1 $TOOLCHAIN_PATH $3 "-march=armv7-a -mfloat-abi=softfp -mfpu=neon"
elif [[ $1 == 'arm64' ]]; then
#statements
compile $1 $TOOLCHAIN_PATH $3 "-march=armv8-a"
elif [[ $1 == 'x86' ]]; then
#statements
compile $1 $TOOLCHAIN_PATH $3 "-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32"
elif [[ $1 == 'x86_64' ]]; then
#statements
compile $1 $TOOLCHAIN_PATH $3 "-march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel"
fi