Rework the eglibc download so as to be a little bit saner.
/trunk/scripts/build/libc/eglibc.sh | 25 15 10 0 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
1 # This file adds the function to build the gcc C compiler
3 # Copyright 2007 Yann E. MORIN
4 # Licensed under the GPL v2. See COPYING in the root of this package
7 [ "${CT_CC}" = "gcc" ] || return 0
8 echo "gcc-${CT_CC_VERSION}"
13 # Ah! gcc folks are kind of 'different': they store the tarballs in
14 # subdirectories of the same name! That's because gcc is such /crap/ that
15 # it is such /big/ that it needs being splitted for distribution! Sad. :-(
16 # Arrgghh! Some of those versions does not follow this convention:
17 # gcc-3.3.3 lives in releases/gcc-3.3.3, while gcc-2.95.* isn't in a
18 # subdirectory! You bastard!
19 CT_GetFile "${CT_CC_FILE}" \
20 {ftp,http}://ftp.gnu.org/gnu/gcc{,{,/releases}/${CT_CC_FILE}}
25 CT_ExtractAndPatch "${CT_CC_FILE}"
28 #------------------------------------------------------------------------------
31 # If we're building for bare metal, build the static core gcc,
33 # In case we're not bare metal, and we're NPTL, build the static core gcc.
34 # In any other case, do nothing.
35 case "${CT_BARE_METAL},${CT_THREADS}" in
36 y,*) do_cc_core mode=baremetal build_libgcc=yes;;
37 ,nptl) do_cc_core mode=static build_libgcc=no;;
44 # In case we're building for bare metal, do nothing, we already have
46 # In case we're NPTL, build the shared core gcc.
47 # In any other case, build the static core gcc and the target libgcc.
48 case "${CT_BARE_METAL},${CT_THREADS}" in
50 ,nptl) do_cc_core mode=shared build_libgcc=yes;;
51 *) do_cc_core mode=static build_libgcc=yes;;
55 #------------------------------------------------------------------------------
57 # This function is used to build both the static and the shared core C conpiler,
58 # with or without the target libgcc. We need to know wether:
59 # - we're building static, shared or bare metal: mode=[static|shared|baremetal]
60 # - we need to build libgcc or not : build_libgcc=[yes|no]
61 # Usage: do_cc_core_static mode=[static|shared|baremetal] build_libgcc=[yes|no]
70 CT_TestOrAbort "Internal Error: 'mode' must either 'static', 'shared' or 'baremetal', not '${mode:-(empty)}'" "${mode}" = "static" -o "${mode}" = "shared" -o "${mode}" = "baremetal"
71 CT_TestOrAbort "Internal Error: 'build_libgcc' must be either 'yes' or 'no', not '${build_libgcc:-(empty)}'" "${build_libgcc}" = "yes" -o "${build_libgcc}" = "no"
72 # In normal conditions, ( "${mode}" = "shared" ) implies
73 # ( "${build_libgcc}" = "yes" ), but I won't check for that
75 mkdir -p "${CT_BUILD_DIR}/build-cc-core-${mode}"
76 cd "${CT_BUILD_DIR}/build-cc-core-${mode}"
78 CT_DoStep INFO "Installing ${mode} core C compiler"
81 core_prefix_dir="${CT_CC_CORE_STATIC_PREFIX_DIR}"
82 extra_config="${extra_config} --with-newlib --enable-threads=no --disable-shared"
86 core_prefix_dir="${CT_CC_CORE_SHARED_PREFIX_DIR}"
87 extra_config="${extra_config} --enable-shared"
91 core_prefix_dir="${CT_PREFIX_DIR}"
92 extra_config="${extra_config} --with-newlib --enable-threads=no --disable-shared"
97 if [ "${copy_headers}" = "y" ]; then
98 CT_DoLog DEBUG "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
99 CT_DoExecLog ALL mkdir -p "${core_prefix_dir}/${CT_TARGET}/include"
100 CT_DoExecLog ALL cp -r "${CT_HEADERS_DIR}"/* "${core_prefix_dir}/${CT_TARGET}/include"
103 CT_DoLog EXTRA "Configuring ${mode} core C compiler"
105 extra_config="${extra_config} ${CT_ARCH_WITH_ARCH}"
106 extra_config="${extra_config} ${CT_ARCH_WITH_ABI}"
107 extra_config="${extra_config} ${CT_ARCH_WITH_CPU}"
108 extra_config="${extra_config} ${CT_ARCH_WITH_TUNE}"
109 extra_config="${extra_config} ${CT_ARCH_WITH_FPU}"
110 extra_config="${extra_config} ${CT_ARCH_WITH_FLOAT}"
111 [ "${CT_GMP_MPFR}" = "y" ] && extra_config="${extra_config} --with-gmp=${CT_PREFIX_DIR} --with-mpfr=${CT_PREFIX_DIR}"
112 if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then
113 extra_config="${extra_config} --enable-__cxa_atexit"
115 extra_config="${extra_config} --disable-__cxa_atexit"
118 CT_DoLog DEBUG "Extra config passed: '${extra_config}'"
120 # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532)
121 CC_FOR_BUILD="${CT_CC_NATIVE}" \
122 CFLAGS="${CT_CFLAGS_FOR_HOST}" \
124 "${CT_SRC_DIR}/${CT_CC_FILE}/configure" \
127 --target=${CT_TARGET} \
128 --prefix="${core_prefix_dir}" \
129 --with-local-prefix="${CT_SYSROOT_DIR}" \
131 ${CC_CORE_SYSROOT_ARG} \
134 --enable-symvers=gnu \
135 --enable-languages=c \
136 --enable-target-optspace \
137 ${CT_CC_CORE_EXTRA_CONFIG}
139 if [ "${build_libgcc}" = "yes" ]; then
140 # HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver or
141 # gcc/config/t-libunwind so -lc is removed from the link for
142 # libgcc_s.so, as we do not have a target -lc yet.
143 # This is not as ugly as it appears to be ;-) All symbols get resolved
144 # during the glibc build, and we provide a proper libgcc_s.so for the
145 # cross toolchain during the final gcc build.
147 # As we cannot modify the source tree, nor override SHLIB_LC itself
148 # during configure or make, we have to edit the resultant
149 # gcc/libgcc.mk itself to remove -lc from the link.
150 # This causes us to have to jump through some hoops...
152 # To produce libgcc.mk to edit we firstly require libiberty.a,
153 # so we configure then build it.
154 # Next we have to configure gcc, create libgcc.mk then edit it...
155 # So much easier if we just edit the source tree, but hey...
156 if [ ! -f "${CT_SRC_DIR}/${CT_CC_FILE}/gcc/BASE-VER" ]; then
157 CT_DoExecLog ALL make configure-libiberty
158 CT_DoExecLog ALL make ${PARALLELMFLAGS} -C libiberty libiberty.a
159 CT_DoExecLog ALL make configure-gcc configure-libcpp
160 CT_DoExecLog ALL make ${PARALLELMFLAGS} all-libcpp
162 CT_DoExecLog ALL make configure-gcc configure-libcpp configure-build-libiberty
163 CT_DoExecLog ALL make ${PARALLELMFLAGS} all-libcpp all-build-libiberty
165 # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here.
166 if [ -d "${CT_SRC_DIR}/${CT_CC_FILE}/libdecnumber" ]; then
167 CT_DoExecLog ALL make configure-libdecnumber
168 CT_DoExecLog ALL make ${PARALLELMFLAGS} -C libdecnumber libdecnumber.a
171 # Starting with GCC 4.3, libgcc.mk is no longer built,
172 # and libgcc.mvars is used instead.
174 gcc_version_major=$(echo ${CT_CC_VERSION} |sed -r -e 's/^([^\.]+)\..*/\1/')
175 gcc_version_minor=$(echo ${CT_CC_VERSION} |sed -r -e 's/^[^\.]+\.([^.]+).*/\1/')
177 if [ ${gcc_version_major} -eq 4 -a ${gcc_version_minor} -ge 3 \
178 -o ${gcc_version_major} -gt 4 ]; then
179 libgcc_rule="libgcc.mvars"
180 build_rules="all-gcc all-target-libgcc"
181 install_rules="install-gcc install-target-libgcc"
183 libgcc_rule="libgcc.mk"
184 build_rules="all-gcc"
185 install_rules="install-gcc"
188 CT_DoExecLog ALL make ${PARALLELMFLAGS} -C gcc ${libgcc_rule}
189 sed -r -i -e 's@-lc@@g' gcc/${libgcc_rule}
191 build_rules="all-gcc"
192 install_rules="install-gcc"
195 if [ "${CT_CANADIAN}" = "y" ]; then
196 CT_DoLog EXTRA "Building libiberty"
197 CT_DoExecLog ALL make ${PARALLELMFLAGS} all-build-libiberty
200 CT_DoLog EXTRA "Building ${mode} core C compiler"
201 CT_DoExecLog ALL make ${PARALLELMFLAGS} ${build_rules}
203 CT_DoLog EXTRA "Installing ${mode} core C compiler"
204 CT_DoExecLog ALL make ${install_rules}
209 #------------------------------------------------------------------------------
212 # If building for bare metal, nothing to be done here, the static core conpiler is enough!
213 [ "${CT_BARE_METAL}" = "y" ] && return 0
215 CT_DoStep INFO "Installing final compiler"
217 mkdir -p "${CT_BUILD_DIR}/build-cc"
218 cd "${CT_BUILD_DIR}/build-cc"
220 CT_DoLog EXTRA "Configuring final compiler"
222 # Enable selected languages
224 [ "${CT_CC_LANG_CXX}" = "y" ] && lang_opt="${lang_opt},c++"
225 [ "${CT_CC_LANG_FORTRAN}" = "y" ] && lang_opt="${lang_opt},fortran"
226 [ "${CT_CC_LANG_ADA}" = "y" ] && lang_opt="${lang_opt},ada"
227 [ "${CT_CC_LANG_JAVA}" = "y" ] && lang_opt="${lang_opt},java"
228 [ "${CT_CC_LANG_OBJC}" = "y" ] && lang_opt="${lang_opt},objc"
229 [ "${CT_CC_LANG_OBJCXX}" = "y" ] && lang_opt="${lang_opt},obj-c++"
230 CT_Test "Building ADA language is not yet supported. Will try..." "${CT_CC_LANG_ADA}" = "y"
231 CT_Test "Building Objective-C language is not yet supported. Will try..." "${CT_CC_LANG_OBJC}" = "y"
232 CT_Test "Building Objective-C++ language is not yet supported. Will try..." "${CT_CC_LANG_OBJCXX}" = "y"
233 CT_Test "Building ${CT_CC_LANG_OTHERS//,/ } language(s) is not yet supported. Will try..." -n "${CT_CC_LANG_OTHERS}"
234 lang_opt=$(echo "${lang_opt},${CT_CC_LANG_OTHERS}" |sed -r -e 's/,+/,/g; s/,*$//;')
236 extra_config="--enable-languages=${lang_opt}"
237 extra_config="${extra_config} --disable-multilib"
238 extra_config="${extra_config} ${CT_ARCH_WITH_ARCH}"
239 extra_config="${extra_config} ${CT_ARCH_WITH_ABI}"
240 extra_config="${extra_config} ${CT_ARCH_WITH_CPU}"
241 extra_config="${extra_config} ${CT_ARCH_WITH_TUNE}"
242 extra_config="${extra_config} ${CT_ARCH_WITH_FPU}"
243 extra_config="${extra_config} ${CT_ARCH_WITH_FLOAT}"
244 [ "${CT_SHARED_LIBS}" = "y" ] || extra_config="${extra_config} --disable-shared"
245 [ "${CT_GMP_MPFR}" = "y" ] && extra_config="${extra_config} --with-gmp=${CT_PREFIX_DIR} --with-mpfr=${CT_PREFIX_DIR}"
246 [ -n "${CT_CC_PKGVERSION}" ] && extra_config="${extra_config} --with-pkgversion=${CT_CC_PKGVERSION}"
247 [ -n "${CT_CC_BUGURL}" ] && extra_config="${extra_config} --with-bugurl=${CT_CC_BUGURL}"
248 [ "${CT_CC_SJLJ_EXCEPTIONS_USE}" = "y" ] && extra_config="${extra_config} --enable-sjlj-exceptions"
249 [ "${CT_CC_SJLJ_EXCEPTIONS_DONT_USE}" = "y" ] && extra_config="${extra_config} --disable-sjlj-exceptions"
250 if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then
251 extra_config="${extra_config} --enable-__cxa_atexit"
253 extra_config="${extra_config} --disable-__cxa_atexit"
256 CT_DoLog DEBUG "Extra config passed: '${extra_config}'"
258 # --enable-symvers=gnu really only needed for sh4 to work around a
259 # detection problem only matters for gcc-3.2.x and later, I think.
260 # --disable-nls to work around crash bug on ppc405, but also because
261 # embedded systems don't really need message catalogs...
262 CC_FOR_BUILD="${CT_CC_NATIVE}" \
263 CFLAGS="${CT_CFLAGS_FOR_HOST}" \
264 CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
265 CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
266 LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \
268 "${CT_SRC_DIR}/${CT_CC_FILE}/configure" \
270 --target=${CT_TARGET} --host=${CT_HOST} \
271 --prefix="${CT_PREFIX_DIR}" \
274 --with-local-prefix="${CT_SYSROOT_DIR}" \
276 --enable-threads=posix \
277 --enable-symvers=gnu \
280 --enable-target-optspace \
281 ${CT_CC_EXTRA_CONFIG}
283 if [ "${CT_CANADIAN}" = "y" ]; then
284 CT_DoLog EXTRA "Building libiberty"
285 CT_DoExecLog ALL make ${PARALLELMFLAGS} all-build-libiberty
288 CT_DoLog EXTRA "Building final compiler"
289 CT_DoExecLog ALL make ${PARALLELMFLAGS} all
291 CT_DoLog EXTRA "Installing final compiler"
292 CT_DoExecLog ALL make install
294 # Create a symlink ${CT_TARGET}-cc to ${CT_TARGET}-gcc to always be able
295 # to call the C compiler with the same, somewhat canonical name.
296 ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}"-{g,}cc 2>&1 |CT_DoLog ALL