#
# usage:        tmw_alsc.sh
#
# abstract:     This Bourne Shell script outputs the TMW_Archive INCREMENT
#		Line Summary.
#
# note(s):      1. This routine must be called using a . (period)
#
#		     TMW_Archive INCREMENT Line Summary
#  ----------------------------------------------------------------------------
#  cat <TMW_Archive INCREMENT line Error file>
#----------------
#
#    'license.dat' file, $MATLAB/etc/license.dat, does not exist . . .
#
#    MATLAB =  ...                  
#
#----------------
#
#    No TMW_Archive INCREMENT lines in $MATLAB/etc/license.dat . . .
#
#    MATLAB =  ...                  
#
#----------------
#
#        No decryption software found. Looked for . . .
#
#--------- CDROM  (SHOULD NEVER HAPPEN!)
#
#        $dear
#
#--------- tape (ufs)
#
#        $MATLAB/update/tape/bin/$ARCH/dear
#        $MATLAB/update/bin/$ARCH/dear
#
#--------- non tape (ufs)
#
#        $MATLAB/update/bin/$ARCH/dear
#
#    MATLAB =  ...                  
#
#    Found decryption software for other MATLAB supported architectures:
#
#	sun4 dec_risc
#
#    If decryption is required, please use a system with one of these other
#    architectures to install MATLAB.
#
#---------------- If no other architectures then Contact the MathWorks.
#
#    Found NO decryption software for any other MATLAB supported architectures.
#
#    Please contact:    The MathWorks, Inc. Technical Support:
#                       Phone: 508-653-1415
#                       FAX:   508-653-2997
#                       Email: support@mathworks.com
#
#----------------
#  ----------------------------------------------------------------------------
#  -> Only toolboxes listed under valid TMW_Archive INCREMENT lines will be 
#  -> decrypted.
#  ----------------------------------------------------------------------------
#----------------
#
#               2. Where to look for dear:
#
#		   MODE = tape
#
#			Should always be there for any ARCH:
#				$MATLAB/update/tape/bin/$ARCH/dear
#			Then check in $MATLAB/update/bin/$ARCH/dear
#
#		   MODE = 
#
#			If running CD, check first on CD:
#				$dear_arch
#		        Then check in $MATLAB/update/bin/$ARCH/dear
#
# Copyright (c) 1994-1998 The Mathworks, Inc. All Rights Reserved.
# $Revision: 1.8 $  $Date: 1998/12/24 17:31:48 $
#----------------------------------------------------------------------------
#
# Check TMW_Archive lines. Variables returned:
#
#    n_archivel = the number of possible TMW_Archive INCREMENT
#                 lines
#
#    ngood_archivel = the number of good TMW_Archive INCREMENT
#                     lines
#
#    temp_file4 = all TMW_Archive lines and any dear output
#
#    dear_exist = 0 if dear does not exist
#                 1 if dear does exists
#
#    license_file_exist = 0 if license file does not exist
#			  1 if license file exists
#
#----------------------------------------------------------------------------
    . $dir/$cktmw_al_sh
    cat /dev/null > $temp_file 2>&1
#----------------------------------------------------------------------------
echo ' 		         TMW_Archive INCREMENT Line Summary' >> $temp_file
echo '--------------------------------------------------------------------------------' >> $temp_file
#----------------------------------------------------------------------------
    if [ "$license_file_exist" = "0" ]; then
#----------------------------------------------------------------------------
echo '' >> $temp_file
echo '    license file does not exist . . .' >> $temp_file
echo '' >> $temp_file
echo "    license file = $Filepath" >> $temp_file
#----------------------------------------------------------------------------
    elif [ "$dear_exist" = "0" ]; then
	cat $temp_file4 >> $temp_file
#----------------------------------------------------------------------------
echo '' >> $temp_file
echo '    No decryption software found. Looked for . . .' >> $temp_file
echo '' >> $temp_file
#----------------------------------------------------------------------------
	if [ "$MODE" = "tape" ]; then
#----------------------------------------------------------------------------
echo '        $MATLAB/update/tape/bin/'"$ARCH"'/dear' >> $temp_file
echo '        $MATLAB/update/bin/'"$ARCH"'/dear' >> $temp_file
echo '' >> $temp_file
echo "    MATLAB =  $MATLAB" >> $temp_file
#----------------------------------------------------------------------------
	elif [ "$CD_ROOT" != "" ]; then
#
# This SHOULD NEVER HAPPEN! Internal error.
#
#----------------------------------------------------------------------------
echo "        $dear" >> $temp_file
echo '' >> $temp_file
#----------------------------------------------------------------------------
	else
#----------------------------------------------------------------------------
echo '        $MATLAB/update/bin/'"$ARCH"'/dear' >> $temp_file
echo '' >> $temp_file
echo "    MATLAB =  $MATLAB" >> $temp_file
#----------------------------------------------------------------------------
	fi
#
# Look for other architectures in $MATLAB/update/bin.
#
#
        other_dear=0
	(cd $MATLAB/update/bin) > /dev/null 2>&1
        if [ $? -eq 0 ]; then
	    start_archlist=`(cd $MATLAB/update/bin; ls)`
	    if [ "$start_archlist" != "" ]; then
		archlist=
		for single_arch in $start_archlist
		do
		    if [ -f $MATLAB/update/bin/$single_arch/dear ]; then
			archlist="$archlist $single_arch"
		    fi
		done
		if [ "$archlist" != "" ]; then
		    other_dear=1
		fi
	    fi
	fi
	if [ "$other_dear" != "0" ]; then
#----------------------------------------------------------------------------
echo '' >> $temp_file
echo '    Found decryption software for other MATLAB supported architectures:' >> $temp_file
echo '' >> $temp_file
echo "       $archlist" >> $temp_file
echo '' >> $temp_file
echo '    If decryption is required, please use a system with one of these other' >> $temp_file
echo '    architectures to install MATLAB.' >> $temp_file
#----------------------------------------------------------------------------
	else
#----------------------------------------------------------------------------
echo '' >> $temp_file
echo '    Found NO decryption software for any other MATLAB supported architectures.'  >> $temp_file
echo '' >> $temp_file
echo '    Please contact:    The MathWorks, Inc. Technical Support:' >> $temp_file
echo '                       Phone: 508-647-7000' >> $temp_file
echo '                       FAX:   508-647-7201' >> $temp_file
echo '                       Email: support@mathworks.com' >> $temp_file
#----------------------------------------------------------------------------
	fi
    elif [ "$n_archivel" = "0" ]; then
#
# Use for CD-ROM and FTP
#
#----------------------------------------------------------------------------
echo '' >> $temp_file
echo '    No TMW_Archive INCREMENT lines in license file . . .' >> $temp_file
echo '' >> $temp_file
echo "    license file = $Filepath" >> $temp_file
#----------------------------------------------------------------------------
    else
	cat $temp_file4 >> $temp_file
    fi
#----------------------------------------------------------------------------
echo '' >> $temp_file
echo '--------------------------------------------------------------------------------' >> $temp_file
echo '-> Only toolboxes listed under valid TMW_Archive INCREMENT lines will be' >> $temp_file
echo '-> decrypted. NA* means not available yet. NO* means no plans on Unix.' >> $temp_file
echo '--------------------------------------------------------------------------------' >> $temp_file
#----------------------------------------------------------------------------
    more -cf $temp_file
    . $dir/$cleanup_sh
    exit 0
