#! /bin/sh
################################################################################
#
#  This material contains proprietary software of Entropic Research Lab, Inc.   
#  Any reproduction, distribution, or publication without the the prior	   
#  written permission of Entropic Research Lab, Inc. is strictly prohibited.
#  Any public distribution of copies of this work authorized in writing by
#  Entropic Research Lab, Inc. must bear the notice			
# 								
#      "Copyright (c) 1990 Entropic Research Lab, Inc.; All rights reserved"
# 				
#
#  Install script for ESPS @(#)install	3.20 11/8/88 ESI
#  
################################################################################
#
#  Remember, since this is a shell (/bin/sh) script, there should be
#  no spaces around the = and quote multi-word values.
#
#  Things to check:
#	1. check the machine type default.  Possible values listed just
#	   below.  Search for MACH= to see where its set.  You can also
#	   set it via the command line.
#	2. check floating point type.  This is after option processing 
#	   below.  Search for FLOAT.
#	3. check the destination (target) directory name (SPSDIR).  This
#	   directory doesn't have to exist, but the user-id running this
#	   script must be able to create it.
#	4. There are many other parameters that can be changed in the
#	   block with SPSDIR.  We suggest you leave all of these alone.
#	5. There are some machine dependent parameters after the option
#	   processing.  Check these.  The only ones you should change
#	   are d/a and a/d types in the Masscomp block.  Search for
#          ADDEV, DADEV, ADTYPE, CLKDEV.   Also check the maximum value
#          for the AD converter and DA converter.  It depends on if
#          you have a 12 or 16 bit converter (or whatever size).
#	6. The pager program (like more(1)) that gets called is defined
#	   below.  Set it if you want to use something else.  Search for
#          PAGER.
#	7. The command to do hardcopy plotting must be specified below.
#	   Search for esps_plot.
#	8. Name you C compiler (if its not cc) in CC=.
#	9. Check VTROFF.  Make this equal to your troff command if you
#	   can do troff typeset type output (used by eman -t).
#
ESPS_VERSION=5.0
WAVES_VERSION=5.0
################################################################################
# Option Processing  (see install.hlp)
#
# Option defaults:
#
# Reset the following line if desired.  We suggest using it as is.
# This determines where the target directory is.  This directory 
# doesn't have to exist, but the user-id that the isntall script is run
# under must be able to create it.
#
SPSDIR=/usr/esps
#
CLEAN=			# set CLEAN=clean to do a "make clean" after each
			# install.  Otherwise leave it CLEAN=
DOLOCAL=n 		# y to install a local section
LOCALDIR=local.skel	# name of your local directory (peer to general)
			# ours is local.epi, yours should be something else
			# this is only used if LOLOCAL = y
			#
# LOCAL=" -DDEMO "
# LOCAL="-DESI "	# Should be " " for initial installation
LOCAL=" "
			# if you have any local -D flags, they go here
			# e.g. we do -DESI for our local programs
			# must be non-null for a local part, make it
			# -DXXX, where XXX means something to you
			#
WAVES=n			# y to install waves+, n for no waves
WAVES_TYPE=waves.esi	# one of waves.src, waves.sun3_68881, waves.sun3_fpa,
			# waves.386i, or waves.sun4, or waves.esi
			# depending on your waves type
DOPUB=n			# Make stuff in pub directory.
CATS=n			# y to make cat files for man pages (real slooow...)
MACH=MC5600	# machine type, see above for what they mean
CFLAG=0			# always initialize this to 0
NFLAG=			# passed to make (reserved for -n)
WHATIS=y 		# y to make whatis data base (for man -k)
NODIFFMK=n		# set to y if this system doesn't have diffmk -
			# this is set below in the system dependent part
			# for CONVEX.   Some Suns don't have diffmk
CC=cc			# Name of your C compiler.  For Convex you can
			# use vc here.
ERELNOTE=rel42.doc	# name of release note file for esps
WRELNOTE=wrel31.doc	# name of release note file for waves+

if test MACH = SOLBOURNE
 then
 MACH=SUN4
fi
################################################################################
#
# Configuration for Hardcopy Plotting
#
# The esps plot programs can output tektronix compatible plots.  If your
# hardcopy plotter can handle this (like imagen laser printers) then
# put the right command here to receive tek codes on standard in and
# them.     This is the command run when the -Timagen or -Tplotter
# option is used on the plot programs.  There are several cases shown
# here.  A postscript printer (like an Apple), a local imagen with imagen
# software, an imagen on a CONVEX with iprx, and a remote imagen.
#
# If you have a postscript printer, please contact us for the additional
# software (free).
# 
PLOTCOMMAND=esps_plot	# leave these two lines alone in most cases
export PLOTCOMMAND
#
#  >>> EDIT THE esps_plot SCRIPT BELOW <<<
################################################################################
#
rm -f esps_plot
cat <<ZAP >esps_plot
#! /bin/sh
# do not hack this file.  Change it in the install script and rerun install
# This script is fed a tektronix format plot file in standard input.
#
# For the case of a remote machine do something like: (masscomp is the remote)
# rsh masscomp ipr -Ltektronix -D\"prerasterization on\"
#
# For a postscript printer do:  (We will send tek2ps on request)
# tek2ps -e | lpr
#
# For ipr (imagen) on the local machine you usually do:
ipr -Ltektronix -D"prerasterization on"
#
# For an imagen on CONVEX you might do:
# (echo "@document(language tektronix)"; cat -) | /usr/ucb/lpr -Pip -v
#
ZAP
################################################################################
#
# For plotting the output of image, a Imagen printer is need (for now)
# Put the command that we can pipe Impress output to here:
#
SPOOL_CMD=lpr
#
#
#
################################################################################

if test $# = 0
 then
 echo doing complete installation
 echo Making the library and all programs and installing
 echo all documentation
 echo
fi



while test x$1 != x
do
	case "$1" in
	-p)	SPSDIR=$2; shift;;
	-c)	CFLAG=1; ;;
	-C)	CLEAN=clean; ;;
	-L)	DOLOCAL=y; ;;
	-m)	CATS=y; ;;
	-M)	MACH=$2; shift ;;
	-n)	NFLAG=-n; ;;
	-w)	WHATIS=y; ;;
	-h)	more install.hlp; exit 0;;
	-*)	echo "esps_install: unknown option $i" ; exit 1 ;;
	*)	break;;
	esac
	shift
done
ESPS_BASE=$SPSDIR; export ESPS_BASE
echo Options:
echo SPSDIR=$SPSDIR, ESPS_BASE=$ESPS_BASE, CFLAG=$CFLAG, CLEAN=$CLEAN, DOLOCAL=$DOLOCAL
echo DOPUB=$DOPUB, CATS=$CATS, MACH=$MACH, NFLAG=$NFLAG, WHATIS=$WHATIS
echo Dirs: $*
################################################################################
#
# on Masscomp systems, be sure that we are in the ucb universe
#
if test $MACH = M5600 -o $MACH = M5500
then
  uni=`universe`
  if test $uni != ucb
   then
    echo ERROR: You must be in the ucb universe to install ESPS.
    echo type: universe ucb
    echo and start the install again
    exit 1
  fi
