41 lines
993 B
Makefile
41 lines
993 B
Makefile
# Directories
|
|
SRC_DIR = src
|
|
BIN_DIR = bin
|
|
|
|
# Find all source files and corresponding class files
|
|
SOURCES = $(shell find $(SRC_DIR) -name "*.java")
|
|
CLASSES = $(SOURCES:$(SRC_DIR)/%.java=$(BIN_DIR)/%.class)
|
|
|
|
# Main class for execution
|
|
MAIN_CLASS = controller.Main
|
|
|
|
# Java compiler and runner
|
|
JAVAC = javac
|
|
JAVA = java
|
|
JFLAGS = -d $(BIN_DIR) -cp $(SRC_DIR):$(BIN_DIR) # Ajout du classpath src/ et bin/
|
|
|
|
# Default target: Compile and run
|
|
all: clean compile run
|
|
|
|
# Compile all Java source files
|
|
compile: $(CLASSES)
|
|
@echo "Compilation terminée."
|
|
|
|
# Rule to compile each .java file to a .class file
|
|
$(BIN_DIR)/%.class: $(SRC_DIR)/%.java
|
|
@mkdir -p $(@D)
|
|
$(JAVAC) $(JFLAGS) $<
|
|
|
|
# Run the application
|
|
run:
|
|
@echo "Exécution de l'application..."
|
|
$(JAVA) -cp $(BIN_DIR):$(SRC_DIR) $(MAIN_CLASS)
|
|
|
|
# Clean compiled files
|
|
clean:
|
|
@echo "Nettoyage des fichiers compilés..."
|
|
rm -rf $(BIN_DIR)/*
|
|
|
|
# Phony targets to avoid conflicts
|
|
.PHONY: all compile run clean
|