diff --git a/README.md b/README.md index f06763d..bcb2ea3 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,10 @@ Then ensure you have the following installed on your Linux/FreeBSD box: `Clang 3.2+`, `llvm-devel`, `automake`, `autogen`, `libtool`, `libxml2-devel` (<=10.5 only), `uuid-devel`, `openssl-devel` and the `bash shell`. -Hint: On Ubuntu 12.04 LTS you can use [llvm.org/apt](http://llvm.org/apt) to get a newer version of clang. +Hint 1: You can run 'sudo tools/get_dependencies.sh' to get these automatically +Hint 2: On Ubuntu 12.04 LTS you can use [llvm.org/apt](http://llvm.org/apt) to get a newer version of clang. -Now edit the `SDK_VERSION` in `build.sh`, so it matches the version you have downloaded before. - -Then run `./build.sh` to build the cross toolchain (it will build in its own directory). +Then run `./build.sh` to build the cross toolchain (it will search 'tarballs' for an SDK and then build in its own directory). **Don't forget** to add the printed `` `/osxcross-env` `` to your `~/.profile` or `~/.bashrc`. Then either run `source ~/.profile` or restart your shell session. diff --git a/build.sh b/build.sh index ac79a64..683fd0f 100755 --- a/build.sh +++ b/build.sh @@ -4,8 +4,58 @@ pushd "${0%/*}" &>/dev/null source tools/tools.sh -# SDK version to use -SDK_VERSION=10.8 +# find sdk version to use +guess_sdk_version() +{ + tmp1= + tmp2= + tmp3= + file= + sdk= + sdkcount=`ls tarballs/ | grep MacOSX | wc -l` + sdks=`ls tarballs/ | grep MacOSX` + if [ $sdkcount -eq 0 ]; then + echo no SDK found in 'tarballs/'. please see README.md + exit + elif [ $sdkcount -gt 1 ]; then + for sdk in $sdks; do echo $sdk; done + echo 'more than one MacOSX SDK tarball found. please set' + echo 'SDK_VERSION environment variable for the one you want' + echo '(for example: run SDK_VERSION=10.x build.sh )' + exit 1 + else + sdk=$sdks # only 1 + tmp2=`echo $sdk | sed s/[^0-9.]//g` + tmp3=`echo $tmp2 | sed s/\\\.*$//g` + guess_sdk_version_result=$tmp3 + echo 'found SDK version' $SDK_VERSION 'at tarballs/'$sdk + fi + export guess_sdk_version_result +} + +# make sure there is actually a file with the given SDK_VERSION +verify_sdk_version() +{ + sdkv=$1 + for file in tarballs/*; do + if [ `echo $file | grep OSX.*$sdkv` ]; then + echo "verified at tarballs/"$file + sdk=$file + fi + done + if [ ! $sdk ] ; then + echo cant find SDK for OSX $sdkv in tarballs. exiting + exit + fi +} + +if [ $SDK_VERSION ]; then + echo 'SDK VERSION set in environment variable: ' $SDK_VERSION +else + guess_sdk_version + SDK_VERSION=$guess_sdk_version_result +fi +verify_sdk_version $SDK_VERSION # Minimum targeted OS X version # Must be <= SDK_VERSION diff --git a/tools/trap_exit.sh b/tools/trap_exit.sh index 63ba829..b56fa26 100644 --- a/tools/trap_exit.sh +++ b/tools/trap_exit.sh @@ -1,5 +1,15 @@ #!/usr/bin/env bash +function check_for_bug_1242300() +{ + if [ -e /etc/issue ]; then + if [ "`grep -i ubuntu.13.10 /etc/issue`" ]; then + echo "Ubuntu 13.10 detected. if there was a 'configure:' error" + echo "please see https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1242300" + fi + fi +} + function _exit() { EC=$? @@ -12,6 +22,7 @@ function _exit() remove_locks echo "if it is happening the first time, then just re-run the script" echo "" + check_for_bug_1242300 fi }