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