#!/bin/sh
#------------------------->  Bourne shell - script  <-------------------------#
#- Copyright (C) 199x by International Computer Science Institute            -#
#- This file is part of the GNU Sather package. It is free software; you may -#
#- redistribute  and/or modify it under the terms of the  GNU General Public -#
#- License (GPL)  as  published  by the  Free  Software  Foundation;  either -#
#- version 2 of the license, or (at your option) any later version.          -#
#- This  program  is distributed  in the  hope that it will  be  useful, but -#
#- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY -#
#- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/GPL for more details.        -#
#- The license text is also available from:  Free Software Foundation, Inc., -#
#- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                     -#
#------------->  Please email comments to <bug-sather@gnu.org>  <-------------#

# This file is meant to be sourced in the PP scripts in the Library.
# It creates the necessary library files.
#
# DIR defines the directory relative to pLibary in which the script is running
# DIR=CC
#
#
# CREATE_SATHER lists all files for which a saprep Sather copy has to be made
# for the Sather libraries
# CREATE_SATHER=""
#
# CREATE_NR_SATHER lists all files for which a sather copy and a non reentrant
# copy have to be made (with saprep)
# CREATE_NR_SATHER="" 
#
# CREATE_NR_PSATHER lists all files for which a non reentrant copy has to be
# made for pSather (no files for Sather will be created)
# CREATE_NR_PSATHER=""

if [ "$DIR" = "." ]
then
	pp=
else
	pp=`echo $DIR/ | sed 's/[^/][^/]*/../g'`
fi
DD=`echo $pp../Library/$DIR`
LD=`echo $pp../pLibrary/$DIR`
BIN=`echo ${SATHER_HOME}/Bin`
mkdir $DD 2>/dev/null

if [ "$CREATE_SATHER" != "" ]
then
	( cd ${DD} && rm -f $CREATE_SATHER )
	$BIN/saprep $DD $CREATE_SATHER
fi

if [ "$CREATE_NR_SATHER" != "" ]
then
	( cd ${DD} && rm -f $CREATE_NR_SATHER )
	for i in $CREATE_NR_SATHER 
	do
		rm -f $DD/$i
	done
	$BIN/saprep -nrs $DD $CREATE_NR_SATHER
fi

if [ "$CREATE_NR_PSATHER" != "" ]
then
	for i in $CREATE_NR_PSATHER 
	do
		rm -f $LD/$i
	done
	$BIN/saprep -nr $DD $CREATE_NR_PSATHER
fi

	



