SAE21_2022/Makefile

48 lines
957 B
Makefile
Raw Permalink Normal View History

2023-04-28 23:24:33 +02:00
# If the first argument is "run"...
ifeq (run,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "run"
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(RUN_ARGS):;@:)
endif
2023-04-27 22:28:07 +02:00
### VARIABLES ###
JC = javac
JCFLAGS = -encoding UTF-8 -implicit:none
JVM = java
JVMFLAGS =
SRCDIR = ./src
OUTDIR = ./out
2023-04-28 20:10:44 +02:00
DOCDIR = ./doc
2023-04-27 22:28:07 +02:00
OFILES = $(subst src/,out/,$(subst .java,.class,$(shell find $(SRCDIR)/ -name *.java)))
### REGLES ESSENTIELLES ###
$(OUTDIR)/%.class : $(SRCDIR)/%.java
@mkdir -p $(@D)
${JC} ${JCFLAGS} -cp $(SRCDIR) -d $(@D) $<
$(OUTDIR)/Main.class : $(OFILES)
### REGLES OPTIONNELLES ###
run : $(OUTDIR)/Main.class
2023-04-28 23:24:33 +02:00
${JVM} ${JVMFLAGS} -cp $(OUTDIR) Main $(RUN_ARGS)
2023-04-27 22:28:07 +02:00
clean :
-rm -rf $(OUTDIR)
2023-04-28 20:10:44 +02:00
-rm -rf $(DOCDIR)
2023-04-27 22:28:07 +02:00
mrproper : clean $(OUTDIR)/Main.class
2023-04-28 20:10:44 +02:00
doc :
javadoc -d $(DOCDIR) $(SRCDIR)/*.java
2023-04-27 22:28:07 +02:00
### BUTS FACTICES ###
.PHONY : run clean mrproper
### FIN ###