-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
113 lines (93 loc) · 3.22 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: mnouchet <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/01/06 22:19:57 by mnouchet #+# #+# #
# Updated: 2023/02/09 14:33:39 by mnouchet ### ########.fr #
# #
# **************************************************************************** #
NAME := fdf
## ########################################################################## ##
# INGREDIENTS ##
## ########################################################################## ##
# LIBS libraries to be used
# LIBS_TARGET libraries to be built
# INCS header file locations
#
# SRCS_DIR source directory
# SRCS source files
#
# BUILD_DIR build directory
# OBJS object files
#
# CC compiler
# CFLAGS compiler flags
# CPPFLAGS preprocessor flags
# LDFLAGS linker flags
# LDLIBS libraries name
LIBS := ft mlx
LIBS_TARGET := libs/libft/libft.a \
libs/mlx/mlx.a
INCS := includes \
libs/libft/includes \
libs/mlx
SRCS_DIR := srcs
SRCS := main.c \
types/color.c \
types/node.c \
types/map.c \
types/fdf.c \
draws/line.c \
draws/pixel.c \
draws/node.c \
hooks/renders.c \
hooks/inputs.c
SRCS := $(SRCS:%=$(SRCS_DIR)/%)
BUILD_DIR := .build
OBJS := $(SRCS:$(SRCS_DIR)/%.c=$(BUILD_DIR)/%.o)
CC := cc
CFLAGS := -g3 -Wall -Wextra -Werror
CPPFLAGS := $(INCS:%=-I%)
LDFLAGS := $(addprefix -L,$(dir $(LIBS_TARGET))) -L /opt/X11/lib
LDLIBS := $(addprefix -l,$(LIBS)) -lX11 -lXext
## ########################################################################## ##
# UTENSILS ##
## ########################################################################## ##
# RM force remove
# MAKEFLAGS make flags
# DIR_UP duplicate directory tree
RM := rm -f
MAKEFLAGS += --silent --no-print-directory
DIR_DUP = mkdir -p $(@D)
## ########################################################################## ##
# RECIPES ##
## ########################################################################## ##
# all default goal
# $(NAME) link .o -> archive
# %.o compilation .c -> .o
# clean remove .o
# fclean remove .o + binary
# re remake default goal
all: $(NAME)
$(LIBS_TARGET):
echo "→ Compiling $(@F)"
$(MAKE) -C $(@D)
$(BUILD_DIR)/%.o: $(SRCS_DIR)/%.c
echo "→ Compiling $<"
$(DIR_DUP)
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(NAME): $(LIBS_TARGET) $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $(NAME)
echo "\033[0;32m✓ $@ READY"
bonus: all
clean:
echo "→ Removing objects"
$(RM) $(OBJS)
fclean: clean
echo "→ Removing binaries"
$(RM) $(NAME)
re: fclean all
.PHONY: re