#!/bin/sh
#
# Print modules used directly by argument module. 
#

. sh/tools.sh

if [ -z "$1" ]
then
    echo 1>&2 "$0:  error:  invocation:  $0 MODULE"
    exit 1
fi    

result="`$gcc -MM -MG src/$1.cc $CXXFLAGS -idirafter bin \
|   tr '\\\\' ' ' \
|   $sed 's/^[a-z0-9_.]*://
s/\<src\/[a-z0-9_]*\.cc\>//g
s/\<bin\/[a-z0-9_]*\.config.hh\>//g
s/\<src\/\([a-z0-9_]*\).hh\>/\1/g'`"

# Filter out modules that are not compiled. 

r2=

for module in $result
do
    if [ -r src/$module.cc ]
    then
	r2="$r2 $module"
    fi
done

echo $r2
