#!/bin/csh -f

#  Copyright (c) 1991, 1992, 1993 Xerox Corporation.  All Rights Reserved.  
#  
#  Unlimited use, reproduction, and distribution of this software is
#  permitted.  Any copy of this software must include both the above
#  copyright notice of Xerox Corporation and this paragraph.  Any
#  distribution of this software must comply with all applicable United
#  States export control laws.  This software is made available AS IS,
#  and XEROX CORPORATION DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
#  INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY
#  AND FITNESS FOR A PARTICULAR PURPOSE, AND NOTWITHSTANDING ANY OTHER
#  PROVISION CONTAINED HEREIN, ANY LIABILITY FOR DAMAGES RESULTING FROM
#  THE SOFTWARE OR ITS USE IS EXPRESSLY DISCLAIMED, WHETHER ARISING IN
#  CONTRACT, TORT (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, EVEN IF
#  XEROX CORPORATION IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
#  
#  $Id: ilu-install-lisp,v 1.3 1993/09/23 01:20:29 janssen Exp $

if ( $#argv < 1 ) exit 1
set package = $1

if ( $#argv > 1 ) then
	set directory = $2
else
	set directory = .
endif
cd $directory

if ( $#argv > 2 ) then
	set destdir = $3
else
	set destdir = ${ILUHOME}/lisp
endif

cd /usr/tmp/${package}

echo "Installing Common Lisp for package '$package' from directory /usr/tmp/${package}..."

sed -e "s;/usr/tmp/${package};${ILUHOME}/lisp;" <${package}-sysdcl.lisp >${package}-sysdcl.lisp.2
cp ${package}-sysdcl.lisp.2 ${package}-sysdcl.lisp

${ILUHOME}/bin/ilu-franz -qq -batch -- ${package}-sysdcl <<EOF
(load "/import/commonlisp-library/pdefsys")
(compile-file (sys:command-line-argument 1 :application t))
(with-open-file (s "/usr/tmp/${package}/compiled-lisp-extension.$$"
		 :direction :output)
  (format s "~a" excl:*fasl-default-type*))
(exit 0)
EOF

set extension = `cat /usr/tmp/${package}/compiled-lisp-extension.$$`

foreach file ( `ls ${package}-basics.lisp ${package}-server-procs.lisp ${package}-class-records.c ${package}-sysdcl.lisp` )
	echo $file
	/import/misc/bin/safe-install -m 444 $file $destdir
end
foreach file ( `ls ${package}-basics.${extension} ${package}-server-procs.${extension} ${package}-class-records*.o ${package}-sysdcl.${extension}` )
	echo $file
	/import/misc/bin/safe-install -m 666 $file $destdir
end






