#!/bin/sh
### Copyright 1991, 1992, 1993, 1994, 1995, 1997 Cygnus Solutions
### All Rights Reserved.

##############
###
### This really needs to nestle up snuggly to the Installation notes.  If
### you change this script, please be sure the installation notes get
### coordinated too.
###
##############

### this is our release version, usually the basename of the installation
### directory, eg is 'progressive-XXXXXX' for /usr/cygnus/progressive-XXXXXX
RELEASE_TAG=xscale-010413

### put these here for convenience in editing
HOST=i686-pc-linux-gnulibc2.1
TARGET=xscale-elf
GCCvn=2.9-xscale-010413

### What bundle is this?  Usually something like 'Emacs' or 'comp-tools'
BUNDLE=cross-tools

### this is the default installation repository. We use this to test whether or
### not GCC_EXEC_PREFIX should be set when doing "Install test comp-tools".
ROOTING_REAL=/usr/cygnus
ROOTING_DEFAULT=${ROOTING_REAL}

### this is where we install into.  (useful for testing).
INSTALLDIR=${ROOTING_DEFAULT}

### FIXINCDIR will be set in comp-tools-fix and cross-tools-fix,
### but clear it initially
FIXINCDIR=""

### where to write the log files
RELEASE_ROOT=${INSTALLDIR}/${RELEASE_TAG}

LOGDIR=${RELEASE_ROOT}

### who to call in bad situations
HOTLINE="the Cygnus Solutions Hotline at +1 800 CYGNUS1"

### what the release doc is called and a few sections thereof
NOTES="the Installation Notes"
CHANGING_PATHS="\"Changing the Paths\""
NO_ACCESS="\"No Access to ${INSTALLDIR}\?\""
MIGHT_WRONG="\"Some Things that Might go Wrong\""
WHY_FIXINCLUDES="Why Convert System Header Files\?"
ANOTHER_TAPE="\"Steps to install with another machine\'s tape drive\""

### for debugging
#PATH=/bin:/usr/bin ; export PATH

PATH=/bin:/usr/bin:/usr/ucb:/usr/bsd:$PATH ; export PATH

### each system has a different default tape device, and a different scheme
### for the non-rewinding device name of that tape drive.  This value needs
### to be a NON-rewinding tape drive.
TAPE=${TAPE-/dev/tape}

### clear and/or initialize some variables
ACTIONS=

INSTALLHOST=default
ERROR=

install_src=false
install_bin=false

### some tool defaults
DD=dd
DDOPTS="ibs=124b"   # some systems can't handle this (eg AIX)

TAR=tar
TARFLAGS="xvf -"

SED=sed

#### end of all variable initializations -- NO substitutions should be used
#### past this section

### now start some function declarations

guess_system()
{
    ### next try uname
    if (uname > /dev/null) 2>&1 ; then
        UNAME="`uname -s``uname -m``uname -r`"
    else
        UNAME="machine without a uname command (type of machine unknown)"
    fi # (uname)

    ### map into names we recognize
    case "${UNAME}" in
        AIX*)            /usr/bin/oslevel > /dev/null 2>&1
                         OSLEVEL=`/usr/bin/oslevel`
                         case "$OSLEVEL:$HOST" in
                         *325*) rev=3.2.5; arch=rs6000; DDOPTS="";;
                         4*:powerpc*) rev=4.1; arch=powerpc;;
                         4*) rev=4.1; arch=rs6000;;
                         esac
                         INSTALLHOST="${arch}-ibm-aix${rev}" ;;
        SunOSsun4*5.5*)  case $HOST in
			 sparc-sun-solaris2)
        		 	INSTALLHOST=sparc-sun-solaris2; NOWARN=1 ;;
			 *)
        		 	INSTALLHOST=sparc-sun-solaris2.5 ;;
			 esac
			 ;;
        SunOSsun4*5*)    INSTALLHOST=sparc-sun-solaris2 ;;
        SunOSsun4*)      INSTALLHOST=sparc-sun-sunos4.1 ;;
        IRIX*)           INSTALLHOST=mips-sgi-irix5 ;;
        HP-UX9000/7*|HP-UX9000/8?[1679]*) 
		 case `uname -r` in
		 *.10.20*)
		 	case $HOST in
		 	hppa1.1-hp-hpux10)
				INSTALLHOST=hppa1.1-hp-hpux10; NOWARN=1 ;;
		 	*)
				INSTALLHOST=hppa1.1-hp-hpux10.20 ;;
			esac
			;;
		 *)
			INSTALLHOST=hppa1.1-hp-hpux`uname -r | sed 's/[^.]*.[0B]*\(.*\)\..*/\1/'`;;
		 esac
		 ;;
        OSF1alphaV3.2*)  INSTALLHOST=alpha-dec-osf3.2C ;;
        OSF1alpha[VX]4.*) INSTALLHOST=alpha-dec-osf4.0 ;;
	Linuxi[3-6]861.2.13) INSTALLHOST=i486-linux ;;
	Linux*)          INSTALLHOST=unsupported-linux ;;
        *)               INSTALLHOST=unknown ;;
    esac # ${UNAME}
}


