#! /bin/csh

# PREP -- Convert a large distribution file into a set of split files and a
# CHECKSUMS file.
#
# Usage:	prep file[.Z] [file[.Z] ...]

while ($1 != "")
	# Compress file if not already compressed.
	if ($1:e == "Z") then
	    set file = $1
	else
	    echo "compress $1"
	    compress -f $1
	    set file = $1.Z
	endif

	# Split the distribution file.
	set root = $file:r
	echo -n "${file}: "
	cat $file | bsplit -v -p ${root}. -s .Z
	rm -f $file

	# Make the CHECKSUMS file.
	echo ${file}: >> CHECKSUMS
	echo "compute the BSD checksums"
	echo "	----- BSD checksums -----" >> CHECKSUMS
	foreach i (${root}.*.Z)
	    echo -n "	$i	" >> CHECKSUMS
	    sum $i >> CHECKSUMS
	end
	echo "" >> CHECKSUMS

	echo "compute the SYSV checksums"
	echo "	----- SYSV checksums -----" >> CHECKSUMS
	foreach i (${root}.*.Z)
	    echo -n "	" >> CHECKSUMS
	    /usr/5bin/sum $i >> CHECKSUMS
	end
	echo "" >> CHECKSUMS

	# Advance to next argument.
	shift
end
