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 | 3e5c7d0 | 2012-03-08 18:45:24 +0000 | [diff] [blame] | 30 | EXTRA_FLAGS="-std=c++0x -stdlib=libc++ -fstrict-aliasing -Wstrict-aliasing=2 \ |
Howard Hinnant | dfa81ca | 2012-03-08 20:23:24 +0000 | [diff] [blame^] | 31 | -Wsign-conversion -Wshadow -Wconversion -Wunused-variable \ |
| 32 | -Wnewline-eof" |
Howard Hinnant | f81cdff | 2012-01-24 23:42:30 +0000 | [diff] [blame] | 33 | |
| 34 | case $TRIPLE in |
| 35 | *-apple-*) |
| 36 | if [ -z $RC_XBS ] |
| 37 | then |
| 38 | RC_CFLAGS="-arch i386 -arch x86_64" |
| 39 | fi |
| 40 | SOEXT=dylib |
| 41 | if [ -n "$SDKROOT" ] |
| 42 | then |
| 43 | EXTRA_FLAGS+="-isysroot ${SDKROOT}" |
| 44 | CXX=`xcrun -sdk "${SDKROOT}" -find clang++` |
| 45 | CC=`xcrun -sdk "${SDKROOT}" -find clang` |
| 46 | fi |
| 47 | LDSHARED_FLAGS="-o libc++abi.dylib \ |
| 48 | -dynamiclib -nodefaultlibs \ |
| 49 | -current_version ${RC_ProjectSourceVersion} \ |
| 50 | -compatibility_version 1 \ |
| 51 | -install_name /usr/lib/libc++abi.dylib \ |
| 52 | -lSystem" |
| 53 | ;; |
| 54 | *-*-mingw*) |
| 55 | # FIXME: removing libgcc and libsupc++ dependencies means porting libcxxrt and LLVM/compiler-rt |
| 56 | SOEXT=dll |
| 57 | LDSHARED_FLAGS="-o libc++abi.dll \ |
| 58 | -shared -nodefaultlibs -Wl,--export-all-symbols -Wl,--allow-multiple-definition -Wl,--out-implib,libc++abi.dll.a \ |
| 59 | -lsupc++ -lpthread -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcr100 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt" |
| 60 | ;; |
| 61 | *) |
| 62 | RC_CFLAGS="-fPIC" |
| 63 | SOEXT=so |
| 64 | LDSHARED_FLAGS="-o libc++abi.so.1.0 \ |
| 65 | -shared -nodefaultlibs -Wl,-soname,libc++abi.so.1 \ |
| 66 | -lpthread -lrt -lc -lstdc++" |
| 67 | ;; |
| 68 | esac |
| 69 | |
| 70 | if [ -z $RC_XBS ] |
| 71 | then |
| 72 | rm -f libc++abi.1.$SOEXT* |
| 73 | fi |
| 74 | |
| 75 | set -x |
| 76 | |
| 77 | for FILE in ../src/*.cpp; do |
Howard Hinnant | 6a16979 | 2012-02-03 18:36:36 +0000 | [diff] [blame] | 78 | $CXX -c -g -O3 $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE |
Howard Hinnant | f81cdff | 2012-01-24 23:42:30 +0000 | [diff] [blame] | 79 | done |
| 80 | case $TRIPLE in |
| 81 | *-*-mingw*) |
| 82 | for FILE in ../src/support/win32/*.cpp; do |
| 83 | $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE |
| 84 | done |
| 85 | ;; |
| 86 | esac |
| 87 | $CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS |
| 88 | |
| 89 | if [ -z $RC_XBS ] |
| 90 | then |
| 91 | rm *.o |
| 92 | fi |