fi
#
################################################################################
#
# -h flag for cross compiling to another machine.  Used for masscomp only
#HFLAG="-h68010 -fsoft"
HFLAG=
#
################################################################################
#
# -DNOPAD option to produce a version that works with old (pre-3.1) Sun
# data files (don't fool with this)
#NOPAD="-DNOPAD"
NOPAD=
#
################################################################################
#
# we strongly suggest leaving all of these lines as they are:
#
SINCP=$SPSDIR/include	# SINCP is the parent of the include file directory
SINC=$SINCP/esps	# SINC is ESPS include file directory
LIBDIR=$SPSDIR/lib	# LIBDIR is library directory
WAVESDIR=$LIBDIR/waves  # WAVESDIR is where the waves libraries go
WAVESMENUS=$WAVESDIR/menus # WAVESMENUS holds waves menu scripts.
WAVESFILES=$WAVESDIR/files # WAVESFILES holds general waves+ datafiles.
MENUDIR=$LIBDIR/menus	# MENUDIR is where mbuttons and fbuttons scripts go.
COLORMAPDIR=$LIBDIR/colormap # where mbuttons and fbuttons scripts go.
FILTDIR=$LIBDIR/filters # FILTDIR is where filter data files go.
FILESDIR=$LIBDIR/files  # FILESDIR are where data files go.
KEYDIR=$LIBDIR/keys	# KEYDIR for license keys
PARAMSDIR=$LIBDIR/params # PARAMSDIR holds paramater files.
MANDIR=$SPSDIR/man	# MANDIR is the parent man directory
BINDIR=$SPSDIR/bin	# BINDIR is the directory for binaries
OLDBIN=$BINDIR/old	# OLDBIN is a place for old binaries
LIBNAME=libespsg.a	# LIBNAME is the name of the ESPS library
EHDRLIB=libhdre.a	# EHDRLIB is the name of the header library
		   	# compiled for an ESPS license only
WHDRLIB=libhdrw.a	# WHDRLIB is the name of the header library
			# compiled for an ESPS or waves+ license
SHDRLIB=libhdrs.a	# commpiled for ESPS/waves or ERS
 EXVLIB=libexv.a		# ESPS XView library
#EXVLIB=
 EXV_LIB=${LIBDIR}/${EXVLIB}
#EXV_LIB=
LLIBROOT=espsg		# LLIBROOT is root of lint library file name
			# LLIBNAME is the lint library name
LLIBNAME=llib-l${LLIBROOT}.ln 
SPSLIB=${EXV_LIB}" "${LIBDIR}/${EHDRLIB}" "${LIBDIR}/${LIBNAME}
			# The ESPS library for use on dependency rules
WSPSLIB=${EXV_LIB}" "${LIBDIR}/${WHDRLIB}" "${LIBDIR}/${LIBNAME}
SSPSLIB=${EXV_LIB}" "${LIBDIR}/${SHDRLIB}" "${LIBDIR}/${LIBNAME}
			# The ESPS library for use on dependency rules
			# for waves related programs
LINTLIB=$LIBDIR/$LLIBNAME
PLOTDIR=$LIBDIR		# Where the plotting programs go
			# The name of the lint source file for echeck
LINTFILE=$LIBDIR/llib-lespsg.c
			# SINCLP is the local h file parent directory
SINCLP=$SPSDIR/include.local 
SINCL=$SINCLP/esps	# SINCL is the local include directory
			# the same as BINDIR.
################################################################################
#
# These are the access mode variables.  These can be reset to limit
# access to group if desired
#
PROGMOD=0755		# PROGMOD is the access mode for programs
MANMOD=0644		# MANMOD is the access mode for man pages
HMOD=0444		# HMOD is the access mode for include files
LIBMOD=0644		# LIBMOD is the mode of the library
SPSMOD=0755		# SPSMOD is mode of main esps directory
MANDIRMOD=0755		# mode of man directory
CATMOD=0777		# mode of man/cat? directories
BINDIRMOD=0755		# mode of bin directory
LIBDIRMOD=0755		# mode of lib directory
SINCMOD=0755		# mode of include directory
#
################################################################################
#
# Define STRIP if you want binaries striped before installation
#
STRIP=strip			# causes binaries to be striped(1) 
#STRIP="@echo no strip done on"	# use this one to not strip programs
#
# Some other initial values that not all systems have
RANLIB=ranlib
EQN=eqn
# Define the command for ln. This might be overridden on some systems.
LINK='ln -s'
################################################################################
#  Possible System type values:
#  enter the default below, or use -m command line option
#
# MACH=M5500		# 68010 Masscomp
# MACH=M5600		# 68020 Masscomp
# MACH=SUN3		# Sun 3 series
# MACH=SUN4		# Sun 4 series
# MACH=SUN386i		# Sun 386i 
# MACH=CONVEX		# Convex
# MACH=DS3100		# DEC Station 3100 (MIPS RISC)
# MACH=VAX		# DEC Vax (running Ultrix only!)
#
#  
#
################################################################################
#
#  Specify floating point type: 
#  
#  Find your machine type below and set the correct floating point
#  option.
#
################################################################################
#  For SUN3:
#  Remove comment from the correct one, comment out the others
#  See the Sun3 'cc' man page for information about this.  If in doubt
#  use -fsoft for now.  It will always work, but is slow.
#
# SUN3
#
if test $MACH = SUN3
 then
FLOAT=-f68881	
# FLOAT=-ffpa
# FLOAT=-fsky
# FLOAT=-fsoft
# FLOAT=-fswitch
# FLOAT=
fi
#
################################################################################
# SUN4   -- No floating point options needed
#
if test $MACH = SUN4
 then
  FLOAT=
fi
################################################################################
# SUN386i   -- No floating point options needed
#
if test $MACH = SUN386i
 then
  FLOAT=
fi
################################################################################
#  For Masscomp:  M5500 or M5600
#
#  Use the -f option to generate hardware floating point support.  On a 
#  68020 machine with the 68881 chip, no -f is used.  See the Masscomp
#  cc(1) man page for details.  There might be other options that aren't
#  listed here.  Go ahead and use them if they seem right for your system.
#
if test $MACH = M5500 -o $MACH = M5600
 then
FLOAT=		# use for 68020 masscomp with only 68881
#FLOAT=-fsoft	# software floating point on 68010 with no floating hw
#FLOAT=-f 	# hardware floating point board
fi
#
#
################################################################################
#  For CONVEX, use the -fi option if IEEE floating point is desired.
#  This is required if you want to share binary data files with Suns or
#  Masscomps.
#
if test $MACH = CONVEX
 then
FLOAT=-fi	# use IEEE floating point mode
fi
#
#
#
#
################################################################################
# DEC DS3100   -- No floating point options needed
#
if test $MACH = DS3100
 then
  FLOAT=
fi
################################################################################
# DEC VAX   -- No floating point options needed
#
if test $MACH = VAX
 then
  FLOAT=
fi
################################################################################
echo ESPS Installation Script started at `date`
echo ESPS Installation Script started at `date` $ESPS_VERSION
echo Targert directory: $SPSDIR
echo Library directory: $LIBDIR
echo Machine type: $MACH
echo Floating point option: $FLOAT
echo LOCAL: $LOCAL
################################################################################
# All other machine dependent defines will go here.
# Don't change ours the first time around.  You probably won't ever want
# to change them.
#
################################################################################
# Machine dependent defines for SUN3:
#
if test $MACH = SUN3
 then
  XWIN=YES
  SUNVIEW=YES
  TOUCH="touch -f"		# must use -f to touch read-only files
  MKLINTLIB="lint -D$MACH -I$SINCP -C$LLIBROOT -DLIB"
  LINT="lint -b -c "		# just plain lint here (see lint(1))
  PLAY=				# no play program on Sun
  RECORD=			# no record program on Sun
  MCD=mcd			# Our version of mcd(1)
  MCD_PROG=$MCD			# should always be $MCD on Sun
  RANGE=			# sun version of range program
  SHOWRAS=showras		# sun only program
  DEBUGGER=dbx			# name of the Sun symbolic debugger
  XVIEW_INC="/usr/openwin/include "
  XVIEW_LIB="-L/usr/openwin/lib -lxview -lolgx -lX11"
  if test $SUNVIEW = YES
   then
    MCD=mcd			# sunview mcd program
    WINDOWS=" -DSUNVUE "	# defines which window system we have
    WIN_INC=" "
    WINLIBS="-lsuntool -lsunwindow -lpixrect"
    MCD_PROG=mcd		# Name of Sunview mcd program
    RANGE=			# no range program
  fi
  if test $XWIN = YES
   then
    MCD_PROG=xmcd		# xmcd for Xwindows on Sun
    MCD=xmcd_sun3		# xmcd_sun3 source directory 
    WINDOWS=" -I/home/openwin/include -DXWIN " # For system with only X windows	
    RANGE=			# Range not needed with X
    WINLIBS="-L/home/openwin/lib -lX11"	# X window library
  fi
  if test $SUNVIEW = YES -a $XWIN = YES
   then
    WINDOWS=" -I/usr/openwin/include -DXWIN -DSUNVUE "
    WINLIBS="-L/usr/openwin/lib -lX11 -lsuntool -lsunwindow -lpixrect "
    MCD="mcd xmcd_sun3"
   fi
  SUNOS=OS4			# Put your SUN OS level here OS3 or OS4
  XVIEW_B_OPT="-Bstatic"
