-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (53 loc) · 1.77 KB
/
Makefile
File metadata and controls
65 lines (53 loc) · 1.77 KB
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
#______command and their flags______#
RM = rm -rf
CFLAGS = -Wall -Wextra -Werror
MLXFLAGS = -lmlx -lXext -lX11
CC = gcc
AR = ar -crs
INCLUDES = includes
#______directories______#
OBJ_DIR = obj
BNS_DIR_OBJ = $(OBJ_DIR)_bonus
SRC_DIR = src
BNS_DIR = bns
INCLUDES = includes
LIB_INCLUDES = libft/includes
#______mandatory and bonus files______#
FILES = main.c parse_map.c parse_map_utils.c exit.c init.c init_utils.c input.c moves.c\
player.c player_utils.c rendering.c rendering_utils.c gameOver.c
FILES_BONUS = main.c parse_map.c parse_map_utils.c exit.c init.c init_utils.c input.c moves.c\
player.c player_utils.c rendering.c rendering_utils.c gameOver.c\
enemy_move.c enemy_move_utils.c
#______patterns and substitutions______#
SOURCES = $(FILES:%.c=$(SRC_DIR)/%.c)
OBJECTS = $(SOURCES:$(SRC_DIR)%.c=$(OBJ_DIR)%.o)
BONUS_SRC = $(FILES_BONUS:%.c=$(BNS_DIR)/%_bonus.c)
BONUS_OBJ = $(BONUS_SRC:$(BNS_DIR)%.c=$(BNS_DIR_OBJ)%.o)
#______static library name______#
NAME = so_long
NAME_BONUS = bonus
LIB = libft
#______________Rules______________#
$(NAME): $(OBJECTS) $(LIB)/libft.a
$(CC) $(CFLAGS) $^ -I$(INCLUDES) -I$(LIB_INCLUDES) $(MLXFLAGS) -o $@
$(NAME_BONUS): $(BONUS_OBJ) $(LIB)/libft.a
$(CC) $(CFLAGS) $^ -I$(INCLUDES) -I$(LIB_INCLUDES) $(MLXFLAGS) -o $@
# impicit rule for mandatory
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(OBJ_DIR)
$(CC) $(CFLAGS) -I$(INCLUDES) -I$(LIB_INCLUDES) -c $< $(MLXFLAGS) -o $@
# impicit rule for bonus
$(BNS_DIR_OBJ)/%.o: $(BNS_DIR)/%.c
@mkdir -p $(BNS_DIR_OBJ)
$(CC) $(CFLAGS) -I$(INCLUDES) -I$(LIB_INCLUDES) -c $< $(MLXFLAGS) -o $@
$(LIB)/%.a:
$(MAKE) all -C $(LIB)
re: fclean all
all: $(NAME) $(NAME_BONUS)
#______cleaning______#
clean:
$(RM) $(OBJ_DIR)
$(RM) $(BNS_DIR_OBJ)
$(MAKE) -C $(LIB) fclean
fclean: clean
$(RM) $(NAME) $(NAME_BONUS)