-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
115 lines (95 loc) · 4.43 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: maldavid <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/08/09 23:12:16 by maldavid #+# #+# #
# Updated: 2022/08/10 21:45:56 by maldavid ### ########.fr #
# #
# **************************************************************************** #
####################################
#
# GLOBAL INFORMATIONS
#
####################################
NAME = release/openlibft.a
CC = gcc
CXX = g++
FASM = fasm
CFLAGS = -Wall -Wextra -Werror -Iincludes -Isrc/includes -O3 -fPIE
SRC_C = $(wildcard src/**/*.c)
SRC_C += $(wildcard src/**/**/*.c)
SRC_CXX = $(wildcard src/**/**/*.cpp)
SRC_S = $(wildcard src/**/*.asm)
SRC_S += $(wildcard src/**/**/*.asm)
OBJ_C = $(SRC_C:.c=.o)
OBJ_CXX = $(SRC_CXX:.cpp=.o)
OBJ_S = $(SRC_S:.asm=.o)
NUM_CF = $(shell ls -l src/**/*.c | wc -l)
NUM_CF += $(shell ls -l src/**/**/*.c | wc -l)
NUM_SF = $(shell ls -l src/**/*.asm | wc -l)
NUM_SF += $(shell ls -l src/**/**/*.asm | wc -l)
NUM_CXXF = $(shell ls -l src/**/**/*.cpp | wc -l)
ISA = $(shell $(FASM) ISA/check.asm > /dev/null && ISA/check | rev | cut -c 2- | rev && rm ISA/check)
CFLAGS += -D$(subst /, -D , $(ISA))
cnt = 1
##################################
#
# COLOR
#
##################################
GREEN = \033[38;5;82m
RED = \033[38;5;196m
YELLOW = \033[38;5;226m
ORANGE = \033[38;5;202m
PURPLE = \033[38;5;207m
LBLUE = \033[38;5;45m
BLUE = \033[38;5;26m
RESET = \033[00m
##################################
#
# DEBUG MODE
#
##################################
ifdef DEBUG
CFLAGS += -g3
endif
define ascii_art
██████╗ ██████╗ ███████╗███╗ ██╗██╗ ██╗██████╗ ███████╗████████╗
██╔═══██╗██╔══██╗██╔════╝████╗ ██║██║ ██║██╔══██╗██╔════╝╚══██╔══╝
██║ ██║██████╔╝█████╗ ██╔██╗ ██║██║ ██║██████╔╝█████╗ ██║
██║ ██║██╔═══╝ ██╔══╝ ██║╚██╗██║██║ ██║██╔══██╗██╔══╝ ██║
╚██████╔╝██║ ███████╗██║ ╚████║███████╗██║██████╔╝██║ ██║
╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝╚══════╝╚═╝╚═════╝ ╚═╝ ╚═╝
OpenLibft Created by 42 Angouleme
[ Version : 0.0.1 (alpha) ]
endef
export ascii_art
all: BANNER $(NAME)
BANNER:
@printf "$(LBLUE)$$ascii_art$(RESET)"
%.o: %.c
@printf "$(LBLUE)[$(PURPLE)+$(LBLUE)] compile C... $(GREEN)$<$(LBLUE) [$(GREEN)$(cnt)$(YELLOW)/$(NUM_CF)$(LBLUE)] \r"
@$(CC) $(CFLAGS) -c $< -o $@
$(eval cnt=$(shell echo $$(($(cnt)+1))))
%.o: %.cpp
@printf "$(LBLUE)[$(PURPLE)+$(LBLUE)] compile C++... $(GREEN)$<$(LBLUE) [$(GREEN)$(cnt)$(YELLOW)/$(NUM_CF)$(LBLUE)] \r"
@$(CXX) $(CFLAGS) -std=c++17 -c $< -o $@
$(eval cnt=$(shell echo $$(($(cnt)+1))))
%.o: %.asm
@printf "$(LBLUE)[$(PURPLE)+$(LBLUE)] compile Assembly... $(GREEN)$<$(LBLUE) [$(GREEN)$(cnt)$(YELLOW)/$(NUM_SF)$(LBLUE)] \r"
@$(FASM) $< $@ > /dev/null
$(eval cnt=$(shell echo $$(($(cnt)+1))))
$(NAME): $(OBJ_C) $(OBJ_S) $(OBJ_CXX)
@printf "\n"
@mkdir -p release
@ar rcs $(NAME) $(OBJ_C) $(OBJ_S) $(OBJ_CXX)
@printf "$(LBLUE)[$(PURPLE)+$(LBLUE)] Release has been builded release/openlibft.a !$(RESET)\n"
clean:
@rm -rf $(OBJ_C) $(OBJ_S) $(OBJ_CXX)
fclean: clean
@rm -rf $(NAME)
re: BANNER fclean $(NAME)
.PHONY: all shared clean fclean re