-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
165 lines (150 loc) · 5.31 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: amalliar <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/02/09 23:55:29 by amalliar #+# #+# #
# Updated: 2020/10/08 16:59:24 by amalliar ### ########.fr #
# #
# **************************************************************************** #
SHELL := /bin/sh
CC := clang
CFLAGS := -Wall -Wextra -fdiagnostics-color -g -pipe \
-march=native -O2 -flto
INCLUDE := -I./include -I./libft/include -I./libmlx -I$(HOME)/.brew/Cellar/sdl2/2.0.12_1/include -I./ssdl2/include
NAME := cub3D
LIBFT := ./libft/libft.a
LIBMLX := ./libmlx/libmlx.dylib
LIBS := -L./libft -lft -L. -lmlx -framework OpenGL -framework AppKit -L$(HOME)/.brew/Cellar/sdl2/2.0.12_1/lib -lSDL2
SRCDIR := src
OBJDIR := .obj
DEPDIR := .dep
SRCS := src/attempt_item_pickup.c \
src/button_press_handler.c \
src/button_release_handler.c \
src/colors.c \
src/colors_2.c \
src/exit_failure.c \
src/expose_handler.c \
src/graphics.c \
src/graphics_2.c \
src/graphics_3.c \
src/graphics_4.c \
src/item_pickup.c \
src/item_pickup_2.c \
src/key_press_handler.c \
src/key_release_handler.c \
src/load_audio.c \
src/load_map.c \
src/load_map_2.c \
src/load_map_3.c \
src/load_map_4.c \
src/load_map_5.c \
src/load_scene.c \
src/load_textures.c \
src/mlx_image_to_bmp_file.c \
src/object_collision.c \
src/process_effects.c \
src/process_enemie_states.c \
src/process_enemie_states_2.c \
src/process_enemie_states_3.c \
src/process_enemie_states_4.c \
src/process_game_state.c \
src/process_interact_request.c \
src/process_key_states.c \
src/process_key_states_2.c \
src/process_mouse_motion.c \
src/process_physics.c \
src/process_physics_2.c \
src/process_physics_3.c \
src/process_physics_4.c \
src/render_floor_and_ceiling.c \
src/render_hud.c \
src/render_hud_2.c \
src/render_scene.c \
src/render_sprites.c \
src/render_walls.c \
src/render_walls_2.c \
src/render_walls_3.c \
src/render_walls_4.c \
src/switch_weapon.c \
src/take_screenshot.c \
src/winclose_handler.c \
src/main.c \
src/main_2.c
OBJS := $(SRCS:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
DEPS := $(SRCS:$(SRCDIR)/%.c=$(DEPDIR)/%.d)
# Run multiple threads.
MAKEFLAGS = -j 4 --output-sync=recurse --no-print-directory
# Protect against make incorrectly setting 'last modified' attribute
# when running in parallel (-j flag).
POST_COMPILE = mv -f $(DEPDIR)/$*.tmp $(DEPDIR)/$*.d && touch $@
# Define some colors for echo:
LGREEN := \033[1;32m
WHITE := \033[1;37m
NOC := \033[0m
bonus: $(NAME)
$(NAME): $(OBJS) $(LIBFT) $(LIBMLX)
@echo "$(LGREEN)Linking executable $(NAME)$(NOC)"
$(CC) $(CFLAGS) $(INCLUDE) ./ssdl2/audio.c $(OBJS) $(LIBS) -o $@
@echo "Built target $(NAME)"
.PHONY: bonus
all:
@$(MAKE) fclean
@git checkout -f master
@$(MAKE)
.PHONY: all
linux:
@$(MAKE) fclean
@git checkout -f linux
@$(MAKE)
.PHONY: linux
$(LIBFT): NONE
@$(MAKE) -C ./libft
$(LIBMLX): NONE
@$(MAKE) -C ./libmlx MAKEFLAGS= -j 1
@cp ./libmlx/libmlx.dylib .
.PHONY: NONE
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(DEPDIR)/%.d | $(OBJDIR) $(DEPDIR)
$(CC) $(CFLAGS) $(INCLUDE) -MMD -MF $(DEPDIR)/$*.tmp -c $< -o $@
@$(POST_COMPILE)
$(OBJDIR):
@mkdir -p $(OBJDIR)
$(DEPDIR):
@mkdir -p $(DEPDIR)
$(DEPDIR)/%.d: ;
.PRECIOUS: $(DEPDIR)/%.d
clean:
@$(MAKE) -C ./libft clean
@$(MAKE) -C ./libmlx clean
@echo "$(WHITE)Removing C object files...$(NOC)"
@-rm -rf $(OBJDIR)
@echo "$(WHITE)Removing make dependency files...$(NOC)"
@-rm -rf $(DEPDIR)
.PHONY: clean
fclean: clean
@$(MAKE) -C ./libft fclean
@-rm -f libmlx.dylib
@echo "$(WHITE)Removing executable $(NAME)$(NOC)"
@-rm -f $(NAME)
.PHONY: fclean
re:
$(MAKE) fclean
$(MAKE) bonus
.PHONY: re
help:
@echo "The following are some of the valid targets for this Makefile:"
@echo "... all (the default if no target is provided)"
@echo "... bonus"
@echo "... linux"
@echo "... clean"
@echo "... fclean"
@echo "... re"
.PHONY: help
# Do not include dependency files if the current goal is
# set to clean/fclean/re.
ifeq ($(findstring $(MAKECMDGOALS), clean fclean re),)
-include $(DEPS)
endif