|
|
|
@ -31,9 +31,12 @@ case "$xpkg" in |
|
|
|
pkg_gcc_version=${pkg_gcc_version%-cross-*} |
|
|
|
pkg_gcc_target="${pkg_gcc_cross}-unknown-linux-gnu" |
|
|
|
|
|
|
|
prefix=usr |
|
|
|
set_confopt |
|
|
|
|
|
|
|
var_append confopt " " "--target=$pkg_gcc_target" |
|
|
|
echo_status "Preparing to build a cross-gcc package for $pkg_gcc_cross." |
|
|
|
var_append INSTALL_WRAPPER_FILTER "|" 'sed -r "\,/share/(info|locale)/, d"' |
|
|
|
var_append INSTALL_WRAPPER_FILTER "|" 'sed -r "\,(/share/(info|locale)|/usr/(man|info)), d"' |
|
|
|
;; |
|
|
|
gcc?|gcc??) |
|
|
|
;; |
|
|
|
@ -43,254 +46,157 @@ case "$xpkg" in |
|
|
|
;; |
|
|
|
esac |
|
|
|
|
|
|
|
case "$pkg_gcc_version" in |
|
|
|
34|4*) |
|
|
|
gcc_lib_dir="gcc/${pkg_gcc_target}/${ver%%-*}" |
|
|
|
;; |
|
|
|
*) |
|
|
|
gcc_lib_dir="gcc-lib/${pkg_gcc_target}/${ver%%-*}" |
|
|
|
;; |
|
|
|
esac |
|
|
|
|
|
|
|
patchfiles="`ls $patchfiles $confdir/gcc$pkg_gcc_version/*.patch \ |
|
|
|
$confdir/gcc$pkg_gcc_version/*.patch.$arch 2>/dev/null | tr '\n' ' '`" |
|
|
|
$confdir/gcc$pkg_gcc_version/*.patch.$arch 2>/dev/null | tr '\n' ' '`" |
|
|
|
|
|
|
|
if [ $stagelevel -le 1 ]; then |
|
|
|
patchfiles="`ls $patchfiles $confdir/gcc$pkg_gcc_version/*.patch.cross \ |
|
|
|
$confdir/gcc$pkg_gcc_version/*.patch.cross.$arch 2>/dev/null | tr '\n' ' '`" |
|
|
|
patchfiles="`ls $patchfiles $confdir/gcc$pkg_gcc_version/*.patch.cross \ |
|
|
|
$confdir/gcc$pkg_gcc_version/*.patch.cross.$arch 2>/dev/null | tr '\n' ' '`" |
|
|
|
fi |
|
|
|
|
|
|
|
create_links() { |
|
|
|
for x ; do |
|
|
|
if [ -f "$root/$prefix/bin/$x-${pkg_gcc_version}" ] ; then |
|
|
|
rm -vf $root/$prefix/bin/$x |
|
|
|
ln -vs $x-${pkg_gcc_version} $root/$prefix/bin/$x |
|
|
|
fi |
|
|
|
x="${pkg_gcc_target}-$x" |
|
|
|
if [ -f $root/$prefix/bin/$x-${pkg_gcc_version} ] ; then |
|
|
|
rm -vf $root/$prefix/bin/$x |
|
|
|
ln -vs $x-${pkg_gcc_version} $root/$prefix/bin/$x |
|
|
|
fi |
|
|
|
done |
|
|
|
} |
|
|
|
|
|
|
|
genrockspecs() { |
|
|
|
# Hint for the reader: |
|
|
|
# The options are listed in _inverse_ order here. |
|
|
|
x="$base/build/$ROCKCFG_ID" |
|
|
|
tr '\n' '@' < specs | sed \ |
|
|
|
-e "s|@\\*link:@|@*link:@-L $x/usr/$arch_target/lib |" \ |
|
|
|
-e "s|@\\*link:@|@*link:@-L $x/usr/local/lib |" \ |
|
|
|
-e "s|@\\*link:@|@*link:@-L $x/usr/lib |" \ |
|
|
|
-e "s|@\\*link:@|@*link:@-L $x/lib |" \ |
|
|
|
-e "s|@\\*link:@|@*link:@-L $x/ROCK/tools.cross/$arch_target/lib |" \ |
|
|
|
-e "s|@\\*link:@|@*link:@-rpath-link $x/lib:$x/usr/lib |" \ |
|
|
|
-e "s|@\\*cpp:@|@*cpp:@-I $x/usr/$arch_target/include |" \ |
|
|
|
-e "s|@\\*cpp:@|@*cpp:@-I $x/usr/local/include |" \ |
|
|
|
-e "s|@\\*cpp:@|@*cpp:@-I $x/usr/include |" \ |
|
|
|
| tr '@' '\n' > specs.cross |
|
|
|
tr '\n' '@' < specs | sed \ |
|
|
|
-e "s|@\\*link_libgcc:@|@*link_libgcc:@-L /ROCK/tools.cross/$arch_target/lib |" \ |
|
|
|
-e "s|@\\*link_libgcc:@|@*link_libgcc:@-L /usr/$arch_target/lib |" \ |
|
|
|
-e "s|@\\*link_libgcc:@|@*link_libgcc:@-L /usr/local/lib |" \ |
|
|
|
-e "s|@\\*link_libgcc:@|@*link_libgcc:@-L /usr/lib |" \ |
|
|
|
-e "s|@\\*link_libgcc:@|@*link_libgcc:@-L /lib |" \ |
|
|
|
-e "s|@\\*link:@|@*link:@-rpath-link /lib:/usr/lib |" \ |
|
|
|
-e "s|@\\*cpp:@|@*cpp:@-I $x/usr/$arch_target/include |" \ |
|
|
|
-e "s|@\\*cpp:@|@*cpp:@-I $x/usr/local/include |" \ |
|
|
|
-e "s|@\\*cpp:@|@*cpp:@-I $x/usr/include |" \ |
|
|
|
| tr '@' '\n' > specs.chroot |
|
|
|
} |
|
|
|
|
|
|
|
hook_add preconf 2 |
|
|
|
custmain() { |
|
|
|
hook_eval preconf |
|
|
|
|
|
|
|
# In stage 1 we only build a normal c compiler (no c++, etc) |
|
|
|
# |
|
|
|
if [ $stagelevel -le 1 ] ; then |
|
|
|
echo 'Setting LANGUAGES="c" in Makefile.in.' |
|
|
|
sed -i -e 's/LANGUAGES="[^"]*"/LANGUAGES="c"/g' Makefile.in |
|
|
|
elif [ "$ROCKCFG_DEBUG" = 1 ] ; then |
|
|
|
if [ -f libstdc++*/configure ] ; then |
|
|
|
echo "Setting DEBUG_FLAGS='-s' in libstdc++ configure." |
|
|
|
sed -i -e "s/DEBUG_FLAGS='-g'/DEBUG_FLAGS='-s'/g" libstdc++*/configure |
|
|
|
if [ "$pkg_gcc_cross" ] ; then |
|
|
|
configprefix="" |
|
|
|
confopt="--prefix=$root/$prefix \ |
|
|
|
--host=$arch_target --target=$pkg_gcc_target \ |
|
|
|
--disable-nls --disable-multilib" |
|
|
|
|
|
|
|
# A gcc with shared libraries needs at least this file from glibc. |
|
|
|
if [ ! -e $root/$prefix/$pkg_gcc_target/lib/crti.o ] ; then |
|
|
|
echo_status "Building only static gcc because there is no cross-glibc (yet)." |
|
|
|
var_append confopt " " "--disable-shared --enable-languages=c" |
|
|
|
makeopt="all-gcc" |
|
|
|
makeinstopt="install-gcc" |
|
|
|
else |
|
|
|
var_append confopt " " "--enable-shared --enable-languages=c,c++" |
|
|
|
makeopt="" |
|
|
|
makeinstopt="install" |
|
|
|
fi |
|
|
|
elif [ $stagelevel -eq 0 ] ; then |
|
|
|
configprefix="" |
|
|
|
confopt="--prefix=${CLFS}/$cross_tools \ |
|
|
|
--host=${CLFS_HOST} --target=${CLFS_TARGET} \ |
|
|
|
--with-sysroot=${CLFS} --disable-nls --disable-shared \ |
|
|
|
--enable-languages=c" |
|
|
|
makeopt="all-gcc" |
|
|
|
makeinstopt="install-gcc" |
|
|
|
elif [ $stagelevel -eq 1 ] ; then |
|
|
|
configprefix="" |
|
|
|
confopt="--prefix=${CLFS}/$cross_tools \ |
|
|
|
--host=${CLFS_HOST} --target=${CLFS_TARGET} \ |
|
|
|
--with-sysroot=${CLFS} --disable-nls --enable-shared \ |
|
|
|
--enable-languages=c,c++ --enable-__cxa_atexit \ |
|
|
|
--enable-c99 --enable-long-long --enable-threads=posix" |
|
|
|
makeopt="" |
|
|
|
makeinstopt="install" |
|
|
|
elif [ $stagelevel -ge 2 ] ; then |
|
|
|
var_append extraconfopt " " " \ |
|
|
|
--enable-shared \ |
|
|
|
--enable-__cxa_atexit \ |
|
|
|
--enable-c99 --enable-long-long --enable-threads=posix \ |
|
|
|
--enable-clocale=gnu" |
|
|
|
if [ $stagelevel -eq 2 ] ; then |
|
|
|
var_append extraconfopt " " "--enable-languages=c,c++ \ |
|
|
|
--disable-libstdcxx-pch" |
|
|
|
else |
|
|
|
var_append confopt ' ' '--enable-languages=$languages' |
|
|
|
x="ROCKCFG_PKG_GCC${pkg_gcc_version}_PROFILED" |
|
|
|
if [ "${!x}" = 1 ] ; then |
|
|
|
var_append makeopt ' ' "GCJFLAGS=\"\$CXXFLAGS\" \ |
|
|
|
profiledbootstrap" |
|
|
|
fi |
|
|
|
MAKE="$MAKE LIBGCC2_DEBUG_CFLAGS=-s LDFLAGS=-Wl,-s JCFLAGS=-s" |
|
|
|
fi |
|
|
|
|
|
|
|
# GCC rebuilds itself using the xgcc which is build first. xgcc |
|
|
|
# should also use the cc-wrapper. It might be better to patch big |
|
|
|
# amounts of the gcc sources - but this should also do the job. |
|
|
|
# |
|
|
|
export CFLAGS="$(exec -a echo bash \ |
|
|
|
-c ". gcc-${pkg_gcc_version}" 2> /dev/null)" |
|
|
|
export CXXFLAGS="$(exec -a echo bash \ |
|
|
|
-c ". g++-${pkg_gcc_version}" 2> /dev/null)" |
|
|
|
# |
|
|
|
echo "Setting \$CFLAGS to '$CFLAGS'." |
|
|
|
echo "Setting \$CXXFLAGS to '$CXXFLAGS'." |
|
|
|
|
|
|
|
mkdir objdir ; cd objdir |
|
|
|
|
|
|
|
# We install binaries, info-files and man-pages in temporary |
|
|
|
# directories so we can rename it (adding version suffix) before |
|
|
|
# We install binaries, info files and man pages in temporary |
|
|
|
# directories so we can rename them (adding version suffix) before |
|
|
|
# moving them to their final directories. |
|
|
|
# |
|
|
|
makeinstopt="" |
|
|
|
var_append makeopt " " "prefix=/$prefix libdir=/$prefix/lib" |
|
|
|
var_append makeinstopt " " "prefix=$root/$prefix" |
|
|
|
for x in bin info man data ; do |
|
|
|
mkdir -p $builddir/inst_$x |
|
|
|
makeinstopt="$makeinstopt ${x}dir=$builddir/inst_$x" |
|
|
|
var_append makeinstopt " " "${x}dir=$builddir/inst_$x" |
|
|
|
done |
|
|
|
|
|
|
|
# NAMING VARIANT!? INTRODUCED IN GCC-3.2.1 |
|
|
|
if [ $arch = powerpc ] ; then |
|
|
|
ln -s ppc-nocross-linux-gnu powerpc-nocross-linux-gnu |
|
|
|
fi |
|
|
|
|
|
|
|
# add the multi-lib config |
|
|
|
if [ "$ROCKCFG_MULTILIB" = 1 ] ; then |
|
|
|
confopt="$confopt --enable-multilib" |
|
|
|
else |
|
|
|
confopt="$confopt --disable-multilib" |
|
|
|
fi |
|
|
|
|
|
|
|
# do not install gc headers |
|
|
|
if [ "$xpkg" != "gcc2" ] ; then |
|
|
|
sed -i 's, install-includeHEADERS,,;' ../boehm-gc/include/Makefile.in |
|
|
|
fi |
|
|
|
|
|
|
|
# In stage 1 everything is a little bit more complicated |
|
|
|
# |
|
|
|
if [ $stagelevel -le 1 ] ; then |
|
|
|
# libstdc++ locales are not installed to the $datadir without this. |
|
|
|
var_append INSTALL_WRAPPER_FILTER "|" "sed -e \ |
|
|
|
's,$root/$prefix/share\(/locale/.*/libstdc++.mo\),$builddir/inst_data\1,'" |
|
|
|
|
|
|
|
create_config_cache > config.cache |
|
|
|
eval $configprefix bash ../configure $confopt --enable-languages=c |
|
|
|
|
|
|
|
# creating native libiberty for build system |
|
|
|
# (needed to build helper apps like gengenrtl) |
|
|
|
# |
|
|
|
mkdir -p $arch_build ; cd $arch_build |
|
|
|
CC=$BUILDCC bash ../../configure |
|
|
|
make all-libiberty ; cd .. |
|
|
|
|
|
|
|
MAKE="$MAKE LANGUAGES=c" |
|
|
|
|
|
|
|
# GCC thinks it can share object files between build and |
|
|
|
# target if the CPUs are compatible, which isn't true if we |
|
|
|
# are cross-building from glibc to dietlibc. So we also build |
|
|
|
# helper programs with dietlibc if this is not a cross build |
|
|
|
# between cpu architectures. |
|
|
|
# |
|
|
|
if ! [ "$pkg_dietlibc_useit" = 1 -a "$ROCKCFG_CROSSBUILD" = 0 ] |
|
|
|
then |
|
|
|
MAKE="$MAKE CC_FOR_BUILD='$BUILDCC'" |
|
|
|
fi |
|
|
|
|
|
|
|
# Fixincludes doesn't run when cross-building, but we |
|
|
|
# need a syslimits.h for a working gcc |
|
|
|
# |
|
|
|
mkdir -p gcc/include |
|
|
|
echo '#include "/usr/include/limits.h"' > gcc/include/syslimits.h |
|
|
|
var_append extraconfopt " " "--enable-version-specific-runtime-libs" |
|
|
|
fi |
|
|
|
|
|
|
|
hook_eval premake |
|
|
|
if [ "$ROCKCFG_MULTILIB" = 0 ] ; then |
|
|
|
var_append extraconfopt " " "--disable-multilib" |
|
|
|
else |
|
|
|
var_append extraconfopt " " "--enable-multilib" |
|
|
|
fi |
|
|
|
|
|
|
|
# Build and install |
|
|
|
# |
|
|
|
eval $MAKE prefix=/$prefix libdir=/$prefix/lib |
|
|
|
hook_eval inmake |
|
|
|
eval $MAKE prefix=$root/$prefix $makeinstopt install |
|
|
|
custmain="custmain" |
|
|
|
custmain () { |
|
|
|
# Don't install libiberty, use the one from binutils instead. |
|
|
|
cp libiberty/Makefile.in{,.orig} |
|
|
|
sed 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in.orig > \ |
|
|
|
libiberty/Makefile.in |
|
|
|
|
|
|
|
if [ "$ROCKCFG_CROSSBUILD" = 1 -a -d ../libstdc++-v3 ]; then |
|
|
|
rm -rf * |
|
|
|
var_append CXX_WRAPPER_REMOVE " " "-lstdc++" |
|
|
|
eval $configprefix bash ../libstdc++-v3/configure $confopt |
|
|
|
eval make prefix=/$prefix libdir=/$prefix/lib |
|
|
|
eval make prefix=$root/$prefix $makeinstopt install |
|
|
|
fi |
|
|
|
if [ $stagelevel -eq 2 ] ; then |
|
|
|
cp gcc/gccbug.in{,.orig} |
|
|
|
sed 's/@have_mktemp_command@/yes/' gcc/gccbug.in.orig > gcc/gccbug.in |
|
|
|
|
|
|
|
# This stuff needs manual installation |
|
|
|
# |
|
|
|
echo "Creating /$prefix/${pkg_gcc_target} ..." |
|
|
|
mkdir -p $root/$prefix/${pkg_gcc_target}/lib |
|
|
|
cd $root/$prefix/${pkg_gcc_target}/lib |
|
|
|
for x in Mcrt1.o crti.o gcrt1.o crt1.o crtn.o |
|
|
|
do ln -sf ../../lib/$x . ; done |
|
|
|
if [ -f ../../../lib/ld-linux-$arch_machine.so.2 ] ; then |
|
|
|
ln -sf ../../../lib/ld-linux-$arch_machine.so.2 . |
|
|
|
elif [ -f ../../../lib/ld-linux.so.2 ] ; then |
|
|
|
ln -sf ../../../lib/ld-linux.so.2 . |
|
|
|
fi |
|
|
|
else |
|
|
|
cp gcc/Makefile.in{,.orig} |
|
|
|
sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in |
|
|
|
fi |
|
|
|
|
|
|
|
if [ $xpkg = gcc2 -a "$ROCKCFG_PKG_GCC2_NO_CHILL" != 0 ] ; then |
|
|
|
# gcc-2.x contains no 'java' compiler |
|
|
|
confopt="$confopt --enable-languages=c,c++,objc,f77" |
|
|
|
elif [ "$ROCKCFG_DIETLIBC_ALL" = 1 -o "$ROCKCFG_DIETLIBC_gcc3" = 1 ] ; then |
|
|
|
# FIXME: c++ and java are not working with dietlibc |
|
|
|
confopt="$confopt --enable-languages=c,objc" |
|
|
|
elif [ $xpkg = gcc32 -a "$ROCKCFG_PKG_GCC32_NO_JAVA" != 0 ] || \ |
|
|
|
[ $xpkg = gcc33 -a "$ROCKCFG_PKG_GCC33_NO_JAVA" != 0 ] || \ |
|
|
|
[ $xpkg = gcc34 -a "$ROCKCFG_PKG_GCC34_NO_JAVA" != 0 ]; then |
|
|
|
confopt="$confopt --enable-languages=c,c++,objc,f77" |
|
|
|
elif [ $xpkg = gcc40 -a "$ROCKCFG_PKG_GCC40_NO_JAVA" != 0 ] || \ |
|
|
|
[ $xpkg = gcc41 -a "$ROCKCFG_PKG_GCC41_NO_JAVA" != 0 ]; then |
|
|
|
confopt="$confopt --enable-languages=c,c++,objc,f95" |
|
|
|
elif [ $xpkg = gcc42 -a "$ROCKCFG_PKG_GCC42_NO_JAVA" != 0 ]; then |
|
|
|
confopt="$confopt --enable-languages=c,c++,objc,fortran" |
|
|
|
elif [ "$arch" = mips ] ; then |
|
|
|
# FIXME: MIPS doesn't like the Java compiler |
|
|
|
confopt="$confopt --disable-libgcj" |
|
|
|
languages="c" |
|
|
|
while read lang ; do |
|
|
|
x="" |
|
|
|
case $lang in |
|
|
|
c++) x="ROCKCFG_PKG_GCC${pkg_gcc_version}_CPP" |
|
|
|
;; |
|
|
|
esac |
|
|
|
if [ $stagelevel -ge 3 ] ; then |
|
|
|
case $lang in |
|
|
|
ada) x="ROCKCFG_PKG_GCC${pkg_gcc_version}_ADA" |
|
|
|
;; |
|
|
|
f77|f95|fortran) |
|
|
|
x="ROCKCFG_PKG_GCC${pkg_gcc_version}_FORTRAN" |
|
|
|
;; |
|
|
|
java) x="ROCKCFG_PKG_GCC${pkg_gcc_version}_JAVA" |
|
|
|
;; |
|
|
|
objc) x="ROCKCFG_PKG_GCC${pkg_gcc_version}_OBJC" |
|
|
|
;; |
|
|
|
obj-c++) |
|
|
|
x="ROCKCFG_PKG_GCC${pkg_gcc_version}_OBJCPP" |
|
|
|
;; |
|
|
|
esac |
|
|
|
fi |
|
|
|
|
|
|
|
# See http://gcc.gnu.org/gcc-3.2/c++-abi.html |
|
|
|
# and http://www.codesourcery.com/cxx-abi/. |
|
|
|
if [ $xpkg != gcc2 ] ; then |
|
|
|
confopt="$confopt --enable-__cxa_atexit" |
|
|
|
if [ "${!x}" = 1 ] ; then |
|
|
|
var_append languages "," "$lang" |
|
|
|
fi |
|
|
|
done <<< "$( sed -nr 's,^language="(.*)",\1,p' gcc/*/config-lang.in )" |
|
|
|
|
|
|
|
# Set enable-shared |
|
|
|
if [ "$diet_dynamic_static" == "static" ] ; then |
|
|
|
confopt="$confopt --enable-shared=no" |
|
|
|
else |
|
|
|
confopt="$confopt --enable-shared=yes" |
|
|
|
fi |
|
|
|
mkdir -v ../objdir ; cd ../objdir |
|
|
|
|
|
|
|
# Configure, build and install as usual |
|
|
|
# |
|
|
|
eval $configprefix bash ../configure $confopt --with-gnu-as \ |
|
|
|
--enable-version-specific-runtime-libs \ |
|
|
|
--with-gnu-ld --enable-threads=posix |
|
|
|
eval echo $configprefix ../gcc-*/configure $confopt |
|
|
|
eval $configprefix ../gcc-*/configure $confopt |
|
|
|
|
|
|
|
hook_eval premake |
|
|
|
if [ $xpkg = gcc34 -a "$ROCKCFG_PKG_GCC34_PROFILED" != 0 ]; then |
|
|
|
eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" profiledbootstrap" |
|
|
|
elif [ $xpkg = gcc40 -a "$ROCKCFG_PKG_GCC40_PROFILED" != 0 ]; then |
|
|
|
eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" profiledbootstrap" |
|
|
|
elif [ $xpkg = gcc41 -a "$ROCKCFG_PKG_GCC41_PROFILED" != 0 ]; then |
|
|
|
eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" profiledbootstrap" |
|
|
|
elif [ $xpkg = gcc42 -a "$ROCKCFG_PKG_GCC42_PROFILED" != 0 ]; then |
|
|
|
eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" profiledbootstrap" |
|
|
|
else |
|
|
|
eval "$MAKE GCJFLAGS=\"$CXXFLAGS\" all" |
|
|
|
fi |
|
|
|
hook_eval inmake |
|
|
|
eval "$MAKE $makeinstopt install" |
|
|
|
eval make $makeopt |
|
|
|
|
|
|
|
# Fix the location of any improperly installed (F77) libraries |
|
|
|
mv -vf $root/$prefix/lib/$gcc_lib_dir/../lib* \ |
|
|
|
$root/$prefix/lib/$gcc_lib_dir || true |
|
|
|
if [ $stagelevel -eq 4 ] ; then |
|
|
|
make -k check || true |
|
|
|
../gcc-*/contrib/test_summary |
|
|
|
fi |
|
|
|
|
|
|
|
hook_eval postmake |
|
|
|
|
|
|
|
# GCC 4 does not install a specs file and removes old ones. |
|
|
|
# Regenerate the file with -dumpspecs. |
|
|
|
# |
|
|
|
cd $builddir/inst_bin |
|
|
|
if [ "${pkg_gcc_version:0:1}" -ge "4" ]; then |
|
|
|
if [ "$ROCKCFG_CROSSBUILD" == 1 ]; then |
|
|
|
$root/ROCK/tools.cross/crosscc/${pkg_gcc_target}-gcc -dumpspecs > \ |
|
|
|
$root/${prefix}/lib/${gcc_lib_dir}/specs |
|
|
|
else |
|
|
|
for x in gcc ${pkg_gcc_target}-gcc ; do |
|
|
|
[ -f "${x}" ] && ./${x} -dumpspecs > \ |
|
|
|
$root/${prefix}/lib/${gcc_lib_dir}/specs |
|
|
|
done |
|
|
|
fi |
|
|
|
fi |
|
|
|
eval make $makeinstopt |
|
|
|
|
|
|
|
if [ $stagelevel -ge 2 -a -z "$pkg_gcc_cross" ] ; then |
|
|
|
# Rename and install binaries |
|
|
|
# |
|
|
|
cd $builddir/inst_bin ; mkdir -p $root/$prefix/bin |
|
|
|
@ -302,12 +208,6 @@ custmain() { |
|
|
|
done |
|
|
|
done |
|
|
|
|
|
|
|
# gcc2 does not contain an own c++filt ... - so use the binutils one |
|
|
|
# |
|
|
|
if [ "$xpkg" = gcc2 ] ; then |
|
|
|
ln -vsf $root/$prefix/bin/c++filt-2 c++filt-binutils |
|
|
|
fi |
|
|
|
|
|
|
|
# Rename and install info-files |
|
|
|
# |
|
|
|
cd $builddir/inst_info ; mkdir -p $root/$prefix/info |
|
|
|
@ -336,7 +236,18 @@ custmain() { |
|
|
|
fi |
|
|
|
true |
|
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
cd $builddir/inst_man/man7 |
|
|
|
mkdir -p $root/$prefix/man/man7 |
|
|
|
for x in * ; do |
|
|
|
[ ! -f $x ] && continue # e.g. if $x becomes '*' somehow |
|
|
|
mv -v $x $root/$prefix/man/man7/${x%.1}-${pkg_gcc_version}.7 |
|
|
|
if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then |
|
|
|
ln -sf ${x%.1}-${pkg_gcc_version}.7 $root/$prefix/man/man7/$x |
|
|
|
fi |
|
|
|
true |
|
|
|
done |
|
|
|
|
|
|
|
# Rename and install locales |
|
|
|
# |
|
|
|
if [ -d "$builddir/inst_data/locale" ] ; then |
|
|
|
@ -355,8 +266,6 @@ custmain() { |
|
|
|
true |
|
|
|
done |
|
|
|
fi |
|
|
|
|
|
|
|
hook_eval postdoc |
|
|
|
|
|
|
|
# Create various symlinks for cc, c++, cpp and f77. |
|
|
|
# |
|
|
|
@ -395,198 +304,26 @@ custmain() { |
|
|
|
create_links gfortran |
|
|
|
fi |
|
|
|
|
|
|
|
# Inject our default optimisation options so when the user calls |
|
|
|
# gcc/g++ they match the ones used to precompile the headers ... |
|
|
|
# Save the options affecting optimization only. |
|
|
|
# |
|
|
|
if [ $ROCKCFG_DEFAULT_CC = $xpkg ]; then |
|
|
|
echo "Creating /etc/profile.d/gcc ..." |
|
|
|
{ |
|
|
|
echo "export CFLAGS_SIZE=\"$(echo $( |
|
|
|
eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \ |
|
|
|
\$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \ |
|
|
|
tr ' ' '\n' | sed -e 's/^-SIZE-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \ |
|
|
|
-e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd' |
|
|
|
))\"" |
|
|
|
echo "export CFLAGS_SPEED=\"$(echo $( |
|
|
|
eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \ |
|
|
|
\$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \ |
|
|
|
tr ' ' '\n' | sed -e 's/^-SPEED-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \ |
|
|
|
-e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd' |
|
|
|
))\"" |
|
|
|
echo "export CFLAGS=\"\$CFLAGS_SIZE\"" |
|
|
|
} > $root/etc/profile.d/gcc |
|
|
|
fi |
|
|
|
if [ $ROCKCFG_DEFAULT_CXX = $xpkg ]; then |
|
|
|
echo "Creating /etc/profile.d/gxx ..." |
|
|
|
{ |
|
|
|
echo "export CXXFLAGS_SIZE=\"$(echo $( |
|
|
|
eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \ |
|
|
|
\$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \ |
|
|
|
tr ' ' '\n' | sed -e 's/^-SIZE-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \ |
|
|
|
-e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd' |
|
|
|
))\"" |
|
|
|
echo "export CXXFLAGS_SPEED=\"$(echo $( |
|
|
|
eval echo \$GCC_WRAPPER_INSERT \$GCC_WRAPPER_APPEND \ |
|
|
|
\$GCC${ver:0:1}_WRAPPER_INSERT \$GCC${ver:0:1}_WRAPPER_APPEND | \ |
|
|
|
tr ' ' '\n' | sed -e 's/^-SPEED-/-/' -e '/^-O/ { p; d; }' -e '/^-mcpu=/ { p; d; }' \ |
|
|
|
-e '/-march=/ { p; d; }' -e '/-mtune=/ { p; d; }' -e 'd' |
|
|
|
))\"" |
|
|
|
echo "export CXXFLAGS=\"\$CFLAGS_SIZE\"" |
|
|
|
} > $root/etc/profile.d/gxx |
|
|
|
fi |
|
|
|
|
|
|
|
# Create symlinks for runtime libraries so they can be found by |
|
|
|
# the dynamic loader and force rebuilding of the wrapper links |
|
|
|
# |
|
|
|
if [ $stagelevel -gt 1 ] ; then |
|
|
|
[ $ROCKCFG_DEFAULT_CC = $xpkg ] && \ |
|
|
|
( mkdir -p $root/$prefix/lib ; cd $root/$prefix/lib ; \ |
|
|
|
ln -vfs ${gcc_lib_dir}/*.so.* . ; ) |
|
|
|
rm -fv $base/build/$ROCKCFG_ID/ROCK/$toolsdir/.lastupdate |
|
|
|
fi |
|
|
|
|
|
|
|
if [ "$ROCKCFG_PSEUDONATIVE" = 1 ]; then |
|
|
|
echo "Adapting gcc specs file..." |
|
|
|
cd $root/$prefix/lib/${gcc_lib_dir} |
|
|
|
genrockspecs |
|
|
|
|
|
|
|
# echo "Linking gcc libs to tools.cross..." |
|
|
|
# cd $root/ROCK/tools.cross/lib/${gcc_lib_dir}/ |
|
|
|
# ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.a . |
|
|
|
# ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.la . |
|
|
|
# ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.so . |
|
|
|
# ln -sf ../../../../../../$prefix/lib/${gcc_lib_dir}/*.so.* . |
|
|
|
fi |
|
|
|
|
|
|
|
true |
|
|
|
[ "$ROCKCFG_DEFAULT_CC" = $xpkg ] && \ |
|
|
|
( mkdir -p $root/$prefix/lib ; cd $root/$prefix/lib ; \ |
|
|
|
ln -vfs ${gcc_lib_dir}/*.so.* . ; ) |
|
|
|
fi |
|
|
|
rm -fv $base/build/$ROCKCFG_ID/ROCK/$toolsdir/.lastupdate |
|
|
|
} |
|
|
|
|
|
|
|
gcc_cross() { |
|
|
|
mkdir -p $root/$prefix/$pkg_gcc_target/{bin,lib} |
|
|
|
|
|
|
|
if [ "$stagelevel" -eq 0 ] |
|
|
|
then |
|
|
|
rm -f $root/$prefix/$pkg_gcc_target/include |
|
|
|
if [ -f $root/$prefix/include/stdio.h ]; then |
|
|
|
ln -s ../include $root/$prefix/$pkg_gcc_target/include |
|
|
|
elif [ -f $root/$prefix/diet-include/stdio.h ]; then |
|
|
|
ln -s ../diet-include $root/$prefix/$pkg_gcc_target/include |
|
|
|
fi |
|
|
|
|
|
|
|
bindir="$root/$prefix/crosscc" |
|
|
|
mkdir -p $root/$prefix/crosscc |
|
|
|
fi |
|
|
|
|
|
|
|
if [ "$pkg_gcc_version" != "2" ]; then |
|
|
|
if [ "$ROCKCFG_PSEUDONATIVE" = 1 -o "$ROCKCFG_CROSSBUILD" = 1 ]; then |
|
|
|
confopt="$confopt --enable-languages=c,c++" |
|
|
|
else |
|
|
|
confopt="$confopt --enable-languages=c" |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
mkdir objdir ; cd objdir ; hook_eval preconf |
|
|
|
eval bash ../configure --program-prefix=${pkg_gcc_target}- --disable-cpp \ |
|
|
|
--disable-shared --disable-multilib $confopt |
|
|
|
if [ -d libiberty ]; then make -C libiberty; fi |
|
|
|
if [ -d texinfo ]; then make -C texinfo; fi |
|
|
|
|
|
|
|
hook_eval premake |
|
|
|
if [ "$xpkg" = "gcc2" ] ; then |
|
|
|
make -C gcc all LANGUAGES="c" |
|
|
|
hook_eval inmake |
|
|
|
make -C gcc install LANGUAGES="c" |
|
|
|
else |
|
|
|
# workaround for at least gcc-3.2.3 |
|
|
|
mkdir -p $root/$prefix/lib/${gcc_lib_dir} |
|
|
|
if [ -d gcc ]; then |
|
|
|
make -C gcc all |
|
|
|
hook_eval inmake |
|
|
|
make -C gcc install |
|
|
|
else |
|
|
|
make all-gcc |
|
|
|
hook_eval inmake |
|
|
|
make install-gcc |
|
|
|
create_links() { |
|
|
|
for x ; do |
|
|
|
if [ -f "$root/$prefix/bin/$x-${pkg_gcc_version}" ] ; then |
|
|
|
rm -vf $root/$prefix/bin/$x |
|
|
|
ln -vs $x-${pkg_gcc_version} $root/$prefix/bin/$x |
|
|
|
fi |
|
|
|
fi |
|
|
|
hook_eval postmake |
|
|
|
|
|
|
|
if [ -f $root/$prefix/lib/${gcc_lib_dir}/libgcc.a ]; then |
|
|
|
${pkg_gcc_target}-ranlib \ |
|
|
|
$root/$prefix/lib/${gcc_lib_dir}/libgcc.a |
|
|
|
fi |
|
|
|
|
|
|
|
if [ "$stagelevel" -eq 0 ]; then |
|
|
|
x="$root/$prefix/crosscc/${arch_target}" |
|
|
|
ln -svf ${arch_target}-gcc $x-gcc-${pkg_gcc_version} |
|
|
|
ln -svf ${arch_target}-g++ $x-g++-${pkg_gcc_version} |
|
|
|
ln -svf ${arch_target}-gcc $x-kcc-${pkg_gcc_version} |
|
|
|
ln -svf ${arch_target}-gcc $x-kcc |
|
|
|
ln -svf ${arch_target}-gcc $x-cc |
|
|
|
rm -vf "$root/$prefix/crosscc/gcc" |
|
|
|
rm -vf "$root/$prefix/crosscc/gcj" |
|
|
|
|
|
|
|
cd $root/$prefix/$arch_target/lib |
|
|
|
for x in Mcrt1.o crt1.o crti.o crtn.o gcrt1.o \ |
|
|
|
libc.a libc.so libc_nonshared.a |
|
|
|
do |
|
|
|
if [ ! -e $x ]; then |
|
|
|
ln -fvs $root/../../usr/lib/$x $x |
|
|
|
fi |
|
|
|
done |
|
|
|
|
|
|
|
for x in ld-linux{,-$arch_machine}.so.2 ld.so.1 libc.so.{6,6.1} |
|
|
|
do ln -fvs $root/../../lib/$x $x ; done |
|
|
|
|
|
|
|
# glibc uses -lgcc_s with --as-needed, which fails if libgcc_s.{so,a} |
|
|
|
# is not even there. -- clifford & fake |
|
|
|
# |
|
|
|
# the shared object is not really needed. |
|
|
|
#if [ ! -e $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.so ]; then |
|
|
|
# ${pkg_gcc_target}-gcc -shared -nostdlib \ |
|
|
|
# -o $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.so -x c /dev/null |
|
|
|
#fi |
|
|
|
if [ ! -e $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.a ]; then |
|
|
|
${pkg_gcc_target}-gcc -x c /dev/null -c -o null.o |
|
|
|
${pkg_gcc_target}-ar q null.a null.o; rm -f null.o |
|
|
|
${pkg_gcc_target}-ranlib null.a |
|
|
|
mv null.a $root/$prefix/lib/${gcc_lib_dir}/libgcc_s.a |
|
|
|
x="${pkg_gcc_target}-$x" |
|
|
|
if [ -f $root/$prefix/bin/$x-${pkg_gcc_version} ] ; then |
|
|
|
rm -vf $root/$prefix/bin/$x |
|
|
|
ln -vs $x-${pkg_gcc_version} $root/$prefix/bin/$x |
|
|
|
fi |
|
|
|
|
|
|
|
rm -f $root/$prefix/.lastupdate |
|
|
|
fi |
|
|
|
|
|
|
|
# GCC 4 does not install a specs file and removes old ones. |
|
|
|
# Regenerate the file with -dumpspecs. |
|
|
|
# |
|
|
|
if [ "${pkg_gcc_version:0:1}" -ge "4" ]; then |
|
|
|
[ "$stagelevel" -eq 0 ] && $root/$prefix/crosscc/${pkg_gcc_target}-gcc -dumpspecs > $root/$prefix/lib/${gcc_lib_dir}/specs |
|
|
|
[ "$stagelevel" -ne 0 ] && $root/$prefix/bin/${pkg_gcc_target}-gcc -dumpspecs > $root/$prefix/lib/${gcc_lib_dir}/specs |
|
|
|
fi |
|
|
|
|
|
|
|
if [ "$stagelevel" -eq 0 -o "$ROCKCFG_PSEUDONATIVE" = 1 ]; then |
|
|
|
echo "Adapting gcc specs file..." |
|
|
|
cd $root/$prefix/lib/${gcc_lib_dir} |
|
|
|
genrockspecs |
|
|
|
fi |
|
|
|
|
|
|
|
true |
|
|
|
done |
|
|
|
} |
|
|
|
|
|
|
|
if [ "$stagelevel" -eq 0 -o -n "$pkg_gcc_cross" ] |
|
|
|
then |
|
|
|
custmain="gcc_cross" |
|
|
|
else |
|
|
|
custmain="custmain" |
|
|
|
fi |
|
|
|
|
|
|
|
case "$pkg_gcc_version" in |
|
|
|
34|4*) |
|
|
|
gcc_lib_dir="gcc/${pkg_gcc_target}/${ver%%-*}" |
|
|
|
;; |
|
|
|
*) |
|
|
|
gcc_lib_dir="gcc-lib/${pkg_gcc_target}/${ver%%-*}" |
|
|
|
;; |
|
|
|
esac |
|
|
|
|