-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
+for MODULE in $MODULES; do
+ module="$(echo $MODULE | cut -b1 | tr A-Z a-z)$(echo $MODULE | cut -b2-)"
+ echo "$INCLUDES" | while read include; do
+ if test -z "$include"; then continue; fi
+ base="$include/$module"
+ if test \( "$INTER" = "1" \) -a \( -f "$base".mli \) ; then
+ ## if we want to depend only on cmi of a module
+ echo -n "$base"."cmi "
+ elif test -f "$base".ml -o -f "$base".mly -o -f "$base".mll -o -f "$base".pack; then
+ ## else we depend on the implementation
+ echo -n "$base"."$ext "
+ break
+ elif test -f "$base".mli; then
+ ## and fall back on depending on the cmi if the cmx is not available
+ ## (which prevents cross-module inlining in the case of cmx)
+ echo -n "$base"."cmi "
+ break
+ fi
+ done