#!/bin/sh

if [ -z $2 ]; then
    FNDDIR=.
else
    FNDDIR=$2
fi

case "$1" in
bsd)
    find $FNDDIR -name Makefile.bsd -execdir sh -c 'echo -n "===> "; pwd; install -v -C -m 0644 {} Makefile' \;
    ;;
linux)
    find $FNDDIR -name Makefile.gmk -execdir sh -c 'echo -n "===> "; pwd; install -v -C -m 0644 {} Makefile' \;
    ;;
clean)
    find $FNDDIR -name Makefile -execdir sh -c 'echo -n "===> "; pwd; rm -f {}' \;
    ;;
*)
    echo "Usage: `basename $0` {bsd|linux|clean} [/path/to/dir]" >&2
    ;;
esac

exit 0
