2010-05-25 01:49:41 +08:00
|
|
|
#! /bin/sh
|
|
|
|
#
|
|
|
|
# Set the $TRIPLE environment variable to your system's triple before
|
|
|
|
# running this script. If you set $CXX, that will be used to compile
|
2010-12-11 03:47:54 +08:00
|
|
|
# the library. Otherwise we'll use clang++.
|
2010-05-25 01:49:41 +08:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
if [ `basename $(pwd)` != "lib" ]
|
|
|
|
then
|
|
|
|
echo "current directory must be lib"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2010-06-03 02:20:39 +08:00
|
|
|
if [ -z "$CXX" ]
|
2010-05-12 03:42:16 +08:00
|
|
|
then
|
2010-09-15 04:26:27 +08:00
|
|
|
CXX=clang++
|
2010-05-12 03:42:16 +08:00
|
|
|
fi
|
|
|
|
|
2011-05-05 05:50:46 +08:00
|
|
|
if [ -z "$CC" ]
|
|
|
|
then
|
|
|
|
CC=clang
|
|
|
|
fi
|
|
|
|
|
2010-09-11 04:42:36 +08:00
|
|
|
if [ -z $MACOSX_DEPLOYMENT_TARGET ]
|
|
|
|
then
|
2011-05-25 04:27:31 +08:00
|
|
|
if [ -z $IPHONEOS_DEPLOYMENT_TARGET ]
|
|
|
|
then
|
2011-10-05 07:11:56 +08:00
|
|
|
MACOSX_DEPLOYMENT_TARGET=10.7
|
2011-05-25 04:27:31 +08:00
|
|
|
fi
|
2010-09-11 04:42:36 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z $RC_ProjectSourceVersion ]
|
|
|
|
then
|
|
|
|
RC_ProjectSourceVersion=1
|
|
|
|
fi
|
|
|
|
|
2011-12-02 04:21:04 +08:00
|
|
|
EXTRA_FLAGS="-std=c++0x -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion \
|
|
|
|
-Wnewline-eof -Wpadded -Wmissing-prototypes -Wstrict-aliasing=2 \
|
|
|
|
-Wstrict-overflow=4"
|
2011-05-29 21:57:49 +08:00
|
|
|
|
2010-05-25 01:49:41 +08:00
|
|
|
case $TRIPLE in
|
|
|
|
*-apple-*)
|
2011-05-06 09:13:20 +08:00
|
|
|
if [ -z $RC_XBS ]
|
2010-05-25 01:49:41 +08:00
|
|
|
then
|
2010-08-12 02:11:36 +08:00
|
|
|
RC_CFLAGS="-arch i386 -arch x86_64"
|
2010-05-25 01:49:41 +08:00
|
|
|
fi
|
|
|
|
SOEXT=dylib
|
2010-09-11 04:42:36 +08:00
|
|
|
if [ "$MACOSX_DEPLOYMENT_TARGET" == "10.6" ]
|
|
|
|
then
|
2011-01-28 05:01:51 +08:00
|
|
|
EXTRA_FLAGS="-std=c++0x -U__STRICT_ANSI__"
|
2010-09-11 04:42:36 +08:00
|
|
|
LDSHARED_FLAGS="-o libc++.1.dylib \
|
|
|
|
-dynamiclib -nodefaultlibs -current_version 1 \
|
|
|
|
-compatibility_version 1 \
|
2011-02-16 08:40:06 +08:00
|
|
|
-install_name /usr/lib/libc++.1.dylib \
|
2010-09-11 04:42:36 +08:00
|
|
|
-Wl,-reexport_library,/usr/lib/libc++abi.dylib \
|
2010-12-17 22:46:43 +08:00
|
|
|
-Wl,-unexported_symbols_list,libc++unexp.exp \
|
2010-09-11 04:42:36 +08:00
|
|
|
/usr/lib/libSystem.B.dylib"
|
|
|
|
else
|
2011-06-10 07:31:35 +08:00
|
|
|
RE_EXPORT_LINE="/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++abi.exp"
|
2011-05-05 05:50:46 +08:00
|
|
|
if [ -n "$SDKROOT" ]
|
|
|
|
then
|
|
|
|
EXTRA_FLAGS+="-isysroot ${SDKROOT}"
|
2011-06-10 07:31:35 +08:00
|
|
|
if echo "${RC_ARCHS}" | grep -q "armv7"
|
2011-05-25 04:27:31 +08:00
|
|
|
then
|
2011-06-10 07:31:35 +08:00
|
|
|
RE_EXPORT_LINE="${SDKROOT}/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++sjlj-abi.exp"
|
|
|
|
else
|
|
|
|
RE_EXPORT_LINE="-Wl,-reexport_library,${SDKROOT}/usr/lib/libc++abi.dylib"
|
2011-05-25 04:27:31 +08:00
|
|
|
fi
|
2011-05-05 05:50:46 +08:00
|
|
|
CXX=`xcrun -sdk "${SDKROOT}" -find clang++`
|
|
|
|
CC=`xcrun -sdk "${SDKROOT}" -find clang`
|
|
|
|
fi
|
|
|
|
LDSHARED_FLAGS="-o libc++.1.dylib \
|
2010-09-11 04:42:36 +08:00
|
|
|
-dynamiclib -nodefaultlibs \
|
2011-10-08 03:52:29 +08:00
|
|
|
-current_version ${RC_ProjectSourceVersion} \
|
2011-10-08 07:55:11 +08:00
|
|
|
-compatibility_version 1 \
|
2011-02-16 08:40:06 +08:00
|
|
|
-install_name /usr/lib/libc++.1.dylib \
|
2010-09-11 04:42:36 +08:00
|
|
|
-lSystem \
|
2010-12-17 22:46:43 +08:00
|
|
|
-Wl,-unexported_symbols_list,libc++unexp.exp \
|
2011-06-10 07:31:35 +08:00
|
|
|
${RE_EXPORT_LINE} \
|
2011-10-05 07:11:56 +08:00
|
|
|
-Wl,-force_symbols_not_weak_list,notweak.exp \
|
|
|
|
-Wl,-force_symbols_weak_list,weak.exp"
|
2010-09-11 04:42:36 +08:00
|
|
|
fi
|
2010-05-25 01:49:41 +08:00
|
|
|
;;
|
2011-09-29 05:39:20 +08:00
|
|
|
*-*-mingw*)
|
|
|
|
# FIXME: removing libgcc and libsupc++ dependencies means porting libcxxrt and LLVM/compiler-rt
|
|
|
|
SOEXT=dll
|
|
|
|
LDSHARED_FLAGS="-o libc++.dll \
|
|
|
|
-shared -nodefaultlibs -Wl,--export-all-symbols -Wl,--allow-multiple-definition -Wl,--out-implib,libc++.dll.a \
|
|
|
|
-lsupc++ -lpthread -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcr100 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt"
|
|
|
|
;;
|
2010-05-25 01:49:41 +08:00
|
|
|
*)
|
|
|
|
RC_CFLAGS="-fPIC"
|
|
|
|
SOEXT=so
|
|
|
|
LDSHARED_FLAGS="-o libc++.so.1.0 \
|
|
|
|
-shared -nodefaultlibs -Wl,-soname,libc++.so.1 \
|
2011-05-29 21:57:49 +08:00
|
|
|
-lpthread -lrt -lc -lstdc++"
|
2010-05-25 01:49:41 +08:00
|
|
|
;;
|
|
|
|
esac
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2011-05-06 09:13:20 +08:00
|
|
|
if [ -z $RC_XBS ]
|
2010-05-12 03:42:16 +08:00
|
|
|
then
|
2010-05-25 01:49:41 +08:00
|
|
|
rm -f libc++.1.$SOEXT*
|
2010-05-12 03:42:16 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
set -x
|
|
|
|
|
2010-05-25 01:49:41 +08:00
|
|
|
for FILE in ../src/*.cpp; do
|
2011-01-28 05:01:51 +08:00
|
|
|
$CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -nostdinc++ -I../include $FILE
|
2010-05-12 03:42:16 +08:00
|
|
|
done
|
2011-09-29 05:39:20 +08:00
|
|
|
case $TRIPLE in
|
|
|
|
*-*-mingw*)
|
|
|
|
for FILE in ../src/support/win32/*.cpp; do
|
|
|
|
$CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -nostdinc++ -I../include $FILE
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
esac
|
2011-05-05 05:50:46 +08:00
|
|
|
$CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
#libtool -static -o libc++.a *.o
|
|
|
|
|
2013-02-06 08:04:54 +08:00
|
|
|
# Create the link for the final library name, so that we can use this directory
|
|
|
|
# as a link target for the tests.
|
|
|
|
case $TRIPLE in
|
|
|
|
*-apple-*)
|
|
|
|
rm -f libc++.dylib
|
|
|
|
ln -s libc++.1.dylib libc++.dylib
|
|
|
|
;;
|
|
|
|
*-*-mingw*)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
rm -f libc++.so
|
|
|
|
ln -s libc++.so.1 libc++.so
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2011-05-06 09:13:20 +08:00
|
|
|
if [ -z $RC_XBS ]
|
2010-05-12 03:42:16 +08:00
|
|
|
then
|
|
|
|
rm *.o
|
|
|
|
fi
|