-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
77 lines (59 loc) · 1.53 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
NAME = fdf
SRCS += core/map_reader.c
SRCS += core/map_loader.c
SRCS += core/map_preprocess.c
SRCS += core/renderer.c
SRCS += core/renderer_update.c
SRCS += core/camera.c
SRCS += core/errors.c
SRCS += core/line_clipping.c
SRCS += core/line_drawing.c
OBJS = $(SRCS:.c=.o)
FLAGS = -Wall -Wextra -Werror
FLAGS += -O2 -march=native -flto
LIBS = -l ft -L libft
INCLUDES = -I libft/ -I core/
##### MLX
MLX_SRCS += mlx_gui/main.c
MLX_SRCS += mlx_gui/mlx_gui.c
MLX_SRCS += mlx_gui/mlx_keyboard.c
MLX_OBJS = $(MLX_SRCS:.c=.o)
MLX_INCLUDES = -I mlx_gui/ -I minilibx_macos/
# Custom MLX with added mlx_set_relative_mouse_mode()
MLX_LIBS = -l mlx -L minilibx_macos
MLX_LIBS += -framework OpenGL -framework AppKit
##### SDL
SDL_SRCS += sdl_gui/main.c
SDL_SRCS += sdl_gui/sdl_gui.c
SDL_SRCS += sdl_gui/sdl_keyboard.c
SDL_OBJS = $(SDL_SRCS:.c=.o)
SDL_CFLAGS = $(shell sdl2-config --cflags)
SDL_LDFLAGS = $(shell sdl2-config --libs)
ifeq ($(MAKECMDGOALS), sdl)
OBJS += $(SDL_OBJS)
INCLUDES += $(SDL_CFLAGS)
LIBS += $(SDL_LDFLAGS)
else
OBJS += $(MLX_OBJS)
INCLUDES += $(MLX_INCLUDES)
LIBS += $(MLX_LIBS)
endif
all: $(NAME)
mlx sdl: $(NAME)
$(NAME): $(OBJS)
make -C ./libft
make -C ./minilibx_macos
gcc -o $(NAME) $(OBJS) $(INCLUDES) $(LIBS)
# $^ is the dependencies of the rule
# $@ is the name of the rule
%.o : %.c
gcc $(FLAGS) -c $^ $(INCLUDES) -o $@
clean :
make clean -C ./libft
make clean -C ./minilibx_macos
rm -f $(OBJS) $(MLX_OBJS) $(SDL_OBJS)
fclean : clean
make fclean -C ./libft
make fclean -C ./minilibx_macos
rm -f $(NAME)
re : fclean $(NAME)