-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
82 lines (61 loc) · 2.17 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
# **************************************************************************** #
# COLORS #
# COM_COLOR=blue, OBJ_COLOR=green, ERROR_COLOR=red, WARN_COLOR=yellow #
# **************************************************************************** #
COM_COLOR := \033[0;34m
OBJ_COLOR := \033[0;32m
ERROR_COLOR := \033[0;31m
WARN_COLOR := \033[0;33m
# **************************************************************************** #
# VARIABLES #
# **************************************************************************** #
NAME := push_swap
CC := gcc
CFLAGS := -Wall -Werror -Wextra -Iheader
DEPFLAGS = -MMD -MF $(DDIR)$*.d
SDIR := srcs/
ODIR := obj/
DDIR := $(ODIR)deps/
LIBFT_DIR := 42cursus-Libft/
LDLIBS := $(LIBFT_DIR)libft.a
SRCS := push_swap.c \
init_stack.c \
input_handling.c \
free_mem.c \
sort_small.c \
sort_big.c \
sorting_utils.c \
swap_operations.c \
push_operations.c \
rotate_operations.c \
reverse_rotate_operations.c \
list_functions.c
OBJS := $(SRCS:%.c=$(ODIR)%.o)
DEPS := $(SRCS:%.c=$(DDIR)%.d)
# **************************************************************************** #
# RULES #
# **************************************************************************** #
.PHONY: all clean fclean re
all: $(NAME)
$(NAME): LIBFT $(ODIR) $(DDIR) $(DEPS) $(OBJS)
@ $(CC) $(CFLAGS) $(DEPFLAGS) $(OBJS) -o $@ $(LDLIBS)
@echo "$(COM_COLOR)...creating: $(NAME)"
$(ODIR):
@mkdir $@
@echo "$(OBJ_COLOR)...compiling $(NAME)-object-files..."
$(DDIR):
@mkdir -p $@
@echo "$(OBJ_COLOR)...creating dependencies..."
$(ODIR)%.o: $(SDIR)%.c $(DDIR)%.d
@$(CC) $(CFLAGS) $(CPPFLAGS) $(DEPFLAGS) -c $< -o $@
LIBFT:
@make -C $(LIBFT_DIR)
clean:
@rm -rf $(OBJS) $(ODIR) $(DDIR)
@make clean -C $(LIBFT_DIR)
@echo "$(ERROR_COLOR)...$(NAME)-object files deleted"
fclean: clean
@rm -rf $(NAME) $(LDLIBS)
re: fclean all
$(DEPS):
-include $(DEPS)