-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
140 lines (96 loc) · 3.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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
##
## EPITECH PROJECT, 2018
## Makefile
## File description:
## makefile of the source file
##
ROOT = .
SUBDIRS_COMP := $(wildcard components/*/.)
INSTALL_PATH := /usr/share/nanotekspice
SRC_DIR = sources
CXX = g++
NAME = nanotekspice
BUILD = $(ROOT)/build
SRC = $(SRC_DIR)/main.cpp \
$(SRC_DIR)/Application.cpp \
$(SRC_DIR)/AbstractComponent.cpp \
$(SRC_DIR)/PluginLoader.cpp \
$(SRC_DIR)/Utils.cpp \
$(SRC_DIR)/Exception.cpp \
$(SRC_DIR)/Tristate.cpp \
$(SRC_DIR)/ComponentFactory.cpp \
$(SRC_DIR)/Simulation.cpp \
$(SRC_DIR)/Parser.cpp
CXXFLAGS = -g -I $(ROOT)/includes $(WARN) -std=gnu++17 -export-dynamic -Wall -Wextra
LDFLAGS = -ldl -lstdc++fs -export-dynamic
LIB ?= 1
TEST ?= 0
DEB ?= 0
G = -g -D DEBUG
V ?= @
OBJS = $(patsubst $(SRC_DIR)/%.cpp, $(BUILD)/%.o, $(SRC))
#COLOR
GREEN = \e[1;32m
WHITE = \e[0m
ORANGE = \e[1;33m
RED = \e[1;35m
BLUE = \e[1;34m
debug: CXXFLAGS += $(G)
release: CXXFLAGS += -D INSTALL_PATH="$(INSTALL_PATH)"
##
## Directives
##
all: $(NAME) comps
$(NAME): $(OBJS)
$(V)printf "$(GREEN)Compile sources.$(WHITE)\n"
$(V)$(CXX) -o $(NAME) $(OBJS) $(LDFLAGS)
$(V)printf "$(GREEN)Linking obj and Libraries.$(WHITE)\n"
debug: echo_d $(NAME) comps
release: fclean echo_r $(NAME)
$(BUILD)/$(NAME): $(OBJS)
$(V)printf "$(GREEN)Compile sources.$(WHITE)\n"
$(V)$(CXX) -o $(BUILD)/$(NAME) $(OBJS) $(LDFLAGS)
$(V)printf "$(GREEN)Linking obj and Libraries.$(WHITE)\n"
$(BUILD)/%.o: $(SRC_DIR)/%.cpp
$(V)mkdir -p $(dir $@)
$(V)printf "$(BLUE)Compiling [$(GREEN)$(notdir $<)$(BLUE) -> $(RED)$(notdir $@)$(BLUE)]\n$(WHITE)"
$(V)$(CXX) -o $@ -c $< $(CXXFLAGS) $(LDFLAGS)
clean:
$(V)for dir in $(SUBDIRS_COMP); do \
make --no-print-directory -C $$dir clean; \
done
$(V)rm -rf $(OBJS)
$(V)printf "$(ORANGE)Removing object files.$(WHITE)\n"
fclean: clean
$(V)for dir in $(SUBDIRS_COMP); do \
make --no-print-directory -C $$dir fclean; \
done
$(V)python3 component_generator fclean
$(V)rm -f $(BUILD)/$(NAME)
$(V)rm -f $(ROOT)/$(NAME)
$(V)printf "$(ORANGE)Removing binary file.$(WHITE)\n"
re: fclean
$(V)make --no-print-directory all
echo_build:
$(V)printf "$(GREEN)Begin of the build !\n$(ORANGE)Warnings : \n$(WHITE)"
echo_d:
$(V)printf "$(RED)DEBUG MODE initialized.$(WHITE)\n";
echo_r:
$(V)printf "$(RED)RELEASE MODE initialized.$(WHITE)\n";
comps:
$(V)python3 component_generator
$(V)printf "$(GREEN)Generation components...\n$(WHITE)"
$(V)make --no-print-directory -C . components
components: $(SUBDIRS_COMP)
$(SUBDIRS_COMP):
$(V)printf "$(BLUE)Building $@\n$(WHITE)"
$(V)make --no-print-directory -C $@
install: release plugins displayers
$(V)printf "$(GREEN)Installing on the system at $(INSTALL_PATH)\n$(WHITE)"
$(V)mkdir -p $(INSTALL_PATH)
$(V)cp -r resources $(INSTALL_PATH)
$(V)mkdir -p $(INSTALL_PATH)/components
$(V)cp components/*.so $(INSTALL_PATH)/components
$(V)cp $(NAME) /usr/bin/$(NAME)
$(V)printf "$(GREEN)Done installing at $(INSTALL_PATH)\n$(WHITE)"
.PHONY: clean fclean debug all re echo_debug buildrepo $(SUBDIRS_COMP) components install comps