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