Ajout du makefile
This commit is contained in:
73
makefile
73
makefile
@@ -1,47 +1,58 @@
|
||||
# CHAPITRE 1 : BUT FINAL
|
||||
|
||||
but : blocus
|
||||
|
||||
# CHAPITRE 2 : VARIABLES
|
||||
|
||||
OFILES = main.o \
|
||||
grid.o \
|
||||
player.o \
|
||||
game.o \
|
||||
ai.o \
|
||||
menu.o
|
||||
|
||||
# le compilateur gcc
|
||||
CC = gcc
|
||||
|
||||
CFLAGS = -Wall -ansi -pedantic -g -lgraph
|
||||
# options de compilation
|
||||
CFLAGS = -Wall -Wextra -Werror
|
||||
LDFLAGS = -lgraph
|
||||
|
||||
# CHAPITRE 3 : DEPENDANCES (REGLES IMPLICITES)
|
||||
# nom de l'exécutable
|
||||
NAME = blokus
|
||||
|
||||
main.o : main.h grid.h player.h game.h ai.h menu.h
|
||||
# dossiers
|
||||
SRC_DIR = src
|
||||
INC_DIR = include
|
||||
OBJ_DIR = obj
|
||||
|
||||
grid.o : grid.h player.h struct.h
|
||||
# sources
|
||||
SRCS = $(SRC_DIR)/main.c \
|
||||
$(SRC_DIR)/jeu.c \
|
||||
$(SRC_DIR)/jeu_humain.c \
|
||||
$(SRC_DIR)/jeu_ia.c
|
||||
|
||||
player.o : player.h grid.h struct.h
|
||||
# objets
|
||||
OBJS = $(SRCS:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
|
||||
|
||||
game.o : game.h grid.h player.h struct.h
|
||||
# headers
|
||||
INCS = -I$(INC_DIR)
|
||||
|
||||
ai.o : ai.h game.h grid.h player.h struct.h
|
||||
# règle par défaut
|
||||
all: $(OBJ_DIR) $(NAME)
|
||||
|
||||
menu.o : menu.h
|
||||
# création du dossier obj s'il n'existe pas
|
||||
$(OBJ_DIR):
|
||||
mkdir -p $(OBJ_DIR)
|
||||
|
||||
# CHAPITRE 4 : DEPENDANCES AVEC COMMANDES
|
||||
# création de l'exécutable
|
||||
$(NAME): $(OBJS)
|
||||
$(CC) $(OBJS) -o $(NAME) $(LDFLAGS)
|
||||
|
||||
blocus : $(OFILES)
|
||||
$(CC) $(CFLAGS) -o blocus $(OFILES)
|
||||
# compilation des fichiers sources
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
$(CC) $(CFLAGS) $(INCS) -c $< -o $@
|
||||
|
||||
# CHAPITRE 5 : NETTOYAGE DES FICHIERS GENERES
|
||||
# nettoyage des fichiers objets
|
||||
clean:
|
||||
rm -rf $(OBJ_DIR)
|
||||
|
||||
clean :
|
||||
-rm -f $(OFILES) blocus
|
||||
# nettoyage complet (fichiers objets et exécutable)
|
||||
fclean: clean
|
||||
rm -f $(NAME)
|
||||
|
||||
# CHAPITRE 6 : BUTS FACTICES
|
||||
# recompilation complète
|
||||
re: fclean all
|
||||
|
||||
.PHONY : but clean
|
||||
# exécution du programme
|
||||
run: all
|
||||
./$(NAME)
|
||||
|
||||
run :
|
||||
./blocus
|
||||
.PHONY: all clean fclean re run
|
||||
|
||||
Reference in New Issue
Block a user