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