TARGET=convert
SRC=$(shell find src/ -name "*.ml" -or  -name "*.mll" -or -name "*.mli" -or -name "*.mly")

all: $(TARGET).js

deps:
	opam install ocamlfind ocamlbuild lwt_ppx js_of_ocaml-ppx js_of_ocaml-lwt 

_build/src/%.byte: $(SRC)
	ocamlbuild -use-ocamlfind -I src -pkgs js_of_ocaml,js_of_ocaml-ppx,lwt_ppx,js_of_ocaml-lwt $(TARGET).byte

%.js: _build/src/%.byte
	js_of_ocaml --opt=3 -o $@  $<
	rm *.byte

clean:
	ocamlbuild -clean

.phony: html

html:  $(TARGET).js
	cp *.js html


