#
# This file is part of OCaml-Java compiler.
# Copyright (C) 2007-2014 Xavier Clerc.
# Original file (lex/Makefile in the OCaml source
# distribution) is Copyright (C) INRIA.
#
# OCaml-Java compiler is free software; you can redistribute it and/or modify
# it under the terms of the Q Public License v1.0 as published by
# Trolltech (with a change to choice of law).
#
# OCaml-Java compiler 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
# Q Public License for more details.
#
# You should have received a copy of the Q Public License
# along with this program.  If not, see
# <http://opensource.org/licenses/QPL-1.0>.
#

# The lexer generator
CAMLJAVA=../ocamljava.opt -strict-sequence -nostdlib -I ../boot -I ../stdlib -java-package 'ocaml.tools.ocamllex'
COMPFLAGS=-w +33..39 -warn-error A
CAMLYACC=../boot/ocamlyacc
YACCFLAGS=-v
CAMLLEX=./ocamllex.opt
CAMLDEP=../tools/ocamldep.opt


OBJS=cset.cmj syntax.cmj parser.cmj lexer.cmj table.cmj lexgen.cmj \
     compact.cmj common.cmj output.cmj outputbis.cmj main.cmj

all: ocamllex

ocamllex: $(OBJS)
	$(CAMLJAVA) $(LINKFLAGS) -o ocamllex.jar $(OBJS)

clean::
	rm -f ocamllex.jar
	rm -f *.cmj *.cmi *.jo *.ja *~

parser.ml parser.mli: parser.mly
	$(CAMLYACC) $(YACCFLAGS) parser.mly

clean::
	rm -f parser.ml parser.mli parser.output

beforedepend:: parser.ml parser.mli

lexer.ml: lexer.mll
	$(CAMLLEX) lexer.mll

clean::
	rm -f lexer.ml

beforedepend:: lexer.ml

.SUFFIXES:
.SUFFIXES: .ml .cmj .mli .cmi

.ml.cmj:
	$(CAMLJAVA) -c $(COMPFLAGS) $<

.mli.cmi:
	$(CAMLJAVA) -c $(COMPFLAGS) $<

depend: beforedepend
	$(CAMLDEP) *.mli *.ml > .depend

include .depend
