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 5 # the library. Otherwise we'll use clang++. 6 7 set -e 8 9 if [ `basename $(pwd)` != "lib" ] 10 then 11 echo "current directory must be lib" 12 exit 1 13 fi 14 15 if [ -z "$CXX" ] 16 then 17 CXX=clang++ 18 fi 19 20 if [ -z "$CXX_LANG" ] 21 then 22 CXX_LANG=c++11 23 fi 24 25 if [ -z "$CC" ] 26 then 27 CC=clang 28 fi 29 30 if [ -z "$MACOSX_DEPLOYMENT_TARGET" ] 31 then 32 if [ -z "$IPHONEOS_DEPLOYMENT_TARGET" ] 33 then 34 MACOSX_DEPLOYMENT_TARGET=10.7 35 fi 36 fi 37 38 if [ -z "$RC_ProjectSourceVersion" ] 39 then 40 RC_ProjectSourceVersion=1 41 fi 42 43 EXTRA_FLAGS="-nostdinc++ -std=${CXX_LANG} -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion \ 44 -Wpadded -Wstrict-aliasing=2 -Wstrict-overflow=4 " 45 46 case $TRIPLE in 47 *-apple-*) 48 if [ -z $RC_XBS ] 49 then 50 RC_CFLAGS="-arch i386 -arch x86_64" 51 fi 52 SOEXT=dylib 53 if [ "$MACOSX_DEPLOYMENT_TARGET" = "10.6" ] 54 then 55 EXTRA_FLAGS="-nostdinc++ -std=c++11 -U__STRICT_ANSI__" 56 LDSHARED_FLAGS="-o libc++.1.dylib \ 57 -dynamiclib -nodefaultlibs -current_version 1 \ 58 -compatibility_version 1 \ 59 -install_name /usr/lib/libc++.1.dylib \ 60 -Wl,-reexport_library,/usr/lib/libc++abi.dylib \ 61 -Wl,-unexported_symbols_list,libc++unexp.exp \ 62 /usr/lib/libSystem.B.dylib" 63 else 64 if [ -n "$SDKROOT" ] 65 then 66 EXTRA_FLAGS+="-isysroot ${SDKROOT} " 67 if echo "${RC_ARCHS}" | grep -q "armv7" 68 then 69 RE_EXPORT_LINE="${SDKROOT}/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++sjlj-abi.exp" 70 else 71 RE_EXPORT_LINE="-Wl,-reexport_library,${SDKROOT}/usr/lib/libc++abi.dylib" 72 fi 73 CXX=`xcrun -sdk "${SDKROOT}" -find clang++` 74 CC=`xcrun -sdk "${SDKROOT}" -find clang` 75 else 76 # Check if we have _LIBCPPABI_VERSION, to determine the reexport list to use. 77 if (echo "#include <cxxabi.h>" | $CXX -E -dM -x c++ - | \ 78 grep _LIBCPPABI_VERSION > /dev/null) 79 then 80 RE_EXPORT_LINE="/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++abi2.exp" 81 else 82 RE_EXPORT_LINE="/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++abi.exp" 83 fi 84 fi 85 LDSHARED_FLAGS="-o libc++.1.dylib \ 86 -dynamiclib -nodefaultlibs \ 87 -current_version ${RC_ProjectSourceVersion} \ 88 -compatibility_version 1 \ 89 -install_name /usr/lib/libc++.1.dylib \ 90 -lSystem \ 91 -Wl,-unexported_symbols_list,libc++unexp.exp \ 92 ${RE_EXPORT_LINE} \ 93 -Wl,-force_symbols_not_weak_list,notweak.exp \ 94 -Wl,-force_symbols_weak_list,weak.exp" 95 fi 96 ;; 97 *-*-mingw*) 98 # FIXME: removing libgcc and libsupc++ dependencies means porting libcxxrt and LLVM/compiler-rt 99 SOEXT=dll 100 LDSHARED_FLAGS="-o libc++.dll \ 101 -shared -nodefaultlibs -Wl,--export-all-symbols -Wl,--allow-multiple-definition -Wl,--out-implib,libc++.dll.a \ 102 -lsupc++ -lpthread -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcr100 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt" 103 ;; 104 *-ibm-*) 105 hostOS=`uname` 106 hostOS=`echo $hostOS | sed -e "s/\s+$//"` 107 hostOS=`echo $hostOS | tr '[A-Z]' '[a-z]'` 108 109 if [ $hostOS = "linux" ] 110 then 111 LDSHARED_FLAGS="-o libc++.so.1 \ 112 -qmkshrobj -Wl,-soname,libc++.so.1 \ 113 -lpthread -lrt -lc -lstdc++" 114 EXTRA_FLAGS="-qlanglvl=extended0x -D__GLIBCXX__=1" 115 else 116 LDSHARED_FLAGS="-o shr.o -qmkshrobj -lpthread -bnoquiet" 117 EXTRA_FLAGS="-qlanglvl=extended0x" 118 fi 119 RC_CFLAGS="-qpic=large" 120 ;; 121 *) 122 RC_CFLAGS="-fPIC" 123 SOEXT=so 124 LDSHARED_FLAGS="-o libc++.so.1.0 \ 125 -shared -nodefaultlibs -Wl,-soname,libc++.so.1 \ 126 -lpthread -lrt -lc -lstdc++" 127 ;; 128 esac 129 130 if [ -z "$RC_XBS" ] 131 then 132 rm -f libc++.1.$SOEXT* 133 fi 134 135 set -x 136 137 for FILE in ../src/*.cpp; do 138 $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE 139 done 140 case $TRIPLE in 141 *-*-mingw*) 142 for FILE in ../src/support/win32/*.cpp; do 143 $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE 144 done 145 ;; 146 esac 147 $CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS 148 149 #libtool -static -o libc++.a *.o 150 151 # Create the link for the final library name, so that we can use this directory 152 # as a link target for the tests. 153 case $TRIPLE in 154 *-apple-*) 155 rm -f libc++.dylib 156 ln -s libc++.1.dylib libc++.dylib 157 ;; 158 *-*-mingw*) 159 ;; 160 *-ibm-*) 161 if [ $hostOS = "linux" ] 162 then 163 rm -f libc++.so 164 ln -s libc++.so.1 libc++.so 165 else #AIX 166 rm -f libc++.a 167 ar r libc++.a shr.o 168 fi 169 ;; 170 *) 171 rm -f libc++.so 172 ln -s libc++.so.1 libc++.so 173 ;; 174 esac 175 176 if [ -z "$RC_XBS" ] 177 then 178 rm *.o 179 fi 180