TOP_DIR = ../../..
include $(TOP_DIR)/Makefile.rules

REQUIRES = rpc,unix,netplex
OBJ = mm_proto_aux.cmo mm_proto_clnt.cmo mm_proto_srv.cmo \
      mm_worker.cmo mm_controller.cmo
SRV_EXPLICIT_OBJ = mm_server.cmo
CLNT_EXPLICIT_OBJ = mm_client.cmo

XOBJ = $(OBJ:.cmo=.cmx)
SRV_EXPLICIT_XOBJ = $(SRV_EXPLICIT_OBJ:.cmo=.cmx)
CLNT_EXPLICIT_XOBJ = $(CLNT_EXPLICIT_OBJ:.cmo=.cmx)

CLEAN_LIST += *.run *.opt

all: mmlib.cma mm_server.run mm_client.run simple.run

opt: mmlib.cmxa mm_server.opt mm_server.opt simple.opt

mm_server.run: $(SRV_EXPLICIT_OBJ)
	$(OCAMLC) -o mm_server.run mmlib.cma $(SRV_EXPLICIT_OBJ) -linkpkg

mm_server.opt: $(SRV_EXPLICIT_XOBJ)
	$(OCAMLOPT) -o mm_server.opt mmlib.cmxa $(SRV_EXPLICIT_XOBJ) -linkpkg

mm_client.run: $(CLNT_EXPLICIT_OBJ)
	$(OCAMLC) -o mm_client.run mmlib.cma $(CLNT_EXPLICIT_OBJ) -linkpkg

mm_client.opt: $(CLNT_EXPLICIT_XOBJ)
	$(OCAMLOPT) -o mm_client.opt mmlib.cmxa $(CLNT_EXPLICIT_XOBJ) -linkpkg

mmlib.cma: $(OBJ)
	$(OCAMLC) -o mmlib.cma -a $(OBJ)

mmlib.cmxa: $(XOBJ)
	$(OCAMLOPT) -o mmlib.cmxa -a $(XOBJ)

simple.run: simple.ml
	$(OCAMLC) -o simple.run simple.ml

simple.opt: simple.ml
	$(OCAMLOPT) -o simple.opt simple.ml


include depend
