#! /bin/sh
# @(#)make_vms.sh	19.1 (ESO-IPG) 02/25/03 13:51:11
# .TYPE           command
# .NAME           make_vms.sh
# .LANGUAGE       shell script
# .ENVIRONMENT    Unix Systems. Executable under SHELL and C-SHELL
# .COMMENTS       
# .REMARKS        
# .AUTHOR         Carlos Guirao
# .VERSION 1.0    881003	Implementation
# .VERSION 1.1    890712	take out graylib.a  KB
# .VERSION 2.1    901102	New directory structure.
# .VERSION 2.2    911003	Removing makefile.com first.

FILTER=`dirname $0`/switch_filter
#FILTER=$MIDASHOME/$MIDVERS/install/vms/switch_filter

rm -f makefile.com

# Print header for makefile.com file
dir=`pwd | sed -e 's/^.*midas/midas/' -e 's/\//\./g'`
dir=`echo [$dir] | tr "[a-z]" "[A-Z]"` 
echo '$ !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++' \
	| tee makefile.com
echo '$ !' | tee -a makefile.com
echo '$ ! .COPYRIGHT   (c) 1991 European Southern Observatory' \
	| tee -a makefile.com
echo '$ ! .ENVIRONMENT VMS' | tee -a makefile.com
echo '$ ! .AUTHOR      Carlos Guirao - [ESO/IPG]' | tee -a makefile.com
echo '$ ! .IDENT       MAKEFILE.COM' | tee -a makefile.com
echo '$ ! .COMMENTS    Compile/link procedure in' $dir | tee -a makefile.com
echo '$ ! .REMARKS     Automatically generated in Unix with make.vms command' \
	| tee -a makefile.com
echo "$ ! .DATE        `date`" | tee -a makefile.com
echo '$ !' | tee -a makefile.com
echo '$ !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++' \
	| tee -a makefile.com
echo '$ !' | tee -a makefile.com
echo '$ SET NOON' | tee -a makefile.com
echo '$ VERIFY = F$VERIFY(1)' | tee -a makefile.com
rm -rf .hidden
mkdir .hidden
chmod g+w .hidden
mv `make -n clean | grep "rm -f" | sed 's/rm -f//'` .hidden >/dev/null 2>&1
make SYS_PREFIX=vms OSSYS="" VMSLIB="ip8lib.a" XWLIB="xlink.opt" LD77=ldvms LDCC=ldvms -n | $FILTER | tee -a makefile.com
echo '$ IF VERIFY .EQ. 0 THEN SET NOVERIFY' | tee -a makefile.com
mv .hidden/* . >/dev/null 2>&1
rm -rf .hidden
