-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (63 loc) · 1.97 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
NAME = push_swap
BNAME = checker
SRC_DIR = src/
OBJ_DIR = obj/
BONUS_DIR = bonus/
LIBFT = libft
PRINTF = libft/ft_printf
CC = gcc
CFLAGS = -Wall -Werror -Wextra -g
RM = rm -f
PSW_DIR = push_swap/
MAND_FILES = push_swap quicksort sortage
COMM_DIR = common/
COMM_FILES = push_moves rev_rot_moves rotation_moves swap_moves utils
BONUS_FILES = checker bonus_utils
SRC_FILES = $(addprefix $(PSW_DIR), $(MAND_FILES))
COM_FILES = $(addprefix $(COMM_DIR), $(COMM_FILES))
SRC_BFILES = $(addprefix $(BONUS_DIR), $(BONUS_FILES))
SRC = $(addprefix $(SRC_DIR), $(addsuffix .c, $(SRC_FILES)))
OBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(SRC_FILES)))
COMMON = $(addprefix $(SRC_DIR), $(addsuffix .c, $(COM_FILES)))
COBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(COM_FILES)))
BSRC = $(addprefix $(SRC_DIR), $(addsuffix .c, $(SRC_BFILES)))
BOBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(SRC_BFILES)))
OBJF = .cache_exists
all: $(NAME)
$(NAME): $(OBJ) $(COBJ) $(OBJF)
@make -C $(LIBFT)
@cp libft/libft.a .
@make -C $(PRINTF)
@cp libft/ft_printf/libftprintf.a .
@$(CC) $(CFLAGS) $(OBJ) $(COBJ) libft.a libftprintf.a -o $(NAME)
$(OBJ_DIR)%.o: $(SRC_DIR)%.c $(OBJF)
@$(CC) $(CFLAGS) -c $< -o $@
$(OBJF):
@mkdir -p $(OBJ_DIR)
@mkdir -p $(OBJ_DIR)$(PSW_DIR)
@mkdir -p $(OBJ_DIR)$(COMM_DIR)
@mkdir -p $(OBJ_DIR)$(BONUS_DIR)
@touch $(OBJF)
bonus: $(BNAME)
$(BNAME): $(BOBJ) $(COBJ) $(OBJF)
@make -C $(LIBFT)
@cp libft/libft.a .
@make -C $(PRINTF)
@cp libft/ft_printf/libftprintf.a .
@$(CC) $(CFLAGS) $(BOBJ) $(COBJ) libft.a libftprintf.a -o $(BNAME)
clean:
@$(RM) -r $(OBJ_DIR)
@make clean -C $(LIBFT)
@make clean -C $(PRINTF)
@$(RM) $(OBJF)
fclean: clean
@$(RM) $(NAME)
@$(RM) libft.a
@$(RM) $(LIBFT)/libft.a
@$(RM) libftprintf.a
@$(RM) checker
@$(RM) $(LIBFT)/ft_printf/libftprintf.a
@rm -rf *.dSYM
@find . -name ".DS_Store" -delete
re: fclean all
.PHONY: all clean fclean re