-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
126 lines (94 loc) · 4.13 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: dpiza <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/11/24 22:45:09 by dpiza #+# #+# #
# Updated: 2021/11/28 18:08:49 by dpiza ### ########.fr #
# #
# **************************************************************************** #
NAME = push_swap
CHECKER = checker
SRCS_DIR = ./src
OBJS_DIR = ./obj
INCLUDES_DIR = ./includes
LIBFT_DIR = ./libft
LIBFT = $(LIBFT_DIR)/libft.a
CC = gcc
CFLAGS = -Wall -Wextra -Werror $(LEAKCHECK)
LEAKCHECK = -g -fsanitize=address
LFLAGS = -L./libft -lft
RM = rm -f
NORM = norminette
INCLUDES_FILES = push_swap.h \
defines.h
INCLUDES = $(addprefix $(INCLUDES_DIR)/, $(INCLUDES_FILES))
# **************************************************************************** #
# PUSH_SWAP #
# **************************************************************************** #
SRCS = push_swap.c \
init.c \
verification.c \
algos.c \
utils.c \
op_common.c \
op_stack_a.c \
op_stack_b.c \
op_stack_ab.c
OBJS = $(addprefix $(OBJS_DIR)/, $(notdir $(SRCS:.c=.o)))
# **************************************************************************** #
# CHECKER #
# **************************************************************************** #
CHECKER_SRC = checker.c \
init.c \
verification.c \
algos.c \
utils.c \
op_common.c \
op_stack_a.c \
op_stack_b.c \
op_stack_ab.c
CHECKER_OBJS = $(addprefix $(OBJS_DIR)/, $(notdir $(CHECKER_SRC:.c=.o)))
# **************************************************************************** #
# MAKE #
# **************************************************************************** #
bonus: all
all: $(NAME) $(CHECKER)
$(NAME): $(LIBFT) $(OBJS) $(INCLUDES)
$(CC) $(CFLAGS) -o $(NAME) $(OBJS) $(LFLAGS)
$(CHECKER): $(LIBFT) $(CHECKER_OBJS) $(INCLUDES)
$(CC) $(CFLAGS) -o $(CHECKER) $(CHECKER_OBJS) $(LFLAGS)
$(LIBFT):
@make -C $(LIBFT_DIR) printf --no-print-directory
$(OBJS_DIR)/%.o: $(SRCS_DIR)/%.c $(INCLUDES_DIR) $(INCLUDES)
@mkdir -p $(OBJS_DIR)
@$(CC) $(FLAGS) -I $(INCLUDES_DIR) -c $< -o $@
.PHONY: all bonus
# **************************************************************************** #
# CLEAN #
# **************************************************************************** #
clean:
@make -C $(LIBFT_DIR) clean --no-print-directory
@$(RM) $(OBJS)
fclean: clean
@make -C $(LIBFT_DIR) fclean --no-print-directory
@$(RM) $(NAME)
@$(RM) $(CHECKER)
@rm -rf $(OBJS_DIR)
re: fclean all
.PHONY: clean fclean re
# **************************************************************************** #
# NORMINETTE #
# **************************************************************************** #
norm:
@$(NORM) $(SRCS_DIR)/*.c $(INCLUDES_DIR)/*.h
.PHONY: norm
# **************************************************************************** #
# TESTS #
# **************************************************************************** #
valgrind: $(NAME)
valgrind --leak-check=full --show-leak-kinds=all \
--track-origins=yes --log-file=valgrind-out.txt ./push_swap 1 3 2
.PHONY: Valgrind