-
Notifications
You must be signed in to change notification settings - Fork 322
/
Copy pathbuild-macos-curl.sh
executable file
·127 lines (95 loc) · 3.75 KB
/
build-macos-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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
#
# Copyright 2016 leenjewel
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# read -n1 -p "Press any key to continue..."
set -u
source ./build-macos-common.sh
if [ -z ${version+x} ]; then
version="7.68.0"
fi
TOOLS_ROOT=$(pwd)
SOURCE="$0"
while [ -h "$SOURCE" ]; do
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
pwd_path="$(cd -P "$(dirname "$SOURCE")" && pwd)"
echo pwd_path=${pwd_path}
echo TOOLS_ROOT=${TOOLS_ROOT}
LIB_VERSION="curl-$(echo $version | sed 's/\./_/g')"
LIB_NAME="curl-$version"
LIB_DEST_DIR="${pwd_path}/../output/macos/curl-universal"
init_log_color
echo "https://github.com/curl/curl/releases/download/${LIB_VERSION}/${LIB_NAME}.tar.gz"
# https://curl.haxx.se/download/${LIB_NAME}.tar.gz
# https://github.com/curl/curl/releases/download/curl-7_69_0/curl-7.69.0.tar.gz
# https://github.com/curl/curl/releases/download/curl-7_68_0/curl-7.68.0.tar.gz
DEVELOPER=$(xcode-select -print-path)
rm -rf "${LIB_DEST_DIR}" "${LIB_NAME}"
[ -f "${LIB_NAME}.tar.gz" ] || curl -LO https://github.com/curl/curl/releases/download/${LIB_VERSION}/${LIB_NAME}.tar.gz >${LIB_NAME}.tar.gz
function configure_make() {
ARCH=$1
SDK=$2
PLATFORM=$3
SDK_PATH=$(xcrun -sdk ${SDK} --show-sdk-path)
log_info "configure $ARCH start..."
if [ -d "${LIB_NAME}" ]; then
rm -fr "${LIB_NAME}"
fi
tar xfz "${LIB_NAME}.tar.gz"
pushd .
cd "${LIB_NAME}"
PREFIX_DIR="${pwd_path}/../output/macos/curl-${ARCH}"
if [ -d "${PREFIX_DIR}" ]; then
rm -fr "${PREFIX_DIR}"
fi
mkdir -p "${PREFIX_DIR}"
OUTPUT_ROOT=${TOOLS_ROOT}/../output/macos/curl-${ARCH}
mkdir -p ${OUTPUT_ROOT}/log
set_macos_cpu_feature "curl" "${ARCH}" "${MACOS_MIN_TARGET}" "${SDK_PATH}"
OPENSSL_OUT_DIR="${pwd_path}/../output/macos/openssl-${ARCH}"
NGHTTP2_OUT_DIR="${pwd_path}/../output/macos/nghttp2-${ARCH}"
export LDFLAGS="${LDFLAGS} -L${OPENSSL_OUT_DIR}/lib -L${NGHTTP2_OUT_DIR}/lib"
macos_printf_global_params "$ARCH" "$SDK" "$PLATFORM" "$PREFIX_DIR" "$OUTPUT_ROOT"
if [[ "${ARCH}" == "x86_64" ]]; then
./Configure --host=$(macos_get_build_host "$ARCH") --prefix="${PREFIX_DIR}" --disable-shared --enable-static --enable-ipv6 --without-libidn2 --with-ssl=${OPENSSL_OUT_DIR} --with-nghttp2=${NGHTTP2_OUT_DIR} >"${OUTPUT_ROOT}/log/${ARCH}.log" 2>&1
else
log_error "not support" && exit 1
fi
log_info "make $ARCH start..."
make clean >>"${OUTPUT_ROOT}/log/${ARCH}.log"
if make -j8 >>"${OUTPUT_ROOT}/log/${ARCH}.log" 2>&1; then
make install >>"${OUTPUT_ROOT}/log/${ARCH}.log" 2>&1
fi
popd
}
log_info "${PLATFORM_TYPE} ${LIB_NAME} start..."
for ((i = 0; i < ${#ARCHS[@]}; i++)); do
if [[ $# -eq 0 || "$1" == "${ARCHS[i]}" ]]; then
configure_make "${ARCHS[i]}" "${SDKS[i]}" "${PLATFORMS[i]}"
fi
done
log_info "lipo start..."
function lipo_library() {
LIB_SRC=$1
LIB_DST=$2
LIB_PATHS=("${ARCHS[@]/#/${pwd_path}/../output/macos/curl-}")
LIB_PATHS=("${LIB_PATHS[@]/%//lib/${LIB_SRC}}")
lipo ${LIB_PATHS[@]} -create -output "${LIB_DST}"
}
mkdir -p "${LIB_DEST_DIR}"
lipo_library "libcurl.a" "${LIB_DEST_DIR}/libcurl-universal.a"
log_info "${PLATFORM_TYPE} ${LIB_NAME} end..."