#
# Put any other SUN3 defines here
  XOFF="set +x"			# how to you turn off set -x in /bin/sh
fi
#
################################################################################
# Machine dependent defines for SUN4:
#
if test $MACH = SUN4
 then
  XWIN=YES
  SUNVIEW=YES
  TOUCH="touch -f"		# must use -f to touch read-only files
  MKLINTLIB="lint -D$MACH -I$SINCP -C$LLIBROOT -DLIB"
  LINT="lint -b -c "		# just plain lint here (see lint(1))
  PLAY=splay			# splay (SS1 codec)
  RECORD=			# no record program on Sun
  RANGE=			# 
  SHOWRAS=showras		# sun only program
  DEBUGGER=dbx			# name of the Sun symbolic debugger
  XVIEW_INC="/h5/openwin3.0/include "
  XVIEW_LIB="-L/h5/openwin3.0/lib -lxview -lolgx -lX11"
  if test $SUNVIEW = YES
   then
    MCD=mcd			# sunview mcd program
    WINDOWS=" -DSUNVUE "	# defines which window system we have
    WIN_INC=" "
    WINLIBS="-lsuntool -lsunwindow -lpixrect"
    MCD_PROG=mcd		# Name of Sunview mcd program
    RANGE=			# no range program
  fi
  if test $XWIN = YES
   then
    MCD_PROG=xmcd		# xmcd for Xwindows on Sun4
    MCD=xmcd_sun4		# xmcd_sun4 source directory 
    WINDOWS=" -I/h5/openwin3.0/include -DXWIN " # For system with only X windows	
    RANGE=			# Range not needed with X
    WINLIBS="-L/h5/openwin3.0/lib -lX11"		# X window library
  fi
  if test $SUNVIEW = YES -a $XWIN = YES
   then
    WINDOWS=" -I/h5/openwin3.0/include -DXWIN -DSUNVUE "
    WINLIBS="-L/h5/openwin3.0/lib  -lX11 -lsuntool -lsunwindow -lpixrect "
    MCD="mcd xmcd_sun4"
   fi
  SUNOS=OS4			# Put your SUN OS level here OS3 or OS4
  XVIEW_B_OPT="-Bstatic"
#   XVIEW_B_OPT=""
#
# Put any other SUN4 defines here
  XOFF="set +x"			# how to you turn off set -x in /bin/sh
fi
#
################################################################################
# Machine dependent defines for SUN386i:
#
if test $MACH = SUN386i
 then
  TOUCH="touch -f"		# must use -f to touch read-only files
  MKLINTLIB="lint -D$MACH -I$SINCP -C$LLIBROOT -DLIB"
  LINT="lint -b -c "		# just plain lint here (see lint(1))
  PLAY=				# no play program on Sun
  RECORD=			# no record program on Sun
  MCD=mcd			# Our version of mcd(1)
  MCD_PROG=$MCD			# should always be $MCD on Sun
  SHOWRAS=showras		# sun only program
  RANGE=			# 
  DEBUGGER=dbx			# name of the Sun symbolic debugger
  WINLIBS="-lsuntool -lsunwindow -lpixrect"
  WINDOWS=" -DSUNVUE "
  XWIN=NO
  SUNOS=OS4			# Put your SUN OS level here OS3 or OS4
#
# Put any other SUN386i defines here
  XOFF="set +x"			# how to you turn off set -x in /bin/sh
fi
#
################################################################################
#
# Machine dependent defines for MASSCOMP
#
if test $MACH = M5600 -o $MACH = M5500
 then
  XWIN=YES			# YES if you have Masscomp X windows, else NO
  SP40=NO			# YES if you have Masscomp GP40 graphics,
				# else NO
				# You CAN have both
  TOUCH=touch
#  DADEV="/dev/dacp0/daf0"	# name of default d/a converter (ef12)
  DADEV="/dev/dacp0/dah0"	# name of default d/a converter (da04)
  CLKDEV="/dev/dacp0/efclk"	# name of the default clock device (ef12)
  ADDEV="/dev/dacp0/adf0"	# name of the default a/d converter (ef12)
  ADTYPE="AD16M"		# type of ad converter
#  MAXDA=2047			# max value to d/a (12 bit)
  MAXAD=2047			# max value to a/d (12 bit)
#  MINDA=-2048			# min value to d/a (12 bit)
  MINAD=-2048			# min value to a/d (12 bit)
  MAXDA=32767			# max value to d/a (16 bit)
#  MAXAD=32767			# max value to a/d (16 bit)
  MINDA=-32768			# min value to d/a (16 bit)
#  MINAD=-32768			# min value to a/d (16 bit)
  MKLINTLIB="att lint -DLIB -D$MACH -I$SINCP -c "
  LINT="att lint -b "		# use att lint on Masscomp
  PLAY=mcplay			# name of play program
  RECORD=mcrecord		# name of record program
  XVIEW_INC="/usr/xview/include "
  XVIEW_LIB="/usr/xview/lib/libxview.a /usr/xview/lib/libolgx.a -lX11"
  if test $SP40 = YES
   then
    MCD=			# no mcd program supplied by us
    WINDOWS=" -DSP40 "		# defines which window system we have
    WINLIBS="-lwindow -lgp"     # window libraries to link in
    MCD_PROG=mcd		# Name of Masscomp mcd program
				# mcd for independent graphics, 
				# mcdigh for integral graphics
    RANGE=mcrange		# Masscomp range program
  fi
  if test $XWIN = YES
   then
    MCD_PROG=xmcd		# xmcd for Xwindows on Masscomp
    MCD=xmcd_mc			# xmcd_mc source directory 
    WINDOWS=" -DXWIN "		# For system with only X windows	
    RANGE=			# Range not needed with X
    WINLIBS="-lX11"		# X window library
  fi
  if test $SP40 = YES -a $XWIN = YES
   then
    WINDOWS=" -DXWIN -DSP40 "
    WINLIBS="-lX11 -lwindow -lgp"
   fi
  DEBUGGER=mdb			# name of the symbolic debugger
  SHOWRAS=			# no showras program
#
# Put any other MASSCOMP defines here
  XOFF="set +x"			# how to you turn off set -x in /bin/sh
fi
#
# NOTE: Possible ADTYPE for Masscomps are: EF12M, AD12F, AD12FA, AD12,
#					   AD16M, LOCALad1, LOCALad2
#
#
################################################################################
# Machine dependent defines for CONVEX:
#
if test $MACH = CONVEX
 then
  XWIN=YES			# YES if X window system, else NO
  TOUCH="touch -f"		# must use -f to touch read-only files
  MKLINTLIB="lint -D$MACH -DLIB -I$SINCP -C$LLIBROOT "
  LINT="lint -b -c "		# just plain lint here (see lint(1))
  DADEV="/dev/ad0"		# device name of default d/a converter 
  ADDEV="/dev/ad0"		# device name of the default a/d converter
  ADTYPE="RTI-732"		# type of ad converter
  MAXDA=2047			# max value to d/a (12 bit)
  MAXAD=2047			# max value to a/d (12 bit)
  MINDA=-2048			# min value to d/a (12 bit)
  MINAD=-2048			# min value to a/d (12 bit)
  PLAY=cplay			# convex play program
  RECORD=crecord		# convex record program
  RANGE=			# No convex range program
  DEBUGGER=csd			# name of the symbolic debugger
  USE_VC=yes			# use vc instead of cc
				# when doing this, put the right flags
				# for vc in LIBCFLAGS and PROGCFLAGS
				# below
  if test $XWIN = YES
   then
    MCD_PROG=xmcd		# xmcd for Xwindows on Convex
    MCD=xmcd_cx			# xmcd_cx source directory 
    WINDOWS=" -DXWIN "		# For system with only X windows	
    RANGE=			# Range not needed with X
    WINLIBS="-lX11"		# X window library
  fi
  SHOWRAS=			# no showras program
