2 ===================================================================
3 --- BuildToolChain (revision 1707)
4 +++ BuildToolChain (working copy)
6 rm -f $3/bin/tclsh* $3/bin/wish*
9 -# If $1 is newer than $2, return 1. Otherwise, return 0.
13 - MAJOR1=`echo $1 | sed 's/\([0-9]*\).*/\1/'`
14 - MINOR1=`echo $1 | sed 's/[0-9]*.\([0-9]*\).*/\1/'`
15 - PATCH1=`echo $1 | sed 's/[0-9]*.[0-9]*.\([0-9]*\).*/\1/'`
16 - MAJOR2=`echo $2 | sed 's/\([0-9]*\).*/\1/'`
17 - MINOR2=`echo $2 | sed 's/[0-9]*.\([0-9]*\).*/\1/'`
18 - PATCH2=`echo $2 | sed 's/[0-9]*.[0-9]*.\([0-9]*\).*/\1/'`
20 - if [ -z "$MAJOR1" -o -z "$MINOR1" -o -z "$PATCH1" -o -z "$MAJOR2" -o -z "$MINOR2" -o -z "$PATCH2" ]; then
24 - if [ "$MAJOR1" -lt "$MAJOR2" ]; then
26 - elif [ "$MAJOR1" -gt "$MAJOR2" ]; then
28 - elif [ "$MINOR1" -lt "$MINOR2" ]; then
30 - elif [ "$MINOR1" -gt "$MINOR2" ]; then
32 - elif [ "$PATCH1" -lt "$PATCH2" ]; then
34 - elif [ "$PATCH1" -gt "$PATCH2" ]; then
41 -# If $1 is compatible with $2, return 1. Otherwise, return 0.
45 - MAJOR1=`echo $1 | sed 's/\([0-9]*\).*/\1/'`
46 - MINOR1=`echo $1 | sed 's/[0-9]*.\([0-9]*\).*/\1/'`
47 - PATCH1=`echo $1 | sed 's/[0-9]*.[0-9]*.\([0-9]*\).*/\1/'`
48 - MAJOR2=`echo $2 | sed 's/\([0-9]*\).*/\1/'`
49 - MINOR2=`echo $2 | sed 's/[0-9]*.\([0-9]*\).*/\1/'`
50 - PATCH2=`echo $2 | sed 's/[0-9]*.[0-9]*.\([0-9]*\).*/\1/'`
52 - if [ -z "$MAJOR1" -o -z "$MINOR1" -o -z "$PATCH1" -o -z "$MAJOR2" -o -z "$MINOR2" -o -z "$PATCH2" ]; then
56 - if [ "$MAJOR1" -eq "$MAJOR2" -a "$MINOR1" -eq "$MINOR2" ]; then
63 -# Install shared libstdc++ libraries into sysroot direcotory
64 +# Install shared libraries into sysroot direcotory
65 # 1st argument is the toolchain install directory
66 # 2nd argument is the toolchain name
68 -install_libstdcpps ()
71 - GCCS=`find $1 -name bfin-linux-uclibc-gcc-* | tr '\n' ' '`
72 + pushd $1/lib/gcc/$2 > /dev/null
74 - while [ -n "$GCCS" ]; do
79 + # install the libraries from the latest version of the toolchain
80 + GCC_VER=$(echo * | tr ' ' '\n' | LC_ALL=C sort | tail -n 1)
83 - for GCC in $GCCS; do
84 - LIBSTDCPP=`$GCC --print-file-name=libstdc++.so`
85 - LIBSTDCPP=`readlink -f $LIBSTDCPP`
86 - LIBSTDCPP_DIR=`dirname $LIBSTDCPP`
87 - LIBSTDCPP_NAME=`basename $LIBSTDCPP`
88 - LIBSTDCPP_VERSION=`echo $LIBSTDCPP_NAME | sed 's/libstdc++.so.\([0-9]*.[0-9]*.[0-9]*\).*/\1/'`
90 - if [ -z "$NEWEST_VERSION" ]; then
91 - NEWEST_VERSION=$LIBSTDCPP_VERSION
96 + # walk each multilib version
97 + for l in $(find -name 'lib*.so') ; do
98 + echo "Installing shared ${l} from gcc dir into runtime sysroot"
100 - is_compat $LIBSTDCPP_VERSION $NEWEST_VERSION
101 - if [ $? -eq 1 ]; then
102 - COMPAT_GCCS="$COMPAT_GCCS $GCC"
103 + DIRNAME=$(dirname ${l})
104 + SONAME=$(readelf -d ${l} | sed -n '/SONAME/s:.*\[\(.*\)\]:\1:p')
105 + FULLNAME=$(basename $(readlink ${l}))
106 + DESTDIR="../../../../$2/runtime/${DIRNAME}/lib"
108 - is_newer $LIBSTDCPP_VERSION $NEWEST_VERSION
109 - if [ $? -eq 1 ]; then
110 - NEWEST_VERSION=$LIBSTDCPP_VERSION
114 - GCCS2="$GCCS2 $GCC"
117 + # move the soname and the full versioned one (if it exists)
118 + # aka libstdc.so.x and libstdc.so.x.y.z
119 + mv ${DIRNAME}/${FULLNAME} ${DESTDIR}/${FULLNAME}
120 + if [ "${FULLNAME}" != "${SONAME}" ] ; then
121 + ln -s ${FULLNAME} ${DESTDIR}/${SONAME}
124 - echo "Installing shared libstdc++ from $NEWEST_GCC"
126 - MULTILIBS=`$NEWEST_GCC --print-multi-lib`
128 - for ml in $MULTILIBS; do
130 - dir=`echo ${ml} | sed -e 's/;.*$//'`
131 - flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`
132 - if [ "$dir" = "." ]; then
135 - dir2=`echo ${dir} | sed -e 's|[^/]*|..|g'`/
138 - LIBSTDCPP=`$NEWEST_GCC $flags --print-file-name=libstdc++.so`
139 - LIBSTDCPP=`readlink -f $LIBSTDCPP`
140 - LIBSTDCPP_DIR=`dirname $LIBSTDCPP`
141 - LIBSTDCPP_NAME=`basename $LIBSTDCPP`
142 - LIBSTDCPP_VERSION=`echo $LIBSTDCPP_NAME | sed 's/libstdc++.so.\([0-9]*.[0-9]*.[0-9]*\).*/\1/'`
143 - MAJOR_NUM=`echo $LIBSTDCPP_VERSION | sed 's/\([0-9]*\).*/\1/'`
145 - cp $LIBSTDCPP $1/$2/runtime/$dir/lib
146 - ln -s $LIBSTDCPP_NAME $1/$2/runtime/$dir/lib/libstdc++.so.$MAJOR_NUM
148 - for G in $COMPAT_GCCS; do
149 - L=`$G $flags --print-file-name=libstdc++.so`
150 - rm -f `dirname $L`/libstdc++.so*
151 - ln -s ../../../../$dir2$2/runtime/$dir/lib/$LIBSTDCPP_NAME `dirname $L`/libstdc++.so
157 + # create a symlink here from the linkable lib to
158 + # the full versioned one so gcc can still find it
159 + rm -f ${l} ${DIRNAME}/${SONAME}
160 + ln -s ${DESTDIR}/${FULLNAME} ${l}
164 -# Install shared libgcc libraries into sysroot direcotory
165 -# 1st argument is the toolchain install directory
166 -# 2nd argument is the toolchain name
167 -# FIXME: Only libgcc_s.so.1 is handled
171 - GCCS=`find $1 -name bfin-linux-uclibc-gcc-* | tr '\n' ' '`
175 - for GCC in $GCCS; do
176 - LIBGCC=`$GCC --print-file-name=libgcc_s.so`
177 - LIBGCC_DIR=`dirname $LIBGCC`
178 - GCC_VERSION=`basename $LIBGCC_DIR`
180 - if [ -z "$NEWEST_VERSION" ]; then
181 - NEWEST_VERSION=$GCC_VERSION
186 - is_newer $GCC_VERSION $NEWEST_VERSION
187 - if [ $? -eq 1 ]; then
188 - NEWEST_VERSION=$GCC_VERSION
193 - echo "Installing libgcc_s from $NEWEST_GCC"
195 - MULTILIBS=`$NEWEST_GCC --print-multi-lib`
197 - for ml in $MULTILIBS; do
199 - dir=`echo ${ml} | sed -e 's/;.*$//'`
200 - flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`
202 - LIBGCC=`$NEWEST_GCC $flags --print-file-name=libgcc_s_$dir.so`
203 - if [ ! -e $LIBGCC ]; then
204 - LIBGCC=`$NEWEST_GCC $flags --print-file-name=libgcc_s.so`
206 - if [ ! -e $LIBGCC ]; then
207 - echo "No libgcc_s.so for $NEWEST_GCC - report an error"
208 - tail -10 $ACTUAL_LOGFILE
212 - LIBGCC=`readlink -f $LIBGCC`
213 - LIBGCC_DIR=`dirname $LIBGCC`
214 - LIBGCC_NAME=`basename $LIBGCC`
216 - cp $LIBGCC $1/$2/runtime/$dir/lib
219 - L=`$G $flags --print-file-name=libgcc_s_$dir.so`
221 - if [ ! -e $L ]; then
222 - L=`$G $flags --print-file-name=libgcc_s.so`
223 - if [ "$dir" != "." ]; then
224 - dir2=`echo ${dir} | sed -e 's|[^/]*|..|g'`/
228 - ln -s ../../../../$dir2$2/runtime/$dir/lib/$LIBGCC_NAME $L
235 @@ -1667,8 +1503,7 @@
237 rm -f $DIR_LINUX_OUTPUT/bfin-linux-uclibc/sys-include
239 - install_libstdcpps $DIR_LINUX_OUTPUT bfin-linux-uclibc
240 - install_libgccs $DIR_LINUX_OUTPUT bfin-linux-uclibc
241 + install_gcc_libs $DIR_LINUX_OUTPUT bfin-linux-uclibc
243 ##################### Test bfin-linux-uclibc #####################