print_help_message()
{
     cat <<EOF

You may supply at least one format on the command line.  Recognized formats are:
    "binaries"      for binaries only
    "source"        for source code only
The default is both source and binaries.

You may also supply actions.  Recognized actions are:
    "extract"       read the appropriate files from tape/file
    "fixincludes"   build a directory of corrected header files for comp-tools 
    "test"          run a very brief verification of your installation

There are three other options:
    --tape=DEVICE   asks Install to read the necessary files from DEVICE. The
                    default DEVICE is ${TAPE}.
    --file=FILE     asks Install to read the necessary files from FILE. The
                    default FILE is ${TAPE}.
    --installdir=DIRECTORY
		    asks Install to install files into DIRECTORY.
                    The default DIRECTORY is ${ROOTING_REAL}.
    --fixincludesdir=DIRECTORY
                    asks Install to fix the files from DIRECTORY.
                    The default DIRECTORY is /usr/include.
EOF
}


print_version_message()
{
     echo "Install, version 2.1"
}

show_exec_prefix_msg()
{
    echo '***' If you want to use the compilation tools in an alternate
    echo '***   ' directory, several environment variables will need
    echo '***   ' to be set.  You probably want to set them with:
    echo ""
    echo "GCC_EXEC_PREFIX=${RELEASE_ROOT}/${EXECDIR}/lib/gcc-lib/ ; export GCC_EXEC_PREFIX"
    GCC_EXEC_PREFIX=${RELEASE_ROOT}/${EXECDIR}/lib/gcc-lib/ ; export GCC_EXEC_PREFIX
    echo ""
    echo '***   ' This is what I will use for the installation tests.
    echo '***   ' For further help, please refer to ${CHANGING_PATHS}
    echo '***   ' in ${NOTES}.
}

show_emacs_alternate_msg()
{
    echo '***' Emacs cannot be installed in an alternate location.  Please
    echo '***' contact Cygnus Support for instructions on how to rebuild
    echo '***' emacs in a different prefix location.
}


#### The Install script is customized by inserting package dependant
#### scripts containing various shell functions when it is generated.
#### There are two functions defined at this time:
####	fix
####		The fix function is called after the package
####		has been loaded.  For example, this function is used
####		by the comp-tools package to run fixincludes and
####		fixproto.
####	verify
####		The verify function is called after the package has
####		been installed.  For example, this function may be
####		used to check that the software is configured
####		properly.
####
#### The control scripts from the POSIX.7.2 draft suggest functions that
#### may be useful for use for future packages.  They are checkinstall,
#### preinstall, postinstall, checkremove, preremove, and postremove
####
####
#### Note that many other install facilities store their package
#### dependant scripts with each distribution.  It would be difficult
#### for us to do the same efficiently.  Their installers are usually
#### programs with built in tar/cpio readers that have the ability to
#### "stop" after control scripts have been extracted.  Since ours is a
#### shell script that must run on many different systems, we would have
#### to either extract the tape contents to a temporary directory and
#### then move it to its final destination; or we would have to perform
#### two passes for each compressed tar image.

