@JAVAC_OPT = -implicit:none -encoding UTF-8\
			-d build -classpath "build:res/mariadb-client.jar" -sourcepath src
PACKAGE = fr.iutfbleau.projetAgile
PACKAGE_PATH = fr/iutfbleau/projetAgile

#------- Variables Puissance 4 ------

View = 	build/$(PACKAGE_PATH)/Puissance4/View/Pion.class \
		build/$(PACKAGE_PATH)/Puissance4/View/Grille.class \
		build/$(PACKAGE_PATH)/Puissance4/View/Puissance4Panel.class \

Utils = build/$(PACKAGE_PATH)/Puissance4/Utils/Constants.class \
		build/$(PACKAGE_PATH)/Puissance4/Utils/GameStatus.class

Events = build/$(PACKAGE_PATH)/Puissance4/Event/GridChangedListener.class \
		build/$(PACKAGE_PATH)/Puissance4/Event/GridEvent.class \
		build/$(PACKAGE_PATH)/Puissance4/Event/StatusEvent.class \
		build/$(PACKAGE_PATH)/Puissance4/Event/PlayerEvent.class

Model = build/$(PACKAGE_PATH)/Puissance4/Model/GrilleModel.class 

Controller = build/$(PACKAGE_PATH)/Puissance4/Controller/GrilleMouseListener.class \
			build/$(PACKAGE_PATH)/Puissance4/Controller/ModelEventListener.class \
			build/$(PACKAGE_PATH)/Puissance4/Controller/ResetGame.class 

#BUT PAR DEFAUT 
ArgileGames.jar : 	build \
					build/$(PACKAGE_PATH)/Main.class 
	@echo "Creating jar..."
	@jar cfme ArgileGames.jar Manifest.txt $(PACKAGE_PATH).Main res/ -C build fr 
	@echo "Finished"

#------- Events ------

build/$(PACKAGE_PATH)/Puissance4/Event/GridEvent.class : src/$(PACKAGE_PATH)/Puissance4/Event/GridEvent.java 
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Puissance4/Event/StatusEvent.class : src/$(PACKAGE_PATH)/Puissance4/Event/StatusEvent.java \
												build/$(PACKAGE_PATH)/Puissance4/Utils/GameStatus.class
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Puissance4/Event/GridChangedListener.class : src/$(PACKAGE_PATH)/Puissance4/Event/GridChangedListener.java \
														build/$(PACKAGE_PATH)/Puissance4/Event/GridEvent.class 
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Puissance4/Event/AbstractGridInitiater.class : src/$(PACKAGE_PATH)/Puissance4/Event/AbstractGridInitiater.java \
														$(Events)
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Puissance4/Event/PlayerEvent.class : src/$(PACKAGE_PATH)/Puissance4/Event/PlayerEvent.java
	@javac $(@JAVAC_OPT) $<

#------- Controleur ------

build/$(PACKAGE_PATH)/Menu/Controller/ObservateurAccueil.class : src/$(PACKAGE_PATH)/Menu/Controller/ObservateurAccueil.java
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Puissance4/Controller/ResetGame.class : src/$(PACKAGE_PATH)/Puissance4/Controller/ResetGame.java 		
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Puissance4/Controller/GrilleMouseListener.class : src/$(PACKAGE_PATH)/Puissance4/Controller/GrilleMouseListener.java
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Puissance4/Controller/ColorChooserListener.class : src/$(PACKAGE_PATH)/Puissance4/Controller/ColorChooserListener.java
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Puissance4/Controller/ColorActionListener.class : src/$(PACKAGE_PATH)/Puissance4/Controller/ColorActionListener.java
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Puissance4/Controller/ModelEventListener.class : src/$(PACKAGE_PATH)/Puissance4/Controller/ModelEventListener.java \
															build/$(PACKAGE_PATH)/Puissance4/Event/GridChangedListener.class \
															build/$(PACKAGE_PATH)/Puissance4/View/Grille.class \
															$(Event)
															
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Menu/Controller/ObservateurMenuSouris.class : src/$(PACKAGE_PATH)/Menu/Controller/ObservateurMenuSouris.java \
															build/$(PACKAGE_PATH)/Menu/View/BoutonsMenu.class
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Puissance4/Controller/Puissance4Controller.class : src/$(PACKAGE_PATH)/Puissance4/Controller/Puissance4Controller.java \
													build/$(PACKAGE_PATH)/Puissance4/Model/GrilleModel.class \
													build/$(PACKAGE_PATH)/Puissance4/View/Grille.class \
													build/$(PACKAGE_PATH)/Puissance4/Utils/GameStatus.class \
													build/$(PACKAGE_PATH)/Puissance4/View/Puissance4Panel.class \
													$(Controller)
	@javac $(@JAVAC_OPT) $<	

