#
# This file is part of Cafesterol.
# Copyright (C) 2007-2010 Xavier Clerc.
# Original file (lex/Makefile in the Objective Caml source
# distribution) is Copyright (C) INRIA.
#
# Cafesterol 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).
#
# Cafesterol 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://qt.nokia.com/doc/4.0/qpl.html>.
#

include ../config/Makefile

# The lexer generator
OCAMLJAVA=../ocamljava -java-package 'ocaml.tools.ocamllex'
COMPFLAGS=-warn-error A
CAMLYACC=../boot/ocamlyacc
YACCFLAGS=-v
CAMLLEX=../boot/ocamlrun ../boot/ocamllex
CAMLDEP=../boot/ocamlrun ../tools/ocamldep


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)
	$(OCAMLJAVA) $(LINKFLAGS) -o ocamllex.jar $(OBJS)
	$(OCAMLJAVA) $(LINKFLAGS) -standalone -o ocamllex-standalone.jar $(OBJS)

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

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

install::
	cp ocamllex.jar ocamllex-standalone.jar $(BINDIR)

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

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

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

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

include .depend
