2013-11-12 00:04:21 +04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2013-12-15 22:06:50 +04:00
|
|
|
pushd "${0%/*}" &>/dev/null
|
|
|
|
|
2014-03-25 02:11:25 +04:00
|
|
|
unset LIBRARY_PATH
|
2013-11-12 00:04:21 +04:00
|
|
|
|
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"
|
|
|
|
|
|
|
|
require wget
|
|
|
|
|
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()
|
|
|
|
{
|
2014-04-06 17:58:15 +04:00
|
|
|
rm -rf $OSXCROSS_BUILD_DIR/have_gcc*
|
2013-12-17 00:53:21 +04:00
|
|
|
}
|
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
|
|
|
|
|
2014-03-25 02:11:25 +04:00
|
|
|
extract "$OSXCROSS_TARBALL_DIR/gcc-$GCC_VERSION.tar.bz2" 1
|
|
|
|
echo ""
|
2013-11-12 00:04:21 +04:00
|
|
|
|
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
|
|
|
|
2014-03-25 02:11:25 +04:00
|
|
|
if [[ "`uname -s`" == *BSD ]]; then
|
2014-04-06 17:58:15 +04:00
|
|
|
export CPATH="/usr/local/include:/usr/pkg/include:$CPATH"
|
|
|
|
export LDFLAGS="-L/usr/local/lib -L/usr/pkg/lib $LDFLAGS"
|
|
|
|
export LD_LIBRARY_PATH="/usr/local/lib:/usr/pkg/lib:$LD_LIBRARY_PATH"
|
2013-12-15 22:06:50 +04:00
|
|
|
fi
|
|
|
|
|
2013-11-12 00:04:21 +04:00
|
|
|
../configure \
|
2014-04-06 17:58:15 +04:00
|
|
|
--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 \
|
|
|
|
--enable-checking=release \
|
|
|
|
--prefix=$OSXCROSS_TARGET_DIR
|
2013-11-12 00:04:21 +04:00
|
|
|
|
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
|
|
|
|
2014-04-07 00:27:59 +04:00
|
|
|
pushd $OSXCROSS_TARGET_DIR/bin &>/dev/null
|
2013-12-15 22:06:50 +04:00
|
|
|
|
|
|
|
if [ ! -f i386-apple-$OSXCROSS_TARGET-base-gcc ]; then
|
2014-04-06 17:58:15 +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++
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2014-04-06 17:58:15 +04:00
|
|
|
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++
|
2013-11-12 00:04:21 +04:00
|
|
|
fi
|
|
|
|
|
2014-04-07 00:27:59 +04:00
|
|
|
echo "compiling wrapper ..."
|
2013-12-15 22:06:50 +04:00
|
|
|
|
2014-04-07 00:27:59 +04:00
|
|
|
export TARGET=$OSXCROSS_TARGET
|
|
|
|
export OSX_VERSION_MIN=$OSXCROSS_OSX_VERSION_MIN
|
|
|
|
export LINKER_VERSION=$OSXCROSS_LINKER_VERSION
|
2013-11-12 00:04:21 +04:00
|
|
|
|
2014-04-07 00:27:59 +04:00
|
|
|
TARGETCOMPILER=gcc \
|
|
|
|
$BASE_DIR/wrapper/build.sh 1>/dev/null
|
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 ""
|