osxcross/oclang/find_intrinsic_headers.sh
2014-03-26 20:32:31 +01:00

33 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# help clang to find its own intrinsic headers
# this issue appears to be fixed in 3.4+
pushd "${0%/*}" &>/dev/null
set -e
SDK_DIR="$1"
test -n "$SDK_DIR" || { echo "no SDK directory given" && exit 1; }
test -e "$SDK_DIR" || { echo "$SDK_DIR does not exist" && exit 1; }
CLANG_VERSION=`echo "int main(){printf(\"%d.%d\",__clang_major__,__clang_minor__);return 0;}" | clang -xc -ansi -otest - 2>/dev/null && ./test && rm test`
CLANG_DIR=`dirname \`which clang\``
CLANG_INTRIN_DIR="$CLANG_DIR/../include/clang/$CLANG_VERSION/include"
test ! -e "$CLANG_INTRIN_DIR" && CLANG_INTRIN_DIR="$CLANG_DIR/../lib/clang/$CLANG_VERSION/include"
test -e "$CLANG_INTRIN_DIR" || { echo "can not find clang intrinsics directory" && exit 1; }
test -f "$CLANG_INTRIN_DIR/xmmintrin.h" || { echo "xmmintrin.h does not exist in $CLANG_INTRIN_DIR" && exit 1; }
echo "found clang intrinsic headers: $CLANG_INTRIN_DIR"
ln -sf $CLANG_INTRIN_DIR/float.h $SDK_DIR/usr/include
ln -sf $CLANG_INTRIN_DIR/*intrin*.h $SDK_DIR/usr/include
ln -sf $CLANG_INTRIN_DIR/mm*.h $SDK_DIR/usr/include
ln -sf $CLANG_INTRIN_DIR/*va*.h $SDK_DIR/usr/include
ln -sf $CLANG_INTRIN_DIR/*cpu*.h $SDK_DIR/usr/include
ln -sf $CLANG_INTRIN_DIR/*math*.h $SDK_DIR/usr/include
ln -sf $CLANG_INTRIN_DIR/*iso*.h $SDK_DIR/usr/include