OCAMLINCLUDES[] +=
    ../libmojave
    ../exec
    ../magic
    ../ast
    ../ir

FILES[] =
    omake_env
    omake_exn_print
    omake_ast_parse
    omake_ast_lex
    omake_exp_parse
    omake_exp_lex
    omake_ir_ast
    omake_ir_semant
    omake_command_digest
    # omake_env_util
#
# The yacc parser file is generated
#
GENPARSE = omake_gen_parse

.SCANNER: scan-ocaml-omake_gen_parse.ml:

MakeOCamlProgram($(GENPARSE), $(GENPARSE))

$(GENPARSE)$(EXE):

#
# All generated files
#
GENERATED_FILES[] =
    omake_ast_lex.ml
    omake_ast_parse.mly
    omake_ast_parse.mli
    omake_ast_parse.ml
    omake_exp_parse.ml
    omake_exp_parse.mli

LocalOCamlGeneratedFiles($(GENERATED_FILES))

omake_ast_parse.mly: $(GENPARSE)$(EXE) omake_ast_parse.input
    ./$(GENPARSE) -o $@ omake_ast_parse.input

clean:
    $(CLEAN) $(GENERATED_FILES) $(GENPARSE)$(EXE) $(GENPARSE).opt $(GENPARSE).run

#
# The final library
#
MakeOCamlLibrary(env, $(FILES))

########################################################################
# Generate the Makefile
#
MAKEFILE_TEXT += $"""
GENPARSE = $(GENPARSE)
omake_ast_parse.mly: $$(GENPARSE)$$(EXE) omake_ast_parse.input
	$$(DOT)$$(GENPARSE) -o $$@ omake_ast_parse.input

omake_ast_lex.ml: omake_ast_lex.mll
omake_ast_lex.cmo: omake_ast_lex.cmi
omake_ast_parse.ml: omake_ast_parse.mly
omake_ast_parse.mli: omake_ast_parse.mly
omake_ast_parse.cmo: omake_ast_parse.cmi
omake_exp_parse.ml: omake_exp_parse.mly
omake_exp_parse.mli: omake_exp_parse.mly
omake_exp_parse.cmo: omake_exp_parse.cmi
"""

MakeLinkFiles(omake_ast_lex.mll omake_ast_parse.input omake_exp_parse.mly)
MakeDontLink($(GENERATED_FILES))
MakeOCamlDepend($(FILES), magic.cma)
MakeMakefile()