#
# Put any other CONVEX defines here
  XOFF="set -"			# how to you turn off set -x in /bin/sh
  NODIFFMK=y			# Convex doesn't have diffmk
fi
#
################################################################################
# Machine dependent defines for HP:
#
if test $MACH = HP300 -o $MACH = HP800
 then
  XWIN=YES			# YES for X window system, else NO
  TOUCH="touch"		
  MKLINTLIB="lint -DLIB -D$MACH -I$SINCP -o $LLIBROOT "
  LINT="lint -b "		# just plain lint here (see lint(1))
  DADEV=""			# device name of default d/a converter 
  ADDEV=""			# device name of the default a/d converter
  ADTYPE=""			# type of ad converter
  MAXDA=2047			# max value to d/a (12 bit)
  MAXAD=2047			# max value to a/d (12 bit)
  MINDA=-2048			# min value to d/a (12 bit)
  MINAD=-2048			# min value to a/d (12 bit)
  PLAY=				# HP play program
  RECORD=			# HP record program
  RANGE=			# No HP range program
  DEBUGGER=xdb			# name of the symbolic debugger
				# below
  WINLIBS=" "
  MORECFLAGS=" -Wc,-Nd2000 -Wc,-Ns4000 "
  DEFINES=" -Dbcopy=memcpy -Drandom=lrand48 -Dsrandom=srand48 "
  if test $XWIN = YES
   then
    MCD_PROG=xmcd		# xmcd for Xwindows on HP
    MCD=xmcd_src		# xmcd source directory 
    WINDOWS=" -DXWIN "		# For system with only X windows	
    RANGE=			# Range not needed with X
    WINLIBS="-lX11"		# X window library
  fi
  SHOWRAS=			# no showras program
  XVIEW_INC="/usr/xview/include "
  XVIEW_LIB="/usr/xview/lib/libxview.a /usr/xview/lib/libolgx.a -lX11 -lBSD"
#
# Put any other HP defines here
  XOFF="set +x"			# how to you turn off set -x in /bin/sh
  NODIFFMK=n			# HP has diffmk
  RANLIB="echo no need to ranlib:" # HP does not have ranlib
  EQN=cat
fi
#
################################################################################
# Machine dependent defines for MACII:
#
if test $MACH = MACII
 then
  XWIN=YES			# YES for X window system, else NO
  TOUCH="touch"		
  MKLINTLIB="lint -DLIB -D$MACH -I$SINCP -o $LLIBROOT "
  LINT="lint -b "		# just plain lint here (see lint(1))
  DADEV=""			# device name of default d/a converter 
  ADDEV=""			# device name of the default a/d converter
  ADTYPE=""			# type of ad converter
  MAXDA=2047			# max value to d/a (12 bit)
  MAXAD=2047			# max value to a/d (12 bit)
  MINDA=-2048			# min value to d/a (12 bit)
  MINAD=-2048			# min value to a/d (12 bit)
  PLAY=				# play program
  RECORD=			# record program
  RANGE=			# No range program
  DEBUGGER=xdb			# name of the symbolic debugger
				# below
  WINLIBS=" "
  MORECFLAGS="  "
  DEFINES="  -Drandom=lrand48 -Dsrandom=srand48 "
  if test $XWIN = YES
   then
    MCD_PROG=xmcd		# xmcd for Xwindows on HP
    MCD=xmcd_mac		# xmcd source directory 
    WINDOWS=" -DXWIN "		# For system with only X windows	
    RANGE=			# Range not needed with X
    WINLIBS="-lX11"		# X window library
  fi
  SHOWRAS=			# no showras program
  XVIEW_INC="/home/openwin/include "
  XVIEW_LIB="-L/home/openwin/lib -lxview -lolgx -lX11"
#
# Put any other HP defines here
  XOFF="set +x"			# how to you turn off set -x in /bin/sh
  NODIFFMK=n			# HP has diffmk
  RANLIB="echo no need to ranlib:" # HP does not have ranlib
  EQN=cat
fi
#
# Machine dependent defines for DS3100:
#
if test $MACH = DS3100
 then
  XWIN=YES			# Must have X windows
  TOUCH="touch -f"		# must use -f to touch read-only files
  MKLINTLIB="lint -D$MACH -I$SINCP -c -DLIB"
  LINT="lint -b "		# just plain lint here (see lint(1))
  PLAY=				# no play program on Sun
  RECORD=			# no record program on Sun
  XVIEW_INC="/usr/xview/include "
  XVIEW_LIB="/usr/xview/lib/libxview.a /usr/xview/lib/libolgx.a /usr/esps/lib/libX11.a"
  if test $XWIN = YES
   then
    MCD_PROG=xmcd		# xmcd for Xwindows 
    MCD=xmcd_ds3100		# xmcd binary directory 
    WINDOWS=" -DXWIN "	# For system with only X windows	
    RANGE=			# Range not needed with X
    WINLIBS=" $LIBDIR/libX11.a "	# X window library
  fi
  DEBUGGER=dbx			# name of the symbolic debugger
  SHOWRAS=			# no showras program
#
# Put any other DS3100 defines here
  XOFF="set -"			# how to you turn off set -x in /bin/sh
  EQN=cat
fi
#
#
# Machine dependent defines for IBM 6000:
#
if test $MACH = IBM_RS6000
 then
  XWIN=YES			# Must have X windows
  TOUCH="touch -f"		# must use -f to touch read-only files
  MKLINTLIB="lint -D$MACH -I$SINCP -c -DLIB"
  LINT="lint -b "		# just plain lint here (see lint(1))
  PLAY=				# no play program on Sun
  RECORD=			# no record program on Sun
  XVIEW_INC="/usr/XView/usr/include  "
  XVIEW_LIB="/usr/XView/usr/lib/libxview.a /usr/XView/usr/lib/libolgx.a /usr/lib/X11.a  "
  if test $XWIN = YES
   then
    MCD_PROG=xmcd		# xmcd for Xwindows 
    MCD=xmcd		# xmcd binary directory 
    WINDOWS=" -DXWIN "	# For system with only X windows	
    RANGE=			# Range not needed with X
    WINLIBS=" -lX11 "	# X window library
  fi
  DEBUGGER=dbx			# name of the symbolic debugger
  SHOWRAS=			# no showras program
#
# Put any other IBM defines here
  XOFF="set -"			# how to you turn off set -x in /bin/sh
  EQN=eqn
  MORECFLAGS="  -qchars=signed -w "
fi
#
################################################################################
# Machine dependent defines for VAX:
#
if test $MACH = VAX
 then
  XWIN=YES			# Must have X windows
  TOUCH="touch -f"		# must use -f to touch read-only files
  MKLINTLIB="lint -D$MACH -I$SINCP -C$LLIBROOT -DLIB"
  LINT="lint -b "		# just plain lint here (see lint(1))
  PLAY=				# no play program on Sun
  RECORD=			# no record program on Sun
  XVIEW_INC="/usr/xview/include "
  XVIEW_LIB="-L/usr/xview/lib -lxview $LIBDIR/libX11.a"
  if test $XWIN = YES
   then
    MCD_PROG=xmcd		# xmcd for Xwindows 
    MCD=xmcd_vax		# xmcd binary directory 
    WINDOWS=" -DXWIN "	# For system with only X windows	
    RANGE=			# Range not needed with X
    WINLIBS=" $LIBDIR/libX11.a "	# X window library
  fi
  DEBUGGER=dbx			# name of the symbolic debugger
  SHOWRAS=			# no showras program
  LIBMV=" -lmV "		# additional math lib on Vax
