#! /bin/sh
#---------------------------------------------------------------------------#
# Copyright (C) 2000 The University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public License - see the file COPYING in the Mercury distribution.
#---------------------------------------------------------------------------#
#
# canonical_grade --grade <grade-to-be-canonicalized>
#
# This script is meant to be used mainly during the autoconfiguration process.
# It is meant to be invoked with a --grade <grade> option, whose value should
# be a possibly noncanonical grade name given by a human as part of an argument
# to the configure script. The job of this script is to print the canonical
# name of the grade. The script fails after printing an error message if the
# purported "grade" given is not a grade at all, not even a non-canonical one.

# include the file `init_grade_options.sh-subr'
@INIT_GRADE_OPTIONS@

usage="Usage: canonical_grade --grade <actual>"

while : ; do
    case "$1" in
	# include the file `parse_grade_options.sh-subr'
	@PARSE_GRADE_OPTIONS@

	--)
		shift
		break ;;
	*)
		break ;;
    esac
    shift
done

if test $# -ne 0
then
	echo "$usage"
	exit 1
fi

# include the file `final_grade_options.sh-subr'
@FINAL_GRADE_OPTIONS@

# include the file `canonical_grade.sh-subr'
@CANONICAL_GRADE@

echo $GRADE
exit 0
