source: scripts/scripts/native-scripts/native-gcc.sh@ e0507947

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since e0507947 was e0507947, checked in by Jim Gifford <clfs@…>, 19 years ago

r2503@server (orig r1242): ryan | 2006-03-10 02:06:12 -0800

r1292@rei: lfs | 2006-03-07 20:00:23 +1100
gcc build script updates for gcc-4.1.0


  • Property mode set to 100755
File size: 9.5 KB
Line 
1#!/bin/bash
2
3# cross-lfs native gcc build
4# --------------------------
5# $LastChangedBy$
6# $LastChangedDate$
7# $LastChangedRevision$
8# $HeadURL$
9#
10
11cd ${SRC}
12
13LOG="gcc-native.log"
14
15set_libdirname
16setup_multiarch
17
18unpack_tarball gcc-${GCC_VER}
19
20if [ ! "${libdirname}" = "lib" ]; then
21 extra_conf="--libdir=/usr/${libdirname}"
22fi
23
24#3.0 20030427
25# Cannot trust ${GCC_VER} to supply us with the correct
26# gcc version (especially if cvs).
27# Grab it straight from version.c
28cd ${SRC}/${PKGDIR}
29target_gcc_ver=`grep version_string gcc/version.c | \
30 sed 's@.* = \(\|"\)\([0-9.]*\).*@\2@g'`
31# As of gcc4, the above doesn't cut it... check gcc/BASE-VER
32if [ -z "${target_gcc_ver}" -a -f gcc/BASE-VER ]; then
33 target_gcc_ver=`cat gcc/BASE-VER`
34fi
35
36# if target has no floating point unit, use soft float
37if [ "${WITHOUT_FPU}" = "Y" ]; then
38 extra_conf="${extra_conf} --with-float=soft"
39fi
40
41if [ ! "Y" = "${MULTIARCH}" ]; then
42 # If we are not multi-arch, disable multilib
43 extra_conf="${extra_conf} --enable-multilib=no"
44
45 # HACK: this sets abi to n32 with mips... this should be handled
46 # by the multiarch funcs somehow... and set according to DEFAULTENV
47 case ${TGT_ARCH} in
48 mips* )
49 extra_conf="${extra_conf} --with-abi=${DEFAULTENV}"
50 ;;
51 esac
52fi
53
54# if we are using gcc-3.4x, set libexecdir to /usr/${libdirname}
55case ${target_gcc_ver} in
56 3.4* | 4.* )
57 extra_conf="${extra_conf} --libexecdir=/usr/${libdirname}"
58 ;;
59esac
60
61# Set in build-init to enable version specific runtime libs, and whether
62# to use a program suffix
63if [ "Y" = "${USE_VER_SPEC_RT_LIBS}" ]; then
64 extra_conf="${extra_conf} --enable-version-specific-runtime-libs" ; fi
65if [ "Y" = "${USE_PROGRAM_SUFFIX}" ]; then
66 extra_conf="${extra_conf} --program-suffix=-${target_gcc_ver}" ; fi
67
68cd ${SRC}/${PKGDIR}
69case ${target_gcc_ver} in
70 3.4.3 )
71 # Apply linkonce patch for gcc (should be fixed come gcc 3.4.4)
72 apply_patch gcc-3.4.3-linkonce-1
73 # Remove library search paths that cause issues with libtool on
74 # multi-arch systems
75 # TODO: check to see if this applies to ealier gcc versions, and
76 # decide if this should only be applied if doing a multi-archi
77 # build
78 apply_patch gcc-3.4.3-remove_standard_startfile_prefix_from_startfile_prefixes-1
79
80 # Arm fixes
81 apply_patch gcc-3.4.0-arm-bigendian
82 apply_patch gcc-3.4.0-arm-nolibfloat
83 apply_patch gcc-3.4.0-arm-lib1asm
84 ;;
85 4.0.0 )
86 apply_patch gcc-4.0.0-fix_tree_optimisation_PR21173
87 apply_patch gcc-4.0.0-reload_check_uninitialized_pseudos_PR20973
88 apply_patch gcc-4.0.0-remove_standard_startfile_prefix_from_startfile_prefixes-1
89 ;;
90 4.0.* | 4.1.* )
91 apply_patch gcc-4.0.0-remove_standard_startfile_prefix_from_startfile_prefixes-1
92 ;;
93esac
94
95
96# Dont run fixincludes
97# ( Following mimics the nofixincludes patch )
98# NOTE: This needs to be fixed for gcc4
99# Also avoid debug symbols in libgcc2
100cd ${SRC}/${PKGDIR}/gcc
101
102test -f Makefile.in-ORIG ||
103 cp Makefile.in Makefile.in-ORIG
104
105#grep -Ev '(README| ./fixinc.sh )' Makefile.in-ORIG | \
106sed 's@LIBGCC2_DEBUG_CFLAGS = -g@LIBGCC2_DEBUG_CFLAGS =@g' Makefile.in-ORIG \
107 > Makefile.in
108
109# Problems arise when building 64bit libgcc_s during a multilib
110# build if the 64bit crt objects reside under */lib64 as
111# -B${HST_TOOLS}/${TARGET}/lib is passed during the build causing
112# us to link in the 32bit crt objects.,
113# This is because -B*/lib overrides the specs file so the multilib
114# spec isnt used to determine lib dir.
115# Here we just remove -B*/lib from FLAGS_FOR_TARGET.
116#
117# NOTE: for gcc-3.3.3 all we had do edit was configure.in,
118# FLAGS_FOR_TARGET was only specified here.
119# As of gcc-3.4.0 we need to edit configure itself.
120# So, we'll just attempt to edit both
121
122cd ${SRC}/${PKGDIR}
123for file in configure configure.in; do
124 grep FLAGS_FOR_TARGET ${file} > /dev/null 2>&1 &&
125 {
126 # copy instead of move, we will want to retain perms
127 test -f ${file}-ORIG ||
128 cp -p ${file} ${file}-ORIG
129
130 sed '/FLAGS_FOR_TARGET.*\/lib\//s@-B[^ ]*/lib/@@g' \
131 ${file}-ORIG > ${file}
132 }
133done
134
135test -d ${SRC}/gcc-${GCC_VER}-native &&
136 rm -rf ${SRC}/gcc-${GCC_VER}-native
137
138mkdir -p ${SRC}/gcc-${GCC_VER}-native &&
139cd ${SRC}/gcc-${GCC_VER}-native &&
140
141max_log_init Gcc ${GCC_VER} native ${CONFLOGS} ${LOG}
142CC="${CC-gcc} ${ARCH_CFLAGS}" \
143CXX="${CXX-g++} ${ARCH_CFLAGS}" \
144CFLAGS="-O2 -pipe ${TGT_CFLAGS}" \
145CXXFLAGS="-O2 -pipe ${TGT_CFLAGS}" \
146../${PKGDIR}/configure --prefix=/usr \
147 --host=${TARGET} \
148 --enable-languages=c,c++ --enable-__cxa_atexit \
149 --enable-c99 --enable-long-long --enable-threads=posix \
150 --enable-shared ${extra_conf} \
151 --mandir=/usr/share/man \
152 --infodir=/usr/share/info \
153 >> ${LOGFILE} 2>&1 &&
154echo " o Configure OK" || barf
155# --enable-languages=c,c++,f77,objc,ada,java,pascal,treelang --enable-__cxa_atexit \
156
157min_log_init ${BUILDLOGS} &&
158if [ "Y" = "${NOBOOTSTRAP}" ]; then
159 make ${PMFLAGS} LDFLAGS="-s" \
160 >> ${LOGFILE} 2>&1
161else
162 make ${PMFLAGS} BOOT_LDFLAGS="-s" BOOT_CFLAGS="-O2 -pipe ${TGT_CFLAGS}" \
163 STAGE1_CFLAGS="-O2 -pipe ${TGT_CFLAGS}" bootstrap \
164 >> ${LOGFILE} 2>&1
165fi &&
166echo " o Build OK" || barf
167
168min_log_init ${TESTLOGS} &&
169make -k check \
170 >> ${LOGFILE} 2>&1 &&
171echo " o Test OK" || errmsg
172
173min_log_init ${INSTLOGS} &&
174make install \
175 >> ${LOGFILE} 2>&1 &&
176echo " o Install OK" || barf
177
178#3.0 20030503
179# Create symlinks if we chose to add a version suffix
180if [ "Y" = "${USE_PROGRAM_SUFFIX}" ]; then
181 for prog in c++ c++filt cpp g++ gcc gccbug gcov ; do
182 if [ -f /usr/bin/${prog}-${target_gcc_ver} ]; then
183 echo " o Creating ${prog} -> ${prog}-${target_gcc_ver} symlink..."
184 ln -sf ${prog}-${target_gcc_ver} /usr/bin/${prog}
185 fi
186 done
187 for prog in gcc g++ c++ ; do
188 if [ -f /usr/bin/${TARGET}-${prog}-${target_gcc_ver} ]; then
189 echo " o Creating ${TARGET}-${prog} -> ${TARGET}-${prog}-${target_gcc_ver} symlink ..."
190 ln -sf ${TARGET}-${prog}-${target_gcc_ver} \
191 /usr/bin/${TARGET}-${prog}
192 fi
193 done
194fi # USE_PROGRAM_SUFFIX
195
196ln -s ../usr/bin/cpp /lib &&
197ln -sf gcc /usr/bin/cc
198rm /usr/${libdirname}/libiberty.a
199
200# Following req'd when using --enable-version-specific-runtime-libs
201if [ Y = "${USE_VER_SPEC_RT_LIBS}" ]; then
202 # TODO: BIG TODO HERE
203 # MAKE THIS HANDLE "libdirname"
204 # -----------------------------
205 # look into gcc_libdir/../lib/libdirname symlinks for multiarch
206 # This is appropriate for x86_64, bit others need to be checked...
207 # We will also in the future want to modify these default gcc .so
208 # install directories
209 #
210
211 gcc_libdir=`/usr/bin/gcc --print-file-name include | \
212 sed 's@include@@g'`
213
214 # Better make a symlink for the c++ includes
215 mkdir /usr/include/c++
216 ln -s ${gcc_libdir}/include/c++ /usr/include/c++/${target_gcc_ver}
217
218 # Add the path to our new c++ libs in /etc/ld.so.conf
219 echo "${gcc_libdir}" >> /etc/ld.so.conf
220 if [ Y = "${MULTIARCH}" ]; then
221 echo "${gcc_libdir}/32" >> /etc/ld.so.conf
222 fi
223
224 # TODO: choose whether to just delete existing libgcc_s.so links pointing to
225 # ${TOOLS} or just create the following over the top
226
227 # Create hardlink and symlinks for libgcc_s in /usr/lib
228 case ${target_gcc_ver} in
229 3.4* | 4.* )
230 if [ Y = "${MULTIARCH}" ]; then
231 # 32bit libs
232 ln -f ${gcc_libdir}/../lib/libgcc_s.so.1 \
233 /usr/lib/libgcc_s-${target_gcc_ver}.so.1
234 ln -sf libgcc_s-${target_gcc_ver}.so.1 \
235 /usr/lib/libgcc_s.so.1
236 ln -sf libgcc_s.so.1 /usr/lib/libgcc_s_32.so
237 ln -sf libgcc_s.so.1 /usr/lib/libgcc_s.so
238 # 64bit libs
239 ln -f ${gcc_libdir}/../lib64/libgcc_s.so.1 \
240 /usr/lib64/libgcc_s-${target_gcc_ver}.so.1
241 ln -sf libgcc_s-${target_gcc_ver}.so.1 \
242 /usr/lib64/libgcc_s.so.1
243 ln -sf libgcc_s.so.1 /usr/lib64/libgcc_s.so
244 else
245 ln -f ${gcc_libdir}/../lib/libgcc_s.so.1 \
246 /usr/lib/libgcc_s-${target_gcc_ver}.so.1
247 ln -sf libgcc_s-${target_gcc_ver}.so.1 /usr/lib/libgcc_s.so.1
248 ln -sf libgcc_s.so.1 /usr/lib/libgcc_s.so
249 fi
250 ;;
251 * )
252 # TODO: Have to check this for gcc < 3.4
253 ln -f ${gcc_libdir}/libgcc_s.so.1 \
254 /usr/${libdirname}/libgcc_s-${target_gcc_ver}.so.1
255 if [ Y = "${MULTIARCH}" ]; then
256 # 32bit libs
257 ln -f ${gcc_libdir}/32/libgcc_s.so.1 \
258 /usr/lib/libgcc_s-${target_gcc_ver}.so.1
259 ln -sf libgcc_s-${target_gcc_ver}.so.1 \
260 /usr/lib/libgcc_s.so.1
261 ln -sf libgcc_s.so.1 /usr/lib/libgcc_s_32.so
262 ln -sf libgcc_s.so.1 /usr/lib/libgcc_s.so
263 # 64bit libs
264 ln -f ${gcc_libdir}/libgcc_s.so.1 \
265 /usr/lib64/libgcc_s-${target_gcc_ver}.so.1
266 ln -sf libgcc_s-${target_gcc_ver}.so.1 \
267 /usr/lib64/libgcc_s.so.1
268 ln -sf libgcc_s.so.1 /usr/lib64/libgcc_s.so
269 else
270 ln -f ${gcc_libdir}/libgcc_s.so.1 \
271 /usr/lib/libgcc_s-${target_gcc_ver}.so.1
272 ln -sf libgcc_s-${target_gcc_ver}.so.1 \
273 /usr/lib/libgcc_s.so.1
274 ln -sf libgcc_s.so.1 /usr/lib/libgcc_s.so
275 fi
276 ;;
277 esac
278
279fi
Note: See TracBrowser for help on using the repository browser.