build/$(PACKAGE_PATH)/Menu/Controller/ObservateurFenetre.class : src/$(PACKAGE_PATH)/Menu/Controller/ObservateurFenetre.java
	@javac $(@JAVAC_OPT) $<

#------- Modele ------

build/$(PACKAGE_PATH)/Puissance4/Model/GrilleModel.class : src/$(PACKAGE_PATH)/Puissance4/Model/GrilleModel.java \
												build/$(PACKAGE_PATH)/Puissance4/Event/AbstractGridInitiater.class \
												$(Utils)
	@javac $(@JAVAC_OPT) $< 

#------- Utils ------

build/$(PACKAGE_PATH)/Puissance4/Utils/Constants.class : src/$(PACKAGE_PATH)/Puissance4/Utils/Constants.java
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Puissance4/Utils/GameStatus.class : src/$(PACKAGE_PATH)/Puissance4/Utils/GameStatus.java
	@javac $(@JAVAC_OPT) $<

#------- Vue ------

build/$(PACKAGE_PATH)/Puissance4/View/Pion.class : src/$(PACKAGE_PATH)/Puissance4/View/Pion.java \
										build/$(PACKAGE_PATH)/Puissance4/Utils/Constants.class
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Puissance4/View/Grille.class : src/$(PACKAGE_PATH)/Puissance4/View/Grille.java \
											build/$(PACKAGE_PATH)/Puissance4/View/Pion.class \
											build/$(PACKAGE_PATH)/Puissance4/Utils/Constants.class
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Puissance4/View/Puissance4Panel.class :  src/$(PACKAGE_PATH)/Puissance4/View/Puissance4Panel.java \
												build/$(PACKAGE_PATH)/Puissance4/View/Pion.class \
												build/$(PACKAGE_PATH)/Puissance4/View/Grille.class \
												build/$(PACKAGE_PATH)/Puissance4/Utils/Constants.class
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Puissance4/View/ColorChooserDialog.class :  src/$(PACKAGE_PATH)/Puissance4/View/ColorChooserDialog.java \
												build/$(PACKAGE_PATH)/Puissance4/Controller/ColorActionListener.class \
												build/$(PACKAGE_PATH)/Puissance4/Controller/ColorChooserListener.class
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Menu/View/BoutonsMenu.class : src/$(PACKAGE_PATH)/Menu/View/BoutonsMenu.java
	@javac $(@JAVAC_OPT) $<

build/$(PACKAGE_PATH)/Menu/View/Menu.class : src/$(PACKAGE_PATH)/Menu/View/Menu.java \
										build/$(PACKAGE_PATH)/Menu/Controller/ObservateurMenuSouris.class \
										build/$(PACKAGE_PATH)/Menu/View/BoutonsMenu.class \
										build/$(PACKAGE_PATH)/Menu/Controller/ObservateurFenetre.class \
										build/$(PACKAGE_PATH)/Menu/Controller/ObservateurAccueil.class \
										build/$(PACKAGE_PATH)/Puissance4/LancementPuissance4.class 
	@javac $(@JAVAC_OPT) $<
									

build/$(PACKAGE_PATH)/Main.class : src/$(PACKAGE_PATH)/Main.java \
								build/$(PACKAGE_PATH)/Menu/View/Menu.class
	@echo "Classes compiled"
	@javac $(@JAVAC_OPT) $<	

build/$(PACKAGE_PATH)/Puissance4/LancementPuissance4.class : src/$(PACKAGE_PATH)/Puissance4/LancementPuissance4.java \
													build/$(PACKAGE_PATH)/Jeu.class \
													build/$(PACKAGE_PATH)/Puissance4/Controller/Puissance4Controller.class \
													build/$(PACKAGE_PATH)/Puissance4/View/ColorChooserDialog.class \
													build/$(PACKAGE_PATH)/Puissance4/View/Grille.class \
													build/$(PACKAGE_PATH)/Puissance4/Model/GrilleModel.class
	@javac -implicit:none -d build -classpath "build:res/mariadb-client.jar" -sourcepath src $<



build/$(PACKAGE_PATH)/Jeu.class : src/$(PACKAGE_PATH)/Jeu.java 
	@javac $(@JAVAC_OPT) $<



build :
	@mkdir build
	@echo "Creating Folder"


# BUT FACTICES:
.PHONY: clear doc run

doc :
	@echo "Creating documentation..."
	@javadoc -quiet -d doc -cp build -sourcepath src -subpackages fr.iutfbleau.projetAgile
	@echo "Finished"
	
run: ArgileGames.jar
	@java -jar ArgileGames.jar&

clean : 
	@rm -rf build/*
