#! /bin/sh

# Copyright 1994, Cray Research, Inc.
#                 
# Permission to use, copy, modify and distribute this software and
# its accompanying documentation (the "Software") is granted without
# fee, provided that the above copyright notice and this permission
# notice appear in all copies of the Software and all supporting
# documentation, and the name of Cray Research, Inc. not be used in
# advertising or publicity pertaining to distribution of the 
# Software without the prior specific, written permission of Cray
# Research, Inc.  The Software is a proprietary product of Cray
# Research, Inc., and all rights not specifically granted by this
# license shall remain in Cray Research, Inc.  No charge may be made
# for the use or distribution of the Software.  The Software may be
# distributed as a part of a different product for which a fee is
# charged, if (i) that product contains or provides substantial
# functionality that is additional to, or different from, the
# functionality of the Software, and (ii) no separate, special or
# direct charge is made for the Software.
#         
# THE SOFTWARE IS MADE AVAILABLE "AS IS", AND ALL EXPRESS AND
# IMPLIED WARRANTIES, INCLUDING THE IMPLIED WARRANTIES OF FITNESS
# FOR A PARTICULAR PURPOSE, MERCHANTABILITY, AND FREEDOM FROM
# VIOLATION OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, ARE HEREBY
# DISCLAIMED AND EXCLUDED BY CRAY RESEARCH, INC.  CRAY RESEARCH,
# INC. WILL NOT BE LIABLE IN ANY EVENT FOR ANY CONSEQUENTIAL,
# SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES ARISING OUT OF OR IN
# CONNECTION WITH THE PERFORMANCE OF THE SOFTWARE OR ITS USE BY ANY
# PERSON, OR ANY FAILURE OR NEGLIGENCE ON THE PART OF CRAY RESEARCH,
# INC., EXCEPT FOR THE GROSS NEGLIGENCE OR WILLFUL MISCONDUCT OF
# CRAY RESEARCH.
# 
# This License Agreement shall be governed by, and interpreted and
# construed in accordance with, the laws of the State of Minnesota,
# without reference to its provisions on the conflicts of laws, and
# excluding the United Nations Convention of the International Sale
# of Goods.

# 07/08/94 - Added commas following arguments in the .arg macro.
#          - .resource macro prints default value on same line as resource, class.
#          - Added a .stdargs macro, which creates the resource_name argument, and the
#            Cvo_Object | Display argument.

fn=$1

AWK=awk
langprog=../source/lang.awk

if [ -r "$fn" ]
then
  bfn="`basename $1`"
  nfn="`basename $1 .lang`"
  if [ "$bfn" = "${nfn}.lang" ]
  then
    nfnindex=${nfn}.index
    nfncrossref=${nfn}.cref.html
    nfncrossreftmp=${nfn}.creftmp
    nfnbody=${nfn}.body
    nfn=${nfn}.html
    echo $fn -\> $nfn
    rm -f ${nfn} ${nfnindex} ${nfncrossref} ${nfncrossreftmp} ${nfnbody}
    touch ${nfncrossreftmp} ${nfnindex}
    cat $fn | expand | $AWK -v OUTPUT="${nfn}" -v INDEX="${nfnindex}" -v CROSSREF="${nfncrossreftmp}" -f "${langprog}" > ${nfnbody}
    cat ../source/copyright.html ${nfnindex} ${nfnbody} > ${nfn}
    cat ../source/copyright.html ${nfncrossreftmp} > ${nfncrossref}
    rm -f ${nfnindex} ${nfnbody} ${nfncrossreftmp}
  else
    echo Filename must have .lang suffix.
  fi
else
  echo Argument required.
fi
