# Variables
SRC_DIR = src
BIN_DIR = bin
RES_DIR = $(SRC_DIR)/com/charpentierbalocchi/dorfjavatik/resources
JAVAC = javac
JAVA = java
JAVADOC = javadoc
MAIN = com.charpentierbalocchi.dorfjavatik.view.FenetreDemarrage

# Compilation flags
JFLAGS = -d $(BIN_DIR) -encoding UTF-8 -sourcepath $(SRC_DIR)

# Default rule
all: clean compile copy-resources

# Rule to compile the java files
compile:
	@echo "Compilation des fichiers source java..."
	@mkdir -p $(BIN_DIR)
	@$(JAVAC) $(JFLAGS) $(SRC_DIR)/com/charpentierbalocchi/dorfjavatik/controller/*.java
	@$(JAVAC) $(JFLAGS) $(SRC_DIR)/com/charpentierbalocchi/dorfjavatik/model/*.java
	@$(JAVAC) $(JFLAGS) $(SRC_DIR)/com/charpentierbalocchi/dorfjavatik/util/*.java
	@$(JAVAC) $(JFLAGS) $(SRC_DIR)/com/charpentierbalocchi/dorfjavatik/view/*.java

# Rule to copy resources
copy-resources:
	@echo "Copying resources..."
	@cp -r $(RES_DIR) $(BIN_DIR)

# Rule to run the application
run: compile copy-resources
	@echo "Lancement du jeu..."
	@$(JAVA) -cp $(BIN_DIR) $(MAIN)

# Rule to generate Javadoc
javadoc:
	@echo "Generating Javadoc..."
	@$(JAVADOC) -d $(BIN_DIR)/docs -sourcepath $(SRC_DIR) -subpackages com.charpentierbalocchi.dorfjavatik

# Rule to clean the project
clean:
	@echo "Nettoyage en cours..."
	@rm -rf $(BIN_DIR)

.PHONY: all compile run javadoc clean copy-resources