#
  XOFF="set -"			# how to you turn off set -x in /bin/sh
  EQN=cat
fi
#
################################################################################
################################################################################
# Machine dependent defines for SG:
#
if test $MACH = SG
 then
  XWIN=YES			# Must have X windows
  TOUCH="touch -f"		# must use -f to touch read-only files
  MKLINTLIB="lint -D$MACH -I$SINCP -c -DLIB"
  LINT="lint -b "		# just plain lint here (see lint(1))
  PLAY=				# no play program on Sun
  RECORD=			# no record program on Sun
  if test $XWIN = YES
   then
    MCD_PROG=xmcd		# xmcd for Xwindows 
    MCD=xmcd_sg		# xmcd binary directory 
    WINDOWS=" -DXWIN "		# For system with only X windows	
    RANGE=			# Range not needed with X
    WINLIBS="-lX11"		# X window library
  fi
  DEBUGGER=dbx			# name of the symbolic debugger
  SHOWRAS=			# no showras program
  RANLIB="echo no need to ranlib: "
#
# Put any other SG defines here
  XOFF="set -"			# how to you turn off set -x in /bin/sh
  MORECFLAGS=" -cckr  -I/usr/include/bsd -signed -lsun"
  BSDLIB=" -lsun /usr/lib/libbsd.a "
  EQN=cat
  XVIEW_INC="/usr/xview/include "
  XVIEW_LIB="/usr/xview/lib/libxview.a /usr/xview/lib/libolgx.a -lX11 -lsun -lbsd -lmalloc"
  AUDIOLIB=" -laudio "

fi
#
################################################################################
#
################################################################################
# Machine dependent defines for SONY:
#
if test $MACH = SONY_RISC
 then
  XWIN=YES
  TOUCH="touch -f"		# must use -f to touch read-only files
  MKLINTLIB="lint -DLIB -D$MACH -I$SINCP -c "
  LINT="lint -b -c "		# just plain lint here (see lint(1))
  PLAY=				# Sony play program
  RECORD=			# no record program on Sun
  RANGE=			# 
  SHOWRAS=
  DEBUGGER=dbx			# name of the symbolic debugger
  MORECFLAGS=" -Wf,-XNd20000 "
  XVIEW_INC="/usr/xview/include "
  XVIEW_LIB="/usr/xview/lib/libxview.a /usr/xview/lib/libolgx.a -lX11"
  if test $XWIN = YES
   then
    MCD_PROG=xmcd		# xmcd for Xwindows on Sony
    MCD=xmcd_sonyr		# xmcd_Sony source directory 
    WINDOWS="  -DXWIN " 		# For system with only X windows	
    RANGE=			# Range not needed with X
    WINLIBS=" -lX11"		# X window library
  fi
#
# Put any other SONY defines here
  XOFF="set -"			# how to you turn off set -x in /bin/sh
  NODIFFMK=y			# SONY doesn't have diffmk
fi
#
################################################################################
################################################################################
#
# You might want to change these.
#
# if you have a "typeset" command (itroff, iroff, vtroff, etc)
# define it here.
VTROFF=itroff
#
# define your default pager here.  Most people use more.
DEFAULT_PAGER=more
#
################################################################################
#
# leave these alone
#
if test x$SUNOS != x
 then
  SUNOSLEVEL=-D$SUNOS
fi
LIBCFLAGS="-O $MORECFLAGS $DEFINES $NOPAD $HFLAG -DLIB -DSCCS -I$SINCP $LOCAL -D$MACH $FLOAT"
LIBFFLAGS="-O $HFLAG $FLOAT"
OLIBCFLAGS="-O $MORECFLAGS $DEFINES $NOPAD $HFLAG -DLIB -DSCCS -I$SINCP $LOCAL -D$MACH $FLOAT"
PROGCFLAGS="$MORECFLAGS $LOCAL $DEFINES $NOPAD $HFLAG -DSCCS -I$SINCP -D$MACH $FLOAT $SUNOSLEVEL"
PROGFFLAGS="$HFLAG $FLOAT"
#
LIBLINTFLAGS="$DEFINES -DLIB -I$SINCP $LOCAL -D$MACH"
LINTFLAGS="$DEFINES -I$SINCP -D$MACH"
#
# comment this out if you don't want to install the programs (perhaps)
# for testing purposes
INSTALL=install
#
SRCDIR=${SPSDIR}/general/src
#
# end of installation variables
################################################################################
#
echo Sun OS level is $SUNOS
echo PROGCFLAGS is $PROGCFLAGS
#
#  Nothing below here to change
#
HERE=`pwd`
PATH="$HERE:$PATH"
export PATH

cd src
umask 022

if test $CFLAG = 0
then
 if test ! -d $SPSDIR
 then
   echo $SPSDIR doesn\'t exist, trying to make it...
   echo mkdir $SPSDIR
   mkdir $SPSDIR
   chmod $SPSMOD $SPSDIR
 fi
