#!/bin/sh # GCC package build script (written by volkerdi@slackware.com) # # Copyright 2003, 2004 Slackware Linux, Inc., Concord, California, USA # Copyright 2005, 2006 Patrick J. Volkerding, Sebeka, Minnesota, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # Some notes, Fri May 16 12:31:32 PDT 2003: # # Why i486 and not i386? Because the shared C++ libraries in gcc-3.2.x will # require 486 opcodes even when a 386 target is used (so we already weren't # compatible with the i386 for Slackware 9.0, didn't notice, and nobody # complained :-). gcc-3.3 fixes this issue and allows you to build a 386 # compiler, but the fix is done in a way that produces binaries that are not # compatible with gcc-3.2.x compiled binaries. To retain compatibility with # Slackware 9.0, we'll have to use i486 (or better) as the compiler target # for gcc-3.3. # # It's time to say goodbye to i386 support in Slackware. I've surveyed 386 # usage online, and the most common thing I see people say when someone asks # about running Linux on a 386 is to "run Slackware", but then they also # usually go on to say "be sure to get an OLD version, like 4.0, before glibc, # because it'll be more efficient." Now, if that's the general advice, then # I see no reason to continue 386 support in the latest Slackware (and indeed # it's no longer easily possible). # ----------------------------------------------------------------------------- # Note by Michelino Chionchio, Thu Jul 21 00:35:47 UTC 2007 # ----------------------------------------------------------------------------- # This is just a litle adjustment of the Patrick J. Volkerding script in order # to install gcc34 in /opt/gcc34 instead of default directory. # I've only modified the $INSPREFIX variable and other minor things, # Thanks to Eric Hameleers whose gcc34.SlackBuild helped me vary much. # http://www.slackware.com/~alien/slackbuilds/gcc34/build/gcc34.SlackBuild # Acording to Eric: # " This is a gcc34 compatibility SlackBuild for use in Slackware > 11.0 , # where gcc4 is the default compiler suite. # This gcc34 build installs to $INSPREFIX and will not interfere with gcc4. # *** Use gcc34 in your scripts, as follows *** # * By using environment variables: # Most softwares support the CC and CXX environment variables. # First assign them, then run configure and/or make. Example: # CC=gcc34 CXX=g++34 ./configure # # * Using configure support: # If the software is using the standard GNU automake and configure, # then there is a chance it supports other compilers by passing in # a setting to the configure script. # First run configure --help to see if it mentions anything. # The following example is from MPlayer: # ./configure --help # ./configure --cc=gcc34 " # ----------------------------------------------------------------------------- VERSION=3.4.6 ARCH=${ARCH:-i486} TARGET=$ARCH-slackware-linux BUILD=1mch INSPREFIX=/opt/gcc34 PRGSUFFIX=34 CWD=`pwd` # Temporary build location. This should *NOT* be a directory # path a non-root user could create later... #TMP=/gcc-`mcookie` TMP=${TMP:-/tmp/tgz} # This is the DESTDIR target: PKG=$TMP/package-gcc34 # Clear the build locations: if [ -d $TMP ]; then rm -rf $TMP fi mkdir -p $PKG/usr/doc/gcc-$VERSION cd $TMP tar xjvf $CWD/gcc-$VERSION.tar.bz2 # install docs ( cd gcc-$VERSION # Fix perms/owners 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 {} \; mkdir -p $PKG/usr/doc/gcc-$VERSION # Only the most recent ChangeLog... shouldn't be too big. :) cp -a \ BUGS COPYING COPYING.LIB ChangeLog FAQ INSTALL MAINTAINERS README* *.html \ $PKG/usr/doc/gcc-$VERSION mkdir -p $PKG/usr/doc/gcc-${VERSION}/gcc ( cd gcc cp -a ABOUT* COPYING* LANG* ONEWS README* SERVICE \ $PKG/usr/doc/gcc-$VERSION/gcc ) mkdir -p $PKG/usr/doc/gcc-${VERSION}/libstdc++-v3 ( cd libstdc++-v3 cp -a README $PKG/usr/doc/gcc-${VERSION}/libstdc++-v3 cp -a docs/html/faq/index.html $PKG/usr/doc/gcc-${VERSION}/libstdc++-v3/faq.html ) ) # build gcc ( mkdir gcc.build.lnx; cd gcc.build.lnx; ../gcc-$VERSION/configure \ --prefix=$INSPREFIX \ --program-suffix=$PRGSUFFIX \ --enable-shared \ --enable-threads=posix \ --enable-__cxa_atexit \ --enable-languages=c,c++ \ --disable-checking \ --with-gnu-ld \ --verbose \ --target=${TARGET} \ --host=${TARGET} # Start the build: make -j2 bootstrap make -j2 info # Set GCCCHECK=something to run the tests if [ ! -z $GCCCHECK ]; then make -j2 check fi make install DESTDIR=$PKG make -i install-info DESTDIR=$PKG chmod 755 $PKG/$INSPREFIX/lib/libgcc_s.so.1 # This is provided by binutils, so delete it here: rm -f $PKG/$INSPREFIX/lib/libiberty.a # Strip out unneeded stuff from the libraries and binaries [Redoundant because 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 ) # Most people debug their own code (not the libraries), so we'll strip these. # It cuts the size down quite a bit. find $PKG -name "*.a" | xargs file | grep "archive" | cut -f 1 -d : | xargs strip -g # Fix stuff up: ( cd $PKG/$INSPREFIX/info ; rm dir ; gzip -9 * ) ( cd $PKG mkdir -p lib cd lib ln -sf ${INSPREFIX}/bin/cpp${PRGSUFFIX} . ) ( cd $PKG/$INSPREFIX/bin mv g++${PRGSUFFIX} g++-gcc-$VERSION mv gcc${PRGSUFFIX} gcc-$VERSION ln -sf g++-gcc-$VERSION g++${PRGSUFFIX} ln -sf gcc-$VERSION gcc${PRGSUFFIX} ln -sf g++${PRGSUFFIX} c++${PRGSUFFIX} ln -sf gcc${PRGSUFFIX} cc${PRGSUFFIX} ln -sf gcc-$VERSION ${TARGET}-gcc${PRGSUFFIX} ln -sf gcc-$VERSION ${TARGET}-gcc${PRGSUFFIX}-${VERSION} ln -sf g++-gcc-$VERSION ${TARGET}-c++${PRGSUFFIX} ln -sf g++-gcc-$VERSION ${TARGET}-g++${PRGSUFFIX} ) ( cd $PKG/$INSPREFIX/man gzip -9 */* cd man1 mkdir -p $PKG/usr/man/man1 mv g++${PRGSUFFIX}.1.gz $PKG/usr/man/man1/ mv gcc${PRGSUFFIX}.1.gz $PKG/usr/man/man1/ mv cpp${PRGSUFFIX}.1.gz $PKG/usr/man/man1/ mv gcov${PRGSUFFIX}.1.gz $PKG/usr/man/man1/ cd $PKG/usr/man/man1/ ln -sf g++${PRGSUFFIX}.1.gz c++${PRGSUFFIX}.1.gz ln -sf gcc${PRGSUFFIX}.1.gz cc${PRGSUFFIX}.1.gz cd $PKG/$INSPREFIX/man/man7 mkdir -p $PKG/usr/man/man7 mv fsf-funding.7.gz $PKG/usr/man/man7/fsf-funding${PRGSUFFIX}.7.gz mv gfdl.7.gz $PKG/usr/man/man7/gfdl${PRGSUFFIX}.7.gz mv gpl.7.gz $PKG/usr/man/man7/gpl${PRGSUFFIX}.7.gz rm -rf $PKG/$INSPREFIX/man ) # Add profile scripts so that the gcc34 binaries will be found in the PATH mkdir -p $PKG/etc/profile.d zcat $CWD/gcc34.sh.gz > $PKG/etc/profile.d/gcc34.sh zcat $CWD/gcc34.csh.gz > $PKG/etc/profile.d/gcc34.csh chmod 755 $PKG/etc/profile.d/gcc34.sh chmod 755 $PKG/etc/profile.d/gcc34.csh mkdir -p $PKG/install # Install the descriptions: ( cd $CWD cat slack-desc > $PKG/install/slack-desc cat slack-desc > $PKG/usr/doc/gcc-$VERSION/slack-desc cat gcc34.SlackBuild > $PKG/usr/doc/gcc-$VERSION/gcc34.SlackBuild ) # keep a log ) 2>&1 | tee $TMP/gcc34.build.log # Filter all .la files (thanks much to Mark Post for the sed script): ( cd $TMP for file in `find . -type f -name "*.la"` ; do cat $file | sed -e 's%-L/gcc-[[:graph:]]* % %g' > $TMP/tmp-la-file cat $TMP/tmp-la-file > $file done rm $TMP/tmp-la-file ) # build the tgz package ( cd $PKG requiredbuilder -v -y -s $CWD $PKG makepkg -l y -c n $CWD/gcc$PRGSUFFIX-$VERSION-$ARCH-$BUILD.tgz ) echo "Package created"