#! /bin/sh
#
#	@(#)Mksample	3.5 (motonori/WIDE) 3/16/94
#
#	Generate sample description file
#

PATH=/bin:/usr/bin:/usr/ucb
export PATH

case "$CF_DEBUG" in
*sample*|*all*)
	exec 2> DEBUG.Mksample.$$
	set -vx 
	;;
*)	;;
esac

# input file to generate sample.def
SAMPLEIN="$1"

# get PROTO file name from input file
exec < $SAMPLEIN
# make IFS contain SPC, TAB and EQUAL
IFS='= 	'
while read LINE
do
	case "$LINE" in
	CF_TYPE=*)	# type of sendmail.cf
		set $LINE
		CF_TYPE="$2" ;;
	PROTO=*)	# get prototype filename
		set $LINE
		PROTO="$2" ;;
	FEATURE=*)	# get feature definition filename
		set $LINE
		FEATURE="$2" ;;
	*) ;;		# anything else should be ignored
	esac
done

# print header part of sample.def
cat << EoF
# directory of master files
#MASTERDIR=$MASTERDIR
# directory of tools
#TOOLDIR=$TOOLDIR

### type of sendmail.cf
CF_TYPE=$CF_TYPE
### prototype filename
#PROTO=$PROTO
### feature definition filename
#FEATURE=$FEATURE

###
EoF

# extract feature control statements from feature description file
while read LINE
do
	case "$LINE" in
	#*) ;;	# comment line
	"") ;;	# empty line
	*)
		set $LINE
		if [ -f "$MASTERDIR/$1" ]
		then
			echo "# [$1]"
			grep '^#|' $MASTERDIR/$1 | sed 's/.*#|//'
			echo
		fi ;;
	esac
done < $SAMPLEIN

exit 0
