-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
73 lines (63 loc) · 1.79 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
NAME = ./crash
LIBFT_DIR := ./submodules/42_libft
GNL_DIR := ./submodules/42_get_next_line
SRC = $(shell find ./src -name "*.c")
OBJ = $(SRC:.c=.o)
SRC_DIR = ./src
CFLAGS := -Wall -Werror -Wextra #-g -fsanitize=address
HEADER := -I./include/
LIBS := -L$(LIBFT_DIR) -lft \
-L$(GNL_DIR) -lftgnl \
-lreadline
RED=$(shell tput setaf 1)
GREEN=$(shell tput setaf 2)
YELLOW=$(shell tput setaf 3)
BLUE=$(shell tput setaf 4)
PURPLE=$(shell tput setaf 5)
CYAN=$(shell tput setaf 6)
NC=$(shell tput sgr0) # Reset
$(NAME): $(LIBFT_DIR)/libft.a $(GNL_DIR)/libftgnl.a $(OBJ)
@echo "$(CYAN)Linking $(NAME)...$(NC)"
@cc $(CFLAGS) $(OBJ) $(LIBS) -o $(NAME)
%.o: %.c
@mkdir -p $(@D)
@printf "$(PURPLE)$(notdir $<) $(NC)"
@cc -c $< $(CFLAGS) $(HEADER) -o $@
$(LIBFT_DIR)/libft.a:
@echo "$(YELLOW)Making libft...$(NC)"
@make -C $(LIBFT_DIR) comp > /dev/null
$(GNL_DIR)/libftgnl.a:
@echo "$(YELLOW)Making get_next_line...$(NC)"
@make -C $(GNL_DIR) > /dev/null
all: $(NAME)
@echo "$(GREEN)$(NAME) is done!$(NC)"
clean:
@echo "$(RED)\nCleaning up object files...$(NC)"
@rm -f $(OBJ) $(BOBJ) > /dev/null
@make -C $(LIBFT_DIR) clean > /dev/null
@make -C $(GNL_DIR) clean > /dev/null
@echo "$(RED)"
rm -rf $(OBJ_DIR)
@echo "$(NC)"
fclean: clean
@echo "$(RED)Removing binaries...$(NC)"
@make -C $(LIBFT_DIR) fclean > /dev/null
@make -C $(GNL_DIR) fclean > /dev/null
@rm -f $(NAME) $(BNAME)
re: fclean all
comp:
@echo "$(GREEN)Updating submodules and recompiling...$(NC)"
@git submodule update --init --remote
@make re
@make clean
@clear
normcomp:
@echo "$(GREEN)Updating submodules...$(NC)"
@git submodule update --init --remote
@echo "$(GREEN)\nChecking norminette...$(NC)"
@cd ./include && norminette
@cd ./src && norminette
@make re
@make clean
@clear
.PHONY: all clean fclean re comp normcomp