#! /bin/sh # Install a newly built gcc from its build directory # without affecting the main system compiler. # # Run this script from inside a directory called gcc-X.Y.Z-build # where X.Y.Z is your # full gcc version number. # # Martin Guy , November 2008 set -e # Exit if anything fails unexpectedly vendor=crunch lname=armv4tl-$vendor-linux-gnueabi lver=$(basename `/bin/pwd` | sed 's/gcc-\([0-9]\.[0-9]\.[0-9]\)-build/\1/') case $lver in 4.1.?) suffix=4.1-$vendor ;; 4.2.?) suffix=4.2-$vendor ;; 4.3.?) suffix=4.3-$vendor ;; *) echo "Failed to extract version number from current directory name." exit 1 ;; esac rm -rf /usr/local/lib{,exec}/gcc/$lname/$lver make install > /dev/null 2>&1 || { echo "Installation failed." exit 1 } # Make the GCC libraries local to this one version, otherwise their presence in # /usr/local/lib overrides the system compiler's ones. mv /usr/local/lib/lib{gcc,gomp,iberty,mudflap}* \ /usr/local/lib/gcc/$lname/$lver/ # Reduce size of binaries for packaged version strip /usr/local/bin/{gcc,cpp}-$suffix \ /usr/local/libexec/gcc/$lname/$lver/{cc1,collect2} # Remove junk and long-named versions of compiler. rm /usr/local/bin/$lname-gcc-$lver rm /usr/local/bin/{$lname-gcc,gccbug,gcov}-$suffix rm -r /usr/local/lib/gcc/$lname/$lver/install-tools rmdir /usr/local/lib/gcc/$lname/$lver/finclude # empty fortran header dir case "$lver" in 4.3.*) # 4.3 doesn't work unless it has some fixed headers. By default it fixes # just about everything that happened to be on the build system. # Here we just leave what Debian gcc-4.3 has. ( cd /usr/local/lib/gcc/$lname/$lver/include-fixed find * -maxdepth 0 \ ! -path README \ ! -path limits.h \ ! -path syslimits.h \ ! -path linux \ -exec rm -r {} \; ) ;; *) # 4.1 and 4.2 don't seem to have this ;; esac # Leave gcc-4.X-crunch manual page because option flags have changed. rm /usr/local/man/man1/{cpp,gcov}-$suffix.1 rm /usr/local/info/{cpp,cppinternals,gcc,gccinstall,gccint,libgomp}.info echo Now you probably want to run tarball gcc-$suffix