#!/bin/bash
################################################################################
#
# dodoc - installs file into documentation directory
#
# Part of cygport - Cygwin packaging application
# Copyright (C) 2006, 2007 Yaakov Selkowitz
# Provided by the Cygwin Ports project <http://cygwinports.dotsrc.org/>
#
# cygport is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cygport is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cygport.  If not, see <http://www.gnu.org/licenses/>.
#
# $Id: dodoc 5517 2009-01-18 09:37:55Z yselkowitz $
#
################################################################################
set -e

case "${_docinto_dir}" in
	'')	docdir=/usr/share/doc/${P} ;;
	/*)	docdir=/usr/share/doc${_docinto_dir} ;;
	*)	docdir=/usr/share/doc/${P}/${_docinto_dir} ;;
esac

dodir ${docdir}

for i
do
	if [ -f ${i} -o -L ${i} ]
	then
		if [ "x$(file -b ${i})" != "xempty" -a ! -f ${D}${docdir}/${i} ]
		then
			/bin/install -m0644 ${i} ${D}${docdir} || error "dodoc ${i} failed"
		fi
	elif [ -f ${i}.txt -o -L ${i}.txt ]
	then
		if [ "x$(file -b ${i}.txt)" != "xempty" -a ! -f ${D}${docdir}/${i}.txt ]
		then
			/bin/install -m0644 ${i}.txt ${D}${docdir} || error "dodoc ${i}.txt failed"
		fi
	fi
done
