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

REQUIRES = rpc,unix,netplex
OBJ = sort2_proto_aux.cmo sort2_proto_clnt.cmo sort2_proto_srv.cmo \
      sort2_worker.cmo sort2_controller.cmo
SRV_EXPLICIT_OBJ = sort2_server.cmo
CLNT_EXPLICIT_OBJ = sort2_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: sort2lib.cma sort2_server.run sort2_client.run

opt: sort2lib.cmxa sort2_server.opt sort2_client.opt

sort2_server.run: $(SRV_EXPLICIT_OBJ)
	$(OCAMLC) -o sort2_server.run sort2lib.cma $(SRV_EXPLICIT_OBJ) -linkpkg

sort2_server.opt: $(SRV_EXPLICIT_XOBJ)
	$(OCAMLOPT) -o sort2_server.opt sort2lib.cmxa $(SRV_EXPLICIT_XOBJ) -linkpkg

sort2_client.run: $(CLNT_EXPLICIT_OBJ)
	$(OCAMLC) -o sort2_client.run sort2lib.cma $(CLNT_EXPLICIT_OBJ) -linkpkg

sort2_client.opt: $(CLNT_EXPLICIT_XOBJ)
	$(OCAMLOPT) -o sort2_client.opt sort2lib.cmxa $(CLNT_EXPLICIT_XOBJ) -linkpkg

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

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

include depend
