2014-04-06 22:27:59 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
pushd "${0%/*}" &>/dev/null
|
|
|
|
pushd .. &>/dev/null
|
|
|
|
source ./tools/tools.sh
|
|
|
|
popd &>/dev/null
|
|
|
|
|
2014-04-22 19:34:08 +02:00
|
|
|
set +e
|
2020-08-15 20:07:54 +02:00
|
|
|
if [ -n "$VERSION" ]; then
|
2019-11-02 13:26:21 +01:00
|
|
|
if [ -n "$SDK_VERSION" ]; then
|
2019-06-01 19:57:44 +02:00
|
|
|
if [ -z "$X86_64H_SUPPORTED" ]; then
|
2019-11-02 13:26:21 +01:00
|
|
|
if [ $(osxcross-cmp $SDK_VERSION ">=" 10.8) -eq 1 ]; then
|
2019-06-01 19:57:44 +02:00
|
|
|
X86_64H_SUPPORTED=1
|
|
|
|
else
|
|
|
|
X86_64H_SUPPORTED=0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -z "$I386_SUPPORTED" ]; then
|
2019-11-02 13:26:21 +01:00
|
|
|
if [ $(osxcross-cmp $SDK_VERSION "<=" 10.13) -eq 1 ]; then
|
2019-06-01 19:57:44 +02:00
|
|
|
I386_SUPPORTED=1
|
|
|
|
else
|
|
|
|
I386_SUPPORTED=0
|
|
|
|
fi
|
|
|
|
fi
|
2020-08-15 20:07:54 +02:00
|
|
|
if [ -z "$ARM_SUPPORTED" ]; then
|
|
|
|
if [ $(osxcross-cmp $SDK_VERSION ">=" 11.0) -eq 1 ]; then
|
|
|
|
ARM_SUPPORTED=1
|
|
|
|
else
|
|
|
|
ARM_SUPPORTED=0
|
|
|
|
fi
|
|
|
|
fi
|
2015-06-27 19:01:56 +02:00
|
|
|
fi
|
2014-04-22 19:34:08 +02:00
|
|
|
fi
|
|
|
|
set -e
|
|
|
|
|
2019-06-01 19:57:44 +02:00
|
|
|
if [ -z "$I386_SUPPORTED" ]; then
|
|
|
|
I386_SUPPORTED=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$X86_64H_SUPPORTED" ]; then
|
|
|
|
X86_64H_SUPPORTED=0
|
2016-10-29 19:26:05 +02:00
|
|
|
fi
|
2014-04-06 22:27:59 +02:00
|
|
|
|
2020-08-15 20:07:54 +02:00
|
|
|
if [ -z "$ARM_SUPPORTED" ]; then
|
|
|
|
ARM_SUPPORTED=0
|
|
|
|
fi
|
2019-06-01 19:57:44 +02:00
|
|
|
|
2014-04-06 22:27:59 +02:00
|
|
|
function create_wrapper_link
|
|
|
|
{
|
2014-09-28 20:46:38 +02:00
|
|
|
# arg 1:
|
|
|
|
# program name
|
2014-05-17 23:15:15 +02:00
|
|
|
# arg 2:
|
2014-09-28 20:46:38 +02:00
|
|
|
# 1: create a standalone link and links with the target triple prefix
|
|
|
|
# 2: create links with target triple prefix and shortcut links such
|
|
|
|
# as o32, o64, ...
|
|
|
|
#
|
|
|
|
# example:
|
|
|
|
# create_wrapper_link osxcross 1
|
|
|
|
# creates the following symlinks:
|
|
|
|
# -> osxcross
|
|
|
|
# -> i386-apple-darwinXX-osxcross
|
|
|
|
# -> x86_64-apple-darwinXX-osxcross
|
|
|
|
# -> x86_64h-apple-darwinXX-osxcross
|
2014-05-17 23:15:15 +02:00
|
|
|
|
|
|
|
if [ $# -ge 2 ] && [ $2 -eq 1 ]; then
|
2019-06-01 19:57:44 +02:00
|
|
|
verbose_cmd create_symlink "${TARGETTRIPLE}-wrapper" \
|
|
|
|
"${1}"
|
2014-05-17 23:15:15 +02:00
|
|
|
fi
|
|
|
|
|
2019-06-01 19:57:44 +02:00
|
|
|
if [ $I386_SUPPORTED -eq 1 ]; then
|
|
|
|
verbose_cmd create_symlink "${TARGETTRIPLE}-wrapper" \
|
2019-11-02 13:26:21 +01:00
|
|
|
"i386-apple-${TARGET}-${1}"
|
2019-06-01 19:57:44 +02:00
|
|
|
fi
|
2014-05-17 23:15:15 +02:00
|
|
|
|
2019-06-01 19:57:44 +02:00
|
|
|
verbose_cmd create_symlink "${TARGETTRIPLE}-wrapper" \
|
2019-11-02 13:26:21 +01:00
|
|
|
"x86_64-apple-${TARGET}-${1}"
|
2014-09-28 20:46:38 +02:00
|
|
|
|
2020-08-15 20:07:54 +02:00
|
|
|
if ([[ $1 != gcc* ]] && [[ $1 != g++* ]] && [[ $1 != *gstdc++ ]]); then
|
|
|
|
if [ $X86_64H_SUPPORTED -eq 1 ]; then
|
|
|
|
verbose_cmd create_symlink "${TARGETTRIPLE}-wrapper" \
|
|
|
|
"x86_64h-apple-${TARGET}-${1}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $ARM_SUPPORTED -eq 1 ]; then
|
|
|
|
verbose_cmd create_symlink "${TARGETTRIPLE}-wrapper" \
|
|
|
|
"arm64-apple-${TARGET}-${1}"
|
|
|
|
verbose_cmd create_symlink "${TARGETTRIPLE}-wrapper" \
|
|
|
|
"arm64e-apple-${TARGET}-${1}"
|
|
|
|
fi
|
2014-05-17 23:15:15 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -ge 2 ] && [ $2 -eq 2 ]; then
|
2019-06-01 19:57:44 +02:00
|
|
|
if [ $I386_SUPPORTED -eq 1 ]; then
|
|
|
|
verbose_cmd create_symlink "${TARGETTRIPLE}-wrapper" \
|
|
|
|
"o32-${1}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
verbose_cmd create_symlink "${TARGETTRIPLE}-wrapper" \
|
|
|
|
"o64-${1}"
|
2014-09-28 20:46:38 +02:00
|
|
|
|
2019-06-01 19:57:44 +02:00
|
|
|
if [ $X86_64H_SUPPORTED -eq 1 ] &&
|
2015-08-29 13:23:52 +02:00
|
|
|
([[ $1 != gcc* ]] && [[ $1 != g++* ]] && [[ $1 != *gstdc++ ]]); then
|
2019-06-01 19:57:44 +02:00
|
|
|
verbose_cmd create_symlink "${TARGETTRIPLE}-wrapper" \
|
|
|
|
"o64h-${1}"
|
2014-05-17 23:15:15 +02:00
|
|
|
fi
|
2020-08-15 20:07:54 +02:00
|
|
|
|
|
|
|
if [ $ARM_SUPPORTED -eq 1 ]; then
|
|
|
|
verbose_cmd create_symlink "${TARGETTRIPLE}-wrapper" \
|
|
|
|
"oa64-${1}"
|
|
|
|
verbose_cmd create_symlink "${TARGETTRIPLE}-wrapper" \
|
|
|
|
"oa64e-${1}"
|
|
|
|
fi
|
2014-05-17 23:15:15 +02:00
|
|
|
fi
|
2014-04-06 22:27:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[ -z "$TARGETCOMPILER" ] && TARGETCOMPILER=clang
|
|
|
|
|
2019-11-02 13:26:21 +01:00
|
|
|
TARGETTRIPLE=x86_64-apple-${TARGET}
|
2014-04-06 22:27:59 +02:00
|
|
|
|
|
|
|
FLAGS=""
|
|
|
|
|
|
|
|
if [ -n "$BWPLATFORM" ]; then
|
|
|
|
PLATFORM=$BWPLATFORM
|
|
|
|
|
|
|
|
if [ $PLATFORM = "Darwin" -a $(uname -s) != "Darwin" ]; then
|
2015-10-04 18:02:07 +02:00
|
|
|
CXX=$(xcrun -f clang++)
|
|
|
|
#CXX=$(xcrun -f g++)
|
2014-05-17 23:15:15 +02:00
|
|
|
FLAGS+="-fvisibility-inlines-hidden "
|
2014-04-06 22:27:59 +02:00
|
|
|
elif [ $PLATFORM = "FreeBSD" -a $(uname -s) != "FreeBSD" ]; then
|
2020-08-15 20:07:54 +02:00
|
|
|
CXX=amd64-pc-freebsd13.0-clang++
|
2014-05-17 23:15:15 +02:00
|
|
|
elif [ $PLATFORM = "NetBSD" -a $(uname -s) != "NetBSD" ]; then
|
|
|
|
CXX=amd64-pc-netbsd6.1.3-clang++
|
2014-04-06 22:27:59 +02:00
|
|
|
fi
|
2014-05-17 23:15:15 +02:00
|
|
|
|
|
|
|
[ -z "$BWCOMPILEONLY" ] && BWCOMPILEONLY=1
|
2014-04-06 22:27:59 +02:00
|
|
|
else
|
2016-11-10 10:04:39 +01:00
|
|
|
[ -z "$PORTABLE" ] && FLAGS="$CXXFLAGS "
|
2014-04-06 22:27:59 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$BWCXX" ]; then
|
|
|
|
[ "$CXX" != "$BWCXX" ] && echo "using $BWCXX" 1>&2
|
|
|
|
CXX=$BWCXX
|
|
|
|
fi
|
|
|
|
|
2014-05-17 23:15:15 +02:00
|
|
|
if [ "$PLATFORM" == "Linux" ]; then
|
|
|
|
FLAGS+="-isystem quirks/include "
|
2014-04-06 22:27:59 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
function compile_wrapper()
|
|
|
|
{
|
2019-10-23 10:56:08 +02:00
|
|
|
mkdir -p ${TARGET_DIR}/bin
|
2014-05-17 23:15:15 +02:00
|
|
|
export PLATFORM
|
|
|
|
export CXX
|
|
|
|
|
2014-09-27 10:07:15 +02:00
|
|
|
verbose_cmd $MAKE clean
|
2014-04-06 22:27:59 +02:00
|
|
|
|
2019-11-02 13:26:21 +01:00
|
|
|
ADDITIONAL_CXXFLAGS="$FLAGS" \
|
2014-09-27 10:07:15 +02:00
|
|
|
verbose_cmd $MAKE wrapper -j$JOBS
|
2014-04-06 22:27:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
compile_wrapper
|
|
|
|
|
2014-05-17 23:15:15 +02:00
|
|
|
if [ -n "$BWCOMPILEONLY" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
2014-04-06 22:27:59 +02:00
|
|
|
|
2019-06-01 19:57:44 +02:00
|
|
|
verbose_cmd mv wrapper "${TARGET_DIR}/bin/${TARGETTRIPLE}-wrapper"
|
2014-04-06 22:27:59 +02:00
|
|
|
|
2019-10-23 10:56:08 +02:00
|
|
|
pushd "${TARGET_DIR}/bin" &>/dev/null
|
2014-04-06 22:27:59 +02:00
|
|
|
|
2014-05-17 23:15:15 +02:00
|
|
|
if [ $TARGETCOMPILER = "clang" ]; then
|
|
|
|
create_wrapper_link clang 2
|
|
|
|
create_wrapper_link clang++ 2
|
|
|
|
create_wrapper_link clang++-libc++ 2
|
2015-08-22 23:15:27 +02:00
|
|
|
create_wrapper_link clang++-stdc++ 2
|
|
|
|
create_wrapper_link clang++-gstdc++ 2
|
2014-04-06 22:27:59 +02:00
|
|
|
elif [ $TARGETCOMPILER = "gcc" ]; then
|
2014-05-17 23:15:15 +02:00
|
|
|
create_wrapper_link gcc 2
|
|
|
|
create_wrapper_link g++ 2
|
|
|
|
create_wrapper_link g++-libc++ 2
|
2014-04-06 22:27:59 +02:00
|
|
|
fi
|
|
|
|
|
2014-05-17 23:15:15 +02:00
|
|
|
create_wrapper_link cc
|
|
|
|
create_wrapper_link c++
|
2014-04-06 22:27:59 +02:00
|
|
|
|
2014-05-17 23:15:15 +02:00
|
|
|
create_wrapper_link osxcross 1
|
|
|
|
create_wrapper_link osxcross-conf 1
|
|
|
|
create_wrapper_link osxcross-env 1
|
|
|
|
create_wrapper_link osxcross-cmp 1
|
2015-06-21 14:07:19 +02:00
|
|
|
create_wrapper_link osxcross-man 1
|
2014-09-28 20:46:38 +02:00
|
|
|
create_wrapper_link pkg-config
|
2014-04-06 22:27:59 +02:00
|
|
|
|
2014-04-14 21:59:03 +02:00
|
|
|
if [ "$PLATFORM" != "Darwin" ]; then
|
2014-05-17 23:15:15 +02:00
|
|
|
create_wrapper_link sw_vers 1
|
2019-11-02 13:26:21 +01:00
|
|
|
|
|
|
|
if which dsymutil &>/dev/null; then
|
|
|
|
# If dsymutil is in PATH then it's most likely a recent
|
|
|
|
# LLVM dsymutil version. In this case don't wrap it.
|
|
|
|
# Just create target symlinks.
|
|
|
|
|
2019-11-04 20:32:05 +01:00
|
|
|
verbose_cmd create_symlink $(which dsymutil) x86_64-apple-$TARGET-dsymutil
|
|
|
|
|
2019-11-02 13:26:21 +01:00
|
|
|
if [ $I386_SUPPORTED -eq 1 ]; then
|
|
|
|
verbose_cmd create_symlink $(which dsymutil) i386-apple-$TARGET-dsymutil
|
|
|
|
fi
|
|
|
|
if [ $X86_64H_SUPPORTED -eq 1 ]; then
|
|
|
|
verbose_cmd create_symlink $(which dsymutil) x86_64h-apple-$TARGET-dsymutil
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
create_wrapper_link dsymutil 1
|
|
|
|
fi
|
|
|
|
|
2015-06-21 11:46:01 +02:00
|
|
|
create_wrapper_link xcrun 1
|
2020-03-10 16:49:39 +01:00
|
|
|
create_wrapper_link xcodebuild 1
|
2014-04-14 21:59:03 +02:00
|
|
|
fi
|
2014-04-06 22:27:59 +02:00
|
|
|
|
|
|
|
popd &>/dev/null
|
|
|
|
popd &>/dev/null
|