scummvm random work
[patches.git] / blackfin-simpler-gcc-lib-install.patch
1 Index: BuildToolChain
2 ===================================================================
3 --- BuildToolChain (revision 1707)
4 +++ BuildToolChain (working copy)
5 @@ -792,205 +792,41 @@
6 rm -f $3/bin/tclsh* $3/bin/wish*
7 }
8
9 -# If $1 is newer than $2, return 1. Otherwise, return 0.
10 -
11 -is_newer ()
12 -{
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/'`
19 -
20 - if [ -z "$MAJOR1" -o -z "$MINOR1" -o -z "$PATCH1" -o -z "$MAJOR2" -o -z "$MINOR2" -o -z "$PATCH2" ]; then
21 - return 0;
22 - fi
23 -
24 - if [ "$MAJOR1" -lt "$MAJOR2" ]; then
25 - return 0;
26 - elif [ "$MAJOR1" -gt "$MAJOR2" ]; then
27 - return 1;
28 - elif [ "$MINOR1" -lt "$MINOR2" ]; then
29 - return 0;
30 - elif [ "$MINOR1" -gt "$MINOR2" ]; then
31 - return 1;
32 - elif [ "$PATCH1" -lt "$PATCH2" ]; then
33 - return 0;
34 - elif [ "$PATCH1" -gt "$PATCH2" ]; then
35 - return 1;
36 - else
37 - return 0;
38 - fi
39 -}
40 -
41 -# If $1 is compatible with $2, return 1. Otherwise, return 0.
42 -
43 -is_compat ()
44 -{
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/'`
51 -
52 - if [ -z "$MAJOR1" -o -z "$MINOR1" -o -z "$PATCH1" -o -z "$MAJOR2" -o -z "$MINOR2" -o -z "$PATCH2" ]; then
53 - return 0;
54 - fi
55 -
56 - if [ "$MAJOR1" -eq "$MAJOR2" -a "$MINOR1" -eq "$MINOR2" ]; then
57 - return 1;
58 - else
59 - return 0;
60 - fi
61 -}
62 -
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
67
68 -install_libstdcpps ()
69 +install_gcc_libs ()
70 {
71 - GCCS=`find $1 -name bfin-linux-uclibc-gcc-* | tr '\n' ' '`
72 + pushd $1/lib/gcc/$2 > /dev/null
73
74 - while [ -n "$GCCS" ]; do
75 - GCCS2=""
76 - COMPAT_GCCS=""
77 - NEWEST_VERSION=""
78 - NEWEST_GCC=""
79 + # install the libraries from the latest version of the toolchain
80 + GCC_VER=$(echo * | tr ' ' '\n' | LC_ALL=C sort | tail -n 1)
81 + cd "${GCC_VER}"
82
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/'`
89 -
90 - if [ -z "$NEWEST_VERSION" ]; then
91 - NEWEST_VERSION=$LIBSTDCPP_VERSION
92 - NEWEST_GCC=$GCC
93 - COMPAT_GCCS=$GCC
94 - continue
95 - fi
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"
99
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"
107
108 - is_newer $LIBSTDCPP_VERSION $NEWEST_VERSION
109 - if [ $? -eq 1 ]; then
110 - NEWEST_VERSION=$LIBSTDCPP_VERSION
111 - NEWEST_GCC=$GCC
112 - fi
113 - else
114 - GCCS2="$GCCS2 $GCC"
115 - fi
116 - done
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}
122 + fi
123
124 - echo "Installing shared libstdc++ from $NEWEST_GCC"
125 -
126 - MULTILIBS=`$NEWEST_GCC --print-multi-lib`
127 -
128 - for ml in $MULTILIBS; do
129 -
130 - dir=`echo ${ml} | sed -e 's/;.*$//'`
131 - flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`
132 - if [ "$dir" = "." ]; then
133 - dir2=
134 - else
135 - dir2=`echo ${dir} | sed -e 's|[^/]*|..|g'`/
136 - fi
137 -
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/'`
144 -
145 - cp $LIBSTDCPP $1/$2/runtime/$dir/lib
146 - ln -s $LIBSTDCPP_NAME $1/$2/runtime/$dir/lib/libstdc++.so.$MAJOR_NUM
147 -
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
152 - done
153 -
154 - done
155 -
156 - GCCS=$GCCS2
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}
161 done
162 -}
163
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
168 -
169 -install_libgccs ()
170 -{
171 - GCCS=`find $1 -name bfin-linux-uclibc-gcc-* | tr '\n' ' '`
172 -
173 - NEWEST_VERSION=""
174 - NEWEST_GCC=""
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`
179 -
180 - if [ -z "$NEWEST_VERSION" ]; then
181 - NEWEST_VERSION=$GCC_VERSION
182 - NEWEST_GCC=$GCC
183 - continue
184 - fi
185 -
186 - is_newer $GCC_VERSION $NEWEST_VERSION
187 - if [ $? -eq 1 ]; then
188 - NEWEST_VERSION=$GCC_VERSION
189 - NEWEST_GCC=$GCC
190 - fi
191 - done
192 -
193 - echo "Installing libgcc_s from $NEWEST_GCC"
194 -
195 - MULTILIBS=`$NEWEST_GCC --print-multi-lib`
196 -
197 - for ml in $MULTILIBS; do
198 -
199 - dir=`echo ${ml} | sed -e 's/;.*$//'`
200 - flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`
201 -
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`
205 - fi
206 - if [ ! -e $LIBGCC ]; then
207 - echo "No libgcc_s.so for $NEWEST_GCC - report an error"
208 - tail -10 $ACTUAL_LOGFILE
209 - exit 1
210 - fi
211 -
212 - LIBGCC=`readlink -f $LIBGCC`
213 - LIBGCC_DIR=`dirname $LIBGCC`
214 - LIBGCC_NAME=`basename $LIBGCC`
215 -
216 - cp $LIBGCC $1/$2/runtime/$dir/lib
217 -
218 - for G in $GCCS; do
219 - L=`$G $flags --print-file-name=libgcc_s_$dir.so`
220 - dir2=
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'`/
225 - fi
226 - fi
227 - rm -f $L*
228 - ln -s ../../../../$dir2$2/runtime/$dir/lib/$LIBGCC_NAME $L
229 - done
230 - done
231 + popd > /dev/null
232 }
233
234 run_tests ()
235 @@ -1667,8 +1503,7 @@
236 done
237 rm -f $DIR_LINUX_OUTPUT/bfin-linux-uclibc/sys-include
238
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
242
243 ##################### Test bfin-linux-uclibc #####################
244