ERLC=erlc
SRCDIR=.
UTILSDIR=../utils
BEAMDIR=../ebin
LOGSDIR=../logs
DEPS=$(UTILSDIR)/latency.erl $(UTILSDIR)/vectorclock.erl


all: compile
	
compile: chat.erl causal_chat.erl $(DEPS)
	$(info Compiling...)
	@ mkdir -p $(BEAMDIR)
	@ mkdir -p $(LOGSDIR)
	@ $(ERLC) -o $(BEAMDIR) $(DEPS) $(SRCDIR)/*.erl
	$(info Run from first terminal with "erl -pa $(BEAMDIR)/ -sname main@localhost")
	$(info Run from second terminal with "erl -pa $(BEAMDIR)/ -remsh main@localhost")

clean:
	$(info Cleaning...)
	@ rm -f $(BEAMDIR)/*.beam
	@ rm -f $(LOGSDIR)/*
	@ rm -f erl_crash.dump
