OCAMLC = ocamlc
OCAMLCP = ocamlcp
OCAMLOPT = ocamlopt.opt
OCAMLDEP = ocamldep
OCAMLLEX = ocamllex
OCAMLYACC = ocamlyacc
OCAMLYFLAGS = 

#INCLUDES = -I ../mylibs

OCAMLFLAGS = $(INCLUDES) -g #-p a
OCAMLCPFLAGS =
OCAMLOPTFLAGS = $(INCLUDES) -w A -inline 5 -unsafe -ccopt -static

BYTE_OBJS = log_float.cmo precision.cmo parse_types.cmo search.cmo	\
agnostic.cmo relative_entropy.cmo choose.cmo binomial.cmo		\
auto_approx.cmo shell.cmo train_n_test.cmo parse_parameters.cmo		\
lex_parameters.cmo

OPT_OBJS = $(subst .cmo,.cmx,$(BYTE_OBJS))

LIB_OBJS = 

LIB_OPT_OBJS = $(subst .cmo,.cmx,$(LIB_OBJS))

TARGETS = bound

all: $(TARGETS)

install: $(TARGETS)
	cp $+ ga /usr/local/bin

$(TARGETS): %: $(OPT_OBJS) %.cmx
	$(OCAMLOPT) -o $@ $(OCAMLOPTFLAGS) $(LIB_OPT_OBJS) $+; strip $@

# Suffixes.
.SUFFIXES: .ml .mli .cmo .cmi .cmx

%.cmo: %.ml 
	$(OCAMLC) $(OCAMLFLAGS) -c $<

%.cmi: %.mli
	$(OCAMLC) $(OCAMLFLAGS) -c $<

%.cmx: %.ml
	$(OCAMLOPT) $(OCAMLOPTFLAGS) -c $<

%.ml: %.mll
	$(OCAMLLEX) $<

%.ml %.mli: %.mly
	$(OCAMLYACC) $(OCAMLYFLAGS) $<

parse_parameters.cmo parse_parameters.cmx: parse_parameters.cmi
bound.cmo: lex_parameters.cmi

# Clean.
clean:
	rm -f $(TARGETS) *.cm[iox] lexer_val.ml parse_val.ml lexer_val.mli parse_val.mli *.o *~ *.opt

# Depend.
depend:
	$(OCAMLDEP) $(INCLUDES) *.mli *.ml *.mly *.mll > .depend

.PHONY: clean depend

include .depend

