Version française
Home     About     Download     Resources     Contact us    
Browse thread
mkdepend for caml programs
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Robbert VanRenesse <rvr@c...>
Subject: mkdepend for caml programs


I wasn't aware of the existence of one, so I produced the following.
I'm not entirely sure of its correctness, but it's a start.  If
somebody knows of a better one, I'd be interested.

				Robbert

----------8<----------8<----------8<----------8<----------8<----------

#
# camldep -- produce Makefile dependencies for caml programs.
#
# Usage: camldep *.ml *.mli >> Makefile
# 

for file
do
	case $file in
	*.ml)	base=`basename $file .ml`
		obj=$base.zo
		dep="$base"
		;;
	*.mli)	base=`basename $file .mli`
		obj=$base.zi
		dep=""
		;;
	*)	echo "Unknown file type: $file" >&2
		exit 1
	esac
	echo -n $obj: $file
	dep="$dep "`sed -n -e 's/.*#open *"\([^"]*\)".*/\#\#\1/p' \
		-e 's/\([a-zA-Z][a-zA-Z0-9_]*\)__[a-zA-Z][a-zA-Z0-9_]*/\\
\##\\1\\
/gp' $file | sed -n -e "/##$base/d" -e 's/^##\(.*\)/\1/p' | sort -u`
	for i in $dep
	do
		if test -f $i.mli
		then
			echo -n " $i.zi"
		elif test -f $i.ml -a $i != $base
		then
			echo -n " $i.zo"
		fi
	done
	echo
done