#! /bin/sh
#
# This shell script walks down the source tree, generating a Makefile from
# each template Makefile.m4 it finds.  It MUST be run from the config
# subdirectory!
#
#################################################################
# Copyright notice.						#
# This software is copyrighted (c) 1991 by Matt Bishop and the	#
# Trustees of Dartmouth College.  All rights reserved.		#
# 								#
# Author:	Matt Bishop					#
# Address:	Department of Mathematics and Computer Science	#
#	 	Dartmouth College				#
# 		Hanover, NH  03755-1831				#
# 		USA						#
# telephone:	+1 603 646 3267					#
# fax:		+1 603 646 1312					#
# internet:	Matt.Bishop@dartmouth.edu			#
# usenet:	...!decvax!dartvax!Matt.Bishop			#
#################################################################
#
VERSION="Version GAMMA 6/31/91 Matt.Bishop@dartmouth.edu"	# version
PATH=/usr/ucb:/usr/bin:/bin			# search path
#
# set up the signal handler
#
trap 'echo "Aborting ..."; rm -f Settmp; exit 2' 1 2 3 15
#
# switch to the root directory
#
cd ..
#
# create the actual Makefile maker
# note we delay interpretation of the contents
# (geez, would THAT be a mess!!!)
#
cat > Settmp << 'xxEOFxx'
#! /bin/sh
# get the directory name of the file
CURWD=`expr $1 : '\(.*\)/[^/]*'`
# go there
cd $CURWD
if  test -r Makefile.m4
then
	# if the template can be read,
	# make the desired Makefile
	echo Making $CURWD/Makefile ...
	m4 Makefile.m4 > Makefile
fi
# bye!
exit 0
xxEOFxx
#
# now scan the source tree
# wherever you see a file named Makefile.m4,
# generate a Makefile
find . -name Makefile.m4 -exec sh Settmp {} \;
#
# done! delete the Makefile Maker
#
rm -f Settmp
#
# now copy the des.h and desproto.h
#
cd config
make includefiles
#
# remind the user to remake the definitions file
#
echo Remember to make the machine description file if needed
echo To do so, type \"make machine\"
#
# bye
#
exit 0
