#!/bin/csh -fx
###############################################################################
#
# File:           PDIST:MAKE-BARE-PSL
# Description:    This file constructs a new  BARE-PSL
# Author:         Leigh Stoller
# Created:        01-Nov-86
# Modified:       
# Mode:           C Shell
# Package:        Tools
#
# (c) Copyright 1982, University of Utah
# %
# % Redistribution and use in source and binary forms, with or without
# % modification, are permitted provided that the following conditions are met:
# %
# %    * Redistributions of source code must retain the relevant copyright
# %      notice, this list of conditions and the following disclaimer.
# %    * Redistributions in binary form must reproduce the above copyright
# %      notice, this list of conditions and the following disclaimer in the
# %      documentation and/or other materials provided with the distribution.
# %
# % THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# % AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# % THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# % PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR
# % CONTRIBUTORS
# % BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# % CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# % SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# % INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# % CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# % ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# % POSSIBILITY OF SUCH DAMAGE.
#
###############################################################################
# Revisions:
# 
# 21.Nov 1991 (Winfried Neun)
#  changes to support .img files (for IBM RS6000, HP Risc, etc
#
###############################################################################

unset inprocess


if ($MACHINE == apollo) then
   set imagesize=3000000
  else if ($MACHINE == sun386) then
   set imagesize=3000000
  else if ($MACHINE == cray-t3d) then
   set imagesize=20000000
  else if ($MACHINE == Alpha) then
   set imagesize=12000000
  else if ($MACHINE == Mips_dec) then
   set imagesize=8000000
  else if ($MACHINE == Mips_iris) then
   set imagesize=8000000
  else if ($MACHINE == Ibmrs) then
   set imagesize=8000000
  else if ($MACHINE == brock) then
   set imagesize=1000
  else if ($MACHINE == AMD64) then
   set imagesize=1000
  else if ($MACHINE == AMD64_ext) then
   set imagesize=1000
  else if ($MACHINE == macintel64) then
   set imagesize=1000
  else if ($MACHINE == mingw-w64) then
   set imagesize=1000
  else if ($MACHINE == freeBSD64) then
   set imagesize=1000
  else if ($MACHINE == aarch64) then
   set imagesize=1000
  else
   set imagesize=10000000 
endif


pushd $pnkl			# Go where the files to be loaded are.
setenv SavingPSL yes		# skip user startup before savesystem

if ( -e $psys/.imago) then
    mv -f $psys/bare-psl.img $psys/old-bare-psl.img
  else
    mv -f $psys/bare-psl $psys/old-bare-psl
endif

$pxk/bpsl -td $imagesize << EOF
(setq loaddirectories* '("" "$pl/"))
(on verboseload)
(setq symbolfilename* "$pxk/bpsl")
(cond ((equal "cray-t3d" (getenv "MACHINE")) (copyd 'pre-main 'pre-main-2)))
(savesystem 
  (cond ((unboundp '**low-case) "Bare PSL 3.4")
        (t "Bare PSL 4.2"))
         "\$psys/bare-psl" NIL)
(exitlisp)
EOF

cat > $psys/bare-psl << EOFFF
#
\$pxk/bpsl -td $imagesize -f \$psys/bare-psl.img \$*
#
EOFFF

chmod +x $psys/bare-psl

cat > $psys/tmp.sed << EOFF
s/HERE/$PROOT/g
EOFF

## sed -f  $psys/tmp.sed  $PROOT/run-bare-psl.tmpl >  $PROOT/run-bare-psl.sh

@ pslcompstatus = $status
popd

if ( -x $psys/sparsify ) then
    if ( -e $psys/.imago) then
        $psys/sparsify $psys/bare-psl.img
      else
        $psys/sparsify $psys/bare-psl
    endif
endif

@ status = $pslcompstatus

# End of file.
