#!/bin/sh
# 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 cspp 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 cspp)
# 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 $CREATE_SATHER 2> /dev/null )
	$BIN/cspp $DD $CREATE_SATHER
fi

if [ "$CREATE_NR_SATHER" != "" ]
then
	( cd ${DD} && rm $CREATE_NR_SATHER 2> /dev/null )
	for i in $CREATE_NR_SATHER 
	do
		rm $DD/$i 2> /dev/null
	done
	$BIN/cspp -nrs $DD $CREATE_NR_SATHER
fi

if [ "$CREATE_NR_PSATHER" != "" ]
then
	for i in $CREATE_NR_PSATHER 
	do
		rm $LD/$i 2> /dev/null
	done
	$BIN/cspp -nr $DD $CREATE_NR_PSATHER
fi

	



