blob: 67d10591a38f3a5658ba7cd88b71fa0be35c757c [file] [log] [blame]
Howard Hinnantf81cdff2012-01-24 23:42:30 +00001#! /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
7set -e
8
9if [ `basename $(pwd)` != "lib" ]
10then
11 echo "current directory must be lib"
12 exit 1
13fi
14
15if [ -z "$CXX" ]
16then
17 CXX=clang++
18fi
19
20if [ -z "$CC" ]
21then
22 CC=clang
23fi
24
25if [ -z $RC_ProjectSourceVersion ]
26then
27 RC_ProjectSourceVersion=1
28fi
29
Howard Hinnant3e5c7d02012-03-08 18:45:24 +000030EXTRA_FLAGS="-std=c++0x -stdlib=libc++ -fstrict-aliasing -Wstrict-aliasing=2 \
Howard Hinnantdfa81ca2012-03-08 20:23:24 +000031 -Wsign-conversion -Wshadow -Wconversion -Wunused-variable \
32 -Wnewline-eof"
Howard Hinnantf81cdff2012-01-24 23:42:30 +000033
34case $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 ;;
68esac
69
70if [ -z $RC_XBS ]
71then
72 rm -f libc++abi.1.$SOEXT*
73fi
74
75set -x
76
77for FILE in ../src/*.cpp; do
Howard Hinnant6a169792012-02-03 18:36:36 +000078 $CXX -c -g -O3 $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE
Howard Hinnantf81cdff2012-01-24 23:42:30 +000079done
80case $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 ;;
86esac
87$CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS
88
89if [ -z $RC_XBS ]
90then
91 rm *.o
92fi