#!/bin/bash
if [ ${#} -lt 1 ]
then
	echo "${0}: at least one argument needed"
	exit 1
fi

#doman is now FHS compliant:
#
# /usr/share/man
# /usr/X11R6/man
# /opt/gnome/man
# /opt/kde/man

myloc=$DESTTREE
if [ "$myloc" = "" ]
then
	myloc=/usr
fi
if [ "$myloc" = "/usr" ]
then
	myext=/share
else
	myext=""
fi
for x in "$@"
do
	md=${x##*.}
	mandir=man${md:0:1}
	if [ -e ${x} ]
	then
		if [ ! -d ${D}${myloc}${myext}/man/${mandir} ]
	    	then
			install -d ${D}${myloc}${myext}/man/${mandir}
	    	fi
	    	install -m0644 ${x} ${D}${myloc}${myext}/man/${mandir}
	    	gzip -f -9 ${D}${myloc}${myext}/man/${mandir}/${x##*/}
	else
	    	echo "doman: ${x} does not exist."
	fi
done
