2013-12-16 21:53:21 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
BASE_DIR=`pwd`
|
|
|
|
|
|
|
|
export LC_ALL="C"
|
|
|
|
export CC=clang
|
|
|
|
export CXX=clang++
|
|
|
|
|
|
|
|
# enable debug messages
|
|
|
|
test -n "$OCDEBUG" && set -x
|
|
|
|
|
2014-04-06 22:27:59 +02:00
|
|
|
PSCRIPT="`basename $0`"
|
2013-12-16 21:53:21 +01:00
|
|
|
|
2014-04-06 22:27:59 +02:00
|
|
|
if [[ $PSCRIPT != *wrapper/build.sh ]]; then
|
|
|
|
# how many concurrent jobs should be used for compiling?
|
|
|
|
JOBS=`tools/get_cpu_count.sh`
|
2013-12-16 21:53:21 +01:00
|
|
|
|
2014-04-06 22:27:59 +02:00
|
|
|
if [ $PSCRIPT != "build.sh" ]; then
|
|
|
|
`tools/osxcross_conf.sh`
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "you need to complete ./build.sh first, before you can start building $DESC"
|
|
|
|
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
|
|
|
|
echo ""
|
|
|
|
read -p "Please install $1 then press enter"
|
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
|
|
|
}
|
|
|
|
|
2014-03-24 23:11:25 +01:00
|
|
|
if [[ "`uname -s`" == *BSD ]]; then
|
2014-04-06 15:58:15 +02:00
|
|
|
MAKE=gmake
|
2014-03-24 23:11:25 +01:00
|
|
|
else
|
2014-04-06 15:58:15 +02:00
|
|
|
MAKE=make
|
2014-03-24 23:11:25 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
require $MAKE
|
|
|
|
|
|
|
|
function extract()
|
|
|
|
{
|
2014-04-06 15:58:15 +02:00
|
|
|
test $# -ge 2 -a $# -lt 4 && test $2 -eq 2 && echo ""
|
|
|
|
echo "extracting `basename $1` ..."
|
|
|
|
|
|
|
|
local tarflags
|
|
|
|
|
|
|
|
tarflags="xf"
|
|
|
|
test -n "$OCDEBUG" && tarflags+="v"
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
*.pkg)
|
|
|
|
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 -
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unhandled archive type"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ $# -eq 2 -o $# -eq 4 ]; then
|
|
|
|
echo ""
|
|
|
|
fi
|
2014-03-24 23:11:25 +01:00
|
|
|
}
|
|
|
|
|
2014-04-06 22:27:59 +02:00
|
|
|
function verbose_cmd()
|
|
|
|
{
|
|
|
|
echo "$@"
|
|
|
|
eval "$@"
|
|
|
|
}
|
|
|
|
|
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
|