#!/bin/sh
# this script is generated by the configure-script
prefix=$1
shift
mandir=$1
shift
edit_man_sed=$1
shift

datadir="${prefix}/share"
MKDIRS="mkinstalldirs"
INSTALL="/usr/bin/install -c"
INSTALL_DATA="${INSTALL} -m 644"
TMP=${TMPDIR-/tmp}/man$$
trap "rm -f $TMP" 0 1 2 5 15

for i in $*
do
case $i in
*.[0-9]*)
	section=`expr "$i" : '.*\.\([0-9]\)[xm]*'`;
	if [ ! -d $mandir/man${section} ]; then
		$MKDIRS $mandir/man$section
	fi
	source=`basename $i`
	target=`grep "^$source" man/man_db.renames | awk '{print $2}'` 
	if test -z "$target" ; then
		echo '? missing rename for '$source
		target="$source"
	fi
	target="$mandir/man$section/$target"
	sed -e 's,@DATADIR@,$datadir,' < $i | sed -f ${edit_man_sed} >$TMP
	echo installing $target
	$INSTALL_DATA $TMP $target
	;;
esac
done 
