2013-11-12 00:04:21 +04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2013-12-15 22:06:50 +04:00
|
|
|
pushd "${0%/*}" &>/dev/null
|
|
|
|
|
2013-11-12 00:04:21 +04:00
|
|
|
export LIBRARY_PATH=""
|
|
|
|
|
2013-12-17 00:53:21 +04:00
|
|
|
DESC=gcc
|
|
|
|
source tools/tools.sh
|
2013-11-12 21:14:54 +04:00
|
|
|
|
2013-12-15 22:06:50 +04:00
|
|
|
`tools/osxcross_conf.sh`
|
|
|
|
|
2013-11-12 00:04:21 +04:00
|
|
|
# GCC version to build
|
2013-12-15 22:06:50 +04:00
|
|
|
# (<4.7 will not work properly with libc++)
|
2013-11-12 00:04:21 +04:00
|
|
|
GCC_VERSION=4.8.2
|
|
|
|
|
|
|
|
# GCC mirror
|
|
|
|
GCC_MIRROR="ftp://ftp.gwdg.de/pub/misc/gcc/releases"
|
|
|
|
|
2013-11-14 23:28:27 +04:00
|
|
|
set +e
|
2013-11-12 00:04:21 +04:00
|
|
|
require wget
|
2013-11-14 23:28:27 +04:00
|
|
|
set -e
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2013-12-17 00:53:21 +04:00
|
|
|
pushd $OSXCROSS_BUILD_DIR &>/dev/null
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2013-12-17 00:53:21 +04:00
|
|
|
function remove_locks()
|
|
|
|
{
|
|
|
|
rm -rf $OSXCROSS_BUILD_DIR/have_gcc*
|
|
|
|
}
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2013-12-17 00:53:21 +04:00
|
|
|
source $BASE_DIR/tools/trap_exit.sh
|
2013-12-15 22:06:50 +04:00
|
|
|
|
2013-11-16 21:36:44 +04:00
|
|
|
if [ ! -f "have_gcc_${GCC_VERSION}_${OSXCROSS_TARGET}" ]; then
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2013-12-17 00:53:21 +04:00
|
|
|
pushd $OSXCROSS_TARBALL_DIR &>/dev/null
|
2013-11-12 00:04:21 +04:00
|
|
|
wget -c "$GCC_MIRROR/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.bz2"
|
2013-12-17 00:53:21 +04:00
|
|
|
popd &>/dev/null
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2013-12-15 22:06:50 +04:00
|
|
|
echo "cleaning up ..."
|
2013-11-12 00:04:21 +04:00
|
|
|
rm -rf gcc* 2>/dev/null
|
|
|
|
|
|
|
|
echo "extracting gcc ..."
|
|
|
|
tar xf "$OSXCROSS_TARBALL_DIR/gcc-$GCC_VERSION.tar.bz2"
|
|
|
|
|
2013-12-17 00:53:21 +04:00
|
|
|
pushd gcc*$GCC_VERSION* &>/dev/null
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2013-11-16 21:36:44 +04:00
|
|
|
rm -f $OSXCROSS_TARGET_DIR/bin/*-gcc*
|
|
|
|
rm -f $OSXCROSS_TARGET_DIR/bin/*-g++*
|
|
|
|
|
2013-11-12 00:04:21 +04:00
|
|
|
mkdir -p build
|
2013-12-17 00:53:21 +04:00
|
|
|
pushd build &>/dev/null
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2013-12-15 22:06:50 +04:00
|
|
|
if [ "`uname -s`" == "FreeBSD" ]; then
|
|
|
|
export CPATH="/usr/local/include"
|
2014-02-15 18:33:29 +04:00
|
|
|
export LDFLAGS="-L/usr/local/lib $LDFLAGS"
|
2013-12-15 22:06:50 +04:00
|
|
|
MAKE=gmake
|
|
|
|
IS_FREEBSD=1
|
|
|
|
else
|
|
|
|
MAKE=make
|
|
|
|
IS_FREEBSD=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
require $MAKE
|
|
|
|
|
2013-11-12 00:04:21 +04:00
|
|
|
../configure \
|
|
|
|
--target=x86_64-apple-$OSXCROSS_TARGET \
|
|
|
|
--with-ld=$OSXCROSS_TARGET_DIR/bin/x86_64-apple-$OSXCROSS_TARGET-ld \
|
|
|
|
--with-as=$OSXCROSS_TARGET_DIR/bin/x86_64-apple-$OSXCROSS_TARGET-as \
|
|
|
|
--with-sysroot=$OSXCROSS_SDK \
|
|
|
|
--disable-nls \
|
|
|
|
--enable-languages=c,c++,objc,obj-c++ \
|
|
|
|
--without-headers \
|
|
|
|
--enable-multilib \
|
|
|
|
--enable-lto \
|
2014-01-10 22:36:15 +04:00
|
|
|
--enable-checking=release \
|
2013-11-12 00:04:21 +04:00
|
|
|
--prefix=$OSXCROSS_TARGET_DIR
|
|
|
|
|
2013-12-15 22:06:50 +04:00
|
|
|
$MAKE -j$JOBS
|
|
|
|
$MAKE install -j$JOBS
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2013-12-17 00:53:21 +04:00
|
|
|
popd &>/dev/null # build
|
|
|
|
popd &>/dev/null # gcc
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2013-11-16 21:36:44 +04:00
|
|
|
touch "have_gcc_${GCC_VERSION}_${OSXCROSS_TARGET}"
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2013-12-17 00:53:21 +04:00
|
|
|
fi # have gcc
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2013-12-17 00:53:21 +04:00
|
|
|
popd &>/dev/null # build dir
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2013-12-15 22:06:50 +04:00
|
|
|
WRAPPER=$OSXCROSS_TARGET_DIR/bin/x86_64-apple-${OSXCROSS_TARGET}-ogcc
|
|
|
|
cp ogcc/ogcc $WRAPPER
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2013-12-15 22:06:50 +04:00
|
|
|
WRAPPER_SCRIPT=`basename $WRAPPER`
|
|
|
|
WRAPPER_DIR=`dirname $WRAPPER`
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2013-12-17 00:53:21 +04:00
|
|
|
pushd $WRAPPER_DIR &>/dev/null
|
2013-12-15 22:06:50 +04:00
|
|
|
|
|
|
|
if [ ! -f i386-apple-$OSXCROSS_TARGET-base-gcc ]; then
|
2013-11-12 00:04:21 +04:00
|
|
|
mv x86_64-apple-$OSXCROSS_TARGET-gcc x86_64-apple-$OSXCROSS_TARGET-base-gcc
|
|
|
|
mv x86_64-apple-$OSXCROSS_TARGET-g++ x86_64-apple-$OSXCROSS_TARGET-base-g++
|
|
|
|
|
|
|
|
ln -sf x86_64-apple-$OSXCROSS_TARGET-base-gcc i386-apple-$OSXCROSS_TARGET-base-gcc
|
|
|
|
ln -sf x86_64-apple-$OSXCROSS_TARGET-base-g++ i386-apple-$OSXCROSS_TARGET-base-g++
|
|
|
|
fi
|
|
|
|
|
2013-12-15 22:06:50 +04:00
|
|
|
ln -sf $WRAPPER_SCRIPT o32-gcc
|
|
|
|
ln -sf $WRAPPER_SCRIPT o32-g++
|
|
|
|
ln -sf $WRAPPER_SCRIPT o32-g++-libc++
|
|
|
|
|
|
|
|
ln -sf $WRAPPER_SCRIPT o64-gcc
|
|
|
|
ln -sf $WRAPPER_SCRIPT o64-g++
|
|
|
|
ln -sf $WRAPPER_SCRIPT o64-g++-libc++
|
|
|
|
|
|
|
|
ln -sf $WRAPPER_SCRIPT i386-apple-$OSXCROSS_TARGET-gcc
|
|
|
|
ln -sf $WRAPPER_SCRIPT i386-apple-$OSXCROSS_TARGET-g++
|
|
|
|
ln -sf $WRAPPER_SCRIPT i386-apple-$OSXCROSS_TARGET-g++-libc++
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2013-12-15 22:06:50 +04:00
|
|
|
ln -sf $WRAPPER_SCRIPT x86_64-apple-$OSXCROSS_TARGET-gcc
|
|
|
|
ln -sf $WRAPPER_SCRIPT x86_64-apple-$OSXCROSS_TARGET-g++
|
|
|
|
ln -sf $WRAPPER_SCRIPT x86_64-apple-$OSXCROSS_TARGET-g++-libc++
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2013-12-17 00:53:21 +04:00
|
|
|
popd &>/dev/null # wrapper dir
|
2013-11-12 00:04:21 +04:00
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
test_compiler o32-gcc $BASE_DIR/oclang/test.c
|
|
|
|
test_compiler o64-gcc $BASE_DIR/oclang/test.c
|
|
|
|
|
|
|
|
test_compiler o32-g++ $BASE_DIR/oclang/test.cpp
|
|
|
|
test_compiler o64-g++ $BASE_DIR/oclang/test.cpp
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo "Done! Now you can use o32-gcc/o32-g++ and o64-gcc/o64-g++ as compiler"
|
|
|
|
echo ""
|
|
|
|
echo "Example usage:"
|
|
|
|
echo ""
|
|
|
|
echo "Example 1: CC=o32-gcc ./configure --host=i386-apple-$OSXCROSS_TARGET"
|
|
|
|
echo "Example 2: CC=i386-apple-$OSXCROSS_TARGET-gcc ./configure --host=i386-apple-$OSXCROSS_TARGET"
|
|
|
|
echo "Example 3: o64-gcc -Wall test.c -o test"
|
|
|
|
echo "Example 4: x86_64-apple-$OSXCROSS_TARGET-strip -x test"
|
|
|
|
echo ""
|