SAE11_2023/SAE_semestre1/Makefile

31 lines
573 B
Makefile
Raw Normal View History

2023-11-30 13:44:06 +01:00
CC = gcc
2023-12-19 17:27:47 +01:00
CFLAGS = -ansi -pedantic -lgraph
SRCDIR = ./src
HDIR = ./fichier.h
ODIR = ./out
OFILES = $(subst $(SRCDIR)/,$(ODIR)/,$(subst .c,.o,$(shell find $(SRCDIR)/ -type f)))
EXE = snake
2023-12-19 17:27:47 +01:00
.PHONY: all clean run
2023-12-19 17:27:47 +01:00
all: $(EXE)
2023-12-19 17:27:47 +01:00
$(ODIR)/%.o : $(SRCDIR)/%.c
@mkdir -p $(@D)
$(CC) -c $< -o $@
2023-12-19 17:27:47 +01:00
$(EXE) : $(OFILES)
$(CC) $(CFLAGS) -o $(EXE) $(OFILES)
2023-12-19 17:27:47 +01:00
run : $(EXE)
./$(EXE)
2023-12-19 17:27:47 +01:00
clean :
-rm -rf $(ODIR)
# Nouvelle règle pour la dépendance implicite
$(EXE): $(ODIR)/a.out
2023-12-19 17:27:47 +01:00
# Nouvelle règle pour construire 'out/a.out'
$(ODIR)/a.out: $(OFILES)
$(CC) $(CFLAGS) -o $@ $(OFILES)