#!/bin/sh
dep () {
	if [ -f $1 ] ; then
		LIST=`grep '^\\\\input' $1 | sed 's#^\\\\input{\([^}]\+\)}.*#\1#g'`
		for i in $LIST ; do echo $i ; dep $i ; done
	fi
	if [ -f $1 ] ; then
		LIST=`grep '^\\\\includegraphics' $1 | sed 's#^\\\\includegraphics{\([^}]\+\)}.*#\1#g'`
		for i in $LIST ; do echo $i ; done
	fi
}

TEXFILE="$1"
shift
echo "$*: " `dep "$TEXFILE"`
