-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (29 loc) · 1.07 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
NAME = ircserv
SRC_DIR = Src/
OBJ_DIR = .obj/
INCLUDE_DIR = Include/
CC = c++
CFLAGS = -Wall -Wextra -Werror -std=c++98 -g
SRC = main.cpp Server.cpp Socket.cpp User.cpp Channels.cpp message.cpp utils.cpp mode.cpp joinChannel.cpp bot.cpp
OBJP = $(addprefix $(OBJ_DIR), $(notdir $(SRC:.cpp=.o)))
VPATH = $(SRC_DIR)
TOTAL_FILES := $(words $(SRC))
COMPILED_FILES = 0
all: $(NAME)
$(OBJ_DIR)%.o: %.cpp
@mkdir -p $(OBJ_DIR)
@$(CC) $(CFLAGS) -I$(INCLUDE_DIR) -c $< -o $@
@$(eval COMPILED_FILES=$(shell echo $$(($(COMPILED_FILES)+1))))
@$(call print_progress)
$(NAME): $(OBJP)
@$(CC) $(CFLAGS) $(OBJP) -o $(NAME)
@echo "\033[32m\rCompiled ✅ \033[0;37m"
clean:
@echo "\033[0;31mCleaning objects🧹"
@rm -rf $(OBJ_DIR)
fclean: clean
@echo "\033[0;31mRemoving $(NAME) 🗑\033[0;37m"
@rm -rf $(NAME)
re: fclean all
print_progress = @printf "\r\033[K\033[32mCompiling... [%-10s]\033[0m \033[32m%d/%d\033[0m" "$(shell perl -e 'printf "=" x (int($(COMPILED_FILES) * 10 / $(TOTAL_FILES)))')" "$(COMPILED_FILES)" "$(TOTAL_FILES)"
.PHONY: all clean fclean re