gmon.out
-*.dep
+*.dep*
*.cm*
*.o
*.native
.OPTIONS = variable-propagation
-OCAMLFINDPACKAGES = "ulex,unix,expat,camlp4.macro"
+OCAMLFINDPACKAGES = "ulex,unix,expat,camlp4.macro,bigarray"
OCAMLFINDSYNTAX = camlp4o
OCAMLFINDPPOPTS = $(addprefix "-ppopt ", @CAMLP4FLAGS@ -I include)
OCAMLFINDINCLUDES = $(addprefix "-I ", src)
for dir in src tools; do
find $dir -name '*.cm*' -o -name '*.o' -o -name '*.byte' -o \
-name '*.native' -o -name '*.mll' -o -name '*.mly' -o \
- -name '*.class' -o -name '*.dep' | while read file; do
+ -name '*.class' -o -name '*.depo' -o -name '*.depx' | while read file; do
case "$file" in
*.mll)
rm -f "${file%.mll}.ml"
%.class: %.java
javac $<
-%.native$(EXE): %.cmx %.dep
- objects=`cat $*.dep | xargs | sed 's/[.]dep/.cmx/g'`
+%.native$(EXE): %.cmx %.depx
+ objects=`cat $*.depx | xargs | sed 's/[.]depx/.cmx/g'`
+ $(REMAKE) OCAMLNATIVE="-native" $objects #ensure all objects have been built
$(OCAMLOPT) -o $@ $(OCAMLFLAGS) $(OCAMLOPTFLAGS) $(OCAMLFINDLINKFLAGS) $(OCAMLFINDFLAGS) $objects $<
-%.byte$(EXE): %.cmo %.dep
- objects=`cat $*.dep | xargs | sed 's/[.]dep/.cmo/g'`
+%.byte$(EXE): %.cmo %.depo
+ objects=`cat $*.depo | xargs | sed 's/[.]depo/.cmo/g'`
+ $(REMAKE) OCAMLNATIVE="" $objects #ensure all objects have been built
$(OCAMLC) -o $@ $(OCAMLFLAGS) $(OCAMLCFLAGS) $(OCAMLFINDLINKFLAGS) $(OCAMLFINDFLAGS) $objects $<
%.ml:
$(OCAMLLEX) $*.mll
fi
-%.cmx %.dep:
+%.cmx %.depx:
base=$*
target=$@
+ DEPEXT=depx
NATIVE=-native
REMAKE="$(REMAKE) OCAMLNATIVE=$NATIVE"
OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS)"
COMPILE="$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) $(OCAMLFINDFLAGS)"
. tools/ocamldriver.sh
-%.cmo %.dep:
+%.cmo %.depo:
base=$*
target=$@
- NATIVE=
+ DEPEXT=depo
+ NATIVE=""
REMAKE="$(REMAKE) OCAMLNATIVE=$NATIVE"
OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS)"
SRC=$(SRC)
OCAMLDEP="$(OCAMLDEP) $(OCAMLFINDFLAGS)"
SRC=$(SRC)
if test -z "$NATIVE"; then
+ DEPEXT=.depo
COMPILE="$(OCAMLC) $(OCAMLFLAGS) $(OCAMLCFLAGS) $(OCAMLFINDFLAGS)"
else
COMPILE="$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) $(OCAMLFINDFLAGS)"
+ DEPEXT=.depx
fi
. tools/ocamldriver.sh
else
$REMAKE ${base}.ml
modules=`$OCAMLDEP -modules ${base}.ml | cut -f 2- -d ':'`
- objects=`tools/ocamlmoduledep.sh $NATIVE $PACKINCLUDE -I $SRC $modules`
+ if test "$EXT" = "o"; then
+ INTER=-inter
+ fi
+ objects=`tools/ocamlmoduledep.sh $INTER $NATIVE $PACKINCLUDE -I $SRC $modules`
fi
$REMAKE $objects
-deps=`echo $objects | sed "s/[.]cm[i${EXT}]/.dep/g"`
-rm -f ${base}.dep; touch ${base}.dep
+deps=`echo $objects | sed "s/[.]cm[i${EXT}]/.$DEPEXT/g"`
+rm -f ${base}.$DEPEXT; touch ${base}.$DEPEXT
$REMAKE $deps
for f in $deps; do
for g in `cat $f`; do
- if grep -q $g ${base}.dep; then continue; fi
- echo $g >> ${base}.dep
+ if grep -q $g ${base}.$DEPEXT; then continue; fi
+ echo $g >> ${base}.$DEPEXT
done
- if grep -q $f ${base}.dep; then continue; fi
- echo $f >> ${base}.dep
+ if grep -q $f ${base}.$DEPEXT; then continue; fi
+ echo $f >> ${base}.$DEPEXT
done
if test -f ${base}.mli; then $REMAKE PACKINCLUDE="$PACKINCLUDE" ${base}.cmi; fi
if test "$DOPACK"; then
- sorted_objects=`cat ${base}.dep | grep "$PACKDIR" | sed "s/[.]dep/.cm${EXT}/" | xargs`
- cat ${base}.dep | grep -v "$PACKDIR" > ${base}.tmp
- mv ${base}.tmp ${base}.dep
+ sorted_objects=`cat ${base}.$DEPEXT | grep "$PACKDIR" | sed "s/[.]$DEPEXT/.cm${EXT}/" | xargs`
+ cat ${base}.$DEPEXT | grep -v "$PACKDIR" > ${base}.tmp
+ mv ${base}.tmp ${base}.$DEPEXT
$COMPILE -o ${target} -pack $sorted_objects
else
$COMPILE -o ${target} $FORPACK -c $PACKINCLUDE ${base}.ml
PROG="$0"
CMDLINE="$*"
usage() {
- echo "$PROG [-native] [-I dir .. -I dir] Module"
+ echo "$PROG [-inter] [-native] [-I dir .. -I dir] Module"
}
INCLUDES=""
-I)
dir=`echo "$2" | sed "s:^+:$(ocamlc -where)/:"`
INCLUDES="$INCLUDES
-$2"
+$dir"
shift
;;
-native)
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 -z "$include"; then continue; fi
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