# COMMANDES #
JAVAC = javac
# note $$ to get a single shell $
JAVAC_OPTIONS = -encoding "UTF-8" -d build -cp "libs/mariadb-client.jar" -sourcepath "src" -implicit:none
JAVA = java
JAR = jar
EXEC_JAR = ${JAVA} -jar

# CHEMINS RELATIFS
SRC = src/fr/iutfbleau/projetIHM2021FI2
BUILD = build/fr/iutfbleau/projetIHM2021FI2
DOC = doc/fr/iutfbleau/projetIHM2021FI2

# CHOIX NOMS
JAR_MAIN = Main.jar

# BUTS FACTICES #
.PHONY : run clean doc

# BUT PAR DEFAUT #
run : ${JAR_MAIN}
	${EXEC_JAR} ${JAR_MAIN} -cp "libs/mariadb-client.jar"

# AUTRE BUTS
doc :
	javadoc -d doc -cp "libs/mariadb-client.jar" src/fr/iutfbleau/projetIHM2021FI2/API/*.java src/fr/iutfbleau/projetIHM2021FI2/IHM1/*.java src/fr/iutfbleau/projetIHM2021FI2/Model/*.java src/fr/iutfbleau/projetIHM2021FI2/Controller/*.java src/fr/iutfbleau/projetIHM2021FI2/View/*.java

clean :
	rm -rf ${BUILD}/* *.jar


# REGLES DE DEPENDANCE #

## API ##
${BUILD}/API/MonPrint.class : ${SRC}/API/MonPrint.java 
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/API/MonPrint.java

${BUILD}/API/TypeChambre.class : ${SRC}/API/TypeChambre.java 
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/API/TypeChambre.java

${BUILD}/API/Chambre.class : ${SRC}/API/Chambre.java \
	  		     ${BUILD}/API/TypeChambre.class\
			     ${BUILD}/API/MonPrint.class
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/API/Chambre.java

${BUILD}/API/Client.class : ${SRC}/API/Client.java \
                            ${BUILD}/API/MonPrint.class
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/API/Client.java

${BUILD}/API/Prereservation.class : ${SRC}/API/Prereservation.java \
	  		            ${BUILD}/API/TypeChambre.class \
	  		     	    ${BUILD}/API/Client.class 
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/API/Prereservation.java

${BUILD}/API/Reservation.class : ${SRC}/API/Reservation.java \
	  		         ${BUILD}/API/Prereservation.class 
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/API/Reservation.java

${BUILD}/API/PrereservationFactory.class : ${SRC}/API/PrereservationFactory.java \
	  		            ${BUILD}/API/Prereservation.class 
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/API/PrereservationFactory.java

${BUILD}/API/ReservationFactory.class : ${SRC}/API/ReservationFactory.java \
	  		            ${BUILD}/API/Prereservation.class 
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/API/ReservationFactory.java


# ## JARS ##

 ${JAR_MAIN} : ${BUILD}/Main.class
	${JAR} cvfem ${JAR_MAIN} fr.iutfbleau.projetIHM2021FI2.Main Chemin.txt -C build fr


## Model ##

${BUILD}/Model/ConnexionBDD.class : ${SRC}/Model/ConnexionBDD.java
	${JAVAC}  ${JAVAC_OPTIONS} ${SRC}/Model/ConnexionBDD.java

${BUILD}/Model/ConnexionBDD.class : ${SRC}/Model/ConnexionBDD.java
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Model/ConnexionBDD.java

${BUILD}/Model/RecupChambre.class : ${SRC}/Model/RecupChambre.java \
                              ${BUILD}/API/Client.class 
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Model/RecupChambre.java

${BUILD}/Model/PrereservationModel.class : ${SRC}/Model/PrereservationModel.java \
                              ${BUILD}/API/Prereservation.class \
							  ${BUILD}/Model/RecupChambre.class 
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Model/PrereservationModel.java

${BUILD}/Model/PrereservationFactoryModel.class : ${SRC}/Model/PrereservationFactoryModel.java \
                              ${BUILD}/API/PrereservationFactory.class \
							  ${BUILD}/Model/PrereservationModel.class
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Model/PrereservationFactoryModel.java

${BUILD}/Model/RecupClient.class : ${SRC}/Model/RecupClient.java \
                              	 ${BUILD}/API/Chambre.class \
								 ${BUILD}/Model/ConnexionBDD.class 
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Model/RecupClient.java

## Controller ##

${BUILD}/Controller/MainWindowController.class : ${SRC}/Controller/MainWindowController.java
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Controller/MainWindowController.java

${BUILD}/Controller/SearchButtonController.class : ${SRC}/Controller/SearchButtonController.java \
												${BUILD}/Model/PrereservationFactoryModel.class \
												${BUILD}/View/PrereservationView.class
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Controller/SearchButtonController.java

${BUILD}/Controller/SelectButtonController.class : ${SRC}/Controller/SelectButtonController.java \
												${BUILD}/View/ChambresView.class

	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Controller/SelectButtonController.java

## View ##

${BUILD}/View/WindowView.class : ${SRC}/View/WindowView.java \
								${BUILD}/Controller/MainWindowController.class \
								${BUILD}/View/PrereservationView.class
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/View/WindowView.java

${BUILD}/View/PrereservationView.class : ${SRC}/View/PrereservationView.java
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/View/PrereservationView.java

${BUILD}/View/ChambresView.class : ${SRC}/View/ChambresView.java \
							  ${BUILD}/Model/RecupClient.class \
							  ${SRC}/Controller/SelectButtonController.java
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/View/ChambresView.java




## Main ##
${BUILD}/Main.class : ${SRC}/Main.java \
							${BUILD}/Model/ConnexionBDD.class \
							${BUILD}/Controller/SearchButtonController.class \
							${BUILD}/Controller/SelectButtonController.class \
							${BUILD}/View/WindowView.class
	${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Main.java


