2013-12-16 21:53:21 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2015-05-30 21:01:48 +02:00
|
|
|
export LC_ALL="C"
|
|
|
|
|
2014-11-11 22:54:03 +01:00
|
|
|
BASE_DIR=$PWD
|
2013-12-16 21:53:21 +01:00
|
|
|
|
2015-05-30 21:01:48 +02:00
|
|
|
TARBALL_DIR=$BASE_DIR/tarballs
|
|
|
|
BUILD_DIR=$BASE_DIR/build
|
|
|
|
TARGET_DIR=$BASE_DIR/target
|
|
|
|
PATCH_DIR=$BASE_DIR/patches
|
|
|
|
SDK_DIR=$TARGET_DIR/SDK
|
2014-07-17 22:43:29 +02:00
|
|
|
|
2015-07-19 22:28:10 +02:00
|
|
|
PLATFORM=$(uname -s)
|
|
|
|
ARCH=$(uname -m)
|
2015-08-22 23:15:27 +02:00
|
|
|
SCRIPT=$(basename $0)
|
2015-07-19 22:28:10 +02:00
|
|
|
|
2014-07-17 22:43:29 +02:00
|
|
|
if [ -z "$USESYSTEMCOMPILER" ]; then
|
2015-07-17 23:25:59 +02:00
|
|
|
# Default to gcc on some OSs rather than clang due to either
|
|
|
|
# libstdc++ issues (clang uses an outdated version on those)
|
|
|
|
# or some other incompatibilities
|
|
|
|
|
|
|
|
case "$PLATFORM" in
|
|
|
|
CYGWIN* | DragonFly )
|
|
|
|
cc=gcc
|
|
|
|
cxx=g++
|
|
|
|
;;
|
|
|
|
OpenBSD )
|
|
|
|
cc=egcc
|
|
|
|
cxx=eg++
|
|
|
|
;;
|
|
|
|
Darwin )
|
|
|
|
cc=clang
|
|
|
|
cxx=clang++
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
case "$ARCH" in
|
|
|
|
arm* )
|
|
|
|
cc=gcc
|
|
|
|
cxx=g++
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
cc=clang
|
|
|
|
cxx=clang++
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
[ -z "$CC" ] && export CC=$cc
|
|
|
|
[ -z "$CXX" ] && export CXX=$cxx
|
2014-07-17 22:43:29 +02:00
|
|
|
elif [ -n "$CC" -o -n "$CXX" ]; then
|
|
|
|
echo "CC/CXX should not be set, continuing in 5 seconds..." 1>&2
|
|
|
|
sleep 5
|
|
|
|
fi
|
2013-12-16 21:53:21 +01:00
|
|
|
|
2015-07-17 23:25:59 +02:00
|
|
|
|
2013-12-16 21:53:21 +01:00
|
|
|
# enable debug messages
|
2015-08-22 23:15:27 +02:00
|
|
|
[ -n "$OCDEBUG" ] && set -x
|
2013-12-16 21:53:21 +01:00
|
|
|
|
2014-11-25 21:19:13 +01:00
|
|
|
if [[ $SCRIPT != *wrapper/build.sh ]]; then
|
2014-04-06 22:27:59 +02:00
|
|
|
# how many concurrent jobs should be used for compiling?
|
2015-07-20 21:13:36 +02:00
|
|
|
if [ -z "$JOBS" ]; then
|
|
|
|
JOBS=$(tools/get_cpu_count.sh || echo 1)
|
|
|
|
fi
|
2013-12-16 21:53:21 +01:00
|
|
|
|
2014-11-25 21:19:13 +01:00
|
|
|
if [ $SCRIPT != "build.sh" -a $SCRIPT != "build_clang.sh" -a \
|
2015-05-30 21:01:48 +02:00
|
|
|
$SCRIPT != "mount_xcode_image.sh" -a \
|
|
|
|
$SCRIPT != "gen_sdk_package_darling_dmg.sh" -a \
|
|
|
|
$SCRIPT != "gen_sdk_package_p7zip.sh" ]; then
|
2015-07-19 22:28:10 +02:00
|
|
|
eval $(tools/osxcross_conf.sh)
|
2014-04-06 22:27:59 +02:00
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
2014-11-25 21:19:13 +01:00
|
|
|
echo -n "you need to complete ./build.sh first, before you can start "
|
|
|
|
echo "building $DESC"
|
2014-04-06 22:27:59 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2014-04-06 15:58:15 +02:00
|
|
|
fi
|
2013-12-16 21:53:21 +01:00
|
|
|
fi
|
|
|
|
|
2014-03-24 23:11:25 +01:00
|
|
|
function require()
|
2013-12-16 21:53:21 +01:00
|
|
|
{
|
2014-04-06 15:58:15 +02:00
|
|
|
set +e
|
|
|
|
which $1 &>/dev/null
|
|
|
|
while [ $? -ne 0 ]
|
|
|
|
do
|
2015-06-21 19:35:09 +02:00
|
|
|
if [ -z "$UNATTENDED" ]; then
|
|
|
|
echo ""
|
|
|
|
read -p "Please install '$1' then press enter"
|
|
|
|
else
|
|
|
|
echo "Required dependency '$1' is not installed" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2013-12-16 21:53:21 +01:00
|
|
|
which $1 &>/dev/null
|
2014-04-06 15:58:15 +02:00
|
|
|
done
|
|
|
|
set -e
|
2013-12-16 21:53:21 +01:00
|
|
|
}
|
|
|
|
|
2015-07-19 22:28:10 +02:00
|
|
|
if [[ $PLATFORM == *BSD ]] || [ $PLATFORM == "DragonFly" ]; then
|
2014-04-06 15:58:15 +02:00
|
|
|
MAKE=gmake
|
2015-07-19 22:28:10 +02:00
|
|
|
SED=gsed
|
|
|
|
else
|
2015-07-20 21:13:36 +02:00
|
|
|
MAKE=make
|
2015-07-19 22:28:10 +02:00
|
|
|
SED=sed
|
|
|
|
fi
|
|
|
|
|
|
|
|
require $SED
|
2014-03-24 23:11:25 +01:00
|
|
|
require $MAKE
|
|
|
|
|
|
|
|
function extract()
|
|
|
|
{
|
2014-04-06 15:58:15 +02:00
|
|
|
test $# -ge 2 -a $# -lt 4 && test $2 -eq 2 && echo ""
|
2015-07-19 22:28:10 +02:00
|
|
|
echo "extracting $(basename $1) ..."
|
2014-04-06 15:58:15 +02:00
|
|
|
|
|
|
|
local tarflags
|
|
|
|
|
|
|
|
tarflags="xf"
|
|
|
|
test -n "$OCDEBUG" && tarflags+="v"
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
*.pkg)
|
2015-07-19 22:28:10 +02:00
|
|
|
require cpio
|
2014-04-06 15:58:15 +02:00
|
|
|
which xar &>/dev/null || exit 1
|
|
|
|
xar -xf $1
|
|
|
|
cat Payload | gunzip -dc | cpio -i 2>/dev/null && rm Payload
|
|
|
|
;;
|
|
|
|
*.tar.xz)
|
|
|
|
xz -dc $1 | tar $tarflags -
|
|
|
|
;;
|
|
|
|
*.tar.gz)
|
|
|
|
gunzip -dc $1 | tar $tarflags -
|
|
|
|
;;
|
|
|
|
*.tar.bz2)
|
|
|
|
bzip2 -dc $1 | tar $tarflags -
|
|
|
|
;;
|
|
|
|
*)
|
2015-08-22 23:15:27 +02:00
|
|
|
echo "Unhandled archive type" 2>&1
|
2014-04-06 15:58:15 +02:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ $# -eq 2 -o $# -eq 4 ]; then
|
|
|
|
echo ""
|
|
|
|
fi
|
2014-03-24 23:11:25 +01:00
|
|
|
}
|
|
|
|
|
2015-07-19 22:28:10 +02:00
|
|
|
if [[ $PLATFORM == CYGWIN* ]]; then
|
|
|
|
|
|
|
|
# Work around Cygwin brokenness.
|
2015-08-22 23:15:27 +02:00
|
|
|
function ln()
|
|
|
|
{
|
2015-07-19 22:28:10 +02:00
|
|
|
[[ $1 == -* ]] && rm -f $3
|
|
|
|
$(which ln) $@
|
|
|
|
}
|
|
|
|
export -f ln
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2014-04-06 22:27:59 +02:00
|
|
|
function verbose_cmd()
|
|
|
|
{
|
|
|
|
echo "$@"
|
|
|
|
eval "$@"
|
|
|
|
}
|
|
|
|
|
2014-05-10 16:17:16 +02:00
|
|
|
function check_cxx_stdlib()
|
|
|
|
{
|
|
|
|
set +e
|
|
|
|
|
2014-05-10 17:05:58 +02:00
|
|
|
$CXX $CXXFLAGS -std=c++0x $BASE_DIR/tools/stdlib-test.cpp -S -o- \
|
2014-05-10 16:17:16 +02:00
|
|
|
2>$BUILD_DIR/stdlib-test.log 1>/dev/null
|
|
|
|
echo "$?"
|
|
|
|
|
|
|
|
set -e
|
|
|
|
}
|
|
|
|
|
2014-03-24 23:11:25 +01:00
|
|
|
function test_compiler()
|
2013-12-16 21:53:21 +01:00
|
|
|
{
|
2014-04-06 15:58:15 +02:00
|
|
|
echo -ne "testing $1 ... "
|
|
|
|
$1 $2 -O2 -Wall -o test
|
|
|
|
rm test
|
|
|
|
echo "works"
|
2013-12-16 21:53:21 +01:00
|
|
|
}
|
|
|
|
|
2014-03-28 21:04:32 +01:00
|
|
|
function test_compiler_cxx11()
|
|
|
|
{
|
2014-04-06 15:58:15 +02:00
|
|
|
set +e
|
|
|
|
echo -ne "testing $1 -stdlib=libc++ -std=c++11 ... "
|
|
|
|
$1 $2 -O2 -stdlib=libc++ -std=c++11 -Wall -o test &>/dev/null
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
rm test
|
|
|
|
echo "works"
|
|
|
|
else
|
|
|
|
echo "failed (ignored)"
|
|
|
|
fi
|
|
|
|
set -e
|
2014-03-28 21:04:32 +01:00
|
|
|
}
|
|
|
|
|
2013-12-16 21:53:21 +01:00
|
|
|
# exit on error
|
|
|
|
set -e
|