jong357 |
05-29-2007 12:03 PM |
Too many files to name. Bad idea installing both side by side unless you use a different prefix for one of them. Installing 3.4.6 from pasture would effectively destroy your gcc-4 install.
I use 4.2 in /usr and 3.4.6 in /opt. Gnashley has the right of it with making a wrapper script. However, you wouldn't want to append to your PATH on a global basis (such as in /etc/profile.d or /etc/profile) because it'll look in the first PATH directory you specify and use that. So if I put Gnashley's script in /etc/profile.d and just compiled something with "make", it'll use 3.4.6....
What I do is similar to a wrapper script. I make an alias in /etc/bashrc..
Code:
alias gcc346='CC=/opt/gcc-3.4.6/bin/gcc'
Then, if I'm compiling something, and wan't to use 3.4.6, I do what Gnashley does... "gcc346 make"
Or, if I'm calling a build script, "gcc346 foobar.SlackBuild"
Also, appending to your library PATH is unecessary because each seperate instance of gcc knows where to find it's own libs, which is why that bit is commented out in Gnashley's script.
Here is a build script if anyone is interested.. I like to make monolithic gcc packages instead of busting it up.
Code:
#!/bin/sh
#
# $CFLAGS are set globaly in /etc/bashrc
CWD=`pwd`
TMP=/tmp
PKGNAME=gcc
PKG=$TMP/package-$PKGNAME
VERSION=3.4.6
PKGVER=${VERSION}
ARCH=i686
BUILD=1
BOOT_CFLAGS="-march=i686 -O2 -pipe"
rm -rf $PKG
mkdir -p $PKG/install
cd $TMP
echo
echo "$PKGNAME-$VERSION source is now extracting..."
rm -rf $PKGNAME-$VERSION
rm -rf $PKGNAME-build
tar xjf $CWD/$PKGNAME-$VERSION.tar.bz2
mkdir $PKGNAME-build
cd $PKGNAME-$VERSION
chown -R root.root .
find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 754 -exec chmod 755 {} \;
find . -perm 664 -exec chmod 644 {} \;
# Use libiberty.a from Binutils:
sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in
# Prevent the fixincludes script from running & delete debug ref
sed -i.bak \
-e 's,\./fixinc\.sh,-c true,' \
-e '/^LIBGCC2_DEBUG/d' gcc/Makefile.in
cd ../$PKGNAME-build
# See if we should bootstrap or not:
if gcc -dumpversion | grep $VERSION 2>/dev/null 1>/dev/null ;then
bootstrapgcc=no
else
bootstrapgcc=yes
fi
if [ "$CC" = "/opt/gcc-3.4.6/bin/gcc" ]; then
bootstrapgcc=no
fi
if [ "$bootstrapgcc" = "no" ]; then
# rebuilding the same version:
../$PKGNAME-$VERSION/configure --prefix=/opt/$PKGNAME-$VERSION \
--enable-shared \
--disable-multilib \
--disable-bootstrap \
--enable-languages=c,c++ \
--enable-clocale=gnu \
--enable-threads=posix \
--enable-__cxa_atexi
make LDFLAGS="-s"
fi
if [ "$bootstrapgcc" = "yes" ]; then
# upgrading to a new version:
../$PKGNAME-$VERSION/configure --prefix=/opt/$PKGNAME-$VERSION \
--enable-shared \
--disable-multilib \
--enable-languages=c,c++ \
--enable-clocale=gnu \
--enable-threads=posix \
--enable-__cxa_atexit
make LDFLAGS="-s" bootstrap
fi
# Ask the user if they want to run the test suite:
echo
echo "Compilation of $PKGNAME-$VERSION is now done. You might want"
echo "to take the time to review the above output and make sure"
echo "it completed with no errors..."
echo
echo "The GCC test suite is very comprehensive and is almost guaranteed"
echo "to generate a few failures. It also takes quite some time to run..."
echo
echo "Do you wish to test the results? ([y], [n])"
if [ ! "$RESP" ]; then
read RESP;
echo
fi
if [ "$RESP" = "y" ]; then
echo "O.k... Probably not a bad idea..."
echo
runtest=yes
sleep 2
make -k check
fi
if [ "$RESP" = "n" ]; then
echo "Skipping tests..."
echo
sleep 2
fi
make DESTDIR=$PKG install -j1
mkdir -p $PKG/usr/lib
# Should probably keep it where it is and symlink to /usr...
# We really don't have to do this at all actually...
mv $PKG/opt/$PKGNAME-$VERSION/lib/libstdc++.so.6.0.3 $PKG/usr/lib
( cd $PKG/opt/$PKGNAME-$VERSION/lib
ln -sf ../../../usr/lib/libstdc++.so.6.0.3 . )
# Fix info dir
if [ -f $PKG/opt/$PKGNAME-$VERSION/info/dir ]; then
rm $PKG/opt/$PKGNAME-$VERSION/info/dir
fi
# Compress and strip
( cd $PKG/opt/$PKGNAME-$VERSION/man
gzip -9 */*
cd man1
ln -svf g++.1.gz c++.1.gz
ln -svf gcc.1.gz cc.1.gz )
# Redundant becuase of LDFLAGS
( cd $PKG
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null )
find $PKG -name "*.a" | xargs file | grep "archive" | cut -f 1 -d : | xargs strip -g
# Make the package description:
cat << EOF > $PKG/install/slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':'.
|-----handy-ruler----------------------------------------------------------|
gcc: gcc (GCC with C support)
gcc:
gcc: GCC is the GNU Compiler Collection.
gcc:
gcc: This package contains those parts of the compiler collection needed
gcc: to compile C code.
gcc:
gcc:
gcc:
gcc:
gcc:
EOF
# Build the package:
cd $PKG
makepkg -l y -c n $TMP/$PKGNAME-$PKGVER-$ARCH-$BUILD.tgz
if [ "$runtest" = "yes" ]; then
echo "Here are the test results for GCC-$VERSION"
echo
echo
echo "******************************************************************"
echo "* !!!!!!!!!!!!!!! BEGINNING OF TEST SUMMARY !!!!!!!!!!!!!!!!!! *"
echo "******************************************************************"
echo
echo "If this is the only thing you see, then your missing"
echo "some packages that were needed in order to run the test"
echo "suite. Tcl, Expect and DejaGNU must be installed first..."
echo
cd $TMP/$PKGNAME-build
../$PKGNAME-$VERSION/contrib/test_summary
# For just the brief summaries:
#../$PKGNAME-$VERSION/contrib/test_summary | grep -A7 Summ
echo
echo "******************************************************************"
echo "* !!!!!!!!!!!!!!! END OF TEST SUMMARY !!!!!!!!!!!!!!!!!! *"
echo "******************************************************************"
echo
echo "Package creation complete..."
echo
fi
|