-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
49 lines (35 loc) · 1.01 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
# Colors
GREEN = \x1b[32m
NC = \x1b[0m # No Color
CXX = c++
CXXFLAGS = -std=c++98 -Wall -Wextra -Werror
RM = rm -rf
SRC_DIR = srcs
BUILD_DIR = build
NAME = $(BUILD_DIR)/ircserv
# Create source file list maintaining directory structure
SRCS = $(shell find $(SRC_DIR) -name '*.cpp')
# Create object files list with build directory path
OBJECTS = $(SRCS:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o)
# Create directory list for object files
OBJ_DIRS = $(sort $(dir $(OBJECTS)))
INCLUDE = include/IRC.h \
$(shell find $(SRC_DIR) -name '*.hpp')
all: $(NAME)
$(NAME): $(OBJECTS)
@printf "$(GREEN)=> Linking$(NC) $@\n"
@$(CXX) $(OBJECTS) -o $@
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp $(INCLUDE)
@printf "$(GREEN)=> Compiling$(NC) $<\n"
@mkdir -p $(dir $@)
@$(CXX) $(CXXFLAGS) -c $< -o $@
$(BUILD_DIR):
@mkdir -p $(OBJ_DIRS)
clean:
@$(RM) $(BUILD_DIR)
@printf "$(GREEN)=> Cleaned build files$(NC)\n"
fclean: clean
@$(RM) $(NAME)
@printf "$(GREEN)=> Cleaned executable$(NC)\n"
re: fclean all
.PHONY: all clean fclean re