#!/bin/sh

if [ ! -d 'pkg' ]; then mkdir pkg; fi

ff=`cat filelist`

for f in $ff; do
    if [ -z "$f" ]; then
	continue

    elif [ ! -z "`echo $f | grep ':'`" ]; then
        rootdir=`echo $f | sed 's/://'`

    elif [ ! -z "`echo $f | grep '/bin'`" ]; then
	if [ ! -d "pkg/bin" ]; then mkdir pkg/bin; fi
	uf="$rootdir/`basename $f`"
	echo "cp $uf ==> pkg/bin"
	cp $uf pkg/bin

    elif [ ! -z "`echo $f | grep '/man'`" ]; then
	if [ ! -d "pkg/man" ]; then mkdir pkg/man; fi
	uf="$rootdir/man/`basename $f`"
	echo "cp $uf ==> pkg/man"
	cp $uf pkg/man

    elif [ ! -z "`echo $f | grep '/xcin/docs'`" ]; then
	if [ ! -d "pkg/xcin" ]; then mkdir pkg/xcin; fi
	if [ ! -d "pkg/xcin/docs" ]; then mkdir pkg/xcin/docs; fi
	uf="$rootdir/howto/`basename $f`"
	if [ ! -f $uf ]; then
	    uf="$rootdir/misc/`basename $f`"
	fi
	echo "cp $uf ==> pkg/xcin/docs"
	cp $uf pkg/xcin/docs

    elif [ ! -z "`echo $f | grep '/xcin'`" ]; then
	if [ ! -d "pkg/xcin" ]; then mkdir pkg/xcin; fi
	uf="$rootdir/`basename $f`"
	echo "cp $uf ==> pkg/xcin"
	cp $uf pkg/xcin
    fi
done

cp config.status install.status pkg
