#!/bin/sh
# count port which have man pages and use configure
# Johannes Winkelmann, jw at smts dot ch

man_w_config=""
man_wo_config=""
count=0
w_count=0
wo_count=0

if [ -z "$1" ]; then
    echo "Usage: `basename $0`<portdir>"
    exit 1
fi

for r in $*; do
    echo "-- $r"
    count=0
    w_count=0
    wo_count=0
    man_w_config=""
    man_wo_config=""
    for p in $r/*; do
        if [ ! -f $p/Pkgfile ]; then
	    continue
        fi
        
        if [ -n "`grep /man/$ $p/.footprint`" ]; then
	    count=$((count+1))
	    if [ -n "`grep ./configure $p/Pkgfile`" ]; then
		w_count=$((w_count+1))
		man_w_config="$man_w_config `basename $p`"
	    else
		wo_count=$((wo_count+1))
		man_wo_config="$man_wo_config`basename $p` "
	    fi
        fi
    done
    
    if [ -n "$VERBOSE" ]; then
        echo "* ports with man & configure:"
        echo "$man_w_config"
        echo ""
        echo "* ports with man but without configure:"
        echo "$man_wo_config"
        echo ""
	echo "total # of ports: $count"
    fi
    
    echo "man with configure: $w_count"
    echo "man without configure: $wo_count"
done
