osxcross/tools/tools.sh
Thomas Pöchtrager 5afdf2b471 Wrapper changes:
* Support for generating fat object files with gcc and '-foc-use-gcc-libstdc++'
  has been removed.

  This feature was not 100% correctly implemented; using multiple source files
  did not work, i.e.: 'o32-g++ -m32 -m64 a.cpp b.cpp' would have failed;
  And I refuse to implement that, instead I am removing all source file handling
  from the wrapper with this commit for simplicity.

  This feature should be implemented in the gcc driver instead.

  This does NOT affect clang's fat object file support, which is implemented in
  clang's darwin driver.

* '-oc-use-gcc-lib' has been renamed to '-foc-use-gcc-libstdc++'.

* Added support for '-stdc++' and '-gstdc++' compiler "shortcuts"

  o32-clang++ --> uses libstdc++ for <= 10.8 and libc++ for >= 10.9

  o32-clang++-libc++ --> uses the SDK's libc++
  o32-clang++-stdc++ --> uses the SDK's libstdc++
  o32-clang++-gstdc++ --> uses gcc's (build_gcc.sh) libstdc++

* Entirely rewrote the command line parser; the previous one wasn't very
  readable.

* Minor Readme Updates

* Added unit tests

* Removed OSXCROSS_C_STANDARD / OSXCROSS_CXX_STANDARD support

  I am no longer parsing -std=, so this feature has to be dropped.
  Setting the language standard via an env variable isn't a good idea anyway.

* Removed unneeded stuff

Other Changes:

* Version bump to 0.11
2015-08-22 23:15:27 +02:00

199 lines
3.5 KiB
Bash
Executable File

#!/usr/bin/env bash
export LC_ALL="C"
BASE_DIR=$PWD
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
PLATFORM=$(uname -s)
ARCH=$(uname -m)
SCRIPT=$(basename $0)
if [ -z "$USESYSTEMCOMPILER" ]; then
# 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
elif [ -n "$CC" -o -n "$CXX" ]; then
echo "CC/CXX should not be set, continuing in 5 seconds..." 1>&2
sleep 5
fi
# enable debug messages
[ -n "$OCDEBUG" ] && set -x
if [[ $SCRIPT != *wrapper/build.sh ]]; then
# how many concurrent jobs should be used for compiling?
if [ -z "$JOBS" ]; then
JOBS=$(tools/get_cpu_count.sh || echo 1)
fi
if [ $SCRIPT != "build.sh" -a $SCRIPT != "build_clang.sh" -a \
$SCRIPT != "mount_xcode_image.sh" -a \
$SCRIPT != "gen_sdk_package_darling_dmg.sh" -a \
$SCRIPT != "gen_sdk_package_p7zip.sh" ]; then
eval $(tools/osxcross_conf.sh)
if [ $? -ne 0 ]; then
echo -n "you need to complete ./build.sh first, before you can start "
echo "building $DESC"
exit 1
fi
fi
fi
function require()
{
set +e
which $1 &>/dev/null
while [ $? -ne 0 ]
do
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
which $1 &>/dev/null
done
set -e
}
if [[ $PLATFORM == *BSD ]] || [ $PLATFORM == "DragonFly" ]; then
MAKE=gmake
SED=gsed
else
MAKE=make
SED=sed
fi
require $SED
require $MAKE
function extract()
{
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)
require cpio
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" 2>&1
exit 1
;;
esac
if [ $# -eq 2 -o $# -eq 4 ]; then
echo ""
fi
}
if [[ $PLATFORM == CYGWIN* ]]; then
# Work around Cygwin brokenness.
function ln()
{
[[ $1 == -* ]] && rm -f $3
$(which ln) $@
}
export -f ln
fi
function verbose_cmd()
{
echo "$@"
eval "$@"
}
function check_cxx_stdlib()
{
set +e
$CXX $CXXFLAGS -std=c++0x $BASE_DIR/tools/stdlib-test.cpp -S -o- \
2>$BUILD_DIR/stdlib-test.log 1>/dev/null
echo "$?"
set -e
}
function test_compiler()
{
echo -ne "testing $1 ... "
$1 $2 -O2 -Wall -o test
rm test
echo "works"
}
function test_compiler_cxx11()
{
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
}
# exit on error
set -e