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