#!/bin/csh -f
#
#  mk-lisp -- script for building full lisp cores.
#
# $Header: /home/CVS-cmucl/src/tools/mk-lisp,v 1.17 1997/02/05 18:13:01 pw Exp $

# ignore historical option
if ($#argv) then
    if ($argv[1] == "-now") then
	shift
    endif
endif

if ($#argv) then
	set subdir = $argv[1]
	set features = ($argv[2-])
else
	set subdir = alpha
	set features = ()
endif

if $?CMUCL_ROOT then
	set root = $CMUCL_ROOT
else
	set root = /afs/cs/project/clisp
endif

set dest = $root/build/@sys/$subdir
set src = $root/src/$subdir

if (-e $dest/lisp/kernel.core) then
	set core = $dest/lisp/kernel.core
else
	if (-e /usr/tmp/kernel.core) then
		set core = /usr/tmp/kernel.core
	else
		echo Can\'t find the kernel.core
	endif
endif

if (-e $src/VERSION) then
	set version = `cat $src/VERSION`
else
	set version = `/bin/date | awk '{print $3 "-" $2 "-" $6}'`
endif

if (-e $src/FEATURES) then
	set features = ($features `cat $src/FEATURES`)
endif

echo Building lisp.core version $version from the \`\`$subdir\'\' subdir.
echo "Features: $features"

$dest/lisp/lisp -core $core << EOF
(setf *features* (list* $features *features*))
(setf (search-list "target:") '("$dest/" "$src/"))
(in-package "USER")
(load (open "target:tools/worldload.lisp"))
$version
(quit)
EOF

echo 
