#
#  Optpp is based on Alain Frisch's "getopt".  
#  The rest 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.
#

OCAMLPACKS = extlib
OCamlLibrary(optpp, optpp)

CFILES = lz_comp_rl binarray-c get_interpreter_version
INCLUDES += $(OCAML_LIBRARY_DIR)
StaticCLibrary(rlprims, $(CFILES))

# RLFILES = binarray metadata bytecode rlcmp
# OCAMLPACKS += camlp4 bigarray
# OCamlLibrary(rlcmp, $(RLFILES))

RLFILES = binarray metadata bytecode game gameTypes gameParser gameLexer rlcmp
OCAMLPACKS += camlp4 bigarray
GENFILES = gameParser.mli gameParser.ml gameLexer.ml
GENERATED = $(GENFILES) 
OCamlGeneratedFiles($(GENFILES))
OCamlLibrary(rlcmp, $(RLFILES))

KFNFILES = kfnTypes kfnParser kfnLexer
GENFILES = kfnParser.mli kfnParser.ml kfnLexer.ml
GENERATED += $(GENFILES) 
OCamlGeneratedFiles($(GENFILES))
OCamlLibrary(rlkfn, $(KFNFILES))

CASTFILES = cast castParser castLexer
GENFILES = castParser.mli castParser.ml castLexer.ml
GENERATED += $(GENFILES) 
OCamlGeneratedFiles($(GENFILES))
# OCamlLibrary(cast, $(CASTFILES))

# GAMEFILES = game gameParser gameLexer
# GENERATED = gameParser.mli gameParser.ml gameLexer.ml
# OCamlGeneratedFiles($(GENERATED))
# # OCamlLibrary(game, $(GAMEFILES))

CFGFILES = avlTree iSet iMap encoding config \
	cp932 cp936 cp949 text textTransforms
# CFGFILES += $(CASTFILES) $(GAMEFILES)
CFGFILES += $(CASTFILES)
OCamlLibrary(appconfig, $(CFGFILES))


# Build marshalled data files
MDFFILES = cp932_in cp936_in cp949_in mkdatamain
OCamlProgram(mkdatafiles, avlTree iMap $(MDFFILES))
all: mkdatafiles$(EXE)
  ./mkdatafiles$(EXE) ../../lib

.PHONY: clean

clean:
  $(RM) OMakefile.omc $(GENERATED) \
    $(addsuffixes .cmi .cmo .cmx $(EXT_OBJ),optpp \
	$(RLFILES) $(KFNFILES) $(CFGFILES) $(MDFFILES)) \
    $(addsuffixes .cma .cmxa $(EXT_LIB),optpp rlcmp rlkfn appconfig cast game) \
    $(addsuffix $(EXT_OBJ),$(CFILES)) rlprims$(EXT_LIB) mkdatafiles$(EXE)
