2024-05-02 17:48:39 +02:00
|
|
|
# If the first argument is "jeu"...
|
|
|
|
ifeq (jeu,$(firstword $(MAKECMDGOALS)))
|
|
|
|
# use the rest as arguments for "jeu"
|
|
|
|
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
|
|
|
# ...and turn them into do-nothing targets
|
|
|
|
$(eval $(RUN_ARGS):;@:)
|
|
|
|
endif
|
|
|
|
|
|
|
|
### VARIABLES ###
|
|
|
|
|
2024-05-02 11:24:56 +02:00
|
|
|
JC = javac
|
2024-05-02 17:48:39 +02:00
|
|
|
JCFLAGS = -encoding UTF-8 -implicit:none
|
2024-05-02 11:24:56 +02:00
|
|
|
JVM = java
|
2024-05-02 17:48:39 +02:00
|
|
|
JVMFLAGS =
|
|
|
|
|
|
|
|
SRCDIR = ./src
|
|
|
|
OUTDIR = ./out
|
|
|
|
DOCDIR = ./doc
|
|
|
|
|
|
|
|
### LISTE DES FICHIERS SOURCE ###
|
|
|
|
|
2024-05-02 11:24:56 +02:00
|
|
|
SRCFILES := $(wildcard $(SRCDIR)/*.java)
|
|
|
|
|
2024-05-02 17:48:39 +02:00
|
|
|
### LISTE DES FICHIERS OBJET ###
|
|
|
|
|
|
|
|
CLASSFILES := $(patsubst $(SRCDIR)/%.java,$(OUTDIR)/%.class,$(SRCFILES))
|
2024-05-02 11:24:56 +02:00
|
|
|
|
2024-05-02 17:48:39 +02:00
|
|
|
### REGLES ESSENTIELLES ###
|
2024-05-02 11:24:56 +02:00
|
|
|
|
2024-05-02 17:48:39 +02:00
|
|
|
# Compilation de tous les fichiers source
|
|
|
|
$(OUTDIR)/%.class : $(SRCDIR)/%.java | $(OUTDIR)
|
|
|
|
@mkdir -p $(OUTDIR)
|
|
|
|
$(JC) $(JCFLAGS) -cp $(SRCDIR) -d $(OUTDIR) $<
|
2024-05-02 11:24:56 +02:00
|
|
|
|
2024-05-02 17:48:39 +02:00
|
|
|
# Crée le répertoire de sortie s'il n'existe pas
|
|
|
|
$(OUTDIR):
|
|
|
|
mkdir -p $(OUTDIR)
|
2024-05-02 11:24:56 +02:00
|
|
|
|
2024-05-02 17:48:39 +02:00
|
|
|
# La classe Main dépend de tous les fichiers compilés
|
|
|
|
$(OUTDIR)/MainJeu.class : $(CLASSFILES)
|
2024-05-02 11:24:56 +02:00
|
|
|
|
2024-05-02 17:48:39 +02:00
|
|
|
### REGLES OPTIONNELLES ###
|
2024-05-02 11:24:56 +02:00
|
|
|
|
2024-05-02 17:48:39 +02:00
|
|
|
# Règle pour lancer le programme
|
|
|
|
jeu : $(OUTDIR)/MainJeu.class
|
|
|
|
$(JVM) $(JVMFLAGS) -cp $(OUTDIR) MainJeu $(RUN_ARGS)
|
2024-05-02 11:24:56 +02:00
|
|
|
|
2024-05-02 17:48:39 +02:00
|
|
|
# Nettoyage des fichiers générés
|
|
|
|
clean :
|
|
|
|
-rm -rf $(OUTDIR)
|
|
|
|
-rm -rf $(DOCDIR)
|
2024-05-02 11:24:56 +02:00
|
|
|
|
2024-05-02 17:48:39 +02:00
|
|
|
# Nettoyage et suppression des fichiers générés, y compris la classe Main
|
|
|
|
mrproper : clean
|
2024-05-02 11:24:56 +02:00
|
|
|
|
2024-05-02 17:48:39 +02:00
|
|
|
# Génération de la documentation
|
|
|
|
doc :
|
|
|
|
javadoc -d $(DOCDIR) $(SRCDIR)/*.java
|
2024-05-02 11:24:56 +02:00
|
|
|
|
2024-05-02 17:48:39 +02:00
|
|
|
### BUTS FACTICES ###
|
2024-05-02 11:24:56 +02:00
|
|
|
|
2024-05-02 17:48:39 +02:00
|
|
|
.PHONY : jeu clean mrproper doc
|
2024-05-02 11:24:56 +02:00
|
|
|
|
2024-05-02 17:48:39 +02:00
|
|
|
### FIN ###
|