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