mirror of
https://github.com/Relintai/osxcross.git
synced 2025-02-03 22:45:56 +01:00
move duplicate code into a single file
add debug option (OCDEBUG=1 ./<script>) update README
This commit is contained in:
parent
42e3fc51cc
commit
2c38fb673e
12
README.md
12
README.md
@ -15,12 +15,14 @@ If you want, then you can build an up-to-date vanilla GCC as well.
|
||||
|
||||
### WHAT IS NOT WORKING (YET)? ###
|
||||
|
||||
* Debug info is weak, because of the [missing](https://github.com/tpoechtrager/osxcross/blob/master/patches/gcc-dsymutil.patch)
|
||||
[`dsymutil`](http://www.manpagez.com/man/1/dsymutil) (shows only function names, no line numbers)
|
||||
* GCC itself [doesn't build with GCC](https://github.com/tpoechtrager/osxcross/commit/12f5dcdde4bc1000180d25ffda229f0a13cf723d),
|
||||
but builds fine when clang is used to build GCC
|
||||
* Debug info is weak because of the [missing](https://github.com/tpoechtrager/osxcross/blob/master/patches/gcc-dsymutil.patch)
|
||||
[`dsymutil`](http://www.manpagez.com/man/1/dsymutil) (debugger shows only function names).
|
||||
The source code of dsymutil is not publicly available, so it can't be ported to other systems.
|
||||
But you probably don't want debug symbols anyway if you build on a non OS X system.
|
||||
|
||||
* GCC itself [doesn't build with GCC](https://github.com/tpoechtrager/osxcross/commit/12f5dcdde4bc1000180d25ffda229f0a13cf723d),
|
||||
but builds fine when clang is used to build GCC.
|
||||
|
||||
Everything else besides that should work.
|
||||
|
||||
### WHAT CAN I BUILD WITH IT? ###
|
||||
|
||||
|
78
build.sh
78
build.sh
@ -2,12 +2,7 @@
|
||||
|
||||
pushd "${0%/*}" &>/dev/null
|
||||
|
||||
export LC_ALL="C"
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
|
||||
# How many concurrent jobs should be used for compiling?
|
||||
JOBS=`tools/get_cpu_count.sh` || exit 1
|
||||
source tools/tools.sh
|
||||
|
||||
# SDK version to use
|
||||
SDK_VERSION=10.8
|
||||
@ -24,29 +19,12 @@ LINKER_VERSION=134.9
|
||||
# Don't change this
|
||||
OSXCROSS_VERSION=0.5
|
||||
|
||||
function require
|
||||
{
|
||||
which $1 &>/dev/null
|
||||
while [ $? -ne 0 ]
|
||||
do
|
||||
echo ""
|
||||
read -p "Install $1 then press enter"
|
||||
which $1 &>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
JOBSSTR="jobs"
|
||||
if [ $JOBS -eq 1 ]; then
|
||||
JOBSSTR="job"
|
||||
fi
|
||||
|
||||
if [ -z "$OSX_VERSION_MIN" ]; then
|
||||
OSX_VERSION_MIN="default"
|
||||
fi
|
||||
@ -58,11 +36,9 @@ case $SDK_VERSION in
|
||||
10.7*) TARGET=darwin11 ;;
|
||||
10.8*) TARGET=darwin12 ;;
|
||||
10.9*) TARGET=darwin13 ;;
|
||||
*) echo "Invalid SDK Version"; exit 1 ;;
|
||||
*) echo "Invalid SDK Version" && exit 1 ;;
|
||||
esac
|
||||
|
||||
set -e
|
||||
|
||||
echo ""
|
||||
echo "Building OSXCross toolchain, Version: $OSXCROSS_VERSION"
|
||||
echo ""
|
||||
@ -98,9 +74,14 @@ set -e
|
||||
|
||||
CLANG_TARGET_OPTION=`./oclang/check_target_option.sh`
|
||||
|
||||
pushd $BUILD_DIR
|
||||
pushd $BUILD_DIR &>/dev/null
|
||||
|
||||
trap 'test $? -eq 0 || rm -f $BUILD_DIR/have_cctools*' EXIT
|
||||
function remove_locks()
|
||||
{
|
||||
rm -rf $BUILD_DIR/have_cctools*
|
||||
}
|
||||
|
||||
source $BASE_DIR/tools/trap_exit.sh
|
||||
|
||||
if [ "`ls $TARBALL_DIR/cctools*.tar.* | wc -l | tr -d ' '`" != "1" ]; then
|
||||
echo ""
|
||||
@ -121,7 +102,7 @@ rm -rf xar*
|
||||
tar xJfv $TARBALL_DIR/cctools*.tar.xz
|
||||
tar xzfv $TARBALL_DIR/xar*.tar.gz
|
||||
|
||||
pushd cctools*/cctools
|
||||
pushd cctools*/cctools &>/dev/null
|
||||
patch -p0 < $PATCH_DIR/cctools-ld64-1.patch
|
||||
patch -p0 < $PATCH_DIR/cctools-ld64-2.patch
|
||||
patch -p0 < $PATCH_DIR/cctools-ld64-3.patch
|
||||
@ -133,37 +114,37 @@ echo ""
|
||||
./configure --prefix=$TARGET_DIR --target=x86_64-apple-$TARGET
|
||||
make -j$JOBS
|
||||
make install -j$JOBS
|
||||
popd
|
||||
popd &>/dev/null
|
||||
|
||||
pushd $TARGET_DIR/bin
|
||||
pushd $TARGET_DIR/bin &>/dev/null
|
||||
CCTOOLS=`find . -name "x86_64-apple-darwin*"`
|
||||
CCTOOLS=($CCTOOLS)
|
||||
for CCTOOL in ${CCTOOLS[@]}; do
|
||||
CCTOOL_I386=`echo "$CCTOOL" | sed 's/x86_64/i386/g'`
|
||||
ln -sf $CCTOOL $CCTOOL_I386
|
||||
done
|
||||
popd
|
||||
popd &>/dev/null
|
||||
|
||||
fi # have cctools
|
||||
|
||||
if [ ! -f "have_xar_$TARGET" ]; then
|
||||
if [ -n "$FORCE_XAR_BUILD" ] || [ `echo "$SDK_VERSION<=10.5" | bc -l` -eq 1 ]; then
|
||||
|
||||
pushd xar*
|
||||
pushd xar* &>/dev/null
|
||||
set +e
|
||||
sed -i 's/-Wall/-w/g' configure
|
||||
set -e
|
||||
./configure --prefix=$TARGET_DIR
|
||||
make -j$JOBS
|
||||
make install -j$JOBS
|
||||
popd
|
||||
popd &>/dev/null
|
||||
|
||||
fi # SDK <= 10.5
|
||||
fi # have xar
|
||||
|
||||
if [ ! -f "have_cctools_$TARGET" ]; then
|
||||
|
||||
function check
|
||||
function check_cctools
|
||||
{
|
||||
[ -f "/$TARGET_DIR/bin/$1-apple-$TARGET-lipo" ] || exit 1
|
||||
[ -f "/$TARGET_DIR/bin/$1-apple-$TARGET-ld" ] || exit 1
|
||||
@ -173,8 +154,8 @@ function check
|
||||
[ -f "/$TARGET_DIR/bin/$1-apple-$TARGET-strip" ] || exit 1
|
||||
}
|
||||
|
||||
check i386
|
||||
check x86_64
|
||||
check_cctools i386
|
||||
check_cctools x86_64
|
||||
|
||||
touch "have_cctools_${CCTOOLS_REVHASH}_$TARGET"
|
||||
|
||||
@ -218,14 +199,14 @@ esac
|
||||
rm -rf $SDK_DIR/MacOSX$SDK_VERSION* 2>/dev/null
|
||||
mv -f SDKs/*$SDK_VERSION* $SDK_DIR
|
||||
|
||||
pushd $SDK_DIR/MacOSX$SDK_VERSION.sdk
|
||||
pushd $SDK_DIR/MacOSX$SDK_VERSION.sdk &>/dev/null
|
||||
set +e
|
||||
ln -s $SDK_DIR/MacOSX$SDK_VERSION.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/std*.h usr/include 2>/dev/null
|
||||
$BASE_DIR/oclang/find_intrinsic_headers.sh $SDK_DIR/MacOSX$SDK_VERSION.sdk
|
||||
set -e
|
||||
popd
|
||||
popd &>/dev/null
|
||||
|
||||
popd
|
||||
popd &>/dev/null
|
||||
|
||||
WRAPPER=$TARGET_DIR/bin/x86_64-apple-$TARGET-oclang
|
||||
cp -f oclang/oclang $WRAPPER
|
||||
@ -233,7 +214,7 @@ cp -f oclang/oclang $WRAPPER
|
||||
WRAPPER_SCRIPT=`basename $WRAPPER`
|
||||
WRAPPER_DIR=`dirname $WRAPPER`
|
||||
|
||||
pushd $WRAPPER_DIR
|
||||
pushd $WRAPPER_DIR &>/dev/null
|
||||
|
||||
ln -sf $WRAPPER_SCRIPT o32-clang
|
||||
ln -sf $WRAPPER_SCRIPT o32-clang++
|
||||
@ -251,7 +232,7 @@ ln -sf $WRAPPER_SCRIPT x86_64-apple-$TARGET-clang
|
||||
ln -sf $WRAPPER_SCRIPT x86_64-apple-$TARGET-clang++
|
||||
ln -sf $WRAPPER_SCRIPT x86_64-apple-$TARGET-clang++-libc++
|
||||
|
||||
popd
|
||||
popd &>/dev/null
|
||||
|
||||
OSXCROSS_CONF="$TARGET_DIR/bin/osxcross-conf"
|
||||
OSXCROSS_ENV="$TARGET_DIR/bin/osxcross-env"
|
||||
@ -296,15 +277,6 @@ echo "echo \"export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$BDIR/../lib${LIB_PATH}"\
|
||||
|
||||
chmod +x $OSXCROSS_CONF $OSXCROSS_ENV
|
||||
|
||||
|
||||
function test_compiler
|
||||
{
|
||||
echo -ne "testing $1 ... "
|
||||
$1 $2 -O2 -Wall -o test
|
||||
rm test
|
||||
echo "works"
|
||||
}
|
||||
|
||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:`cat $BUILD_DIR/cctools*/cctools/tmp/ldpath`" # libLTO.so
|
||||
|
||||
echo ""
|
||||
@ -316,9 +288,9 @@ test_compiler o32-clang++ $BASE_DIR/oclang/test.cpp
|
||||
test_compiler o64-clang++ $BASE_DIR/oclang/test.cpp
|
||||
|
||||
echo ""
|
||||
echo "Now add the following line"
|
||||
echo "Now add"
|
||||
echo ""
|
||||
echo "\`$OSXCROSS_ENV\`"
|
||||
echo -e "\e[32m\`$OSXCROSS_ENV\`\e[0m"
|
||||
echo ""
|
||||
echo "to your ~/.bashrc or ~/.profile (including the '\`')"
|
||||
echo ""
|
||||
|
63
build_gcc.sh
63
build_gcc.sh
@ -2,24 +2,13 @@
|
||||
|
||||
pushd "${0%/*}" &>/dev/null
|
||||
|
||||
export LC_ALL="C"
|
||||
export LIBRARY_PATH=""
|
||||
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
DESC=gcc
|
||||
source tools/tools.sh
|
||||
|
||||
`tools/osxcross_conf.sh`
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "you need to complete ./build.sh first, before you can start building gcc"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
# How many concurrent jobs should be used for compiling?
|
||||
JOBS=`tools/get_cpu_count.sh`
|
||||
|
||||
# GCC version to build
|
||||
# (<4.7 will not work properly with libc++)
|
||||
GCC_VERSION=4.8.2
|
||||
@ -27,32 +16,24 @@ GCC_VERSION=4.8.2
|
||||
# GCC mirror
|
||||
GCC_MIRROR="ftp://ftp.gwdg.de/pub/misc/gcc/releases"
|
||||
|
||||
function require
|
||||
{
|
||||
which $1 &>/dev/null
|
||||
while [ $? -ne 0 ]
|
||||
do
|
||||
echo ""
|
||||
read -p "Install $1 then press enter"
|
||||
which $1 &>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
set +e
|
||||
require wget
|
||||
set -e
|
||||
|
||||
BASE_DIR=`pwd`
|
||||
pushd $OSXCROSS_BUILD_DIR &>/dev/null
|
||||
|
||||
pushd $OSXCROSS_BUILD_DIR
|
||||
function remove_locks()
|
||||
{
|
||||
rm -rf $OSXCROSS_BUILD_DIR/have_gcc*
|
||||
}
|
||||
|
||||
trap 'test $? -eq 0 || rm -f $OSXCROSS_BUILD_DIR/have_gcc*' EXIT
|
||||
source $BASE_DIR/tools/trap_exit.sh
|
||||
|
||||
if [ ! -f "have_gcc_${GCC_VERSION}_${OSXCROSS_TARGET}" ]; then
|
||||
|
||||
pushd $OSXCROSS_TARBALL_DIR
|
||||
pushd $OSXCROSS_TARBALL_DIR &>/dev/null
|
||||
wget -c "$GCC_MIRROR/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.bz2"
|
||||
popd
|
||||
popd &>/dev/null
|
||||
|
||||
echo "cleaning up ..."
|
||||
rm -rf gcc* 2>/dev/null
|
||||
@ -60,7 +41,7 @@ rm -rf gcc* 2>/dev/null
|
||||
echo "extracting gcc ..."
|
||||
tar xf "$OSXCROSS_TARBALL_DIR/gcc-$GCC_VERSION.tar.bz2"
|
||||
|
||||
pushd gcc*$GCC_VERSION*
|
||||
pushd gcc*$GCC_VERSION* &>/dev/null
|
||||
|
||||
rm -f $OSXCROSS_TARGET_DIR/bin/*-gcc*
|
||||
rm -f $OSXCROSS_TARGET_DIR/bin/*-g++*
|
||||
@ -68,7 +49,7 @@ rm -f $OSXCROSS_TARGET_DIR/bin/*-g++*
|
||||
patch -p0 < $OSXCROSS_PATCH_DIR/gcc-dsymutil.patch
|
||||
|
||||
mkdir -p build
|
||||
pushd build
|
||||
pushd build &>/dev/null
|
||||
|
||||
if [ "`uname -s`" == "FreeBSD" ]; then
|
||||
export CPATH="/usr/local/include"
|
||||
@ -101,14 +82,14 @@ fi
|
||||
$MAKE -j$JOBS
|
||||
$MAKE install -j$JOBS
|
||||
|
||||
popd #build
|
||||
popd #gcc
|
||||
popd &>/dev/null # build
|
||||
popd &>/dev/null # gcc
|
||||
|
||||
touch "have_gcc_${GCC_VERSION}_${OSXCROSS_TARGET}"
|
||||
|
||||
fi #have gcc
|
||||
fi # have gcc
|
||||
|
||||
popd #build dir
|
||||
popd &>/dev/null # build dir
|
||||
|
||||
WRAPPER=$OSXCROSS_TARGET_DIR/bin/x86_64-apple-${OSXCROSS_TARGET}-ogcc
|
||||
cp ogcc/ogcc $WRAPPER
|
||||
@ -116,7 +97,7 @@ cp ogcc/ogcc $WRAPPER
|
||||
WRAPPER_SCRIPT=`basename $WRAPPER`
|
||||
WRAPPER_DIR=`dirname $WRAPPER`
|
||||
|
||||
pushd $WRAPPER_DIR
|
||||
pushd $WRAPPER_DIR &>/dev/null
|
||||
|
||||
if [ ! -f i386-apple-$OSXCROSS_TARGET-base-gcc ]; then
|
||||
mv x86_64-apple-$OSXCROSS_TARGET-gcc x86_64-apple-$OSXCROSS_TARGET-base-gcc
|
||||
@ -142,15 +123,7 @@ 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++
|
||||
|
||||
popd #wrapper dir
|
||||
|
||||
function test_compiler
|
||||
{
|
||||
echo -ne "testing $1 ... "
|
||||
$1 $2 -O2 -Wall -o test
|
||||
rm test
|
||||
echo "works"
|
||||
}
|
||||
popd &>/dev/null # wrapper dir
|
||||
|
||||
echo ""
|
||||
|
||||
|
@ -2,19 +2,11 @@
|
||||
|
||||
pushd "${0%/*}" &>/dev/null
|
||||
|
||||
export LC_ALL="C"
|
||||
|
||||
`tools/osxcross_conf.sh`
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "you need to complete ./build.sh first, before you can start building libc++"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -e
|
||||
DESC=libc++
|
||||
source tools/tools.sh
|
||||
|
||||
if [ `echo "${OSXCROSS_SDK_VERSION}<10.7" | bc -l` -eq 1 ]; then
|
||||
echo "you must use the SDK from 10.7 or newer to get libc++ compiled"
|
||||
echo "you must use the SDK from 10.7 or newer to get $DESC compiled"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -24,47 +16,39 @@ JOBS=`tools/get_cpu_count.sh`
|
||||
# libc++ version to build
|
||||
LIBCXX_VERSION=3.3
|
||||
|
||||
function require
|
||||
{
|
||||
which $1 &>/dev/null
|
||||
while [ $? -ne 0 ]
|
||||
do
|
||||
echo ""
|
||||
read -p "Install $1 then press enter"
|
||||
which $1 &>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
BASE_DIR=`pwd`
|
||||
|
||||
set +e
|
||||
require wget
|
||||
require cmake
|
||||
set -e
|
||||
|
||||
pushd $OSXCROSS_BUILD_DIR
|
||||
pushd $OSXCROSS_BUILD_DIR &>/dev/null
|
||||
|
||||
trap 'test $? -eq 0 || rm -f $OSXCROSS_BUILD_DIR/have_libcxx*' EXIT
|
||||
function remove_locks()
|
||||
{
|
||||
rm -f $OSXCROSS_BUILD_DIR/have_libcxx*
|
||||
}
|
||||
|
||||
source $BASE_DIR/tools/trap_exit.sh
|
||||
|
||||
if [ ! -f "have_libcxx_${LIBCXX_VERSION}_${OSXCROSS_TARGET}" ]; then
|
||||
|
||||
pushd $OSXCROSS_TARBALL_DIR
|
||||
pushd $OSXCROSS_TARBALL_DIR &>/dev/null
|
||||
wget -c "http://llvm.org/releases/3.3/libcxx-${LIBCXX_VERSION}.src.tar.gz"
|
||||
popd
|
||||
popd &>/dev/null
|
||||
|
||||
tar xzfv "$OSXCROSS_TARBALL_DIR/libcxx-${LIBCXX_VERSION}.src.tar.gz"
|
||||
pushd libcxx-${LIBCXX_VERSION}*
|
||||
pushd libcxx-${LIBCXX_VERSION}* &>/dev/null
|
||||
rm -rf build
|
||||
mkdir build
|
||||
|
||||
pushd build
|
||||
pushd build &>/dev/null
|
||||
|
||||
# remove conflicting versions
|
||||
rm -rf $OSXCROSS_SDK/usr/include/c++/v1
|
||||
rm -rf $OSXCROSS_SDK/usr/lib/libc++.dylib
|
||||
rm -rf $OSXCROSS_SDK/usr/lib/libc++.*.dylib
|
||||
|
||||
function cmakeerror()
|
||||
function cmake_error()
|
||||
{
|
||||
echo -e "\e[1m"
|
||||
echo "It looks like CMake failed."
|
||||
@ -91,19 +75,19 @@ cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX=$OSXCROSS_SDK/../libcxx_$OSXCROSS_SDK_VERSION \
|
||||
-DCMAKE_AR=$OSXCROSS_CCTOOLS_PATH/x86_64-apple-$OSXCROSS_TARGET-ar \
|
||||
-DCMAKE_RANLIB=$OSXCROSS_CCTOOLS_PATH/x86_64-apple-$OSXCROSS_TARGET-ranlib \
|
||||
-DCMAKE_CXX_FLAGS="-arch i386 -arch x86_64" || cmakeerror
|
||||
-DCMAKE_CXX_FLAGS="-arch i386 -arch x86_64" || cmake_error
|
||||
|
||||
make -j$JOBS
|
||||
make install -j$JOBS
|
||||
|
||||
popd #build
|
||||
popd #libcxx
|
||||
popd &>/dev/null # build
|
||||
popd &>/dev/null # libcxx
|
||||
|
||||
touch "have_libcxx_${LIBCXX_VERSION}_${OSXCROSS_TARGET}"
|
||||
|
||||
fi #have libcxx
|
||||
fi # have libcxx
|
||||
|
||||
popd #build dir
|
||||
popd &>/dev/null # build dir
|
||||
|
||||
function test_compiler_clang
|
||||
{
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
set -e
|
||||
|
||||
which cc &>/dev/null || { echo "1" && exit 0; }
|
||||
|
||||
prog="cpucount"
|
||||
|
||||
pushd "${0%/*}" >/dev/null 2>&1
|
||||
@ -11,6 +13,6 @@ case "$(uname -s)" in
|
||||
prog="${prog}.exe" ;;
|
||||
esac
|
||||
|
||||
test ! -f $prog && cc cpucount.c -o cpucount
|
||||
test ! -f $prog && cc cpucount.c -o cpucount &>/dev/null
|
||||
|
||||
eval "./${prog}"
|
||||
|
@ -2,9 +2,8 @@
|
||||
|
||||
pushd "${0%/*}" &>/dev/null
|
||||
|
||||
OSXCROSS_CONF=`which osxcross-conf 2>/dev/null`
|
||||
test $? -eq 0 || OSXCROSS_CONF="../target/bin/osxcross-conf"
|
||||
test -f $OSXCROSS_CONF || exit 1
|
||||
OSXCROSS_CONF="../target/bin/osxcross-conf"
|
||||
test -f $OSXCROSS_CONF || { OSXCROSS_CONF=`which osxcross-conf 2>/dev/null` || exit 1; }
|
||||
|
||||
$OSXCROSS_CONF || exit 1
|
||||
`dirname $OSXCROSS_CONF`/osxcross-env
|
||||
|
44
tools/tools.sh
Normal file
44
tools/tools.sh
Normal file
@ -0,0 +1,44 @@
|
||||
#!/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
|
||||
|
||||
# how many concurrent jobs should be used for compiling?
|
||||
JOBS=`tools/get_cpu_count.sh`
|
||||
|
||||
if [ "`basename $0`" != "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
|
||||
fi
|
||||
|
||||
function require
|
||||
{
|
||||
which $1 &>/dev/null
|
||||
while [ $? -ne 0 ]
|
||||
do
|
||||
echo ""
|
||||
read -p "Please install $1 then press enter"
|
||||
which $1 &>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
function test_compiler
|
||||
{
|
||||
echo -ne "testing $1 ... "
|
||||
$1 $2 -O2 -Wall -o test
|
||||
rm test
|
||||
echo "works"
|
||||
}
|
||||
|
||||
# exit on error
|
||||
set -e
|
19
tools/trap_exit.sh
Normal file
19
tools/trap_exit.sh
Normal file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function _exit()
|
||||
{
|
||||
EC=$?
|
||||
if [ $EC -ne 0 ]; then
|
||||
SCRIPT=`basename $0`
|
||||
echo ""
|
||||
echo "exiting with abnormal exit code ($EC)"
|
||||
test -n "$OCDEBUG" || echo "run 'OCDEBUG=1 ./$SCRIPT' to enable debug messages"
|
||||
echo "removing stale locks..."
|
||||
remove_locks
|
||||
echo "if it is happening the first time, then just re-run the script"
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
trap _exit EXIT
|
||||
|
Loading…
Reference in New Issue
Block a user