-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
82 lines (56 loc) · 1.74 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
NAME = cub3D
TMP = tmp
SRCS = $(wildcard ./srcs/*.c)
OBJS = $(patsubst ./srcs/%.c, ./tmp/%.o, $(SRCS))
BONUS_ = 0
CC = gcc
CFLAGS = -Wall -Wextra -Werror
LIB = ./lib
LIBFT = $(LIB)/libft
LIBGNL = $(LIB)/get_next_line
LIBMLX_L = $(LIB)/mlx_linux
LIBMLX_L_ = -L$(LIBMLX_L) -lmlx_Linux -lXext -lX11 -lm -lz
# LIBMLX_L_ = -L$(LIBMLX_L) -lmlx_Linux -lXext -lX11 -lm
LIBMLX_M = $(LIB)/mlx
LIBMLX_M_ = -L$(LIBMLX_M) -lmlx -framework OpenGL -framework AppKit
MACH_EXTRA = install_name_tool -change @loader_path/libbass.dylib @loader_path/bass/libbass.dylib $(NAME) \
&& install_name_tool -change libmlx.dylib @loader_path/${LIBMLX_M}/libmlx.dylib $(NAME)
UNIX_NAME = $(shell uname -s)
ifeq ($(UNIX_NAME),Darwin)
LIBMLX = $(LIBMLX_M)
LIBMLX_LINK = $(LIBMLX_M_)
else ifeq ($(UNIX_NAME),Linux)
LIBMLX = $(LIBMLX_L)
LIBMLX_LINK = $(LIBMLX_L_)
endif
INCLUDES = -I./includes -I$(LIBMLX)
LINKERS = -L$(LIBGNL) -lgnl -L$(LIBFT) -lft $(LIBMLX_LINK)
RM = rm -rf
.PHONY: all clean fclean re bonus bonus_on
./tmp/%.o: ./srcs/%.c ./includes/cub3D.h
$(CC) $(CFLAGS) $(INCLUDES) -D OS_NAME=$(UNIX_NAME) \
-D BONUS=$(BONUS_) -o $@ -c $<
all: bonus
bonus: bonus_on $(NAME)
bonus_on:
$(eval BONUS_ = 1)
$(TMP):
@mkdir $(TMP)
$(NAME): $(TMP) $(OBJS)
@$(MAKE) -C $(LIBFT) all
@$(MAKE) -C $(LIBGNL) all
@$(MAKE) -C $(LIBMLX) all
# @$(CC) $(CFLAGS) $(INCLUDES) $(OBJS) $(LINKERS) -o $(NAME)
@$(CC) $(CFLAGS) $(INCLUDES) $(OBJS) $(LINKERS) -Wl,--allow-multiple-definition -o $(NAME)
ifeq ($(UNIX_NAME),Darwin)
@$(MACH_EXTRA)
endif
clean:
@$(MAKE) -C $(LIBFT) clean
@$(MAKE) -C $(LIBGNL) clean
@$(RM) $(TMP)
fclean: clean
@$(MAKE) -C $(LIBFT) fclean
@$(MAKE) -C $(LIBGNL) fclean
@$(RM) $(NAME)
re: fclean all