• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
7set -e
8
9if [ `basename $(pwd)` != "lib" ]
10then
11	echo "current directory must be lib"
12	exit 1
13fi
14
15if [ -z "$CXX" ]
16then
17	CXX=clang++
18fi
19
20if [ -z "$CC" ]
21then
22    CC=clang
23fi
24
25if [ -z $MACOSX_DEPLOYMENT_TARGET ]
26then
27	if [ -z $IPHONEOS_DEPLOYMENT_TARGET ]
28	then
29		MACOSX_DEPLOYMENT_TARGET=10.7
30	fi
31fi
32
33if [ -z $RC_ProjectSourceVersion ]
34then
35  RC_ProjectSourceVersion=1
36fi
37
38EXTRA_FLAGS="-std=c++0x -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion \
39             -Wnewline-eof -Wpadded -Wmissing-prototypes -Wstrict-aliasing=2 \
40             -Wstrict-overflow=4"
41
42case $TRIPLE in
43  *-apple-*)
44    if [ -z $RC_XBS ]
45    then
46      RC_CFLAGS="-arch i386 -arch x86_64"
47    fi
48    SOEXT=dylib
49	if [ "$MACOSX_DEPLOYMENT_TARGET" == "10.6" ]
50	then
51	    EXTRA_FLAGS="-std=c++0x -U__STRICT_ANSI__"
52		LDSHARED_FLAGS="-o libc++.1.dylib \
53			-dynamiclib -nodefaultlibs -current_version 1 \
54			-compatibility_version 1 \
55			-install_name /usr/lib/libc++.1.dylib \
56			-Wl,-reexport_library,/usr/lib/libc++abi.dylib \
57			-Wl,-unexported_symbols_list,libc++unexp.exp  \
58			/usr/lib/libSystem.B.dylib"
59	else
60		RE_EXPORT_LINE="/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++abi.exp"
61		if [ -n "$SDKROOT" ]
62		then
63			EXTRA_FLAGS+="-isysroot ${SDKROOT}"
64			if echo "${RC_ARCHS}" | grep -q "armv7"
65			then
66				RE_EXPORT_LINE="${SDKROOT}/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++sjlj-abi.exp"
67			else
68				RE_EXPORT_LINE="-Wl,-reexport_library,${SDKROOT}/usr/lib/libc++abi.dylib"
69			fi
70			CXX=`xcrun -sdk "${SDKROOT}"  -find clang++`
71			CC=`xcrun -sdk "${SDKROOT}"  -find clang`
72		fi
73	    LDSHARED_FLAGS="-o libc++.1.dylib \
74			-dynamiclib -nodefaultlibs  \
75			-current_version ${RC_ProjectSourceVersion} \
76			-compatibility_version 1 \
77			-install_name /usr/lib/libc++.1.dylib \
78			-lSystem  \
79			-Wl,-unexported_symbols_list,libc++unexp.exp  \
80			${RE_EXPORT_LINE}  \
81			-Wl,-force_symbols_not_weak_list,notweak.exp \
82			-Wl,-force_symbols_weak_list,weak.exp"
83	fi
84    ;;
85  *-*-mingw*)
86    # FIXME: removing libgcc and libsupc++ dependencies means porting libcxxrt and LLVM/compiler-rt
87    SOEXT=dll
88    LDSHARED_FLAGS="-o libc++.dll \
89        -shared -nodefaultlibs -Wl,--export-all-symbols -Wl,--allow-multiple-definition -Wl,--out-implib,libc++.dll.a \
90        -lsupc++ -lpthread -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcr100 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt"
91	;;
92  *)
93    RC_CFLAGS="-fPIC"
94    SOEXT=so
95    LDSHARED_FLAGS="-o libc++.so.1.0 \
96        -shared -nodefaultlibs -Wl,-soname,libc++.so.1 \
97        -lpthread -lrt -lc -lstdc++"
98    ;;
99esac
100
101if [ -z $RC_XBS ]
102then
103    rm -f libc++.1.$SOEXT*
104fi
105
106set -x
107
108for FILE in ../src/*.cpp; do
109	$CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -nostdinc++ -I../include $FILE
110done
111case $TRIPLE in
112  *-*-mingw*)
113  for FILE in ../src/support/win32/*.cpp; do
114    $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -nostdinc++ -I../include $FILE
115  done
116  ;;
117esac
118$CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS
119
120#libtool -static -o libc++.a *.o
121
122if [ -z $RC_XBS ]
123then
124    rm *.o
125fi
126