-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEpitech_Makefile
108 lines (94 loc) · 2.88 KB
/
Epitech_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
##
## This is a Basic Makefile Template
## Copyright (C) 2017 paul-marie.bettinelli@epitech.eu
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
##
##
## THIS IS A DEFAULT MAKEFILE LIKE EVERY TEK' SHOULD HAVE
##
## To use it, you must to have the following architecture:
## source / object / include / tests - repository for C, or
## Source / Object / Include / Tests - repository for C++
##
LD = @ld
CC = @gcc
CXX = @g++
EXTENSION = .c
ifeq ($(EXTENSION), .c)
SRC = $(wildcard $(addprefix source/, *)$(EXTENSION))
NOM = $(basename $(notdir $(SRC)))
OBJ = $(addprefix object/, $(addsuffix .o, $(NOM)))
SRC-CRIT = $(wildcard $(addprefix tests/, *)$(EXTENSION))
OBJ-CRIT = $(SRC-CRIT:$(EXTENSION)=.o)
else
SRC = $(wildcard $(addprefix Source/, *)$(EXTENSION))
NOM = $(basename $(notdir $(SRC)))
OBJ = $(addprefix Object/, $(addsuffix .o, $(NOM)))
SRC-CRIT = $(wildcard $(addprefix Tests/, *)$(EXTENSION))
OBJ-CRIT = $(SRC-CRIT:$(EXTENSION)=.o)
endif
CPPFLAGS += -Wall -Wextra -fPIC
LDFLAGS += -g3
CFLAGS += -Iinclude -fno-builtin
CXXFLAGS += -IInclude -fno-builtin
CRITFLAGS = -lcriterion --coverage
NAME = project_name
END = \033[0m
BOLD = \033[1m
GREY = \033[30m
RED = \033[31m
GREEN = \033[32m
YELLOW = \033[33m
BLUE = \033[34m
PURPLE = \033[35m
CYAN = \033[36m
WHITE = \033[37m
all: $(NAME)
$(NAME): $(OBJ)
ifeq ($(EXTENSION), .c)
@$(CC) $(LDFLAGS) -o $(NAME) $(OBJ)
else
@$(CXX) $(LDFLAGS) -o $(NAME) $(OBJ)
endif
@echo "$(GREEN)* * * * * COMPLETED * * * * *$(END)"
test_run: $(OBJ-CRIT)
ifeq ($(EXTENSION), .c)
@$(CC) $(CFLAGS) $(CRITFLAGS) $(OBJ-CRIT)
else
@$(CXX) $(CXXFLAGS) $(CRITFLAGS) $(OBJ-CRIT)
endif
@echo "$(GREEN)* * * * * COMPLETED * * * * *$(END)"
./a.out
clean:
@find . -type f \( -iname "*~" \) -delete
@$(RM) $(OBJ)
@$(RM) $(OBJ-CRIT)
@echo "$(RED)* * * * * CLEANED * * * * *$(END)"
fclean: clean
@$(RM) $(NAME)
@$(RM) a.out
re: fclean all
ifeq ($(EXTENSION), .c)
object/%.o: source/%$(EXTENSION)
@$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< \
&& echo "$(GREEN)[OK]$(BOLD)" $< "$(END)" \
|| echo "$(RED)[KO]$(BOLD)" $< "$(END)"
else
Object/%.o: Source/%$(EXTENSION)
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< \
&& echo "$(GREEN)[OK]$(BOLD)" $< "$(END)" \
|| echo "$(RED)[KO]$(BOLD)" $< "$(END)"
endif
.PHONY: all test_run clean fclean re