Update build scripts
[android/toolchain/build.git] / build-sysroot.sh
1 #!/bin/sh
2 #
3 # build-sysroot.sh
4 #
5 # collect files from an Android tree to assemble a sysroot suitable for
6 # building a standable toolchain.
7 #
8
9 PRODUCT_DIR=$1
10 SYSROOT=$2
11 LIB_ROOT=$SYSROOT/usr/lib
12 INCLUDE_ROOT=$SYSROOT/usr/include
13
14 install_file ()
15 {
16     mkdir -p $2/`dirname $1`
17     cp -fp $1 $2/$1
18 }
19
20 install_helper ()
21 {
22   (cd $1 && find . -type f | while read ff; do install_file $ff $2; done)
23 }
24
25 TOP=$1/../../../..
26
27 # CRT objects that need to be copied
28 CRT_OBJS_DIR=$PRODUCT_DIR/obj/lib
29 CRT_OBJS="$CRT_OBJS_DIR/crtbegin_static.o \
30 $CRT_OBJS_DIR/crtbegin_dynamic.o \
31 $CRT_OBJS_DIR/crtend_android.o"
32
33 # static libraries that need to be copied.
34 STATIC_LIBS_DIR=$PRODUCT_DIR/obj/STATIC_LIBRARIES
35 STATIC_LIBS="$STATIC_LIBS_DIR/libc_intermediates/libc.a \
36 $STATIC_LIBS_DIR/libm_intermediates/libm.a \
37 $STATIC_LIBS_DIR/libstdc++_intermediates/libstdc++.a
38 $STATIC_LIBS_DIR/libthread_db_intermediates/libthread_db.a"
39
40 # dynamic libraries that need to be copied.
41 DYNAMIC_LIBS_DIR=$PRODUCT_DIR/symbols/system/lib
42 DYNAMIC_LIBS="$DYNAMIC_LIBS_DIR/libdl.so \
43 $DYNAMIC_LIBS_DIR/libc.so \
44 $DYNAMIC_LIBS_DIR/libm.so \
45 $DYNAMIC_LIBS_DIR/libstdc++.so \
46 $DYNAMIC_LIBS_DIR/libthread_db.so"
47
48 # Copy all CRT objects and librarires
49 rm -rf $LIB_ROOT
50 mkdir -p $LIB_ROOT
51 cp -f $CRT_OBJS $STATIC_LIBS $DYNAMIC_LIBS $LIB_ROOT
52
53 # Copy headers.  This need to be done in the reverse order of inclusion
54 # in case there are different headers with the same name.
55 INCLUDE_ROOT=$SYSROOT/usr/include
56 rm -rf $INCLUDE_ROOT
57
58 # Check $TOP/bioinc to see if this is new lay-out in cupcake.
59 if [ -d $TOP/bionic ] ;then
60   BIONIC_ROOT=$TOP/bionic
61   LIBC_ROOT=$BIONIC_ROOT/libc
62 else
63   BIONIC_ROOT=$TOP/system
64   LIBC_ROOT=$BIONIC_ROOT/bionic
65 fi
66
67 install_helper $BIONIC_ROOT/libthread_db/include  $INCLUDE_ROOT
68 # for libm, just copy math.h and fenv.h
69 install $BIONIC_ROOT/libm/include/math.h $INCLUDE_ROOT
70 install $BIONIC_ROOT/libm/include/arm/fenv.h $INCLUDE_ROOT
71 install_helper $LIBC_ROOT/kernel/arch-arm $INCLUDE_ROOT
72 install_helper $LIBC_ROOT/kernel/common $INCLUDE_ROOT
73 install_helper $BIONIC_ROOT/libstdc++/include  $INCLUDE_ROOT
74 install_helper $LIBC_ROOT/include $INCLUDE_ROOT
75 install_helper $LIBC_ROOT/arch-arm/include $INCLUDE_ROOT