diff --git a/README.md b/README.md index 0d35507..746da20 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Basically everything you can build on OS X with clang/gcc should build with this ### PACKET MANAGERS ### OSXCross comes with a minimalistic MacPorts Packet Manager. -Please see [README.MACPORTS](https://github.com/tpoechtrager/osxcross/blob/master/README.MACPORTS.md) for more. +Please see [README.MACPORTS](README.MACPORTS.md) for more. ### INSTALLATION: ### diff --git a/build.sh b/build.sh index 370558d..9c6c93b 100755 --- a/build.sh +++ b/build.sh @@ -26,8 +26,8 @@ function guess_sdk_version() exit 1 else sdk=$(find -L tarballs/ -type f | grep MacOSX) - tmp2=$(echo ${sdk/bz2/} | sed s/[^0-9.]//g) - tmp3=$(echo $tmp2 | sed s/\\\.*$//g) + tmp2=$(echo ${sdk/bz2/} | $SED s/[^0-9.]//g) + tmp3=$(echo $tmp2 | $SED s/\\\.*$//g) guess_sdk_version_result=$tmp3 echo 'found SDK version' $guess_sdk_version_result 'at tarballs/'$(basename $sdk) fi @@ -117,7 +117,6 @@ require $CXX require clang require patch -require sed require gunzip pushd $BUILD_DIR &>/dev/null @@ -188,12 +187,12 @@ CCTOOLS=$(find . -name "x86_64-apple-darwin*") CCTOOLS=($CCTOOLS) if [ $X86_64H_SUPPORTED -eq 1 ]; then for CCTOOL in ${CCTOOLS[@]}; do - CCTOOL_X86_64H=$(echo "$CCTOOL" | sed 's/x86_64/x86_64h/g') + CCTOOL_X86_64H=$(echo "$CCTOOL" | $SED 's/x86_64/x86_64h/g') ln -sf $CCTOOL $CCTOOL_X86_64H done fi for CCTOOL in ${CCTOOLS[@]}; do - CCTOOL_I386=$(echo "$CCTOOL" | sed 's/x86_64/i386/g') + CCTOOL_I386=$(echo "$CCTOOL" | $SED 's/x86_64/i386/g') ln -sf $CCTOOL $CCTOOL_I386 done popd &>/dev/null diff --git a/build_binutils.sh b/build_binutils.sh index 5232172..ee7a7d1 100755 --- a/build_binutils.sh +++ b/build_binutils.sh @@ -6,7 +6,7 @@ DESC=binutils USESYSTEMCOMPILER=1 source tools/tools.sh -`tools/osxcross_conf.sh` +eval $(tools/osxcross_conf.sh) # binutils version to build BINUTILS_VERSION=2.25 diff --git a/build_compiler_rt.sh b/build_compiler_rt.sh index f380ccc..65267ee 100755 --- a/build_compiler_rt.sh +++ b/build_compiler_rt.sh @@ -10,7 +10,6 @@ if [ $PLATFORM == "Darwin" ]; then fi require git -require $MAKE set +e @@ -31,35 +30,24 @@ set -e CLANG_VERSION=$(echo "__clang_major__ __clang_minor__ __clang_patchlevel__" | \ clang -xc -E - | tail -n1 | tr ' ' '.') -if [[ $PLATFORM == CYGWIN* ]] && [[ $(which clang) == "/usr/bin/clang" ]]; then - CLANG_LIB_DIR="/usr/lib/clang/$(uname -m)-pc-cygwin" -else - set +e - which llvm-config &>/dev/null && { CLANG_LIB_DIR=$(llvm-config --libdir); } - set -e - - if [ -z "$CLANG_LIB_DIR" ]; then - require $READLINK - CLANG_LIB_DIR="$(dirname $($READLINK -f $(which clang)))/../lib" - fi - - CLANG_LIB_DIR+="/clang" -fi - -if [ ! -d "$CLANG_LIB_DIR" ]; then - echo "$CLANG_LIB_DIR does not exist!" 1>&2 - echo "Installing llvm-dev may help" 1>&2 - exit 1 -fi - # Drop patch level for <= 3.3. if [ $(osxcross-cmp $CLANG_VERSION "<=" 3.3) -eq 1 ]; then CLANG_VERSION=$(echo $CLANG_VERSION | tr '.' ' ' | awk '{print $1, $2}' | tr ' ' '.') fi -CLANG_INCLUDE_DIR="${CLANG_LIB_DIR}/${CLANG_VERSION}/include" -CLANG_DARWIN_LIB_DIR="${CLANG_LIB_DIR}/${CLANG_VERSION}/lib/darwin" +CLANG_LIB_DIR=$(clang -print-search-dirs | grep "libraries: =" | \ + tr '=' ' ' | tr ':' ' ' | awk '{print $2}') + +VERSION=$(echo "${CLANG_LIB_DIR}" | tr '/' '\n' | tail -n1) + +if [ $VERSION != $CLANG_VERSION ]; then + echo "sanity check failed: $VERSION != ${CLANG_VERSION}" 1>&2 + exit 1 +fi + +CLANG_INCLUDE_DIR="${CLANG_LIB_DIR}/include" +CLANG_DARWIN_LIB_DIR="${CLANG_LIB_DIR}/lib/darwin" case $CLANG_VERSION in 3.2*) BRANCH=release_32 ;; @@ -95,7 +83,7 @@ $SED -i "s/Configs += asan_iossim_dynamic//g" make/platform/clang_darwin.mk # Unbreak the -Werror build. if [ -f lib/asan/asan_mac.h ]; then - sed -i "s/ASAN__MAC_H/ASAN_MAC_H/g" lib/asan/asan_mac.h + $SED -i "s/ASAN__MAC_H/ASAN_MAC_H/g" lib/asan/asan_mac.h fi if [ $(osxcross-cmp $CLANG_VERSION ">=" 3.5) -eq 1 ]; then @@ -111,12 +99,12 @@ then exit 1 fi -EXTRA_MAKE_FLAGS="LIPO=\"xcrun lipo\"" +EXTRA_MAKE_FLAGS="LIPO=\"$(xcrun -f lipo)\"" if [ $(osxcross-cmp $CLANG_VERSION "<=" 3.3) -eq 1 ]; then - EXTRA_MAKE_FLAGS+=" AR=\"xcrun ar\"" - EXTRA_MAKE_FLAGS+=" RANLIB=\"xcrun ranlib\"" - EXTRA_MAKE_FLAGS+=" CC=\"xcrun clang\"" + EXTRA_MAKE_FLAGS+=" AR=\"$(xcrun -f ar)\"" + EXTRA_MAKE_FLAGS+=" RANLIB=\"$(xcrun -f ranlib)\"" + EXTRA_MAKE_FLAGS+=" CC=\"$(xcrun -f clang)\"" fi if [ -n "$OCDEBUG" ]; then @@ -135,8 +123,8 @@ echo "" echo "Please run the following commands by hand to install compiler-rt:" echo "" -echo "mkdir -p ${CLANG_LIB_DIR}/${CLANG_VERSION}/include" -echo "mkdir -p ${CLANG_LIB_DIR}/${CLANG_VERSION}/lib/darwin" +echo "mkdir -p ${CLANG_INCLUDE_DIR}" +echo "mkdir -p ${CLANG_DARWIN_LIB_DIR}" echo "cp -r $PWD/include/sanitizer ${CLANG_INCLUDE_DIR}" pushd "clang_darwin" &>/dev/null diff --git a/build_gcc.sh b/build_gcc.sh index 73bcbfb..053143c 100755 --- a/build_gcc.sh +++ b/build_gcc.sh @@ -8,7 +8,7 @@ DESC=gcc USESYSTEMCOMPILER=1 source tools/tools.sh -`tools/osxcross_conf.sh` +eval $(tools/osxcross_conf.sh) # GCC version to build # (<4.7 will not work properly with libc++) diff --git a/tools/get_cpu_count.sh b/tools/get_cpu_count.sh index e406d78..adb579a 100755 --- a/tools/get_cpu_count.sh +++ b/tools/get_cpu_count.sh @@ -15,4 +15,4 @@ esac [ ! -f $prog ] && cc cpucount.c -o cpucount &>/dev/null -eval "./${prog}" +./$prog diff --git a/tools/tools.sh b/tools/tools.sh index a506e72..b0c85c1 100755 --- a/tools/tools.sh +++ b/tools/tools.sh @@ -59,7 +59,9 @@ test -n "$OCDEBUG" && set -x if [[ $SCRIPT != *wrapper/build.sh ]]; then # how many concurrent jobs should be used for compiling? - JOBS=${JOBS:=$(tools/get_cpu_count.sh)} + 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 \ @@ -95,22 +97,12 @@ function require() if [[ $PLATFORM == *BSD ]] || [ $PLATFORM == "DragonFly" ]; then MAKE=gmake -else - MAKE=make -fi - -if [[ $PLATFORM == OpenBSD ]]; then SED=gsed else + MAKE=make SED=sed fi -if [[ $PLATFORM == *BSD ]] || [ $PLATFORM == "Darwin" ]; then - READLINK=greadlink -else - READLINK=readlink -fi - require $SED require $MAKE