#### various functions used to perform post-install fixups (fixincludes, etc.)
fix()
{
    if [ ! -f ${RELEASE_ROOT}/${EXECDIR}/${TARGET}/install-tools/fixincludes ]
    then
        echo "Fixincludes not run for this cross-target."
        return
    fi

    if [ "$FIXINCDIR" = "" ]; then
        cat << EOF
***	There was no directory specified for fixincludes although
***	fixincludes is necessary.  If you already have fixed files
***	for ${TARGET} installed, this is OK.  If not, rerun $0 as
***	    $0 --installdir=<IDIR> --fixincludesdir=<FDIR> fix
***     where <IDIR> is your install directory and <FDIR> is the
***     location of the include files for ${TARGET}.
EOF
        return
    fi

    if [ "${INSTALLHOST}" != "${HOST}" -a "${NOWARN}" != "1" ] ; then
	cat << EOF
***	This machine appears to be for \"${INSTALLHOST}\", while the
***	software on this tape is meant for \"${HOST}\"  
***
***	You may still run \"$0 --extract ...\" on this machine and then
***	run the other steps on the machine on which you wish to install.
***	You will need to do these steps separately.
***	For more information, please refer to
***     ${ANOTHER_TAPE} in ${NOTES}.
EOF
    else
        fixincludes
    fi
}


