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