echo ESPS Version: $ESPS_VERSION - Waves+ Version: $WAVES_VERSION >${SPSDIR}/version
 
 if test ! -d $SINCP
  then
   echo $SINCP doesn\'t exist, trying to make it...
   echo mkdir $SINCP $SINC
   mkdir $SINCP $SINC
   chmod $SINCMOD $SINP $SINC
 fi
 
 if test x$DOLOCAL = xy
  then
  if test ! -d $SINCLP
   then
    echo $SINCLP doesn\'t exist, trying to make it...
    echo mkdir $SINCLP $SINCL
    mkdir $SINCLP $SINCL
    chmod $SINCMOD $SINCLP $SINCL
  fi
 fi
 
 if test ! -d $LIBDIR
  then
   echo $LIBDIR doesn\'t exist, trying to make it...
   echo mkdir $LIBDIR
   mkdir $LIBDIR
   chmod $LIBDIRMOD $LIBDIR
 fi

 for dir in $MENUDIR $FILTDIR $FILESDIR $PARAMSDIR $KEYDIR $COLORMAPDIR
 do
  if test ! -d $dir
  then
   echo $dir doesn\`t exist, trying to make it...
   echo mkdir $dir
   mkdir $dir
   chmod $LIBDIRMOD $dir
  fi
 done

 
 if test ! -d $WAVESDIR
  then
   echo $WAVESDIR doesn\'t exist, trying to make it...
   echo mkdir $WAVESDIR
   mkdir $WAVESDIR
   chmod $LIBDIRMOD $WAVESDIR
 fi

 for dir in $WAVESMENUS $WAVESFILES 
 do
  if test ! -d $dir
  then
   echo $dir doesn\`t exist, trying to make it...
   echo mkdir $dir
   mkdir $dir
   chmod $LIBDIRMOD $dir
  fi
 done

 
 if test ! -d $WAVESDIR/colormaps
  then
   echo $WAVESDIR/colormaps doesn\'t exist, trying to make it...
   echo mkdir $WAVESDIR/colormaps
   mkdir $WAVESDIR/colormaps
   chmod $LIBDIRMOD $WAVESDIR/colormaps
 fi
 
 if test ! -d $WAVESDIR/commands
  then
   echo $WAVESDIR/commands doesn\'t exist, trying to make it...
   echo mkdir $WAVESDIR/commands
   mkdir $WAVESDIR/commands
   chmod $LIBDIRMOD $WAVESDIR/commands
 fi
 
 if test ! -d $LIBDIR/maclib
  then
   echo $LIBDIR/maclib doesn\'t exist, trying to make it...
   echo mkdir $LIBDIR/maclib
   mkdir $LIBDIR/maclib
   chmod $LIBDIRMOD $LIBDIR/maclib
 fi
 
 if test ! -d $LIBDIR/lisp
  then
   echo $LIBDIR/lisp doesn\'t exist, trying to make it...
   echo mkdir $LIBDIR/lisp
   mkdir $LIBDIR/lisp
   chmod $LIBDIRMOD $LIBDIR/lisp
 fi
 
 if test ! -d $SPSDIR/doc
 then
  echo mkdir $SPSDIR/doc
  mkdir $SPSDIR/doc
  chmod $MANDIRMOD $SPSDIR/doc
 fi
 
 if test ! -d $SPSDIR/doc/waves
 then
  echo mkdir $SPSDIR/doc/waves
  mkdir $SPSDIR/doc/waves
  chmod $MANDIRMOD $SPSDIR/doc/waves
 fi
 
 if test ! -d $SPSDIR/demo
 then
  echo mkdir $SPSDIR/demo
  mkdir $SPSDIR/demo
  chmod $MANDIRMOD $SPSDIR/demo
 fi

 if test ! -d $SPSDIR/newdemos
 then
  echo mkdir $SPSDIR/newdemos
  mkdir $SPSDIR/newdemos
  chmod $MANDIRMOD $SPSDIR/newdemos
 fi

 if test ! -d $SPSDIR/pub
 then
  echo mkdir $SPSDIR/pub
  mkdir $SPSDIR/pub
  chmod $MANDIRMOD $SPSDIR/pub
 fi
 
 if test ! -d $SPSDIR/src_examples
 then
  echo mkdir $SPSDIR/src_examples
  mkdir $SPSDIR/src_examples
  chmod $MANDIRMOD $SPSDIR/src_examples
 fi
 
 if  test  ! -d $MANDIR
 then
   echo mkdir $MANDIR 
   mkdir $MANDIR 
 fi
 if test ! -d $MANDIR/man1
 then 
   echo mkdir $MANDIR/man1
   mkdir $MANDIR/man1
 fi
 if test ! -d $MANDIR/man3
 then 
   echo mkdir $MANDIR/man3
   mkdir $MANDIR/man3
 fi
 if test ! -d $MANDIR/man5
 then 
   echo mkdir $MANDIR/man5
   mkdir $MANDIR/man5
 fi
 if test ! -d $MANDIR/cat1
 then 
   echo mkdir $MANDIR/cat1
   mkdir $MANDIR/cat1
 fi
 if test ! -d $MANDIR/cat3
 then 
   echo mkdir $MANDIR/cat3
   mkdir $MANDIR/cat3
 fi
 if test ! -d $MANDIR/cat5
 then 
   echo mkdir $MANDIR/cat5
   mkdir $MANDIR/cat5
 fi
 
 if test ! -d $SPSDIR/general
  then
   echo ln -s $HERE $SPSDIR/general
   ln -s $HERE $SPSDIR/general
 fi

 
 chmod $MANDIRMOD $MANDIR $MANDIR/man* 
 chmod $CATMOD $MANDIR/cat*
 
 if  test  ! -d $BINDIR
 then
   echo mkdir $BINDIR $OLDBIN
   mkdir $BINDIR $OLDBIN
   chmod $BINDIRMOD $BINDIR $OLDBIN
 fi
fi

export SPSDIR PARAMDIR SINC LIBDIR WAVESDIR MANDIR BINDIR OLDBIN SPSLIB PROGMOD 
export MANMOD HMOD EHDRLIB WHDRLIB SHDRLIB WSPSLIB SSPSLIB XVIEW_B_OPT
export LINTFLAGS LINT SRCDIR  SINCP LLIBNAME LIBNAME LIBMOD
export INSTALL LINTLIB HERE PLOTDIR SINCL SINCLP LOCAL
export PROGCFLAGS LIBCFLAGS OLIBCFLAGS LINTFILE MKLINTLIB LLIBROOT
export VTROFF DEFAULT_PAGER FLOAT DADEV ADDEV CLKDEV TOUCH MAXDA MAXAD
export STRIP LINK MACH LIBFFLAGS PROGFLAGS MINDA MINAD
export MCD_PROG WINLIBS CC LOCALDIR
export CATMOD MANDIRMOD XOFF BINDIRMOD SPOOL_CMD RANLIB EQN WINDOWS XWIN
export LIBMV AUDIOLIB

SPSLIB2=$SPSLIB
WSPSLIB2=$WSPSLIB
SSPSLIB2=$SSPSLIB
if test $MACH = SG
 then
  SPSLIB2="$SPSLIB /usr/lib/libsun.a /usr/lib/libbsd.a"
  WSPSLIB2="$WSPSLIB /usr/lib/libsun.a /usr/lib/libbsd.a"
  SSPSLIB2="$SSPSLIB /usr/lib/libsun.a /usr/lib/libbsd.a"
fi

rm -f $HERE/emake
echo '#! /bin/sh' > $HERE/emake
echo exec make \\ >> $HERE/emake
echo  SPSDIR=$SPSDIR \\ >> $HERE/emake
echo  BINDIR=$BINDIR \\ >> $HERE/emake
echo  MANDIR=$MANDIR \\ >> $HERE/emake
echo  LIBDIR=$LIBDIR \\ >> $HERE/emake
echo  PARAMDIR=$LIBDIR/params \\ >> $HERE/emake
echo  WAVESDIR=$WAVESDIR \\ >> $HERE/emake
echo  PROGMOD=$PROGMOD \\ >> $HERE/emake
echo  MANMOD=$MANMOD \\ >> $HERE/emake
echo  OLDBIN=$OLDBIN \\ >> $HERE/emake
echo  SPSLIB=\"$SPSLIB2\" \\ >> $HERE/emake
echo  WSPSLIB=\"$WSPSLIB2\" \\ >> $HERE/emake
echo  SSPSLIB=\"$SSPSLIB2\" \\ >> $HERE/emake
echo  PROGCFLAGS=\"$PROGCFLAGS\" \\ >> $HERE/emake
echo  LINT=\"$LINT\" \\ >> $HERE/emake
echo  LINTFLAGS=\"$LINTFLAGS\" \\ >> $HERE/emake
echo  STRIP=\"$STRIP\" \\ >> $HERE/emake
echo  LINK=\"$LINK\" \\ >> $HERE/emake
echo  SINC=$SINC \\ >> $HERE/emake
echo  LINTLIB=$LINTLIB \\ >> $HERE/emake
echo  PLOTDIR=$PLOTDIR \\ >> $HERE/emake
echo  LIBNAME=$LIBNAME \\ >> $HERE/emake
echo  LLIBNAME=$LLIBNAME \\ >> $HERE/emake
echo  LIBCFLAGS=\"$LIBCFLAGS\" \\ >> $HERE/emake
echo  LIBFFLAGS=\"$LIBFFLAGS\" \\ >> $HERE/emake
echo  PROGFFLAGS=\"$PROGFFLAGS\" \\ >> $HERE/emake
echo  OLIBCFLAGS=\"$OLIBCFLAGS\" \\ >> $HERE/emake
echo  LIBMOD=$LIBMOD \\ >> $HERE/emake
echo  LINTFILE=$LINTFILE \\ >> $HERE/emake
echo  DEFAULT_PAGER=$DEFAULT_PAGER \\ >> $HERE/emake
echo  VTROFF=$VTROFF \\ >> $HERE/emake
echo  MACH=$MACH \\ >> $HERE/emake
echo  FLOAT=$FLOAT \\ >> $HERE/emake
echo  MKLINTLIB=\"$MKLINTLIB\" \\ >> $HERE/emake
echo  CLKDEV=\"$CLKDEV\" \\ >> $HERE/emake
echo  ADDEV=\"$ADDEV\" \\ >> $HERE/emake
echo  DADEV=\"$DADEV\" \\ >> $HERE/emake
echo  MAXAD=$MAXAD \\ >> $HERE/emake
echo  MAXDA=$MAXDA \\ >> $HERE/emake
echo  MINAD=$MINAD \\ >> $HERE/emake
echo  MINDA=$MINDA \\ >> $HERE/emake
echo  ADTYPE=\"$ADTYPE\" \\ >> $HERE/emake
echo  PLOTCOMMAND=\"$PLOTCOMMAND\" \\ >> $HERE/emake
echo  MCD=\"$MCD_PROG\" \\ >> $HERE/emake
echo  HMOD=$HMOD \\ >> $HERE/emake
echo  WINLIBS=\"$WINLIBS\" \\ >> $HERE/emake
echo  CC=\"$CC\" \\ >> $HERE/emake
echo  SPOOL_CMD=\"$SPOOL_CMD\" \\ >> $HERE/emake
echo  RANLIB=\"$RANLIB\" \\ >> $HERE/emake
echo  EQN=$EQN \\ >> $HERE/emake
echo  WINDOWS=\"$WINDOWS\" \\ >> $HERE/emake
echo  XVIEW_INC=\"$XVIEW_INC\" \\ >> $HERE/emake
echo  XVIEW_LIB=\"$XVIEW_LIB\" \\ >> $HERE/emake
echo  XWIN=\"$XWIN\" \\ >> $HERE/emake
echo  EHDRLIB=\"$EHDRLIB\" \\ >> $HERE/emake
echo  SHDRLIB=\"$SHDRLIB\" \\ >> $HERE/emake
echo  EXVLIB=\"$EXVLIB\" \\ >> $HERE/emake
echo  WHDRLIB=\"$WHDRLIB\" \\ >> $HERE/emake
echo  XVIEW_B_OPT=\"$XVIEW_B_OPT\" \\ >> $HERE/emake
echo  BSDLIB=\"$BSDLIB\" \\ >> $HERE/emake
echo  LIBMV=\"$LIBMV\" \\ >> $HERE/emake
echo  AUDIOLIB=\"$AUDIOLIB\" \\ >> $HERE/emake
echo  \$* >> $HERE/emake

chmod 0755 $HERE/emake


if test $NODIFFMK = y
 then
  echo making fake diffmk ...
  echo "echo No diffmk" >$HERE/diffmk
  chmod 0755 $HERE/diffmk
  rm -f $BINDIR/diffmk
  cp $HERE/diffmk $BINDIR/diffmk
  chmod $PROGMOD $BINDIR/diffmk
fi

# if SUN and dynamic link then copy in the Sun xview libraries.
#
if test $CFLAG = 0
then
if test x$1 != xnone -a \( $MACH = SUN4 -o $MACH = SUN3 \) -a x$XVIEW_B_OPT = x 
 then
   echo "Copying Sun shared Xview libraries to $LIBDIR"
   echo "Copying these files: `ls /usr/openwin/lib/lib*.s*`"
   cp /usr/openwin/lib/lib*.s* $LIBDIR
   echo "done copying shared xview libraries."
else
   echo "Not installing shared Xview libraries."
fi
fi

# If a Sun4 then we will ship copies of the Xview include files too.
#
if test $CFLAG=0
then
  if test $MACH = SUN4 
  then
    echo "Copying Sun /usr/openwin/include files along as well..."
    if test ! -d $SPSDIR/include/xview
    then
      mkdir $SPSDIR/include/xview
    fi
    cp -r /usr/openwin/include/xview/* ${SPSDIR}/include/xview
  fi
fi

# DIRS is set to all the directory names that you want to be built by
# this script.   It is replaced by command line names if any are given
#

DIRA=" \
lib libxv elm lib_sp lib_header echeckout utils  addsd copysd misc psps \
utils  addsd copysd misc psps \
refcof testsd cnvlab \
bhd pplain nodiff  \
spectrans fft spscvt stats copysps fftinv select fea_stats distort \
vq lwb mlplot genplot playtest hdshrink $PLAY $RECORD $MCD \
larcbk2rc cbkedit lpcana lpcsynt randplay ils_esps ereverse \
fea_edit wmse_filt me_spec igenplot imlplot pen doc "
DIRS="$DIRA "" \
erlsupport demos plotsd plotspec plot_script $RANGE scatplot comment btosps \
fea2mat mat2fea fea_element eparam notch_filt sdcomp filter fft_filter rem_dc \
fea_deriv filtspec atofilt impulse_rs aplot zero_pole lloydcbk demo \
his classify plotfield find_ep auto cross_cor make_sd addgen addfea \
addfeahd hditem frame window iir_filt image pwr zcross setrange \
transpec toep_solv spgm sfconvert dither featospec spectofea me_sgram \
tofspec sgram setmax mergefea feafunc mbrot sdtofea featosd $SHOWRAS \
mux demux tofeasd esps2mu mu2esps gpstohp getparam exprompt eversion fea_print \
plot3d xtext tutorial fftcep acf xacf cbkd dtw dtw_rec send_xwaves \
filtconvert xpz fbuttons mbuttons get_esps_base findespsfile expromptrun \
addclass vq vqclassify vqdst wsystem einfo elogo clip ../man"

if test x$1 != x
 then
  DIRS=$*
fi

if test $CFLAG = 0
 then
  echo doing regular install $ESPS_VERSION
  echo Installing header files...
  set -x
  cd ../h
  $HERE/emake  install
  if test x$DOLOCAL =  xy
  then
    cd $HERE/../$LOCALDIR/h
    $HERE/emake  install
  fi
  cd $HERE/src
  $XOFF
else
  echo doing clean $VERSION 
  for dir in  $DIRS
   do
    if test $dir != "../man"
    then 
     echo Cleaning $dir...
     set -x
     cd $dir
     $HERE/emake  $NFLAG clean
     cd ..
     $XOFF
    fi
   done
  exit 0
fi

if test $MACH = DS3100 -o $MACH = VAX
 then
 echo Get Xlib and remove XvmsAlloc.o from it...
 set -x
 cp /usr/lib/libX11.a $LIBDIR
 ar dv $LIBDIR/libX11.a XvmsAlloc.o
 ranlib $LIBDIR/libX11.a
 $XOFF
fi

for dir in  $DIRS
 do
  if test -d $dir
  then
   echo Installing $dir...
   set -x
   cd $dir
   $HERE/emake  $NFLAG $INSTALL $CLEAN
   $XOFF
   if test $dir = "../man" 
    then
     cd ../src
    else
     cd ..
   fi
if test $dir = lib -a \( $MACH = M5600 -o $MACH = M5500 \)
 then
     echo getting strtol and strtod...
     set -x
     ar xv /.attlib/libc.a strtod.o strtol.o
     ar rv $LIBDIR/libespsg.a strtod.o strtol.o
     $RANLIB $LIBDIR/libespsg.a
     rm strtod.o strtol.o
     $XOFF
fi
  else
   echo Cannot open $dir, skipping it
  fi
done

echo Producing position independent emake \(run make with all the right parameters\) ...
cat $HERE/emake | sed -e s+$SPSDIR+\`get_esps_base\`+g > $BINDIR/emake
chmod $PROGMOD $BINDIR/emake

echo Producing esps_plot ...
mv $HERE/esps_plot $BINDIR/esps_plot
chmod $PROGMOD $BINDIR/esps_plot

echo Producing position independent ecc \(compile simple esps programs\) command...
cd $HERE
rm -f $BINDIR/ecc
cat <<ZAP | sed -e s+$SPSDIR+\`get_esps_base\`+g >$BINDIR/ecc
#! /bin/sh
echo cc $PROGCFLAGS \$* $SPSLIB -lm
cc $PROGCFLAGS \$* $SPSLIB -lm
ZAP
chmod $PROGMOD $BINDIR/ecc

if test $MACH = CONVEX
 then
echo Producing evc \(compile simple esps programs with vc\) command...
echo Convex only
cd $HERE
rm -f $BINDIR/evc
cat <<ZAP >$BINDIR/evc
#! /bin/sh
echo vc $PROGCFLAGS \$* $SPSLIB -lm
vc $PROGCFLAGS \$* $SPSLIB -lm
ZAP
chmod $PROGMOD $BINDIR/evc
fi

echo Producing elint \(runs lint on simple esps programs\)...
rm -f $BINDIR/elint
cat <<ZAP >$BINDIR/elint
echo $LINT $LINTFLAGS \$* $LINTLIB -lm
$LINT $LINTFLAGS \$* $LINTLIB -lm
ZAP
chmod $PROGMOD $BINDIR/elint

echo Producing edb \(mdb with all the right options\) ...
rm -f $BINDIR/edb
cat <<ZAP >$BINDIR/edb
echo $DEBUGGER -I $SRCDIR/lib \$*
$DEBUGGER -I $SRCDIR/lib \$*
ZAP
chmod $PROGMOD $BINDIR/edb

rm -f $BINDIR/mach_type
cat <<ZAP >$BINDIR/mach_type
echo $MACH
ZAP
chmod $PROGMOD $BINDIR/mach_type

rm -f $LIBDIR/maclib/echeck.ml
cp src/utils/echeck.ml $LIBDIR/maclib/echeck.ml
chmod $PROGMOD $LIBDIR/maclib/echeck.ml

rm -f $LIBDIR/lisp/esps.el
cp src/utils/esps.el $LIBDIR/lisp/esps.el
chmod $PROGMOD $LIBDIR/lisp/esps.el

rm -f $LIBDIR/makefile.ex
cp lib/makefile.ex $LIBDIR/makefile.ex
chmod $MANMOD $LIBDIR/makefile.ex

if test $MACH != SONY_RISC -a $MACH != CONVEX
 then
  echo Fixing the man macro to work with us...
  soelim /usr/lib/tmac/tmac.an | grep -v KNOW |  grep -v "Sun Release" | \
  sed 's/MISC. REFERENCE MANUAL PAGES/ENTROPIC RESEARCH LAB./' | \
  sed 's/\]W/\]Z/g' | sed 's/Last change:/Copyright Entropic Research Lab, Inc./' > $LIBDIR/tmac.an
 else
  cat /usr/lib/tmac/tmac.an | grep -v KNOW  | sed 's/\]W/\]Z/g' | \
  cat - $HERE/copyright.an > $LIBDIR/tmac.an
fi
chmod $MANMOD $LIBDIR/tmac.an

if test $1x = nonex
 then
  exit 0
fi

echo Copying doc files...
cp doc/* $SPSDIR/doc
rm -f doc/esps.rel doc/waves.rel
ln doc/$ERELNOTE doc/esps.rel
ln doc/$WRELNOTE doc/waves.rel
chmod $MANMOD $SPSDIR/doc/*.doc $SPSDIR/doc/*.rel

echo Copying pub files...
tar cf - pub | (cd $SPSDIR ; tar xvf -)
chmod -R og+r $SPSDIR/pub

chmod $MANMOD $SPSDIR/doc/*
chmod 0755 $SPSDIR/doc/waves
chmod $MANMOD $SPSDIR/doc/waves/*

if test $DOPUB = y
then
 echo Making pub binaries...
 echo Making xloadimage in pub directory...
 (cd pub/xloadimage; make -f Makefile.std clean; make -f Makefile.std)
 (cd pub/xloadimage; make -f Makefile.std next_slide)
 echo Installing xloadimage to $BINDIR...
 if test -r pub/xloadimage/xloadimage
 then
   cp pub/xloadimage/xloadimage $BINDIR
   chmod $PROGMOD $BINDIR/xloadimage
   cp pub/xloadimage/next_slide $BINDIR
   chmod $PROGMOD $BINDIR/next_slide
   (cd pub/xloadimage; make -f Makefile.std clean)
 else
   echo "Fatal error: apparantly xloadimage wouldn't make."
 fi

 echo Making xgrabsc in pub/xgrabsc...
 (cd pub/xgrabsc; make)
 if test -r pub/xgrabsc/xgrabsc
 then
   cp pub/xgrabsc/xgrabsc $BINDIR/xgrabsc
   chmod $PROGMOD $BINDIR/xgrabsc
   cp pub/xgrabsc/xgrabsc.man $MANDIR/man1/xgrabsc.1
   chmod $MANMOD $MANDIR/man1/xgrabsc.1
 else
   echo "Fatal error: apparantly xgrabsc woulnd't make."
 fi

 echo Makeing shellforms in pub/shellforms
 (cd pub/shellforms; make)
 echo Installing shellforms into $BINDIR
 if test -r pub/shellforms/sf
 then
   cp pub/shellforms/sf $BINDIR
   chmod $PROGMOD $BINDIR/sf
   cp pub/shellforms/sf.1 $MANDIR/man1
   chmod $MANMOD $MANDIR/man1/sf.1
 fi

 echo Making tpipe in pub/tpipe...
 (cd pub/tpipe; make)
 echo Installing tpipe into $BINDIR...
 if test -r pub/tpipe/tpipe
 then
   cp pub/tpipe/tpipe $BINDIR
   cp pub/tpipe/tpipe.1 $MANDIR/man1
 else
   echo "Fatal error: apparantly tpipe wouldn't make."
 fi
 
 echo Making tek2ps in pub/tek2ps...
 (cd pub/tek2ps; make clean; make)
 if test -r pub/tek2ps/tek2ps
 then
   cp pub/tek2ps/tek2ps $BINDIR
   chmod $PROGMOD $BINDIR/tek2ps 
   (cd pub/tek2ps; make clean)
 else
  echo "Fatal error: apparantly tek2ps wouldn't make."
 fi
else
 echo "Not making pub binaries."
fi

echo Copying src_examples files...
rm -rf $SPSDIR/src_examples/*
tar cf - src_examples | (cd $SPSDIR ; tar xvf -)

if test $MACH != SONY_RISC -a $MACH != CONVEX
 then
  echo Fixing the man macro to work with us...
  soelim /usr/lib/tmac/tmac.an | grep -v KNOW | grep -v MISC  | sed 's/\]W/\]Z/g' | \
  cat - $HERE/copyright.an > $LIBDIR/tmac.an
 else
  cat /usr/lib/tmac/tmac.an | grep -v KNOW  | sed 's/\]W/\]Z/g' | \
  cat - $HERE/copyright.an > $LIBDIR/tmac.an
fi
chmod $MANMOD $LIBDIR/tmac.an




echo ESPS general part of installation done at `date`

if test x$WAVES =  xy
then
  echo Installing Waves+ from $WAVES_TYPE
  waves_dir=$HERE/../$WAVES_TYPE
  if test -d $waves_dir
   then
    set -x
    cd $waves_dir
    $BINDIR/emake install
    $XOFF
   else
    echo Sorry, you do not have a waves+ directory at $waves_dir
   fi
fi

if test x$DOLOCAL =  xy
then
  echo Installing local stuff from  $LOCALDIR
  local_dir=$HERE/../$LOCALDIR
  if test -d $local_dir
   then
    set -x
    cd $local_dir
    ./install 
    $XOFF
   else
    echo Sorry, you do not have a local directory at $local_dir
   fi
fi

if test x$WHATIS = xy
 then
  echo Generating whatis data base...
  set -x
  cd $MANDIR
  $BINDIR/makewhatis 
  $XOFF
fi

if test x$CATS = xy
 then
  echo Making cat files for man pages... \(this takes a long time\)
  set -x
  $BINDIR/emakecats
  $XOFF
fi

echo Producing position independent emakecats ...
cat $BINDIR/emakecats | sed -e s+$SPSDIR+\`get_esps_base\`+g > /tmp/emake
mv -f /tmp/emake $BINDIR/emakecats
chmod $PROGMOD $BINDIR/emakecats


echo ESPS Installation Script done at `date`
echo ESPS Installation Script done at `date` $VERSION 
exit 0

