-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
468 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/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. | ||
|
||
source ./build-common.sh | ||
|
||
if [ -z ${api+x} ]; then | ||
api="10.12" | ||
fi | ||
if [ -z ${arch+x} ]; then | ||
arch=("x86_64") | ||
fi | ||
if [ -z ${sdk+x} ]; then | ||
sdk=("macosx") | ||
fi | ||
if [ -z ${platform+x} ]; then | ||
platform=("MacOSX") | ||
fi | ||
|
||
export PLATFORM_TYPE="macOS" | ||
export MACOS_MIN_TARGET="$api" | ||
export ARCHS=(${arch[@]}) | ||
export SDKS=(${sdk[@]}) | ||
export PLATFORMS=(${platform[@]}) | ||
|
||
function get_macos_arch() { | ||
local common_arch=$1 | ||
case ${common_arch} in | ||
x86_64) | ||
echo "x86-64" | ||
;; | ||
esac | ||
} | ||
|
||
function macos_get_build_host() { | ||
local arch=$(get_macos_arch $1) | ||
case ${arch} in | ||
x86-64) | ||
echo "x86_64-apple-darwin" | ||
;; | ||
esac | ||
} | ||
|
||
function set_macos_cpu_feature() { | ||
local name=$1 | ||
local arch=$(get_macos_arch $2) | ||
local macos_min_target=$3 | ||
local sysroot=$4 | ||
case ${arch} in | ||
x86-64) | ||
export CC="xcrun -sdk macosx clang -arch x86_64" | ||
export CXX="xcrun -sdk macosx clang++ -arch x86_64" | ||
export CFLAGS="-arch x86_64 -target x86_64-apple-darwin -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -Wno-unused-function -fstrict-aliasing -O2 -Wno-ignored-optimization-argument -isysroot ${sysroot} -mmacosx-version-min=${macos_min_target} -I${sysroot}/usr/include" | ||
export LDFLAGS="-arch x86_64 -target x86_64-apple-darwin -march=x86-64 -isysroot ${sysroot} -L${sysroot}/usr/lib " | ||
export CXXFLAGS="-std=c++14 -arch x86_64 -target x86_64-apple-darwin -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -fstrict-aliasing -mmacosx-version-min=${macos_min_target} -I${sysroot}/usr/include" | ||
;; | ||
*) | ||
log_error "not support" && exit 1 | ||
;; | ||
esac | ||
} | ||
|
||
function macos_printf_global_params() { | ||
local arch=$1 | ||
local type=$2 | ||
local platform=$3 | ||
local in_dir=$4 | ||
local out_dir=$5 | ||
echo -e "arch = $arch" | ||
echo -e "type = $type" | ||
echo -e "platform = $platform" | ||
echo -e "PLATFORM_TYPE = $PLATFORM_TYPE" | ||
echo -e "MACOS_MIN_TARGET = $MACOS_MIN_TARGET" | ||
echo -e "in_dir = $in_dir" | ||
echo -e "out_dir = $out_dir" | ||
echo -e "CC = $CC" | ||
echo -e "CXX = $CXX" | ||
echo -e "CFLAGS = $CFLAGS" | ||
echo -e "CXXFLAGS = $CXXFLAGS" | ||
echo -e "LDFLAGS = $LDFLAGS" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#!/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="1.40.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="v$version" | ||
LIB_NAME="nghttp2-$version" | ||
LIB_DEST_DIR="${pwd_path}/../output/macos/nghttp2-universal" | ||
|
||
init_log_color | ||
|
||
echo "https://github.com/nghttp2/nghttp2/releases/download/${LIB_VERSION}/${LIB_NAME}.tar.gz" | ||
|
||
DEVELOPER=$(xcode-select -print-path) | ||
rm -rf "${LIB_DEST_DIR}" "${LIB_NAME}" | ||
[ -f "${LIB_NAME}.tar.gz" ] || curl -LO https://github.com/nghttp2/nghttp2/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/nghttp2-${ARCH}" | ||
if [ -d "${PREFIX_DIR}" ]; then | ||
rm -fr "${PREFIX_DIR}" | ||
fi | ||
mkdir -p "${PREFIX_DIR}" | ||
|
||
OUTPUT_ROOT=${TOOLS_ROOT}/../output/macos/nghttp2-${ARCH} | ||
mkdir -p ${OUTPUT_ROOT}/log | ||
|
||
set_macos_cpu_feature "nghttp2" "${ARCH}" "${MACOS_MIN_TARGET}" "${SDK_PATH}" | ||
|
||
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 --disable-app --disable-threads --enable-lib-only >"${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" 2>&1 | ||
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/nghttp2-}") | ||
LIB_PATHS=("${LIB_PATHS[@]/%//lib/${LIB_SRC}}") | ||
lipo ${LIB_PATHS[@]} -create -output "${LIB_DST}" | ||
} | ||
mkdir -p "${LIB_DEST_DIR}" | ||
lipo_library "libnghttp2.a" "${LIB_DEST_DIR}/libnghttp2-universal.a" | ||
|
||
log_info "${PLATFORM_TYPE} ${LIB_NAME} end..." |
Oops, something went wrong.