#!/bin/bash # --- ROCK-COPYRIGHT-NOTE-BEGIN --- # # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # Please add additional copyright information _after_ the line containing # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by # the ./scripts/Create-CopyPatch script. Do not edit this copyright text! # # ROCK Linux: rock-src/package/base/gcc/gcc.conf # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. A copy of the GNU General Public # License can be found at Documentation/COPYING. # # Many people helped and are helping developing ROCK Linux. Please # have a look at http://www.rocklinux.org/ and the Documentation/TEAM # file for details. # # --- ROCK-COPYRIGHT-NOTE-END --- pkg_gcc_version=${xpkg#gcc} pkg_gcc_target=${arch_target} pkg_gcc_cross="" case "$xpkg" in gcc?-cross-*|gcc??-cross-*) pkg_gcc_cross="${xpkg#gcc*-cross-}" 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)|/usr/(man|info)), d"' ;; gcc?|gcc??) ;; *) echo_error "Not supported $pkg package name: $xpkg" exit 1 ;; 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' ' '`" 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' ' '`" fi 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" if [ $pkg_gcc_version -ge 43 ]; then makeopt="all-gcc all-target-libgcc" makeinstopt="install-gcc install-target-libgcc" else makeopt="all-gcc" makeinstopt="install-gcc" fi 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} \$extraconfopt" var_append extraconfopt " " " \ --with-sysroot=${CLFS} --disable-nls --disable-shared \ --enable-languages=c" if [ $pkg_gcc_version -ge 43 ]; then makeopt="all-gcc all-target-libgcc" makeinstopt="install-gcc install-target-libgcc" else makeopt="all-gcc" makeinstopt="install-gcc" fi elif [ $stagelevel -eq 1 ] ; then configprefix="" confopt="--prefix=${CLFS}/$cross_tools \ --host=${CLFS_HOST} --target=${CLFS_TARGET} \$extraconfopt" var_append extraconfopt " " " \ --with-sysroot=${CLFS} --disable-nls --enable-shared \ --enable-languages=\$languages --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=\$languages \ --disable-libstdcxx-pch" else var_append extraconfopt ' ' '--enable-languages=$languages' x="ROCKCFG_PKG_GCC${pkg_gcc_version}_PROFILED" if [ "${!x}" = 1 ] ; then var_append makeopt ' ' "GCJFLAGS=\"\$CXXFLAGS\" \ profiledbootstrap" fi fi # 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. # var_append makeopt " " "prefix=/$prefix" for x in bin info man data ; do mkdir -p $dummydir/inst_$x eval "${x}dir=$dummydir/inst_$x" done # libstdc++ locales are not installed to the $datadir without this. var_append INSTALL_WRAPPER_FILTER "|" "sed -e \ 's,$root/$prefix/share\(/locale/.*/libstdc++.mo\),$dummydir/inst_data\1,'" var_append extraconfopt " " "--enable-version-specific-runtime-libs" fi if [ "$ROCKCFG_MULTILIB" = 0 ] ; then var_append extraconfopt " " "--disable-multilib" fi 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 [ $stagelevel -eq 2 ] ; then cp gcc/gccbug.in{,.orig} sed 's/@have_mktemp_command@/yes/' gcc/gccbug.in.orig > gcc/gccbug.in cp gcc/Makefile.in{,.orig} sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in fi 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 if [ "${!x}" = 1 ] ; then var_append languages "," "$lang" fi done <<< "$( sed -nr 's,^language="(.*)",\1,p' gcc/*/config-lang.in )" mkdir -v ../objdir ; cd ../objdir eval echo $configprefix ../gcc-*/configure $( eval echo $confopt ) eval $configprefix ../gcc-*/configure $( eval echo $confopt ) eval make $makeopt if [ "$ROCKCFG_DO_CHECK" = 1 -a $stagelevel -ge 4 ] ; then make -k check || true ../gcc-*/contrib/test_summary fi eval make $makeinstopt if [ $stagelevel -eq 0 -a $pkg_gcc_version -ge 43 ]; then cp -v $root/$prefix/lib/$gcc_lib_dir/include-fixed/*.h $root/$prefix/lib/$gcc_lib_dir/include/ fi if [ $stagelevel -ge 2 -a -z "$pkg_gcc_cross" ] ; then # Rename and install binaries # cd $dummydir/inst_bin ; mkdir -p $root/$prefix/bin for y in c++ c++filt g++ cpp f77 g77 gfortran gcc gcov ; do for x in $y ${pkg_gcc_target}-$y ; do if [ -f "$x" ] ; then mv -v $x $root/$prefix/bin/${x}-${pkg_gcc_version} fi done done # Rename and install info-files # cd $dummydir/inst_info ; mkdir -p $root/$prefix/info for x in * ; do [ ! -f $x ] && continue # e.g. if $x becomes '*' somehow fn=$( echo $x | sed "s,\([a-z0-9]*\),\1-${pkg_gcc_version}," ) infoname=$( echo $x | sed "s,\([a-z0-9]*\).*,\1," ) echo "$x -> $root/$prefix/info/$fn" sed "s,$infoname.info,$infoname-${pkg_gcc_version}.info," < $x \ > $root/$prefix/info/$fn if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then cp -v $x $root/$prefix/info/$x fi true done # Rename and install man-pages # cd $dummydir/inst_man/man1 mkdir -p $root/$prefix/man/man1 for x in * ; do [ ! -f $x ] && continue # e.g. if $x becomes '*' somehow mv -v $x $root/$prefix/man/man1/${x%.1}-${pkg_gcc_version}.1 if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then ln -sf ${x%.1}-${pkg_gcc_version}.1 $root/$prefix/man/man1/$x fi true done cd $dummydir/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 "$dummydir/inst_data/locale" ] ; then cd $dummydir/inst_data/locale for x in */LC_MESSAGES/*.mo ; do [ ! -f "$x" ] && continue # e.g. if $x becomes '*' somehow y="$root/$prefix/share/locale/$x" y="${y%.mo}-${pkg_gcc_version}.mo" mkdir -p ${y%/*} echo "$x -> $y" mv $x $y if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then echo "symlink $x -> $y" ln -svf ${y##*/} $root/$prefix/share/locale/$x fi true done fi # Create various symlinks for cc, c++, cpp and f77. # if [ $ROCKCFG_DEFAULT_CC = $xpkg ] ; then create_links gcc cpp gcov rm -f $root/$prefix/bin/cc if [ "$ROCKCFG_DIETLIBC_ALL" = 1 ]; then cat <<- 'EOT' > $root/$prefix/bin/cc #!/bin/sh exec diet gcc "$@" EOT chmod +x $root/$prefix/bin/cc else ln -svf gcc $root/$prefix/bin/cc fi ln -vsf ../$prefix/bin/cpp $root/lib/cpp fi ln -sf gcc-${pkg_gcc_version} $root/$prefix/bin/kcc-${pkg_gcc_version} if [ $ROCKCFG_DEFAULT_KCC = $xpkg ] ; then ln -vsf gcc-${pkg_gcc_version} $root/$prefix/bin/kcc fi if [ $ROCKCFG_DEFAULT_CXX = $xpkg ] ; then create_links c++ c++filt g++ cp -a $confdir/g++-autopch.sh $root/$prefix/bin/g++-autopch chmod +x $root/$prefix/bin/g++-autopch fi if [ $ROCKCFG_DEFAULT_F77 = $xpkg ] ; then create_links g77 if [ -f $root/$prefix/bin/g77 ] ; then rm -vf $root/$prefix/bin/f77 ln -vsf g77 $root/$prefix/bin/f77 fi fi if [ $ROCKCFG_DEFAULT_F95 = $xpkg ] ; then 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 # [ "$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 } 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 }