#(***********************************************************************)
#(*                                                                     *)
#(*                           Moca                                      *)
#(*                                                                     *)
#(*            Pierre Weis, projet Cristal, INRIA Rocquencourt          *)
#(*                                                                     *)
#(*  Copyright 2005 Institut National de Recherche en Informatique et   *)
#(*  en Automatique.  Distributed only by permission.                   *)
#(*                                                                     *)
#(***********************************************************************)

# $Id: Makefile.examples,v 1.6 2008/02/13 19:12:43 weis Exp $

# The Makefile for moca examples

# The directory where Makefile templates reside.
MAKEFILES_DIR = ../Mk

# Include the generic setup for Caml applications.
include $(MAKEFILES_DIR)/Config.mk

# We need to relax the warning is error option of the compiler,
# since moca still generates unused match cases.
CAMLBYTCONFIG = -g $(CAMLBYTINCLUDES)
CAMLBINCONFIG = $(CAMLBININCLUDES)

# The various .mlm source files
# The base names of files that will have a sharing version
FILES_FOR_SHARING= ring_var biocham bool group_commutative_1 group_1 \
  group_null multiset set sequence

# The base names of mlm files that will not have a sharing version
MLMNOSHARING= $(FILES_FOR_SHARING)

# The base names of the sharing versions of mlm files
MLMSHARING=$(FILES_FOR_SHARING:%=%_sharing)

# The complete set of .ml and .mli files generated by mocac
MLGENERATEDNOSHARING=$(MLMNOSHARING:%=%.ml)
MLIGENERATEDNOSHARING=$(MLMNOSHARING:%=%.mli)
MLGENERATEDSHARING=$(MLMSHARING:%=%.ml)
MLIGENERATEDSHARING=$(MLMSHARING:%=%.mli)

MLGENERATED=$(MLGENERATEDNOSHARING) $(MLGENERATEDSHARING)
MLIGENERATED=$(MLIGENERATEDNOSHARING) $(MLIGENERATEDSHARING)

ALLGENERATED=$(MLIGENERATED) $(MLGENERATED)

# Used to compute .depend
CAMLFILES=$(ALLGENERATED)

# The compiled file to produce
BYTOBJS=$(MLGENERATED:%.ml=%.cmo)
BINOBJS=$(MLGENERATED:%.ml=%.cmx)

all: byt bin

byt: $(BYTOBJS)

bin: $(BINOBJS)

configure::
	for i in $(FILES_FOR_SHARING); do \
	  $(LN) $$i.mlm $${i}_sharing.mlms; \
	done

# additional cleaning
clean::
	$(RM) $(ALLGENERATED)
	$(MAKE) depend

beforedepend::
	$(MAKE) $(MLGENERATEDNOSHARING)
	$(MAKE) $(MLGENERATEDSHARING)

depend:: beforedepend

include $(MAKEFILES_DIR)/Caml.mk
