-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
157 lines (114 loc) · 4.83 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
##
## EPITECH PROJECT, 2017
## my_cook
## File description:
## Makefile with build project rule and units tests
##
## Global variable
SUCCESS = /bin/echo -e "\x1b[1m\x1b[33m\#\#\x1b[32m $1\x1b[0m"
INFO = /bin/echo -e "\x1b[1m\x1b[33m\#\#\x1b[34m $1\x1b[0m"
HOST = $(shell printenv HOME)
DEBUG = -g3
COMPILE_LIBRARY = $(shell [ -e $(LIBDIR) ] && echo -e "ok" || echo -e "no")
## Compilation variables
NAME = my_cook
UNIT = units
SRCDIR = src/
TESTSDIR = tests/
SRCNAMES = main.c \
cook.c \
game/wait/wait_loop.c \
game/run/run_loop.c \
utilities/args_handling.c \
utilities/struct_utils.c \
utilities/options_manager.c \
utilities/fct_pointers.c \
utilities/windows_utils.c \
utilities/rect_utils.c \
utilities/sound_manager.c \
events/events_manager.c \
events/mouse_events.c \
assets/buttons_loader.c \
assets/sliders_loader.c \
assets/buttons_manager.c \
assets/sliders_manager.c \
assets/assets_manager.c \
assets/setup/wait_buttons.c \
assets/setup/options_buttons.c \
assets/setup/options_sliders.c \
assets/setup/credits_buttons.c \
assets/sprite_manager.c \
callback/return_callback.c \
callback/sliders/volume_callback.c \
callback/wait/play_btn_callback.c \
callback/wait/settings_btn_callback.c \
callback/wait/credits_btn_callback.c \
callback/wait/quit_btn_callback.c \
callback/default_callback.c \
views/options_view.c \
views/credits_view.c \
debug/logger.c \
debug/buttons_debugger.c \
debug/assets_debugger.c \
debug/sliders_debugger.c
SRC = $(addprefix $(SRCDIR), $(SRCNAMES))
SRCTESTS = $(filter-out src/main.c, $(SRC))\
tests/$(NAME)_wrong_file_tests.c
INC = include
BUILDDIR = build/
BUILDTESTDIR = build_tests/
BUILDSUBDIR = $(shell find $(SRCDIR) -mindepth 1 -type d -printf '%p\n' | sed -e 's/^src\///')
BUILDTESTSUBDIR = $(shell find $(SRCDIR) -mindepth 1 -type d -printf '%p\n' | sed -e 's/^tests\///')
BUILDOBJS = $(addprefix $(BUILDDIR), $(SRCNAMES:.c=.o)) ## Check
BUILDTESTOBJS = $(addprefix $(BUILDTESTDIR), $(SRCTESTS:.c=.o))
LIBDIR = lib/
LIBMY = $(LIBDIR)libmy.a
CC = gcc
CFLAGS = -Wall -Wextra -I$(INC) $(DEBUG)
LFLAGS = $(if $(filter ok, $(COMPILE_LIBRARY)), -L$(LIBDIR) -lmy, ) -lc_graph_prog
UNITS_LIBRARY_FLAG = $(LFLAGS) -lcriterion
OBJ = $($SRC:.c=.o)
## Rules
all: $(BUILDDIR) $(LIBMY) $(NAME)
@$(call SUCCESS, "Project successfully compiled.")
tests_run: $(BUILDTESTDIR) $(LIBMY) $(UNIT)
@$(call SUCCESS, "Unitary tests successfully compiled.")
@clear
@echo -e "\n"
@$(call SUCCESS, "Execution of criterion tests...")
@./$(UNIT)
@$(call SUCCESS, "All tests passed !")
clean:
rm -rf $(BUILDDIR)
rm -rf $(BUILDTESTDIR)
find -name '*.gc*' -delete -or -name 'vgcore.*' -delete
$(if $(filter ok, $(COMPILE_LIBRARY)), make clean -C $(LIBDIR), @$(call INFO, "No lib needed for this project."))
@$(call SUCCESS, "Project fully cleaned.")
fclean: clean
rm -rf $(NAME)
$(if $(filter ok, $(COMPILE_LIBRARY)), make fclean -C $(LIBDIR), @$(call INFO, "No lib needed for this project."))
re: fclean all
$(BUILDDIR):
mkdir -p $(BUILDDIR)
$(foreach subdir, $(BUILDSUBDIR), $(shell mkdir -p $(BUILDDIR)$(subdir)))
$(BUILDTESTDIR):
mkdir -p {$(BUILDTESTDIR)src,$(BUILDTESTDIR)tests}
$(foreach subdir, $(BUILDSUBDIR), $(shell mkdir -p $(BUILDTESTDIR)src/$(subdir)))
$(foreach subdir, $(BUILDTESTSUBDIR), $(shell mkdir -p $(BUILDTESTDIR)tests/$(subdir)))
$(BUILDDIR)%.o: $(SRCDIR)%.c
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILDTESTDIR)src/%.o: $(SRCDIR)%.c
$(CC) $(CFLAGS) -c -o $@ $<
$(CC) $(CFLAGS) -o $(NAME) $(BUILDOBJS) $(LFLAGS)
$(BUILDTESTDIR)tests/%.o: $(TESTSDIR)%.c
$(CC) $(CFLAGS) -c -o $@ $<
$(NAME): $(BUILDOBJS)
$(CC) $(CFLAGS) -o $(NAME) $(BUILDOBJS) $(LFLAGS)
@$(call SUCCESS, "All objects files successfully regrouped in ./$(NAME) binary file.")
$(LIBMY):
$(if $(filter ok, $(COMPILE_LIBRARY)), make -C $(LIBDIR), @$(call INFO, "No lib needed for this project."))
$(UNIT): $(BUILDTESTOBJS)
$(CC) $(CFLAGS) $(UNITS_LIBRARY_FLAG) -o units $(BUILDTESTOBJS) $(LIBDIR)my/src/*.o
@$(call SUCCESS, "All tests objects files successfully regrouped in ./$(NAME) binary file.")
# Just in case those files exist in the root dir
.PHONY : all fclean clean re tests_run