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 |
| 29 | MACOSX_DEPLOYMENT_TARGET=10.6 |
| 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 | d5fed03 | 2011-05-29 13:57:49 +0000 | [diff] [blame^] | 38 | EXTRA_FLAGS="-std=c++0x " |
| 39 | |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 40 | case $TRIPLE in |
| 41 | *-apple-*) |
Nick Kledzik | d982028 | 2011-05-06 01:13:20 +0000 | [diff] [blame] | 42 | if [ -z $RC_XBS ] |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 43 | then |
Howard Hinnant | 0e353f2 | 2010-08-11 18:11:36 +0000 | [diff] [blame] | 44 | RC_CFLAGS="-arch i386 -arch x86_64" |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 45 | fi |
| 46 | SOEXT=dylib |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 47 | if [ "$MACOSX_DEPLOYMENT_TARGET" == "10.6" ] |
| 48 | then |
Howard Hinnant | 30bbc93 | 2011-01-27 21:01:51 +0000 | [diff] [blame] | 49 | EXTRA_FLAGS="-std=c++0x -U__STRICT_ANSI__" |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 50 | LDSHARED_FLAGS="-o libc++.1.dylib \ |
| 51 | -dynamiclib -nodefaultlibs -current_version 1 \ |
| 52 | -compatibility_version 1 \ |
Howard Hinnant | 08774c5 | 2011-02-16 00:40:06 +0000 | [diff] [blame] | 53 | -install_name /usr/lib/libc++.1.dylib \ |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 54 | -Wl,-reexport_library,/usr/lib/libc++abi.dylib \ |
Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 55 | -Wl,-unexported_symbols_list,libc++unexp.exp \ |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 56 | /usr/lib/libSystem.B.dylib" |
| 57 | else |
Nick Kledzik | c6e08d6 | 2011-05-04 21:50:46 +0000 | [diff] [blame] | 58 | RE_EXPORT_FILE="libc++abi.exp" |
| 59 | if [ -n "$SDKROOT" ] |
| 60 | then |
| 61 | EXTRA_FLAGS+="-isysroot ${SDKROOT}" |
Nick Kledzik | 8feadca | 2011-05-24 20:27:31 +0000 | [diff] [blame] | 62 | if [ "${RC_armv7}" = "YES" ] |
| 63 | then |
| 64 | RE_EXPORT_FILE="libc++sjlj-abi.exp" |
| 65 | fi |
Nick Kledzik | c6e08d6 | 2011-05-04 21:50:46 +0000 | [diff] [blame] | 66 | CXX=`xcrun -sdk "${SDKROOT}" -find clang++` |
| 67 | CC=`xcrun -sdk "${SDKROOT}" -find clang` |
| 68 | fi |
| 69 | LDSHARED_FLAGS="-o libc++.1.dylib \ |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 70 | -dynamiclib -nodefaultlibs \ |
| 71 | -current_version ${RC_ProjectSourceVersion} -compatibility_version 1 \ |
Howard Hinnant | 08774c5 | 2011-02-16 00:40:06 +0000 | [diff] [blame] | 72 | -install_name /usr/lib/libc++.1.dylib \ |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 73 | ${SDKROOT}/usr/lib/libc++abi.dylib \ |
| 74 | -lSystem \ |
Howard Hinnant | 2d72b1e | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 75 | -Wl,-unexported_symbols_list,libc++unexp.exp \ |
Nick Kledzik | c6e08d6 | 2011-05-04 21:50:46 +0000 | [diff] [blame] | 76 | -Wl,-reexported_symbols_list,${RE_EXPORT_FILE} \ |
| 77 | -Wl,-force_symbols_not_weak_list,notweak.exp " |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 78 | fi |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 79 | ;; |
| 80 | *) |
| 81 | RC_CFLAGS="-fPIC" |
| 82 | SOEXT=so |
| 83 | LDSHARED_FLAGS="-o libc++.so.1.0 \ |
| 84 | -shared -nodefaultlibs -Wl,-soname,libc++.so.1 \ |
Howard Hinnant | d5fed03 | 2011-05-29 13:57:49 +0000 | [diff] [blame^] | 85 | -lpthread -lrt -lc -lstdc++" |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 86 | ;; |
| 87 | esac |
| 88 | |
Nick Kledzik | d982028 | 2011-05-06 01:13:20 +0000 | [diff] [blame] | 89 | if [ -z $RC_XBS ] |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 90 | then |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 91 | rm -f libc++.1.$SOEXT* |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 92 | fi |
| 93 | |
| 94 | set -x |
| 95 | |
Howard Hinnant | adff489 | 2010-05-24 17:49:41 +0000 | [diff] [blame] | 96 | for FILE in ../src/*.cpp; do |
Howard Hinnant | 30bbc93 | 2011-01-27 21:01:51 +0000 | [diff] [blame] | 97 | $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -nostdinc++ -I../include $FILE |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 98 | done |
| 99 | |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 100 | |
Nick Kledzik | c6e08d6 | 2011-05-04 21:50:46 +0000 | [diff] [blame] | 101 | $CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 102 | |
| 103 | #libtool -static -o libc++.a *.o |
| 104 | |
Nick Kledzik | d982028 | 2011-05-06 01:13:20 +0000 | [diff] [blame] | 105 | if [ -z $RC_XBS ] |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 106 | then |
| 107 | rm *.o |
| 108 | fi |