#! /bin/sh
# $Id: nh,v 1.3 1996/01/11 16:35:59 zeller Exp $
# make new header file

# Copyright (C) 1993 Technische Universitaet Braunschweig, Germany.
# Written by Andreas Zeller (zeller@ips.cs.tu-bs.de).
# 
# This file is part of NORA.
# 
# NORA is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
# 
# NORA 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 the GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public
# License along with NORA -- see the file COPYING.
# If not, write to the Free Software Foundation, Inc.,
# 675 Mass Ave, Cambridge, MA 02139, USA.
# 
# NORA is an experimental inference-based software development
# environment. Contact nora@ips.cs.tu-bs.de for details.

this=`basename $0`
path=`dirname $0`
user=""

case `pwd` in
    *ddd*)    prefix=_DDD;;
    */ice/*)  prefix=_ICE;;
    */ice)    prefix=_ICE;;
    */nora/*) prefix=_Nora;;
    */nora)   prefix=_Nora;;
    *)        prefix=;;
esac

if [ "$1" = "-l" ]; then
  user="-l $2"
  shift 2
fi

for name in $*
do
    name=`basename $name .h`
    file=`echo $name | $path/shorten 10`
    if [ -f $file.h ]; then
	echo "$file.h already exists"
    else
	(
	   echo '// $Id''$ -*- C++ -*-'
	   echo '//'
	   echo
	   echo '#ifndef '$prefix'_'$name'_h'
	   echo '#define '$prefix'_'$name'_h'
	   echo 
	   echo '#ifdef __GNUG__'
	   echo '#pragma interface'
	   echo '#endif'
	   echo
	   echo
	   echo '#endif // '$prefix'_'$name'_h'
	   echo "// DON'T ADD ANYTHING BEHIND THIS #endif"
	) > $file.h
	$path/apply-license $user $file.h > /dev/null
	rm $file.h~
 	${VISUAL:-vi} $file.h
    fi
done
