#!/bin/sh
#
# protize
#
# Author:	Kenneth Chin-Purcell, AHPCRC
#


# Append protoypes to an existing header file.
# Replace the header file only if it is different, to prevent unneeded makes.
# The replace is done with 'cat > file.h' instead of mv, 
#    in case file.h is a symbolic link.

PATH=$PATH:../util

for rawfile
do

file=`expr $rawfile : '\([^.]*\)'`		# get root name
[ -f $file.h ] || touch $file.h 		# make sure .h exists
awk '/\/* Prototypes/ { exit } { print }' \
	$file.h > $file.tmp			# extract header
echo '/* Prototypes */' >>  $file.tmp		# append marker
mkproto $file.c >>  $file.tmp			# append prototypes
cmp -s $file.tmp $file.h || {		 	# compare files
	cat $file.tmp > $file.h
	echo $file.h
}
rm -f $file.tmp

done
