-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
109 lines (82 loc) · 2.93 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
## --- --- --- --- --- --- ###
# PROJECT COMPILATION #
### --- --- --- --- --- --- ###
CC = gcc
CFLAGS = -Wall -Werror -Wextra# -g3 -fsanitize=address
### --- --- --- --- --- --- ###
# PROJECT PATHS #
### --- --- --- --- --- --- ###
INCLUDE = -I include -I libft/include
SRCS_PATH = src/
LIBFT_PATH = libft/
LIBFT = $(LIBFT_PATH)libft.a
LIBFT_REPO = $(LIBFT_PATH)Makefile
MLX_PATH = mlx
ifeq ($(shell uname -s), Darwin)
#CFLAGS += -l $(MLX_PATH)
CFLAGS += -I $(MLX_PATH)
MLXFLAGS = -L $(MLX_PATH) -l $(MLX_PATH) -framework OpenGL -framework AppKit
# MLXFLAGS = -L $(MLX_PATH) -I $(MLX_PATH) -framework OpenGL -framework AppKit
endif
### --- --- --- --- --- --- ###
# PROJECT FILES #
### --- --- --- --- --- --- ###
NAME = cub3d
SRC_FILES = main.c
SRC_OBJS = $(SRC_FILES:%.c=bin/%.o)
### --- --- --- --- --- --- ###
# COLORS & EXTRAS :) #
### --- --- --- --- --- --- ###
NC = \033[0m
RED = \033[0;31m
GREEN = \033[0;32m
LRED = \033[1;31m
LGREEN = \033[1;32m
YELLOW = \033[1;33m
LBLUE = \033[1;34m
TITLE = \033[38;5;33m
### --- --- --- --- --- --- ###
# RULES #
### --- --- --- --- --- --- ###
.PHONY: all re clean fclean norm todo TODO execute
all: $(NAME)
$(NAME): $(LIBFT) $(SRC_OBJS)
@echo "\n${TITLE}Compiling${NC} ${YELLOW}$(NAME)${NC} into ${YELLOW}$(NAME)${NC}\c"
@$(CC) $(CFLAGS) $(INCLUDE) $(MLXFLAGS) $(SRC_OBJS) $(LIBFT) -o $(NAME)
@echo " ${GREEN}[OK]${NC}\n"
$(LIBFT): $(LIBFT_REPO)
@make -C $(LIBFT_PATH)
# TODO debug
$(LIBFT_REPO):
#git clone [email protected]:jkutkut/42madrid-libft libft
@git submodule update --init --recursive
bin:
@mkdir -p $(dir $@)
bin/%.o: src/%.c bin
@echo "$(TITLE)Compiling${NC} $< -> $@\c"
@$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
@echo " ${GREEN}[OK]${NC}"
clean: $(LIBFT_REPO)
@echo "- ${RED}Removing${NC} binary directory"
@rm -rf $(BIN)
@echo "- ${RED}Removing${NC} libft directory"
@make -C $(LIBFT_PATH) fclean
@# TODO mlx
fclean: clean
@echo "- ${RED}Removing${NC} $(NAME)"
@rm -f $(NAME)
@echo "Project ${YELLOW}$(NAME) ${GREEN}clean${NC}.\n"
re: fclean all
### --- --- --- --- --- --- ###
# Development #
### --- --- --- --- --- --- ###
norm:
@norminette $(SRC_FILES:%=$(SRCS_PATH)%) include | sed "s/src/\\`echo '\n\r'`/g"
norm_docker:
docker run --rm -v $(PWD):/docker jkutkut/docker4norminette:latest $(SRC_FILES:%=$(SRCS_PATH)%) include | sed "s/src/\\`echo '\n\r'`/g"
todo:
@cat $(SRC_FILES:%=$(SRCS_PATH)%) | grep '//\stodo:.*' -ioh --color=never
TODO:
@echo "*****************************************"
@grep "TODO" -nr -i --exclude-dir=".git" .
@echo "*****************************************"