-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
71 lines (56 loc) · 2.22 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: flo <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/06/04 14:26:27 by fkeitel #+# #+# #
# Updated: 2024/10/09 16:17:26 by flo ### ########.fr #
# #
# **************************************************************************** #
NAME := cub3d
CFLAGS := -Wall -Wextra -Werror -Wunreachable-code -Ofast -g
LIBMLX := ./MLX42
LIBMLX_URL := https://github.com/codam-coding-college/MLX42.git
LIBFT_DIR := libft
LIBFT := $(LIBFT_DIR)/libft.a
HEADERS := -I ./include -I $(LIBMLX)/include
# Directories
SRC_DIR := srcs
OBJ_DIR := obj
LIBS := $(LIBMLX)/build/libmlx42.a -ldl -lglfw -pthread -lm -L$(LIBFT_DIR) -lft
SRCS := $(shell find $(SRC_DIR) -name '*.c')
OBJS := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRCS))
all: $(LIBFT) libmlx $(NAME)
@chmod 000 manual.txt
@echo "$(NAME) successfully built!"
libmlx:
@if [ ! -d "$(LIBMLX)" ]; then \
git clone $(LIBMLX_URL) $(LIBMLX); \
fi
@cmake -S $(LIBMLX) -B $(LIBMLX)/build
@cmake --build $(LIBMLX)/build --parallel 4
$(LIBFT):
@$(MAKE) -C $(LIBFT_DIR)
# Ensure the obj directory and necessary subdirectories are created
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
@mkdir -p $(@D)
@$(CC) $(CFLAGS) -o $@ -c $< $(HEADERS) && printf "Compiling: $(notdir $<)\n"
$(OBJ_DIR):
@mkdir -p $(OBJ_DIR)
$(NAME): $(OBJS)
@$(CC) $(OBJS) $(LIBS) $(HEADERS) -o $(NAME)
clean:
@rm -rf $(OBJ_DIR)
@rm -rf $(LIBMLX)/build
@$(MAKE) -C $(LIBFT_DIR) clean
fclean: clean
@rm -rf $(NAME) $(BONUS_NAME)
@$(MAKE) -C $(LIBFT_DIR) fclean
@chmod 777 manual.txt
re: fclean all
mlxfclean: fclean
@rm -rf $(LIBMLX)
@rm -rf MLX42
.PHONY: all clean fclean re libmlx