Howard Hinnant | f81cdff | 2012-01-24 23:42:30 +0000 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | # |
| 3 | # Set the $TRIPLE environment variable to your system's triple before |
| 4 | # running this script. If you set $CXX, that will be used to compile |
| 5 | # the library. Otherwise we'll use clang++. |
| 6 | |
| 7 | set -e |
| 8 | |
| 9 | if [ `basename $(pwd)` != "lib" ] |
| 10 | then |
| 11 | echo "current directory must be lib" |
| 12 | exit 1 |
| 13 | fi |
| 14 | |
| 15 | if [ -z "$CXX" ] |
| 16 | then |
| 17 | CXX=clang++ |
| 18 | fi |
| 19 | |
| 20 | if [ -z "$CC" ] |
| 21 | then |
| 22 | CC=clang |
| 23 | fi |
| 24 | |
| 25 | if [ -z $RC_ProjectSourceVersion ] |
| 26 | then |
| 27 | RC_ProjectSourceVersion=1 |
| 28 | fi |
| 29 | |
Howard Hinnant | 2b891bf | 2012-01-30 16:03:23 +0000 | [diff] [blame] | 30 | EXTRA_FLAGS="-std=c++0x -stdlib=libc++ -fstrict-aliasing -Wstrict-aliasing=2" |
Howard Hinnant | f81cdff | 2012-01-24 23:42:30 +0000 | [diff] [blame] | 31 | |
| 32 | case $TRIPLE in |
| 33 | *-apple-*) |
| 34 | if [ -z $RC_XBS ] |
| 35 | then |
| 36 | RC_CFLAGS="-arch i386 -arch x86_64" |
| 37 | fi |
| 38 | SOEXT=dylib |
| 39 | if [ -n "$SDKROOT" ] |
| 40 | then |
| 41 | EXTRA_FLAGS+="-isysroot ${SDKROOT}" |
| 42 | CXX=`xcrun -sdk "${SDKROOT}" -find clang++` |
| 43 | CC=`xcrun -sdk "${SDKROOT}" -find clang` |
| 44 | fi |
| 45 | LDSHARED_FLAGS="-o libc++abi.dylib \ |
| 46 | -dynamiclib -nodefaultlibs \ |
| 47 | -current_version ${RC_ProjectSourceVersion} \ |
| 48 | -compatibility_version 1 \ |
| 49 | -install_name /usr/lib/libc++abi.dylib \ |
| 50 | -lSystem" |
| 51 | ;; |
| 52 | *-*-mingw*) |
| 53 | # FIXME: removing libgcc and libsupc++ dependencies means porting libcxxrt and LLVM/compiler-rt |
| 54 | SOEXT=dll |
| 55 | LDSHARED_FLAGS="-o libc++abi.dll \ |
| 56 | -shared -nodefaultlibs -Wl,--export-all-symbols -Wl,--allow-multiple-definition -Wl,--out-implib,libc++abi.dll.a \ |
| 57 | -lsupc++ -lpthread -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcr100 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt" |
| 58 | ;; |
| 59 | *) |
| 60 | RC_CFLAGS="-fPIC" |
| 61 | SOEXT=so |
| 62 | LDSHARED_FLAGS="-o libc++abi.so.1.0 \ |
| 63 | -shared -nodefaultlibs -Wl,-soname,libc++abi.so.1 \ |
| 64 | -lpthread -lrt -lc -lstdc++" |
| 65 | ;; |
| 66 | esac |
| 67 | |
| 68 | if [ -z $RC_XBS ] |
| 69 | then |
| 70 | rm -f libc++abi.1.$SOEXT* |
| 71 | fi |
| 72 | |
| 73 | set -x |
| 74 | |
| 75 | for FILE in ../src/*.cpp; do |
Howard Hinnant | 6a16979 | 2012-02-03 18:36:36 +0000 | [diff] [blame^] | 76 | $CXX -c -g -O3 $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE |
Howard Hinnant | f81cdff | 2012-01-24 23:42:30 +0000 | [diff] [blame] | 77 | done |
| 78 | case $TRIPLE in |
| 79 | *-*-mingw*) |
| 80 | for FILE in ../src/support/win32/*.cpp; do |
| 81 | $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE |
| 82 | done |
| 83 | ;; |
| 84 | esac |
| 85 | $CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS |
| 86 | |
| 87 | if [ -z $RC_XBS ] |
| 88 | then |
| 89 | rm *.o |
| 90 | fi |