SAE21_2023/Makefile

80 lines
2.0 KiB
Makefile
Raw Normal View History

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
2024-05-02 17:53:25 +02:00
# If the first argument is "creation"...
ifeq (creation,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "creation"
CREATION_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(CREATION_ARGS):;@:)
endif
2024-05-02 17:48:39 +02:00
### 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:53:25 +02:00
# La classe MainJeu dépend de tous les fichiers compilés
2024-05-02 17:48:39 +02:00
$(OUTDIR)/MainJeu.class : $(CLASSFILES)
2024-05-02 11:24:56 +02:00
2024-05-02 17:53:25 +02:00
# La classe MainCreation dépend de tous les fichiers compilés
$(OUTDIR)/MainCreation.class : $(CLASSFILES)
2024-05-02 17:48:39 +02:00
### REGLES OPTIONNELLES ###
2024-05-02 11:24:56 +02:00
2024-05-02 17:53:25 +02:00
# Règle pour lancer le programme MainJeu
2024-05-02 17:48:39 +02:00
jeu : $(OUTDIR)/MainJeu.class
$(JVM) $(JVMFLAGS) -cp $(OUTDIR) MainJeu $(RUN_ARGS)
2024-05-02 11:24:56 +02:00
2024-05-02 17:53:25 +02:00
# Règle pour lancer le programme MainCreation
creation : $(OUTDIR)/MainCreation.class
$(JVM) $(JVMFLAGS) -cp $(OUTDIR) MainCreation $(CREATION_ARGS)
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:53:25 +02:00
.PHONY : jeu creation clean mrproper doc
2024-05-02 11:24:56 +02:00
2024-05-02 17:48:39 +02:00
### FIN ###