# Commandes
JAVAC = javac -encoding UTF-8
JAVA = java
JAR = $(JAVA) -jar
JAVADOC = javadoc
OPTION_DOCS = -d docs/
OPTION_COMPILE = -d build/ -cp "src/Test/libs/mariadb-connector.jar"
OPTION_DOCS = -d docs/ -cp "src/Test/libs/mariadb-connector.jar"
OPTION_EXE = -cp ".:Test/libs/mariadb-connector.jar" Test.TestTexteMNP
OPTION_EXE_A = -cp ".:Test/libs/mariadb-connector.jar" Test.MainAdmin
OPTION_EXE_P = -cp ".:Test/libs/mariadb-connector.jar" Test.MainProf
OPTION_EXE_S = -cp ".:Test/libs/mariadb-connector.jar" Test.MainStudent
RM = rm -rf

# Chemin
API = src/API
MNP = src/MNP
TEST = src/Test
BUILD = build
ALL = *.java

# Arguments
.PHONY: run clean docs

run:
	$(RM) build/*
	$(RM) docs/*
	$(JAVAC) $(OPTION_COMPILE) $(API)/$(ALL) $(MNP)/$(ALL) $(TEST)/$(ALL)
	cp -r src/Test/libs build/Test && cd build/ && $(JAVA) $(OPTION_EXE)

admin:
	$(RM) build/*
	$(RM) docs/*
	$(JAVAC) $(OPTION_COMPILE) $(API)/$(ALL) $(MNP)/$(ALL) $(TEST)/$(ALL)
	cp -r src/Test/libs build/Test && cd build/ && $(JAVA) $(OPTION_EXE_A)

student:
	$(RM) build/*
	$(RM) docs/*
	$(JAVAC) $(OPTION_COMPILE) $(API)/$(ALL) $(MNP)/$(ALL) $(TEST)/$(ALL)
	cp -r src/Test/libs build/Test && cd build/ && $(JAVA) $(OPTION_EXE_S)

prof:
	$(RM) build/*
	$(RM) docs/*
	$(JAVAC) $(OPTION_COMPILE) $(API)/$(ALL) $(MNP)/$(ALL) $(TEST)/$(ALL)
	cp -r src/Test/libs build/Test && cd build/ && $(JAVA) $(OPTION_EXE_P)

clean:
	$(RM) build/*
	$(RM) docs/*

docs:
	$(JAVADOC) $(OPTION_DOCS) $(API)/$(ALL) $(MNP)/$(ALL) $(TEST)/$(ALL)