#
#  Rlc: RealLive-compatible compiler
#  Copyright (C) 2006 Haeleth
#  Revised 2009-2011 by Richard 23
#
#  This program is free software; you can redistribute it and/or modify it under
#  the terms of the GNU General Public License as published by the Free Software
#  Foundation; either version 2 of the License, or (at your option) any later
#  version.
#
#  This program is distributed in the hope that it will be useful, but WITHOUT
#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
#  details.
#
#  You should have received a copy of the GNU General Public License along with
#  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
#  Place - Suite 330, Boston, MA  02111-1307, USA.
#

# Uncomment the following line to show debug output from parsers.
#setenv(DEBUG_PARSERS,true)

# Syntax extension
if $(not $(file-exists pa_matches.cmo))
  section eval
    $(OCAMLC) -c -pp "$(CAMLP4) pa_o.cmo pa_op.cmo pa_extend.cmo q_MLast.cmo pr_dump.cmo" \
              -I $(shell $(CAMLP4) -where) gramlib.cma pa_matches.ml -o pa_matches.cmo

# Main program

PROGRAM = $(EXEDIR)/rlc

FILES []=
  app
  keTypes
  ini
  iniParser
  iniLexer
  keAst
  global
  meta
  strTokens
  memory
  variables
  keAstParser
  codegen
  strLexer
  keULexer
  funcAsm
  intrinsic
  expr
  directive
  function
  select
  goto
  bytecodeGen
  rlBabel
  textout
  compilerFrame
  main

if $(defined-env DEBUG_PARSERS)
  OCAMLYACC = ocamlyacc -v
  export

if $(ENABLE_WIN32)
  OCAML_LINK_FLAGS += -cclib -lversion
  export

GENERATED = iniParser.mli iniParser.ml iniLexer.ml \
            keAstParser.mli keAstParser.ml
OCamlGeneratedFiles($(GENERATED))

OCamlProgram($(PROGRAM), $(FILES))

# Meta-rules:

.DEFAULT: all
.PHONY: all clean

all: $(PROGRAM)$(EXE)

clean:
  $(RM) *.omc $(GENERATED) *.output $(addsuffixes .cmi .cmo .cmx $(EXT_OBJ),$(FILES)) ocamlyacc-silent.sh
  $(RM) $(addsuffixes .cmi .cmo,pa_matches)
