# Lift-reduce: OCaml library NBE of MapReduce loop bodies to
# uncover the uniformity of their processing and speed-up the loops
#
# The library requires the caml-shift library, delimcc.cma and the 
# correspondent .mli files. See caml-shift.tar.gz.
# Please adjust DELIMCC= below to point to the library.
# One code file, lifted_tuples.ml, requires the modified
# pMap.mli and pMap.ml from ExtraLibs. Please see the HANSEI distribution
# for these two files.
#

export BIBTEX := bibtex -min-crossrefs=9999

all: lifted.dvi test

DELIMCC=../../Continuations/caml-shift
OCAMLC=ocamlc

DELIMCCRUN=$(DELIMCC)/dlldelimcc.so $(DELIMCC)/delimcc.cmo
DELIMCCINT=$(DELIMCC)/delimcc.cmi

.SUFFIXES: .ml .mli .cmo .cmi

test: lifted_once lifted_nested lifted_nested_mp lifted_tuples \
	lifted lifted_full

%.cmi: %.mli
	$(OCAMLC) -c -I $(DELIMCC) $<

%.cmo: %.ml %.cmi
	$(OCAMLC) -c -I $(DELIMCC) $<

lifted%: $(LIB) delimcc_simple.cmi delimcc_simple.cmo lifted%.ml
	$(OCAMLC) -o $@ $(DELIMCCRUN) $(filter-out %.cmi,$^)
	./$@

lifted_nested: $(LIB) delimcc_simple.cmi delimcc_simple.cmo \
	lifted_once.cmi lifted_once.cmo lifted_nested.ml
	$(OCAMLC) -o $@ $(DELIMCCRUN) $(filter-out %.cmi,$^)
	./$@

lifted_nested_mp: $(LIB) lifted_nested_mp.ml
	$(OCAMLC) -I $(DELIMCC) -o $@ $(DELIMCCRUN) $(filter-out %.cmi,$^)
	./$@

lifted_tuples: $(LIB) lifted_nested_mp.cmi lifted_nested_mp.cmo \
	pMap.cmi pMap.cmo lifted_tuples.ml
	$(OCAMLC) -I $(DELIMCC) -o $@ $(DELIMCCRUN) nums.cma $(filter-out %.cmi,$^)
	./$@

lifted: $(LIB) lifted.ml
	$(OCAMLC) -I $(DELIMCC) -o $@ $(DELIMCCRUN) $(filter-out %.cmi,$^)
	./$@

lifted_full: $(LIB) lifted_full.ml
	$(OCAMLC) -I $(DELIMCC) -o $@ $(DELIMCCRUN) nums.cma \
	$(filter-out %.cmi,$^)
	./$@




.SUFFIXES: .dvi .pdf .ps .tex

lifted.dvi lifted.pdf: lifted_once.ml lifted_nested.ml ieee-proc/latex8.sty # lifted-nested.scm

.tex.dvi:
# rm -f $(basename $<).{aux,bbl}
	texi2dvi --batch $< && ( killall -USR1 xdvi.bin || true )

.tex.pdf:
	texi2dvi --batch --pdf $<

.pdf.ps:
	pdftops $< $@

.dvi.ps:
	dvips -tletterSize -o$@ $<
