-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
85 lines (63 loc) · 2.65 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
# **************************************************************************** #
# #
# .--. _ #
# Makefile |o_o || | #
# |:_/ || |_ _ ___ __ #
# By: safoh <[email protected]> // \ \ __| | | \ \/ / #
# (| | )|_| |_| |> < #
# Created: 2022/07/07 17:49:38 by safoh /'\_ _/`\__|\__,_/_/\_\ #
# Updated: 2022/07/19 18:22:01 by safoh \___)=(___/ #
# #
# **************************************************************************** #
include makerc/colours.mk
include makerc/makefile.mk
include makerc/unit_makefile.mk
################################################################################
NAME :=push_swap
CC :=gcc
RM :=rm -rfv
CFLAGS =-Wall -Wextra -Werror$(if $(DEBUG), -g -fsanitize=address)\
$(if $(MALLOC), -g)
################################################################################
all: $(NAME)
$(NAME): SHELL :=/bin/bash
$(NAME): $(OBJS) $(MAIN_OBJ) $(LIBFT)
$(CC) $(CFLAGS) $^ $(INCLUDE_FLAGS) -o $(NAME)
@printf "$(BLUE_FG)$(NAME)$(RESET_COLOR) created\n"
$(MAIN_OBJ) $(OBJS): $(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(HEADER)
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(INCLUDE_FLAGS) -c $< -o $@
$(LIBFT):
@$(MAKE) -C $(LIBFT_DIR)
################################################################################
clean:
@$(RM) $(OBJS) $(MAIN_OBJ) $(addprefix $(BUILD_DIR)/, $(COVERAGE))
@$(MAKE) clean -C $(LIBFT_DIR)
@$(MAKE) clean -C $(UNIT_DIR)
fclean: clean
@$(RM) $(NAME) $(UNIT_TEST) libmallocator.a
@$(MAKE) fclean -C $(LIBFT_DIR)
@$(MAKE) fclean -C $(UNIT_DIR)
re: fclean
@$(MAKE)
tests_run: CFLAGS +=-g --coverage ## Launch tests
tests_run: $(OBJS) $(LIBFT)
@$(MAKE) -C $(UNIT_DIR)
@./$(UNIT_TEST) -j0
@gcov $(addprefix build/, $(SRCS)) -n -b -f -a
re_tests: fclean
@$(MAKE) tests_run
debug:
@$(MAKE) DEBUG=1
rebug: fclean
@$(MAKE) debug
re_malloc_test: fclean
@$(MAKE) malloc_test
malloc_test: $(OBJS) $(MAIN_OBJ) $(LIBFT)
@$(MAKE) MALLOC=1
$(CC) $(CFLAGS) $^ -fsanitize=undefined -rdynamic -o $@ $(INCLUDE_FLAGS) -L. -lmallocator
valgrind: all ## Launch valgrind
valgrind --leak-check=full ./$(NAME)
.PHONY: all clean fclean re tests_run debug rebug valgrind malloc_test \
re_malloc_test
################################################################################