Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 1 | #! /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 |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 5 | # the library. Otherwise we'll use clang++. |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 6 | |
| 7 | set -e |
| 8 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 9 | if [ `basename $(pwd)` != "lib" ] |
| 10 | then |
| 11 | echo "current directory must be lib" |
| 12 | exit 1 |
| 13 | fi |
| 14 | |
Howard Hinnant | a6a062d | 2010-06-02 18:20:39 +0000 | [diff] [blame] | 15 | if [ -z "$CXX" ] |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 16 | then |
Howard Hinnant | 45f5717 | 2010-09-14 20:26:27 +0000 | [diff] [blame] | 17 | CXX=clang++ |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 18 | fi |
| 19 | |
Nick Kledzik | c6e08d6 | 2011-05-04 21:50:46 +0000 | [diff] [blame] | 20 | if [ -z "$CC" ] |
| 21 | then |
| 22 | CC=clang |
| 23 | fi |
| 24 | |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 25 | if [ -z $MACOSX_DEPLOYMENT_TARGET ] |
| 26 | then |
Nick Kledzik | 8feadca | 2011-05-24 20:27:31 +0000 | [diff] [blame] | 27 | if [ -z $IPHONEOS_DEPLOYMENT_TARGET ] |
| 28 | then |
Howard Hinnant | 9677458 | 2011-10-04 23:11:56 +0000 | [diff] [blame] | 29 | MACOSX_DEPLOYMENT_TARGET=10.7 |
Nick Kledzik | 8feadca | 2011-05-24 20:27:31 +0000 | [diff] [blame] | 30 | fi |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 31 | fi |
| 32 | |
| 33 | if [ -z $RC_ProjectSourceVersion ] |
| 34 | then |
| 35 | RC_ProjectSourceVersion=1 |
| 36 | fi |
| 37 | |
Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame^] | 38 | EXTRA_FLAGS="-std=c++0x -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion \ |
| 39 | -Wnewline-eof -Wpadded -Wmissing-prototypes -Wstrict-aliasing=2 \ |
| 40 | -Wstrict-overflow=4" |
Howard Hinnant | d5fed03 | 2011-05-29 13:57:49 +0000 | [diff] [blame] | 41 | |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 42 | case $TRIPLE in |
| 43 | *-apple-*) |
Nick Kledzik | d982028 | 2011-05-06 01:13:20 +0000 | [diff] [blame] | 44 | if [ -z $RC_XBS ] |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 45 | then |
Howard Hinnant | 0e353f2 | 2010-08-11 18:11:36 +0000 | [diff] [blame] | 46 | RC_CFLAGS="-arch i386 -arch x86_64" |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 47 | fi |
| 48 | SOEXT=dylib |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 49 | if [ "$MACOSX_DEPLOYMENT_TARGET" == "10.6" ] |
| 50 | then |
Howard Hinnant | 30bbc93 | 2011-01-27 21:01:51 +0000 | [diff] [blame] | 51 | EXTRA_FLAGS="-std=c++0x -U__STRICT_ANSI__" |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 52 | LDSHARED_FLAGS="-o libc++.1.dylib \ |
| 53 | -dynamiclib -nodefaultlibs -current_version 1 \ |
| 54 | -compatibility_version 1 \ |
Howard Hinnant | 08774c5 | 2011-02-16 00:40:06 +0000 | [diff] [blame] | 55 | -install_name /usr/lib/libc++.1.dylib \ |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 56 | -Wl,-reexport_library,/usr/lib/libc++abi.dylib \ |
Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 57 | -Wl,-unexported_symbols_list,libc++unexp.exp \ |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 58 | /usr/lib/libSystem.B.dylib" |
| 59 | else |
Nick Kledzik | 8f5f256 | 2011-06-09 23:31:35 +0000 | [diff] [blame] | 60 | RE_EXPORT_LINE="/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++abi.exp" |
Nick Kledzik | c6e08d6 | 2011-05-04 21:50:46 +0000 | [diff] [blame] | 61 | if [ -n "$SDKROOT" ] |
| 62 | then |
| 63 | EXTRA_FLAGS+="-isysroot ${SDKROOT}" |
Nick Kledzik | 8f5f256 | 2011-06-09 23:31:35 +0000 | [diff] [blame] | 64 | if echo "${RC_ARCHS}" | grep -q "armv7" |
Nick Kledzik | 8feadca | 2011-05-24 20:27:31 +0000 | [diff] [blame] | 65 | then |
Nick Kledzik | 8f5f256 | 2011-06-09 23:31:35 +0000 | [diff] [blame] | 66 | RE_EXPORT_LINE="${SDKROOT}/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++sjlj-abi.exp" |
| 67 | else |
| 68 | RE_EXPORT_LINE="-Wl,-reexport_library,${SDKROOT}/usr/lib/libc++abi.dylib" |
Nick Kledzik | 8feadca | 2011-05-24 20:27:31 +0000 | [diff] [blame] | 69 | fi |
Nick Kledzik | c6e08d6 | 2011-05-04 21:50:46 +0000 | [diff] [blame] | 70 | CXX=`xcrun -sdk "${SDKROOT}" -find clang++` |
| 71 | CC=`xcrun -sdk "${SDKROOT}" -find clang` |
| 72 | fi |
| 73 | LDSHARED_FLAGS="-o libc++.1.dylib \ |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 74 | -dynamiclib -nodefaultlibs \ |
Howard Hinnant | e0a0e51 | 2011-10-07 19:52:29 +0000 | [diff] [blame] | 75 | -current_version ${RC_ProjectSourceVersion} \ |
Howard Hinnant | fdcbd1d | 2011-10-07 23:55:11 +0000 | [diff] [blame] | 76 | -compatibility_version 1 \ |
Howard Hinnant | 08774c5 | 2011-02-16 00:40:06 +0000 | [diff] [blame] | 77 | -install_name /usr/lib/libc++.1.dylib \ |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 78 | -lSystem \ |
Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 79 | -Wl,-unexported_symbols_list,libc++unexp.exp \ |
Nick Kledzik | 8f5f256 | 2011-06-09 23:31:35 +0000 | [diff] [blame] | 80 | ${RE_EXPORT_LINE} \ |
Howard Hinnant | 9677458 | 2011-10-04 23:11:56 +0000 | [diff] [blame] | 81 | -Wl,-force_symbols_not_weak_list,notweak.exp \ |
| 82 | -Wl,-force_symbols_weak_list,weak.exp" |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 83 | fi |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 84 | ;; |
Howard Hinnant | efbe406 | 2011-09-28 21:39:20 +0000 | [diff] [blame] | 85 | *-*-mingw*) |
| 86 | # FIXME: removing libgcc and libsupc++ dependencies means porting libcxxrt and LLVM/compiler-rt |
| 87 | SOEXT=dll |
| 88 | LDSHARED_FLAGS="-o libc++.dll \ |
| 89 | -shared -nodefaultlibs -Wl,--export-all-symbols -Wl,--allow-multiple-definition -Wl,--out-implib,libc++.dll.a \ |
| 90 | -lsupc++ -lpthread -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcr100 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt" |
| 91 | ;; |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 92 | *) |
| 93 | RC_CFLAGS="-fPIC" |
| 94 | SOEXT=so |
| 95 | LDSHARED_FLAGS="-o libc++.so.1.0 \ |
| 96 | -shared -nodefaultlibs -Wl,-soname,libc++.so.1 \ |
Howard Hinnant | d5fed03 | 2011-05-29 13:57:49 +0000 | [diff] [blame] | 97 | -lpthread -lrt -lc -lstdc++" |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 98 | ;; |
| 99 | esac |
| 100 | |
Nick Kledzik | d982028 | 2011-05-06 01:13:20 +0000 | [diff] [blame] | 101 | if [ -z $RC_XBS ] |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 102 | then |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 103 | rm -f libc++.1.$SOEXT* |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 104 | fi |
| 105 | |
| 106 | set -x |
| 107 | |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 108 | for FILE in ../src/*.cpp; do |
Howard Hinnant | 30bbc93 | 2011-01-27 21:01:51 +0000 | [diff] [blame] | 109 | $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -nostdinc++ -I../include $FILE |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 110 | done |
Howard Hinnant | efbe406 | 2011-09-28 21:39:20 +0000 | [diff] [blame] | 111 | case $TRIPLE in |
| 112 | *-*-mingw*) |
| 113 | for FILE in ../src/support/win32/*.cpp; do |
| 114 | $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -nostdinc++ -I../include $FILE |
| 115 | done |
| 116 | ;; |
| 117 | esac |
Nick Kledzik | c6e08d6 | 2011-05-04 21:50:46 +0000 | [diff] [blame] | 118 | $CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 119 | |
| 120 | #libtool -static -o libc++.a *.o |
| 121 | |
Nick Kledzik | d982028 | 2011-05-06 01:13:20 +0000 | [diff] [blame] | 122 | if [ -z $RC_XBS ] |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 123 | then |
| 124 | rm *.o |
| 125 | fi |