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