-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
86 lines (67 loc) · 2.29 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: hsabir <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/01/22 13:45:33 by hsabir #+# #+# #
# Updated: 2022/02/23 15:50:01 by ### ########.fr # #
# #
# **************************************************************************** #
SHELL = /bin/sh
CXXFLAGS := ${CFLAGS}
CXX ?= c++
INC_FLAGS :=
LDFLAGS :=
UNAME = $(shell uname -s)
ifeq ($(UNAME), Linux)
NPROC := $(shell nproc)
else
NPROC := $(shell sysctl -n hw.ncpu)
endif
MAKEFLAGS += --output-sync=target
MAKEFLAGS += --no-print-directory
MAKEFLAGS += -D_DAR-WIN_UNLIMITED_SELECT
NAME ?= containers_ft
NAME_DEBUG ?= containers_stl
BUILD_DIR ?= ./build
SRC_DIRS ?= ./
INCLUDE_DIR ?= ./
SRCS := $(shell find $(SRC_DIRS) -name 'main.cpp')
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
INC_DIRS := $(shell find $(INCLUDE_DIR) -type d)
INC_FLAGS += $(addprefix -I,$(INC_DIRS))
CXXFLAGS += -Wall -Wextra -Werror -Wshadow #-D STD
#CXXFLAGS += -std=c++98 -pedantic
CXXFLAGS += -g3
CXXFLAGS += -fdiagnostics-color
CXXFLAGS += -fsanitize=address
all:
@$(MAKE) -j$(NPROC) $(NAME)
$(NAME): $(OBJS)
@echo Linking $@
@$(CXX) $(CXXFLAGS) $(INC_FLAGS) $(OBJS) $(LDFLAGS) -o $(NAME)
$(BUILD_DIR)/%.cpp.o: %.cpp
@echo Compiling $@
@mkdir -p $(dir $@)
@$(CXX) -c $(CXXFLAGS) $(INC_FLAGS) $< -o $@
debug:
@$(MAKE) -j$(NPROC) $(NAME_DEBUG)
$(NAME_DEBUG): $(OBJS)
@echo Linking $@
@$(CXX) $(CXXFLAGS) $(INC_FLAGS) $(OBJS) $(LDFLAGS) -D STD -o $(NAME_DEBUG)
$(BUILD_DIR)/%.cpp.o: %.cpp
@echo Compiling $@
@mkdir -p $(dir $@)
@$(CXX) -c $(CXXFLAGS) $(INC_FLAGS) $< -o $@
clean:
@rm -rf $(BUILD_DIR)
@echo Clean done
fclean:
@rm -rf $(BUILD_DIR)
@rm -f $(NAME)
@echo Fclean done
re: fclean
@$(MAKE)
.PHONY: all clean fclean re