#!/bin/sh

# Usage: $0 directory make_command make_target

dir=$1
make=$2
target=$3

# If there is a Makefile, then invoke it with a "distclean" target
# Otherwise, remove *.dep, *.po, *.itf files
# Go down the directories tree, so that local Makefiles do not have to
# take care of dependencies

if test -f $dir/Makefile -o -L $dir/Makefile ; then
   cd $dir; $make $target
else
   /bin/rm -f $dir/*.dep $dir/*.po $dir/*.itf $dir/*.o $dir/*.so $dir/*.asr $dir/tmpciao*
fi

for new_dir in $dir/* ; do
    if test -d $new_dir ; then
       $0 $new_dir $make $target
    fi
done
