blob: 5a4a71090f739a8b12f8ec1f5a6f73ff28b02b85 [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 Hinnant6c33e762013-06-17 18:10:34 +000030EXTRA_FLAGS="-std=c++11 -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 \
Howard Hinnant96f01712012-03-09 18:01:37 +000034 -Wstrict-aliasing=2 -Wstrict-overflow=4 -Wunused-parameter \
35 -Wnewline-eof"
Howard Hinnantf81cdff2012-01-24 23:42:30 +000036
37case $TRIPLE in
38 *-apple-*)
39 if [ -z $RC_XBS ]
40 then
41 RC_CFLAGS="-arch i386 -arch x86_64"
42 fi
43 SOEXT=dylib
44 if [ -n "$SDKROOT" ]
45 then
46 EXTRA_FLAGS+="-isysroot ${SDKROOT}"
47 CXX=`xcrun -sdk "${SDKROOT}" -find clang++`
48 CC=`xcrun -sdk "${SDKROOT}" -find clang`
49 fi
50 LDSHARED_FLAGS="-o libc++abi.dylib \
51 -dynamiclib -nodefaultlibs \
52 -current_version ${RC_ProjectSourceVersion} \
53 -compatibility_version 1 \
54 -install_name /usr/lib/libc++abi.dylib \
55 -lSystem"
Nick Kledzika31cad92012-03-14 01:16:14 +000056 if [ -f "${SDKROOT}/usr/local/lib/libCrashReporterClient.a" ]
57 then
58 LDSHARED_FLAGS+=" -lCrashReporterClient"
59 fi
Howard Hinnantf81cdff2012-01-24 23:42:30 +000060 ;;
61 *-*-mingw*)
62 # FIXME: removing libgcc and libsupc++ dependencies means porting libcxxrt and LLVM/compiler-rt
63 SOEXT=dll
64 LDSHARED_FLAGS="-o libc++abi.dll \
65 -shared -nodefaultlibs -Wl,--export-all-symbols -Wl,--allow-multiple-definition -Wl,--out-implib,libc++abi.dll.a \
66 -lsupc++ -lpthread -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcr100 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt"
67 ;;
68 *)
69 RC_CFLAGS="-fPIC"
70 SOEXT=so
71 LDSHARED_FLAGS="-o libc++abi.so.1.0 \
72 -shared -nodefaultlibs -Wl,-soname,libc++abi.so.1 \
73 -lpthread -lrt -lc -lstdc++"
74 ;;
75esac
76
77if [ -z $RC_XBS ]
78then
79 rm -f libc++abi.1.$SOEXT*
80fi
81
82set -x
83
84for FILE in ../src/*.cpp; do
Marshall Clow01c20842013-09-09 23:53:08 +000085 $CXX -c -g -O3 $RC_CFLAGS $EXTRA_FLAGS -I../include $OPTIONS $FILE
Howard Hinnantf81cdff2012-01-24 23:42:30 +000086done
87case $TRIPLE in
88 *-*-mingw*)
89 for FILE in ../src/support/win32/*.cpp; do
Marshall Clow01c20842013-09-09 23:53:08 +000090 $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -I../include $OPTIONS $FILE
Howard Hinnantf81cdff2012-01-24 23:42:30 +000091 done
92 ;;
93esac
94$CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS
95
96if [ -z $RC_XBS ]
97then
98 rm *.o
99fi