-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
85 lines (71 loc) · 2.47 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
NAME = push_swap checker
INCLUDE = -Iinclude -Ilibft/include -Igetnextline/include -Ift_printf/include -Ilibc_vector/include
SRC_DIR = ./src
CHUNK_DIR = $(SRC_DIR)/chunk
UTILS_DIR = $(SRC_DIR)/utils
STACK_DIR = $(SRC_DIR)/stack
OPERATIONS_DIR = $(SRC_DIR)/operations
CHECKER_DIR = $(SRC_DIR)/checker
SOLVER_DIR = $(SRC_DIR)/solver
UTILS = utils parsing max_in_stack
STACK_FILES = stack print_stacks stack_checks stack_operations
OP_FILES = operations push swap rotate reverse_rotate
CHECKER_FILES = checker
CHUNK_FILES = chunk chunk_size
SOLVER_FILES = main solving_utils set_sorted_pos radix_sort chunk_sort optimization smol_sort \
push_chunks_to_b push_chunks_back_to_a
SRCS = $(addprefix $(UTILS_DIR)/, $(addsuffix .c, $(UTILS))) \
$(addprefix $(CHUNK_DIR)/, $(addsuffix .c, $(CHUNK_FILES))) \
$(addprefix $(STACK_DIR)/, $(addsuffix .c, $(STACK_FILES))) \
$(addprefix $(OPERATIONS_DIR)/, $(addsuffix .c, $(OP_FILES)))
CHECKER_SRCS = $(addprefix $(CHECKER_DIR)/, $(addsuffix .c, $(CHECKER_FILES)))
SOLVER_SRCS = $(addprefix $(SOLVER_DIR)/, $(addsuffix .c, $(SOLVER_FILES)))
OBJS = $(SRCS:.c=.o)
CHECKER_OBJS = $(CHECKER_SRCS:.c=.o)
SOLVER_OBJS = $(SOLVER_SRCS:.c=.o)
LIBS_FOR_CHECKER = libft.a getnextline.a ft_printf.a
LIBS_FOR_PUSHSWAP = libft.a ft_printf.a libc_vector.a
# COLORS
PINK = \x1b[35;01m
BLUE = \x1b[34;01m
YELLOW = \x1b[33;01m
GREEN = \x1b[32;01m
RED = \x1b[31;01m
WHITE = \x1b[31;37m
RESET = \x1b[0m
CFLAGS = -Wall -Werror -Wextra -pedantic
ifdef DEBUG
CFLAGS += -g -fsanitize=address
else
CFLAGS += -Ofast
endif
ifdef OPCOUNT
CFLAGS += -D OPCOUNT
endif
SHELL := /bin/bash
export SHELL
export DEBUG
all: $(NAME)
$(word 1, $(NAME)): $(OBJS) $(SOLVER_OBJS) $(LIBS_FOR_PUSHSWAP)
$(CC) $(CFLAGS) $(INCLUDE) $(OBJS) $(SOLVER_OBJS) $(LIBS_FOR_PUSHSWAP) -o $@
@printf "$(PINK)Done building push_swap $(RESET)\n"
$(word 2, $(NAME)): $(OBJS) $(CHECKER_OBJS) $(LIBS_FOR_CHECKER)
$(CC) $(CFLAGS) $(INCLUDE) $(OBJS) $(CHECKER_OBJS) $(LIBS_FOR_CHECKER) -o $@
@printf "$(PINK)Done building checker $(RESET)\n"
%.a: %
# @echo -e "$(GREEN)Compiling $@ in directory $< $(RESET)"
@make -sC $<
cp $</$@ .
%.o: %.c
# echo -e "$(BLUE) Compiling file $< to $@ $(RESET)"
$(CC) -c $(CFLAGS) $(INCLUDE) $^ -o $@
clean:
/bin/rm -f $(OBJS) $(CHECKER_OBJS) $(SOLVER_OBJS)
@/bin/rm -f *.o *~ *.gch
fclean: clean
@make fclean -sC libft
@make fclean -sC getnextline
@make fclean -sC ft_printf
@make fclean -sC libc_vector
/bin/rm -f $(NAME) libft.a getnextline.a ft_printf.a libc_vector.a
re: fclean all