: collect statistics for pascal

sccs=/usr/pascal/sccs
sourcebase=`pwd`
gottarget=0

while [ $# -gt 0 ]
do
	case $1 in
	-sourcebase)
		sourcebase=$2
		shift ;;
	-target)
		gottarget=1
		target=$2
		shift ;;
	*)
		echo "usage: $0 -target <directory> [-sourcebase <directory>]"
		exit 1
	esac
	shift
done

base=`pwd`
cd ${sourcebase}
routine=${base}/@routine_defs
file=${base}/@file_defs

gather_stats -file ${file} -routine ${routine}\
	-source ${sourcebase} 'src/*.[cy]' -sccs ${sccs} 'src/s.*.[cy]'
if [ $? != 0 ]
then
	echo "unable to gather statistics on the src directory"
	exit 1
fi
cat ${file} > ${target}/@file_defs
cat ${routine} > ${target}/@routine_defs

gather_stats -file ${file} -routine ${routine}\
	-source ${sourcebase} 'include/*.h' -sccs ${sccs} 'include/s.*.h'
if [ $? != 0 ]
then
	echo "unable to gather statistics on the include directory"
	exit 1
fi
cat ${file} >> ${target}/@file_defs
cat ${routine} >> ${target}/@routine_defs


gather_stats -file ${file} -routine ${routine}\
	-source ${sourcebase}/lib 'Arith/[a-z]*' -sccs ${sccs}/lib 'Arith/s.[a-z]*'
if [ $? != 0 ]
then
	echo "unable to gather statistics on the Arith directory"
	exit 1
fi
cat ${file} >> ${target}/@file_defs
cat ${routine} >> ${target}/@routine_defs

gather_stats -file ${file} -routine ${routine}\
	-source ${sourcebase}/lib 'Data/[a-z]*' -sccs ${sccs}/lib 'Data/s.[a-z]*'
if [ $? != 0 ]
then
	echo "unable to gather statistics on the Data directory"
	exit 1
fi
cat ${file} >> ${target}/@file_defs
cat ${routine} >> ${target}/@routine_defs

gather_stats -file ${file} -routine ${routine}\
	-source ${sourcebase}/lib 'Date/[a-z]*' -sccs ${sccs}/lib 'Date/s.[a-z]*'
if [ $? != 0 ]
then
	echo "unable to gather statistics on the Date directory"
	exit 1
fi
cat ${file} >> ${target}/@file_defs
cat ${routine} >> ${target}/@routine_defs

gather_stats -file ${file} -routine ${routine}\
	-source ${sourcebase}/lib 'File/[a-z]*' -sccs ${sccs}/lib 'File/s.[a-z]*'
if [ $? != 0 ]
then
	echo "unable to gather statistics on the File directory"
	exit 1
fi
cat ${file} >> ${target}/@file_defs
cat ${routine} >> ${target}/@routine_defs

gather_stats -file ${file} -routine ${routine}\
	-source ${sourcebase}/lib 'Sets/[a-z]*' -sccs ${sccs}/lib 'Sets/s.[a-z]*'
if [ $? != 0 ]
then
	echo "unable to gather statistics on the Sets directory"
	exit 1
fi
cat ${file} >> ${target}/@file_defs
cat ${routine} >> ${target}/@routine_defs

gather_stats -file ${file} -routine ${routine}\
	-source ${sourcebase}/lib 'String/[a-z]*' -sccs ${sccs}/lib 'String/s.[a-z]*'
if [ $? != 0 ]
then
	echo "unable to gather statistics on the String directory"
	exit 1
fi
cat ${file} >> ${target}/@file_defs
cat ${routine} >> ${target}/@routine_defs

gather_stats -file ${file} -routine ${routine}\
	-source ${sourcebase}/lib 'Tran/[a-z]*' -sccs ${sccs}/lib 'Tran/s.[a-z]*'
if [ $? != 0 ]
then
	echo "unable to gather statistics on the Tran directory"
	exit 1
fi
cat ${file} >> ${target}/@file_defs
cat ${routine} >> ${target}/@routine_defs

gather_stats -file ${file} -routine ${routine}\
	-source ${sourcebase}/lib 'Util/[a-z]*' -sccs ${sccs}/lib 'Util/s.[a-z]*'
if [ $? != 0 ]
then
	echo "unable to gather statistics on the Util directory"
	exit 1
fi
cat ${file} >> ${target}/@file_defs
cat ${routine} >> ${target}/@routine_defs


gather_stats -file ${file} -routine ${routine}\
	-source ${sourcebase} 'pc/[a-z]*.[ch]' -sccs ${sccs} 'pc/s.[a-z]*.[ch]'
if [ $? != 0 ]
then
	echo "unable to gather statistics on the pc directory"
	exit 1
fi
cat ${file} >> ${target}/@file_defs
cat ${routine} >> ${target}/@routine_defs

gather_stats -file ${file} -routine ${routine}\
	-source ${sourcebase} 'errlist/*.c' -sccs ${sccs} 'errlist/s.*.c'
if [ $? != 0 ]
then
	echo "unable to gather statistics on the errlist directory"
	exit 1
fi
cat ${file} >> ${target}/@file_defs
cat ${routine} >> ${target}/@routine_defs
