-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
107 lines (79 loc) · 2.95 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: adelille <adelille@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/11/30 19:21:49 by adelille #+# #+# #
# Updated: 2022/05/15 10:54:44 by adelille ### ########.fr #
# #
# **************************************************************************** #
NAME = wordle
CXX = clang++
RM = rm -rf
CXXFLAGS = -Wall -Werror -Wextra
CXXFLAGS += -std=c++98
CXXFLAGS += -g3
# CXXFLAGS += -fsanitize=address
LKFLAGS = -MMD -MP
#NCFLAGS = -lncurses
NCFLAGS = -std=c99
NCFLAGS += $(shell ncursesw5-config --cflags --libs)
#NCFLAGS += -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -Wl,-Bsymbolic-functions -lncursesw -ltinfo
# **************************************************************************** #
# MAKEFILE #
MAKEFLAGS += --silent
SHELL := bash
B = $(shell tput bold)
BLA = $(shell tput setaf 0)
RED = $(shell tput setaf 1)
GRE = $(shell tput setaf 2)
YEL = $(shell tput setaf 3)
BLU = $(shell tput setaf 4)
MAG = $(shell tput setaf 5)
CYA = $(shell tput setaf 6)
WHI = $(shell tput setaf 7)
D = $(shell tput sgr0)
BEL = $(shell tput bel)
CLR = $(shell tput el 1)
# **************************************************************************** #
# SRCS #
SRCSPATH = ./src/
OBJSPATH = ./obj/
INC = ./inc/
rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
#SRCS = $(wildcard $(SRCSPATH)*.cpp) $(wildcard $(SRCSPATH)**/*.cpp)
SRCS = $(call rwildcard,$(SRCSPATH),*cpp)
SRCSNAME = $(subst $(SRCSPATH), , $(SRCS))
OBJSNAME = $(SRCSNAME:.cpp=.o)
OBJS = $(addprefix $(OBJSPATH), $(OBJSNAME))
# *************************************************************************** #
define progress_bar
@i=0
@while [[ $$i -le $(words $(SRCS)) ]] ; do \
printf " " ; \
((i = i + 1)) ; \
done
@printf "$(B)]\r[$(D)"
endef
# *************************************************************************** #
# RULES #
$(OBJSPATH)%.o: $(SRCSPATH)%.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(LKFLAGS) -I$(INC) -c $< -o $@
@printf "$(B)$(GRE)█$(D)"
all: launch $(NAME)
@printf "\n$(B)$(MAG)$(NAME) compiled$(D)\n"
launch:
$(call progress_bar)
$(NAME): $(OBJS)
$(CXX) $(CXXFLAGS) $(OBJS) -o $(NAME) $(NCFLAGS)
clean:
@$(RM) $(OBJSPATH)
fclean: clean
@$(RM) $(NAME)
re: fclean all
-include $(OBJS:.o=.d)
.PHONY: all clean fclean re launch
# **************************************************************************** #