-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (86 loc) Β· 3.2 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: rubennijhuis <[email protected] +#+ #
# +#+ #
# Created: 2022/04/24 20:14:42 by rubennijhui #+# #+# #
# Updated: 2022/06/28 13:30:35 by rubennijhui ######## odam.nl #
# #
# **************************************************************************** #
#=====================================#
#========= General variables =========#
#=====================================#
NAME := bin/example
ASSETS_DIR := assets
BIN_DIR := bin
INCLUDE_DIR := include
LIBS_DIR := libs
OBJS_DIR := objs
SRC_DIR := src
TEST_DIR := test
#=====================================#
#=============== Input ===============#
#=====================================#
LIBS := $(LIBS_DIR)/LibFT/libft.a \
$(LIBS_DIR)/Get-Next-Line/get-next-line.a \
LIBS_HEADERS := -I $(INCLUDE_DIR) \
-I $(LIBS_DIR)/LibFT/include/ \
-I $(LIBS_DIR)/Get-Next-Line/include/ \
INC := $(LIBS_HEADERS)
SRCS := main.c \
test.c \
OBJS = $(addprefix $(OBJS_DIR)/,$(SRCS:.c=.o))
#=====================================#
#========= Command arguments =========#
#=====================================#
CC = gcc
CFLAGS = -Wall -Werror -Wextra -g $(INC)
NO_DEAD_CODE := -O1 -Os -fdata-sections -ffunction-sections -Wl, -dead_strip
#=====================================#
#=============== Rules ===============#
#=====================================#
objs/%.o:src/%.c
@mkdir -p $(dir $@)
@$(CC) -c $(CFLAGS) -o $@ $^
@echo "π¨ Compiling: $^"
all: $(NAME)
$(NAME):$(OBJS) $(LIBS)
@$(CC) $(OBJS) $(LDFLAGS) $(LIBS) $(MLX) $(NO_DEAD_CODE) -o $(NAME)
@echo "β
Built $(NAME)"
clean:
@rm -rf $(OBJS_DIR)
fclean: clean
@make fclean -C $(LIBS_DIR)/LibFT
@rm -f $(NAME)
re: fclean all
#=====================================#
#=========== Special Rules ===========#
#=====================================#
submodules:
@git submodule update --init --recursive
@cd $(LIBS_DIR)/LibFt/ && git pull origin main
@cd $(LIBS_DIR)/Get-Next-Line/ && git pull origin main
run: $(NAME)
@./$(NAME) $(INPUT_FILE)
test:
@make run -C $(TEST_DIR)/
norm:
@echo "\033[92m========= $(NAME) norm ========\033[0m"
@-norminette $(INCLUDE_DIR)
@-norminette $(SRC_DIR)
@echo "\033[92m========= $(NAME) norm ========\033[0m"
@echo
@make norm -C $(LIBS_DIR)/LibFT
#=====================================#
#========== Lib compilation ==========#
#=====================================#
$(LIBS_DIR)/LibFT/libft.a:
@make -C $(LIBS_DIR)/LibFT
$(LIBS_DIR)/Get-Next-Line/get-next-line.a:
@make -C $(LIBS_DIR)/Get-Next-Line
#=====================================#
#================ Misc ===============#
#=====================================#
.PHONY: all re run clean fclean test