fixincludes()
{
    LOGFILE=${LOGDIR}/fixincludes.log

    echo Running fixincludes for ${TARGET}.
    echo Verbose output will be stored in ${LOGFILE}.
    echo This will take some time.

    # this used to be exported -- does it still need to be? 
    LIB=${RELEASE_ROOT}/${EXECDIR}/lib/gcc-lib/${TARGET}/${GCCvn}/include 

    CPP="${RELEASE_ROOT}/${EXECDIR}/bin/gcc -E"
    export CPP		# needed by fixincludes and fixproto
    GCC_EXEC_PREFIX=${RELEASE_ROOT}/${EXECDIR}/lib/gcc-lib/
    export GCC_EXEC_PREFIX

    if [ -f ${RELEASE_ROOT}/${EXECDIR}/${TARGET}/install-tools/fix-header ]
    then
        FIX_HEADER=${RELEASE_ROOT}/${EXECDIR}/${TARGET}/install-tools/fix-header
        export FIX_HEADER   # fixproto needs this
    fi

    if [ -f ${RELEASE_ROOT}/${EXECDIR}/${TARGET}/install-tools/fixproto-defines ]
    then
        FIXPROTO_DEFINES="`${RELEASE_ROOT}/${EXECDIR}/${TARGET}/install-tools/fixproto-defines`"
        export FIXPROTO_DEFINES   # fixproto needs this
    fi

    if mkdir ${LIB}/../tmpdir && cp ${LIB}/*.h ${LIB}/../tmpdir ; then
	true
    else
	cat << EOF
*** Unable to create temporary directory ${LIB}/../tmpdir
***     Please ensure that write permissions for
***     ${LIB} are allowed.
***     Or call ${HOTLINE} for more information.
EOF
        exit 1
    fi

    # See below.  We remove limits.h to see if fixincludes
    # fixed /usr/include/limits.h.
    rm -f ${LIB}/limits.h

    ${RELEASE_ROOT}/${EXECDIR}/${TARGET}/install-tools/fixincludes ${LIB} ${FIXINCDIR} ${RELEASE_ROOT}/src/gcc > ${LOGFILE} 2>&1
    if [ $? -ne 0 ]; then
	cat << EOF
*** There seems to have been a problem with fixincludes.
***	The verbose output from the fixincludes script has been logged in
***     ${LOGFILE}.
***     I do not know how to continue until this problem has been
***     corrected.  If you do not know how to fix it either, please
***     call ${HOTLINE}.
EOF
	mv ${LIB}/../tmpdir/* ${LIB} && rmdir ${LIB}/../tmpdir
	exit 1
    fi  # 
    echo '   ' system header files now ANSI compatible 

    ${RELEASE_ROOT}/${EXECDIR}/${TARGET}/install-tools/fixproto ${LIB} ${LIB} ${FIXINCDIR} >> ${LOGFILE} 2>&1
    if [ $? -ne 0 ]; then
	cat << EOF
*** There seems to have been a problem with fixproto.
***     The verbose output from the fixproto script has been logged in
***     ${LOGFILE}.
***     I do not know how to continue until this problem has been
***     corrected.  If you do not know how to fix it either, please
***     call ${HOTLINE}.
EOF
	mv ${LIB}/../tmpdir/* ${LIB} && rmdir ${LIB}/../tmpdir
	exit 1
    fi	
    echo '   ' ansi/posix prototypes added to include files

    # See the GCC Makefile, target stmp-fixinc, for the details on
    # limits.h handling.  If fixincludes fixed /usr/include/limits.h,
    # it gets installed as ${LIB}/syslimits.h.
    if [ -f ${LIB}/limits.h ]; then
      rm -f ${LIB}/limits.h.sys
      mv ${LIB}/limits.h ${LIB}/limits.h.sys
    fi

    mv ${LIB}/../tmpdir/* ${LIB} && rmdir ${LIB}/../tmpdir 

    if [ -f ${LIB}/limits.h.sys ]; then
      rm -f ${LIB}/syslimits.h
      mv ${LIB}/limits.h.sys ${LIB}/syslimits.h
    fi

    echo Fixed include files installed!
}

#### various functions used to verify release 
verify()
{
    echo "Verify not run for cross-targets."
}


###
### do tape stuff, rewind, etc.
###
### problem is that Unixware uses ``tapdev rewind TAPE'' and mt
### uses ``mt -f TAPE rewind''.  pre-defining TAPE_REWIND and
### TAPE_FSF commands is tricky 'cause you need to make sure that
### you get the user's ``-tape=foo'' command line arg set first.
###
### this was a lot easier.
###
### it takes three command line arguemnts, the canonical host type,
### the mt command you want, and the tape device name.
###

do_mt()
{
    do_mtMTCMD="$1"

    case "$INSTALLHOST" in
        i386-sco3.2v4|*sysv4.2)                       # SVR4 peoples
                         do_mtMTCMD="`echo $do_mtMTCMD | sed s/fsf/rfm/`"
                         tape $do_mtMTCMD $TAPE ;;
        hppa1.1-hp-hpux*|m68k-hp-hpux*|mips-sgi-irix4)  # SVR3 peoples
                         mt -t $TAPE $do_mtMTCMD ;;
        *)                                            # normal peoples
                         mt -f $TAPE $do_mtMTCMD ;;
    esac
    return $?
}

do_mkdir()
{
    DIR="$1"	

    echo Trying to create \"${DIR}\"...
    mkdir ${DIR}
    if [ $? -ne 0 ]; then
	echo '***' I can not make directory, \"${DIR}\".

	### attempt to diagnose...

	DIR=`echo ${DIR} | ${SED} -e 's:/[^/]*$::'`
	if [ ! -d "${DIR}" ] ; then
	    echo '***   ' It looks as though \"${DIR}\" does not even exist.
	    exit 1
	fi

	if [ ! -w "${DIR}" ] ; then
	    echo '***   ' It looks as though you do not have write access to \"${DIR}\".
	    echo '***   ' Please fix this and try running Install again.  For more information
	    echo '***   ' please refer to ${NO_ACCESS} in ${NOTES}.
	    exit 1
	fi

	echo '***   ' I do not know why I can not create \"${DIR}\".  This is a problem.
	echo '***   ' Please call ${HOTLINE}
	exit 1
    fi

    echo Created \"${DIR}\".
}

### trigger words on the command line are:
###     --tape=/dev/device
###     --installdir=/foo
###     --fixincludesdir=/bar
###     bin, src
###     extract, fix, test-installation

while :
do

# Break out if there are no more args
    case $# in
    0)
            break
            ;;
    esac

# Get the first arg, and shuffle
    option=$1
    shift

# Make all options have two hyphens
    orig_option=$option # Save original for error messages
    case $option in
    --*)        ;;
    -*) option=-$option ;;
    esac

# Split out the argument for options that take them
    case $option in
    --*=*)
            optarg=`echo $option | sed -e 's/^[^=]*=//'`
            ;;
    esac

# Now, process the options
    case $option in

    --tape*|--file*)
	TAPE=$optarg;
	### in case this is a tape-image file, make sure that 
	### it's an absolute pathname
	case ${TAPE} in
	/*) ;;
	*)  TAPE=`pwd`/${TAPE} ;;
	esac
	;;

    --installdir*)
        INSTALLDIR=$optarg
        ;;

    --fixincludesdir*)
        FIXINCDIR=$optarg
        ;;

    --with-*)
	case "$option" in
	*=*)    ;;
	*)      optarg=yes ;;
	esac

	withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
	eval $withopt="$optarg"
	withoptions="$withoptions $option"
	;;

    --without-*)
	withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'`
	eval $withopt=no
	withoutoptions="$withoutoptions $option"
	;;

    ### actions
    *extract*)      ACTIONS="${ACTIONS} extract" ;;
    *fix*)          ACTIONS="${ACTIONS} fix" ;;
    *test*)         ACTIONS="${ACTIONS} test" ;;

    ### subsets of the distribution
    *src* | *sour*) 
        install_src=true
        ;;
    *bin*)
        install_bin=true
        ;;

    --version)
        print_version_message
        exit 0
        ;;
    --help)     
        print_help_message
	exit 1
        ;;

    --*)
        echo "Install: Unrecognized option: \"$orig_option\"; use --help for usage." >&2
        exit 1
        ;;
    esac
done


###
###
### check for a myriad of sins
###
###

if [ ! -d "${INSTALLDIR}" ] ; then
    do_mkdir "$INSTALLDIR"
fi

cd "${INSTALLDIR}"
if [ $? -ne 0 ]; then
    echo '*** ' Can not cd to \"${INSTALLDIR}\" because I do not have execute permission.
    ls -lad ${INSTALLDIR}
    echo '*** ' Please fix this and then try running Install again.
    exit 1
fi   # ! -d ${INSTALLDIR}

# Make INSTALLDIR absolute (parts below might need it that way).
# FIXME, do they really?
# FIXME, handle pwd failure from upper dir permission
INSTALLDIR=`cd ${INSTALLDIR} ; pwd`
RELEASE_ROOT=${INSTALLDIR}/${RELEASE_TAG}
LOGDIR=${RELEASE_ROOT}

eval guess_system

### where the binaries are in the release
EXECDIR=H-${HOST}
#EXECDIR=

### if neither binaries nor source were specified, assume 
### user meant for both to be installed.
if $install_bin || $install_src; then
	:
else
	install_bin=true
	install_src=true
fi

### If no actions are specified on the command line, then use the
### default actions.
if [ -z "${ACTIONS}" ] ; then
    ACTIONS="extract fix test"
fi # ${ACTIONS}


### if binaries are intended for this machine
if [ "${INSTALLHOST}" = "${HOST}" ] ; then
    for action in ${ACTIONS} ; do
        case ${action} in
        test)
            OURWD=`(cd ${INSTALLDIR}; pwd) 2>/dev/null`
            if [ -d ${ROOTING_REAL} ] ; then
                DEFAULTWD=`(cd ${ROOTING_REAL}; pwd) 2>/dev/null`
            else
                DEFAULTWD=${ROOTING_REAL}
            fi

            case ${BUNDLE} in
            comp-tools | cross-tools)
                if [ "${OURWD}" != "${DEFAULTWD}" ] ; then
                    eval show_exec_prefix_msg
                fi
                ;;
            emacs)
                if [ "${OURWD}" != "${DEFAULTWD}" ] ; then
                    eval show_emacs_alternate_msg
		    exit 1
                fi
                ;;
            esac
            ;;
        esac
    done
fi


### if we can't read the tape drive...
popdir=`pwd`

if [ ! -d "${RELEASE_ROOT}" ] ; then
    if mkdir ${RELEASE_ROOT} ; then
        true
    else
        do_mkdir $RELEASE_ROOT
    fi
else
    if [ ! -w "${RELEASE_ROOT}" ] ; then
        echo '*** ' Cannot write to \"${RELEASE_ROOT}\" because I do not have write permission.
        ls -lad ${RELEASE_ROOT}
        echo '*** ' Please fix this and then try running Install again.
        exit 1
    fi   # ! -r ${RELEASE_ROOT}
fi   # ! -d ${RELEASE_ROOT}


### There is a window here that I don't know how to handle gracefully from
### shell.  If the directory DID exist and WAS executable but dissappeared
### before we could cd into it, we're kinda hosed.  If you get a call about
### this, make sure the directory exists, is readable, is executable, is the
### either the default installation directory or the -installdir=directory
### given on the command line.  Then ask them to just try again.  A few times.
### If you get the same error every time, we've got a very strange bug.  I
### can't help you.

cd ${INSTALLDIR}
if [ $? -ne 0 ] ; then
    echo '***' Cannot cd to \"${INSTALLDIR}\".  This is a problem.
    echo '***   ' For further help, please refer to
    echo '***   ' ${NO_ACCESS} in ${NOTES} or call
    echo '***   ' ${HOTLINE}
    exit 1
fi

### Make sure that the tape device is readable.  This could also be
### triggered when the "tape" is really a compressed tar file image
### which is not readable.  In that case, calling it a "tape" is a
### misnomer.

if echo ${ACTIONS} | grep extract > /dev/null ; then
    if [ ! -r "${TAPE}" ] ; then
        echo '***' Can not read from TAPE or FILE, \"${TAPE}\".
        cd ${popdir} ; ls -lasd ${TAPE}
        echo '***   ' Try using \"./Install --tape=/dev/something ...\" or
        echo '***   '           \"./Install --file=/some/file ...\" to name your tape
        echo '***   ' drive/file or refer to ${MIGHT_WRONG} in
        echo '***   ' ${NOTES}.
        exit 1
    fi  # ! -r ${popdir}/${TAPE}
fi   # extract in ${ACTIONS}

cd ${popdir}

###
###
### extraction
###
###

if echo ${ACTIONS} | grep extract > /dev/null 2>&1 ; then
    if [ ! -d "${INSTALLDIR}" ] ; then
	do_mkdir "${INSTALLDIR}"
    fi

    if [ ! -d "${RELEASE_ROOT}" ] ; then
	do_mkdir "${RELEASE_ROOT}"
    fi

    cd ${RELEASE_ROOT}
    if [ $? -ne 0 ] ; then
        echo '***' I can not cd to \"${RELEASE_ROOT}\".

        ### attempt to diagnose...

        if [ ! -r "${RELEASE_ROOT}" ] ; then
            echo '***   ' It looks as though you do not have execute permission to \"${RELEASE_ROOT}\".
        fi  # ! -r ${RELEASE_ROOT}

        echo '***   ' For further help, please refer to
        echo '***   ' ${NO_ACCESS} in ${NOTES}.
        exit 1
    fi  # cd status is zero

    for trigger in ${TRIGGERS} ; do
	if [ -r "${trigger}" ] ; then
	    echo '***' \"${RELEASE_ROOT}/${trigger}\" exists and I will not overwrite it.
	    echo '***   ' If you really want to install it again, please remove it first.
	    exit 1
        fi  # -r ${trigger}
    done  # for trigger

    TARLOG=${LOGDIR}/extract.log
    echo It will take some time for me to read the tape.
    echo Verbose output will be saved in ${TARLOG}.
    echo Extracting into \"${LOGDIR}\"... 

    ### make sure things come off the tape as they were written, but minus
    ### what could be a security hole.
    umask 0

    if $install_bin; then
	### ${TAPE} might be a disk image of the tape, so don't try to do tape
	### operations on a file
	if [ -b ${TAPE} -o -c ${TAPE} ]; then

	    ### using the no rewind device, so rewind and fsf to be sure.
	    eval do_mt rewind
	    if [ $? -ne 0 ]; then
		echo '***' Could not rewind tape device \"${TAPE}\".
		exit 1
	    fi

	    eval do_mt fsf
	    if [ $? -ne 0 ]; then
		echo '***' Could not forward space tape device \"${TAPE}\".
		exit 1
	    fi  
	fi

	${DD} ${DDOPTS} if=${TAPE} | \
		compress -d | ${TAR} ${TARFLAGS} 2>> ${TARLOG}

	if [ $? -ne 0 ]; then
	    cat << EOF
*** There appears to have been an extraction error.
***   The output from the tar command has been logged in ${TARLOG}
***   I do not know how to continue until this problem has been
***   corrected.  If you do not know how to fix it either, please
***   call ${HOTLINE}.
EOF
	    exit 1
	fi
	# The filenames in gcc-lib/<target> are too darn long, so
	# here's a workaround
	if [ -f ${EXECDIR}/lib/gcc-lib/${TARGET}.tar ] ; then
	    (cd ${EXECDIR}/lib/gcc-lib
	    ${TAR} ${TARFLAGS} < ${TARGET}.tar 2>> ${TARLOG})
	    if [ $? -ne 0 ]; then
	        cat << EOF
*** There appears to have been an extraction error.
***   The output from the tar command has been logged in ${TARLOG}
***   I do not know how to continue until this problem has been
***   corrected.  If you do not know how to fix it either, please
***   call ${HOTLINE}.
EOF
	        exit 1
	    else
	        (cd ${EXECDIR}/lib/gcc-lib; rm -f ${TARGET}.tar 2>> ${TARLOG})
	    fi
	fi
    fi

    if $install_src; then
	### ${TAPE} might be a disk image of the tape, so don't try to do tape
	### operations on a file
	if [ -b ${TAPE} -o -c ${TAPE} ]; then

	    ### using the no rewind device, so rewind and fsf to be sure.
	    eval do_mt rewind
	    if [ $? -ne 0 ]; then
		echo '***' Could not rewind tape device \"${TAPE}\".
		exit 1
	    fi

	    eval do_mt fsf
	    if [ $? -ne 0 ]; then
		echo '***' Could not forward space tape device \"${TAPE}\".
		exit 1
	    fi  

	    eval do_mt fsf
	    if [ $? -ne 0 ]; then
		echo '***' Could not forward space tape device \"${TAPE}\".
		exit 1
	    fi  
	fi

	${DD} ${DDOPTS} if=${TAPE} | \
		compress -d | ${TAR} ${TARFLAGS} 2>> ${TARLOG}

	if [ $? -ne 0 ]; then
	    cat << EOF
*** There appears to have been an extraction error.
***   The output from the tar command has been logged in ${TARLOG}
***   I do not know how to continue until this problem has been
***   corrected.  If you do not know how to fix it either, please
***   call ${HOTLINE}.
EOF
	    exit 1
	fi
    fi

    echo Cygnus Support software distribution extracted!
fi


###
###
### fix (header files)
###
###

if echo ${ACTIONS} | grep fix > /dev/null 2>&1 ; then
    fix
fi


###
###
### verify the installation
###
###

if echo ${ACTIONS} | grep test > /dev/null 2>&1 && $install_bin ; then
    verify
    echo Cygnus Support software distribution tested!
fi

echo Done.
exit 0

###
### Local Variables:
### comment-column: 0
### fill-column: 131
### End:
###

### End of Install
