X-Git-Url: http://git.nguyen.vg/gitweb/?p=tatoo.git;a=blobdiff_plain;f=tools%2Focamlmoduledep.sh;fp=tools%2Focamlmoduledep.sh;h=3102e1ecc147db0f9758ab236fe4dcc7db659582;hp=0000000000000000000000000000000000000000;hb=f7a43114461b09d79c94a0da51ffbe1aea43dc55;hpb=13a9a0ab8988f32b0c654ddc1192236a028a20d9 diff --git a/tools/ocamlmoduledep.sh b/tools/ocamlmoduledep.sh new file mode 100755 index 0000000..3102e1e --- /dev/null +++ b/tools/ocamlmoduledep.sh @@ -0,0 +1,57 @@ +#!/bin/sh + + +PROG="$0" +CMDLINE="$*" +usage() { + echo "$PROG [-native] [-I dir .. -I dir] Module" +} + +INCLUDES="" +MODULE="" +NATIVE=0 +while true; do + case $1 in + -I) + dir=`echo "$2" | sed "s:^+:$(ocamlc -where)/:"` + INCLUDES="$INCLUDES +$2" + shift + ;; + -native) + NATIVE=1 + ;; + [A-Z]*) + if test -z "$MODULE"; then + MODULE=$1 + else + usage + exit 1 + fi + ;; + *) + echo "ERROR: '$1'" + usage + exit 2 + ;; + esac + shift + if test "$#" -eq 0; then break; fi +done +module="$(echo $MODULE | cut -b1 | tr A-Z a-z)$(echo $MODULE | cut -b2-)" +if test "$NATIVE" = "1"; then + ext=cmx +else + ext=cmo +fi + +echo "$INCLUDES" | while read include; do + base="$include/$module" + if test -f "$base".ml -o -f "$base".mly -o -f "$base".mll -o -d "$base"; then + echo "$base"."$ext" + break + elif test -f "$base".mli; then + echo "$base".cmi + break + fi +done