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