-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
82 lines (54 loc) · 1.64 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
##
## EPITECH PROJECT, 2017
## my_sokoban
## File description:
## Makefile with build project rule and units tests
##
## Color variables
SUCCESS = /bin/echo -e "\x1b[1m\x1b[33m\#\#\x1b[32m $1\x1b[0m"
## Compilation variables
NAME = my_sokoban
SRCDIR = ./src/
SRCNAMES = main.c \
game.c \
map_utils.c \
movements.c \
sokoban.c \
utils.c
SRC = $(addprefix $(SRCDIR), $(SRCNAMES))
INC = ./include
BUILDDIR = ./build/
BUILDSUBDIR = $(shell cd $(SRCDIR) && find . -mindepth 1 -type d -printf '%p\n')
BUILDOBJS = $(addprefix $(BUILDDIR), $(SRCNAMES:.c=.o))
LIBDIR = ./lib/
LIBMY = ./lib/libmy.a
CC = gcc
DEBUG = -g3
CFLAGS = -Wall -Wextra -I$(INC) $(DEBUG) --coverage
LIB_FLAGS = -lmy -lncurses
OBJ = $($SRC:.c=.o)
## Rules
all: $(BUILDDIR) $(LIBMY) $(NAME)
@$(call SUCCESS, "Project successfully compiled.")
@clear
$(BUILDDIR):
mkdir -p $(BUILDDIR)
$(foreach subdir, $(BUILDSUBDIR), $(shell mkdir -p build/$(subdir)))
$(BUILDDIR)%.o: $(SRCDIR)%.c
$(CC) $(CFLAGS) -c -o $@ $<
$(NAME): $(BUILDOBJS)
$(CC) $(CFLAGS) -L$(LIBDIR) $(LIB_FLAGS) -o $(NAME) $(BUILDOBJS) $(LIBDIR)/my/*.o $(LIBFT)
@$(call SUCCESS, "All objects files successfully regrouped in ./$(NAME) binary file.")
$(LIBMY):
make -C $(LIBDIR)
clean:
rm -rf $(BUILDDIR)
find -name '*.gc*' -delete -or -name 'vgcore.*' -delete
make -C $(LIBDIR) clean
@$(call SUCCESS, "Project fully cleaned.")
fclean: clean
rm -rf $(NAME)
make -C $(LIBDIR) fclean
re: fclean all
# Just in case those files exist in the root dir
.PHONY : all fclean clean re