1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # cross-lfs cross-gcc w shared libgcc build
|
---|
4 | # -----------------------------------------
|
---|
5 | # $LastChangedBy$
|
---|
6 | # $LastChangedDate$
|
---|
7 | # $LastChangedRevision$
|
---|
8 | # $HeadURL$
|
---|
9 | #
|
---|
10 |
|
---|
11 | cd ${SRC}
|
---|
12 |
|
---|
13 | LOG="gcc-cross-shared.log"
|
---|
14 |
|
---|
15 | if [ "Y" = "${MULTIARCH}" ]; then
|
---|
16 |
|
---|
17 | vendor_os=`echo ${TARGET} | sed 's@\([^-]*\)-\(.*\)@\2@'`
|
---|
18 |
|
---|
19 | case ${TGT_ARCH} in
|
---|
20 | x86_64 )
|
---|
21 | ;;
|
---|
22 | sparc* )
|
---|
23 | TARGET=sparc64-${vendor_os}
|
---|
24 | ;;
|
---|
25 | powerpc* | ppc* )
|
---|
26 | TARGET=powerpc64-${vendor_os}
|
---|
27 | ;;
|
---|
28 | s390* )
|
---|
29 | TARGET=s390x-${vendor_os}
|
---|
30 | ;;
|
---|
31 | mips*el* )
|
---|
32 | TARGET=mips64el-${vendor_os}
|
---|
33 | ;;
|
---|
34 | * )
|
---|
35 | # TODO: add some error messages etc
|
---|
36 | barf
|
---|
37 | ;;
|
---|
38 | esac
|
---|
39 |
|
---|
40 | else
|
---|
41 | # If we are not bi-arch, disable multilib
|
---|
42 | extra_conf="--enable-multilib=no"
|
---|
43 |
|
---|
44 | # HACK: this sets abi to n32 with mips... this should be handled
|
---|
45 | # by the multiarch funcs somehow... and set according to DEFAULTENV
|
---|
46 | case ${TGT_ARCH} in
|
---|
47 | mips* )
|
---|
48 | extra_conf="${extra_conf} --with-abi=${DEFAULTENV}"
|
---|
49 | ;;
|
---|
50 | esac
|
---|
51 | fi
|
---|
52 |
|
---|
53 | # if target is same as build host, adjust host slightly to
|
---|
54 | # trick configure so we do not produce native tools
|
---|
55 | if [ "${TARGET}" = "${BUILD}" ]; then
|
---|
56 | # extra_conf="--host=${BUILD}x"
|
---|
57 | althost=`echo ${BUILD} | sed 's@\([_a-zA-Z0-9]*\)\(-[_a-zA-Z0-9]*\)\(.*\)@\1\2x\3@'`
|
---|
58 | extra_conf="--host=${althost} ${extra_conf}"
|
---|
59 | fi
|
---|
60 |
|
---|
61 | # if target has no floating point unit, use soft float
|
---|
62 | if [ "${WITHOUT_FPU}" = "Y" ]; then
|
---|
63 | extra_conf="${extra_conf} --with-float=soft"
|
---|
64 | fi
|
---|
65 |
|
---|
66 | unpack_tarball gcc-${GCC_VER}
|
---|
67 |
|
---|
68 | #3.0 20030427
|
---|
69 | # Cannot trust ${GCC_VER} to supply us with the correct
|
---|
70 | # gcc version (especially if cvs).
|
---|
71 | # Grab it straight from version.c
|
---|
72 | cd ${SRC}/${PKGDIR}
|
---|
73 | target_gcc_ver=`grep version_string gcc/version.c | \
|
---|
74 | sed 's@.* = \(\|"\)\([0-9.]*\).*@\2@g'`
|
---|
75 | # As of gcc4, the above doesn't cut it... check gcc/BASE-VER
|
---|
76 | if [ -z "${target_gcc_ver}" -a -f gcc/BASE-VER ]; then
|
---|
77 | target_gcc_ver=`cat gcc/BASE-VER`
|
---|
78 | fi
|
---|
79 |
|
---|
80 | # Apply linkonce patch for gcc (should be fixed come gcc 3.4.4)
|
---|
81 | cd ${SRC}/${PKGDIR}
|
---|
82 | case ${target_gcc_ver} in
|
---|
83 | 3.4.3 )
|
---|
84 | apply_patch gcc-3.4.3-linkonce-1
|
---|
85 | apply_patch gcc-3.4.0-arm-bigendian
|
---|
86 | apply_patch gcc-3.4.0-arm-nolibfloat
|
---|
87 | apply_patch gcc-3.4.0-arm-lib1asm
|
---|
88 | apply_patch gcc-3.4.3-clean_exec_and_lib_search_paths_when_cross-1
|
---|
89 | ;;
|
---|
90 | 4.0.0 )
|
---|
91 | apply_patch gcc-4.0.0-fix_tree_optimisation_PR21173
|
---|
92 | apply_patch gcc-4.0.0-reload_check_uninitialized_pseudos_PR20973
|
---|
93 | apply_patch gcc-4.0.0-clean_exec_and_lib_search_paths_when_cross-1
|
---|
94 | ;;
|
---|
95 | 4.0.* | 4.1.* )
|
---|
96 | apply_patch gcc-4.0.0-clean_exec_and_lib_search_paths_when_cross-1
|
---|
97 | ;;
|
---|
98 | esac
|
---|
99 |
|
---|
100 | # if we are using gcc-3.4x, set libexecdir to */${libdirname}
|
---|
101 | case ${target_gcc_ver} in
|
---|
102 | 3.4* | 4.* )
|
---|
103 | extra_conf="${extra_conf} --libexecdir=${HST_TOOLS}/${libdirname}"
|
---|
104 | ;;
|
---|
105 | esac
|
---|
106 |
|
---|
107 | if [ "${USE_SYSROOT}" = "Y" ]; then
|
---|
108 | extra_conf="${extra_conf} --with-sysroot=${LFS}"
|
---|
109 | else
|
---|
110 | # LFS style build
|
---|
111 | #----------------
|
---|
112 |
|
---|
113 | # source functions for required gcc modifications
|
---|
114 | . ${SCRIPTS}/funcs/cross_gcc-funcs.sh
|
---|
115 |
|
---|
116 | # Alter the generated specs file to
|
---|
117 | # o set dynamic linker to be under ${TGT_TOOLS}/lib{,32,64}
|
---|
118 | # o set startfile_prefix_spec so we search for startfiles
|
---|
119 | # under ${TGT_TOOLS}/lib/lib{,32,64}
|
---|
120 | gcc_specs_mod
|
---|
121 |
|
---|
122 | # Set cpp's default include search path, and the header search path
|
---|
123 | # used by fixincludes to be ${TGT_TOOLS}/include
|
---|
124 | cpp_set_cross_system_header_dir
|
---|
125 |
|
---|
126 | # fix configure so that shared libgcc gets built against the correct
|
---|
127 | # startfiles if the user sets ${TGT_TOOLS} = ${HOST_TOOLS}/${TARGET}
|
---|
128 | configure_fix_flags_for_target
|
---|
129 | fi
|
---|
130 |
|
---|
131 |
|
---|
132 | # The following needs to be done if we are configuring gcc without
|
---|
133 | # --disable-shared
|
---|
134 | # We need to Strip "-lc" from the shared libs list. We don't have libc yet...
|
---|
135 | # Altered files are
|
---|
136 | # gcc/config/t-slibgcc-elf-ver and
|
---|
137 | # gcc/config/t-libunwind (for ia64)
|
---|
138 | #
|
---|
139 | cd ${SRC}/${PKGDIR}/gcc
|
---|
140 | for file in config/t-slibgcc-elf-ver config/t-libunwind; do
|
---|
141 | test -f ${file}-ORIG ||
|
---|
142 | mv ${file} ${file}-ORIG
|
---|
143 | sed '/^SHLIB_LC = /s@-lc@@' ${file}-ORIG > ${file}
|
---|
144 | done
|
---|
145 |
|
---|
146 | test -d ${SRC}/gcc-${GCC_VER}-cross-shared &&
|
---|
147 | rm -rf ${SRC}/gcc-${GCC_VER}-cross-shared
|
---|
148 |
|
---|
149 | mkdir -p ${SRC}/gcc-${GCC_VER}-cross-shared &&
|
---|
150 | cd ${SRC}/gcc-${GCC_VER}-cross-shared &&
|
---|
151 |
|
---|
152 | # NOTE:
|
---|
153 | # Some errors occur on solaris where bash syntax is used with a
|
---|
154 | # standard /bin/sh ( ie: expecting $(command) to be evaluated )
|
---|
155 | # To avoid this issue we override make's default shell with
|
---|
156 | # /bin/bash
|
---|
157 | # This is done via passing CONFIG_SHELL=/bin/bash to
|
---|
158 | # configure, which uses this when it specifies SHELL in
|
---|
159 | # the Makefiles.
|
---|
160 |
|
---|
161 | max_log_init Gcc ${GCC_VER} cross-pt2 ${CONFLOGS} ${LOG}
|
---|
162 | #CONFIG_SHELL=/bin/bash \
|
---|
163 | CFLAGS="-O2 ${HOST_CFLAGS} -pipe" \
|
---|
164 | ../${PKGDIR}/configure --prefix=${HST_TOOLS} \
|
---|
165 | --target=${TARGET} ${extra_conf} \
|
---|
166 | --with-local-prefix=${TGT_TOOLS} --enable-languages=c \
|
---|
167 | --disable-nls --enable-shared \
|
---|
168 | >> ${LOGFILE} 2>&1 &&
|
---|
169 | echo " o Configure OK" || barf
|
---|
170 |
|
---|
171 | min_log_init ${BUILDLOGS} &&
|
---|
172 | #make ${PMFLAGS} BOOT_CFLAGS="-O2 ${HOST_CFLAGS} -pipe" \
|
---|
173 | # STAGE1_CFLAGS="-O ${HOST_CFLAGS} -pipe" all-gcc \
|
---|
174 | make ${PMFLAGS} CFLAGS_FOR_TARGET="-O2 -pipe ${TGT_CFLAGS}" all-gcc \
|
---|
175 | >> ${LOGFILE} 2>&1 &&
|
---|
176 | echo " o Build OK" || barf
|
---|
177 |
|
---|
178 | min_log_init ${INSTLOGS} &&
|
---|
179 | make install-gcc \
|
---|
180 | >> ${LOGFILE} 2>&1 &&
|
---|
181 | echo " o Install OK" || barf
|
---|
182 |
|
---|