-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (59 loc) · 1.82 KB
/
Makefile
File metadata and controls
78 lines (59 loc) · 1.82 KB
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
NAME = main-service
WORK_DIR = $(shell pwd)
SRC_DIR = $(WORK_DIR)/src
BUILD_DIR = $(WORK_DIR)/build
INCLUDE_DIR = $(WORK_DIR)/include
LIB_DIR = $(WORK_DIR)/lib
DATABASE = -lnedb
PACKAGE = $(BUILD_DIR)/$(NAME)
# set stdc++ 17 and multi-threads
CXXFLAGS += -Wall -std=c++17 -pthread
LDFLAGS = -L$(LIB_DIR)
MODULES = $(filter-out src,$(notdir $(shell find $(SRC_DIR) -type d ) ) )
INCLUDES = $(addprefix -I ,$(INCLUDE_DIR))
OBJ_DIR = $(BUILD_DIR)/$(NAME)-obj
# modules optional loading
ifeq ($(MODS),)
SOURCES = $(shell find src -name "*.cpp")
else
SOURCES = $(shell find $(addprefix src/,$(MODS)) -name "*.cpp")
endif
# include shell colors definitions
-include scripts/colors.mk
# include variables and rules generated by Kconfig automatically
-include include/config/auto.conf
-include include/config/auto.conf.cmd
ifeq ($(wildcard .config),)
$(warning $(COLOR_RED)Warning: .config does not exists!$(COLOR_END))
$(warning $(COLOR_RED)To build the project, first run 'make menuconfig'$(COLOR_END))
endif
remove_quote = $(patsubst "%",%,$(1))
# re-configure default compilr
ifneq ($(CONFIG_CC),)
CXX = $(call remove_quote,$(CONFIG_CC))
endif
# compilr optimization level (default -o2)
ifneq ($(CONFIG_CC_OPT),)
CXXFLAGS += $(call remove_quote,$(CONFIG_CC_OPT))
endif
# debug mode , and C define "DEBUG" added
ifeq ($(CONFIG_CC_DEBUG),y)
CXXFLAGS += -DDEBUG -g
endif
# build project by origin Makefile
include scripts/build.mk
# import menuconfig makefile
include scripts/config.mk
.PHONY : clean .detect
# detect
.detect :
ifeq ($(CONFIG_CC_DEBUG),y)
@echo "$(C_YELLOW)Debug mode start up$(C_END)"
endif
@echo "$(C_BLUE)Module <$(MODULES)> has been detected...$(C_END)"
# word count
wc :
@find . "(" -name "*.hpp" -or -name "*.cpp" -or -name "*.h" ")" -print | xargs wc -l
# remove build dictionary
clean :
-rm -rf $(BUILD_DIR)