home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #
- # Script to make a version of gcc that uses the BSD environment.
- # It will create the following files:
- # /usr/ucb/gcc
- # $GNUBIN/ucbgcc
- # And will create a directory
- # $GNU/lib/gcc-lib/sparc-sun-solaris2-bsd/$version
- # that contains
- # hardlinks to every file from sparc-sun-solaris2
- # ucbinclude: a directory with fixed include files from /usr/ucbinclude
- # a specs file that will use these new include files before the SysV ones
- #
- # Use of this C compiler:
- # /usr/ucb/gcc
- # ucbgcc
- # gcc -bsd
- #
- # If you don't have cygnus-bin installed, you'll need to give a path to
- # your gcc source directory because mkucbgcc needs fixinc.svr4.
- #
- # This script has been tested with:
- # cygnus-2.0.2
- # gcc 2.3.2 and 2.3.3
- # on Solaris 2.1
- #
- # Author: Casper Dik (casper@fwi.uva.nl)
- #
- PATH=/bin:$PATH
- export PATH
-
- echo Installing gcc for ucb environment.
- specs=`gcc -v 2>&1 |awk '$2 == "specs" { print $4 }' `
- if [ `basename $specs` != specs -o ! -f $specs ]
- then
- echo 1>&2 "Can't locate gcc or specs file"
- exit 1
- fi
-
- # The specs file lives in <root>/lib/gcc-lib/<mach>/<version>/specs
- svrpath=`dirname $specs`
- version=`basename $svrpath`
- tmp=`dirname $svrpath`
- mach=`basename $tmp`
- tmp=`dirname $tmp`
- if [ gcc-lib != `basename $tmp` ]
- then
- echo 1>&2 "Oops, path to specs file is not what I expect"
- exit 1
- fi
- tmp=`dirname $tmp`
-
- root=`dirname $tmp`
-
- # Not sure about the fixinc.svr4 bit.
- if [ x"$1" != x ]
- then
- fixinc="$1"/fixinc.svr4
- if [ ! -d "$1" ]
- then
- echo 1>&2 "$1: not a directory"
- exit 1
- fi
- if [ ! -x $fixinc -o ! -f $fixinc ]
- then
- echo 1>&2 "$fixinc: Can't execute"
- exit 1
- fi
- elif [ -f $root/lib/fixincludes -a `expr $version : cygnus` != 0 ]
- then
- fixinc=$root/lib/fixincludes
- else
- echo 1>&2 "Usage: $0 <gcc-src-directory> (for fixinc.svr4)"
- exit 1
- fi
-
- if [ lib != `basename $tmp` ]
- then
- echo 1>&2 "Oops, path to specs file is not what I expect"
- exit 1
- fi
- if [ cygnus-2.0.2 != $version -a 2.3.2 != $version -a 2.3.3 != $version ]
- then
- echo 1>&2 "Caveat: not tested for all versions of gcc."
- fi
-
- ucbpath=$root/lib/gcc-lib/$mach-bsd/$version
-
- echo Making directory structure.
- rm -rf $ucbpath/ucbinclude
- rm -f $ucbpath/*
- mkdir -p $ucbpath/ucbinclude
- # Link for gcc -bsd
- rm -f $root/lib/gcc-lib/sd
- ln -s $mach-bsd $root/lib/gcc-lib/sd
-
- echo Making links.
- echo "Expect complaint: \`\`ln: <$svrpath/include> directory''"
- ln $svrpath/* $ucbpath
- set -e
- rm $ucbpath/specs
- echo "Updating specs file."
- sed -e "/^\*cpp:$/N;s%cpp:\n%&-I$root/lib/gcc-lib/$mach-bsd/$version/ucbinclude -I/usr/ucbinclude %"\
- -e "/^\*lib:$/N;s%lib:\n%&-lucb -lsocket -lnsl -lelf -laio %"\
- -e "/^\*link:$/N;s%link:.*$%& -R /usr/ucblib%"\
- -e "s%Y P,%&/usr/ucblib:%g" < $svrpath/specs > $ucbpath/specs
-
- cp $svrpath/include/*.h $ucbpath/ucbinclude
-
- echo Running fixincludes. This may take some time. Output in /tmp/fixincludes.log
- echo Expect complaint from fixincludes about byteorder.h
- $fixinc $ucbpath/ucbinclude /usr/ucbinclude > /tmp/fixincludes.log < /dev/null
-
-
- rm -f /usr/ucb/gcc $root/bin/ucbgcc
- ln -s $root/bin/ucbgcc /usr/ucb/gcc
- cat > $root/bin/ucbgcc << !
- #!/bin/sh
- exec $root/bin/gcc -b $mach-bsd "\$@"
- !
- chmod 755 $root/bin/ucbgcc
-
- echo Installation of /usr/ucb/gcc successfull.
- exit 0
-