blob: 51b9a81e9c4e8e3d1e20e5dccea81c1c4c36012a [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 Hinnant2b891bf2012-01-30 16:03:23 +000030EXTRA_FLAGS="-std=c++0x -stdlib=libc++ -fstrict-aliasing -Wstrict-aliasing=2"
Howard Hinnantf81cdff2012-01-24 23:42:30 +000031
32case $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 ;;
66esac
67
68if [ -z $RC_XBS ]
69then
70 rm -f libc++abi.1.$SOEXT*
71fi
72
73set -x
74
75for FILE in ../src/*.cpp; do
Howard Hinnant6a169792012-02-03 18:36:36 +000076 $CXX -c -g -O3 $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE
Howard Hinnantf81cdff2012-01-24 23:42:30 +000077done
78case $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 ;;
84esac
85$CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS
86
87if [ -z $RC_XBS ]
88then
89 rm *.o
90fi