-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
106 lines (81 loc) · 2.69 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: adelille <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/09/15 15:56:29 by adelille #+# #+# #
# Updated: 2021/12/05 22:25:13 by adelille ### ########.fr #
# #
# **************************************************************************** #
NAME = bsq
NAME_DEBUG = bsq_debug
CC = clang
#CC = gcc
RM = rm -rf
CFLAGS = -Wall -Werror -Wextra
#CFLAGS += -O2
#CFLAGS += -O3
CFLAGS += -Ofast
#CFLAGS += -g
#CFLAGS += -g3
#CFLAGS += -fsanitize=address
# **************************************************************************** #
# 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 = ./srcs/
OBJSPATH = ./objs/
INC = ./includes/
SRCS = $(wildcard $(SRCSPATH)*.c) $(wildcard $(SRCSPATH)**/*.c)
SRCSNAME = $(subst $(SRCSPATH), , $(SRCS))
OBJSNAME = $(SRCSNAME:.c=.o)
OBJS = $(addprefix $(OBJSPATH), $(OBJSNAME))
# *************************************************************************** #
define progress_bar
@i=0
@while [[ $$i -le $(words $(SRCS)) ]] ; do \
printf " " ; \
((i = i + 1)) ; \
done
@printf "$(B)]\r[$(GRE)"
endef
# *************************************************************************** #
# RULES #
all: launch $(NAME)
@printf "\n$(B)$(MAG)$(NAME) compiled$(D)\n"
launch:
$(call progress_bar)
$(NAME): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $(NAME)
$(OBJSPATH)%.o: $(SRCSPATH)%.c
@mkdir -p $(dir $@) # 2> /dev/null || true
$(CC) $(CFLAGS) -I$(INC) -c $< -o $@
@printf "█"
debug:
@make CFLAGS+=-DDEBUG=1 NAME=$(NAME_DEBUG)
#test:
# @make
clean:
@$(RM) $(OBJSPATH)
@echo "$(B)Cleared$(D)"
fclean: clean
@$(RM) $(OBJSPATH)
@$(RM) $(NAME) $(NAME_DEBUG)
re: fclean all
.PHONY: all clean fclean re launch debug test