# package
OCAMLPACKS[] =
     str
     extlib

.PHONY: clean
FILES[] =
	module
	binding
	closureTrans
	bytes
	label
	abc
	cpool
	revList
	instruction
	iSpec
	asm
	codegen
	override
	main

CPPFLAGS+=-I../type

PROGRAM=../codegen

OCAMLOPT   = ocamlopt -for-pack $(capitalize $(basename $(PROGRAM)))
OCAMLOPTLINK= ocamlopt

OCamlProgram(gen_inst,gen_inst)
OCamlLibrary(codegen, $(FILES))
MyOCamlPackage($(PROGRAM), $(FILES))

.DEFAULT:

match_body.h: gen_inst$(EXE) instruction.txt
    ./gen_inst$(EXE) -m < instruction.txt > $@

opcode.h: gen_inst$(EXE) instruction.txt
    ./gen_inst$(EXE) -t < instruction.txt > $@

.SCANNER: instruction.ml : instruction.mlp
    grep "#include \"" $< | sed 's/.*"\(.*\)".*/'$@': \1/'

clean:
	ocaml-clean opcode.h match_body.h instruction.ml gen_inst$(EXE)
