-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (52 loc) · 2.22 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: wbraeckm <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2019/09/25 16:38:11 by wbraeckm #+# #+# #
# Updated: 2020/02/10 17:53:09 by wbraeckm ### ########.fr #
# #
# **************************************************************************** #
NAME = 42sh
CC = gcc
FLAGS = -O3 -Wall -Wextra -Werror -fsanitize=address
INCLUDES = ./includes/
SRCSFOLDER = ./srcs/
OBJFOLDER = ./obj/
.DEFAULT_GOAL = all
LIBFT_FOLDER = ./libft/
include $(LIBFT_FOLDER)libft.mk
include files.mk
SRCS = $(addprefix $(SRCSFOLDER), $(ITEMS))
OBJ = $(addprefix $(OBJFOLDER), $(ITEMS:.c=.o))
OBJSUBS = $(SRCSUBS:./srcs%=./obj%)
LONGEST = $(shell echo $(notdir $(SRCS)) | tr " " "\n" | \
awk ' { if ( length > x ) { x = length; y = $$0 } }END{ print y }' | wc -c \
| sed 's/ //g')
all: $(NAME)
$(OBJFOLDER)/%.o:$(SRCSFOLDER)/%.c $(HEADERS) $(LIBFT_HEADERS) Makefile
@printf "\r$(CC_BLUE)Compiling %-$(LONGEST)s" $(notdir $<)
@$(CC) $(FLAGS) -o $@ -c $< -I$(INCLUDES) -I$(LIBFT_INCLUDES)
@printf "$(CC_GRAY)[$(CC_LIGHT_GREEN)√$(CC_GRAY)]$(CC_EOC)"
$(OBJSUBS):
@mkdir $@
$(NAME): $(LIBFT) $(OBJSUBS) $(OBJ)
@printf "\r$(CC_LIGHT_CYAN)Compiling $(NAME) "
@$(CC) $(FLAGS) -o $(NAME) $(OBJ) -I$(INCLUDES) \
-I$(LIBFT_INCLUDES) $(LIBFT) -ltermcap
@printf "$(CC_GRAY)[$(CC_LIGHT_GREEN)√$(CC_GRAY)]$(CC_EOC)"
@printf " \n"
clean:
@printf "$(CC_RED)"
rm -rf $(OBJFOLDER) $(LIBFT_OBJFOLDER)
@printf "$(CC_EOC)"
fclean: clean
@printf "$(CC_RED)"
rm -rf $(NAME) $(LIBFT)
@printf "$(CC_EOC)"
re: fclean all
norm:
@norminette $(SRCSFOLDER) $(INCLUDES)
.PHONY: norm clean fclean re