-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
163 lines (108 loc) · 3.81 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: shaas <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/06/25 11:26:14 by shaas #+# #+# #
# Updated: 2022/02/09 22:02:47 by shaas ### ########.fr #
# #
# **************************************************************************** #
MAP := affe.ber
# defines #
NAME := so_long
# SRC := dumb_projects/make_a_bi_uebergang_with_mlx.c
SRC := src/so_long.c src/error_stuff.c src/get_next_line.c src/get_next_line_utils.c \
src/get_map.c src/map_errors.c src/create_images.c src/create_window.c src/hooks.c \
src/go_in_direction.c src/win.c
OBJ := $(SRC:.c=.o)
PRINT_SYSTEM = 0
CODE_DIR := src
LIBFT_DIR := libft
LIBFT = $(LIBFT_DIR)/libft.a
# check if mac or linux, compile mlx accordingly #
OS := $(shell uname)
ifeq ($(OS), Darwin)
MLX_DIR = mlx_mac
MLX = $(MLX_DIR)/libmlx.a
COMP1 := gcc -Wall -Wextra -Werror -g -c
COMP2 := gcc -Wall -Wextra -Werror -g $(OBJ) $(LIBFT) $(MLX) -Lmlx_mac -lmlx \
-framework OpenGL -framework AppKit -o $(NAME)
endif
ifeq ($(OS), Linux)
MLX_DIR = mlx_linux
MLX = $(MLX_DIR)/libmlx.a
COMP1 := gcc -Wall -Wextra -Werror -g -l/usr/include -lmlx -O3 -c
COMP2 := gcc -Wall -Wextra -Werror -g $(OBJ) $(LIBFT) -Lmlx_linux -lmlx_Linux \
-L/usr/lib -Imlx_linux -lXext -lX11 -lm -lz -o $(NAME)
endif
# rules #
all: $(NAME)
%.o: %.c
$(COMP1) $< -o $@
$(NAME): $(MLX) $(LIBFT) $(OBJ)
@printf $(YELLOW)"*--------object files created!---------*\n\n"$(RESET)
$(COMP2)
@printf $(LIGHTGREEN)"*--------executable created!-----------*\n\n"$(RESET)
# print out which system we're on, will only be executed once \
even if called multiple times
ifeq ($(PRINT_SYSTEM), 0)
print_system:
$(eval PRINT_SYSTEM = 1)
@printf $(DARKGRAY)$(ITALIC)$(UNDERLINED)"We're on $(OS)\n\n"$(RESET)
endif
# rule for running program
exec: print_system
@printf $(MAGENTA)"*--------executing program!------------*\n\n"$(RESET)
./$(NAME) $(MAP)
# complies & runs immediately
both: $(NAME) exec
$(MLX): print_system
@printf $(LIGHTBLUE)"*--------checking mlx...---------------*\n\n"$(RESET)
@make -s -C $(MLX_DIR) # need to check if works for mac
$(LIBFT): print_system
@printf $(LIGHTBLUE)"*--------checking libft...-------------*\n\n"$(RESET)
@make -C $(LIBFT_DIR)
wsl: # doesnt work yet :/
export DISPLAY=$$(cat /etc/resolv.conf | grep nameserver | awk '{print $$2}'):0.0
clean: print_system
rm -fr $(OBJ)
@printf $(RED)"*--------object files removed!---------*\n\n"$(RESET)
fclean: clean
rm -fr $(NAME)
@printf $(RED)"*--------$(NAME) removed!--------------*\n\n"$(RESET)
re: fclean all
# text modifiers #
RED = "\e[31m"
GREEN = "\e[32m"
YELLOW = "\e[33m"
BLUE = "\e[34m"
MAGENTA = "\e[35m"
CYAN = "\e[36m"
LIGHTGRAY = "\e[37m"
DARKGRAY = "\e[90m"
LIGHTRED = "\e[91m"
LIGHTGREEN = "\e[92m"
LIGHTYELLOW = "\e[93m"
LIGHTBLUE = "\e[94m"
LIGHTMAGENTA = "\e[95m"
LIGHTCYAN = "\e[96m"
RED_BG = "\e[41m"
GREEN_BG = "\e[42m"
YELLOW_BG = "\e[43m"
BLUE_BG = "\e[44m"
MAGENTA_BG = "\e[45m"
CYAN_BG = "\e[46m"
LIGHTGRAY_BG = "\e[47m"
DARKGRAY_BG = "\e[100m"
LIGHTRED_BG = "\e[101m"
LIGHTGREEN_BG = "\e[102m"
LIGHTYELLOW_BG = "\e[103m"
LIGHTBLUE_BG = "\e[104m"
LIGHTMAGENTA_BG = "\e[105m"
LIGHTCYAN_BG = "\e[106m"
BOLD = "\e[1m"
ITALIC = "\e[3m"
UNDERLINED = "\e[4m"
RESET = "\e[0m"