forked from facebookincubator/nimble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
90 lines (71 loc) · 2.84 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
# Copyright (c) Meta Platforms, Inc. and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
.PHONY: all cmake build clean debug release unit submodules
BUILD_BASE_DIR=_build
BUILD_DIR=release
BUILD_TYPE=Release
CMAKE_FLAGS := -DCMAKE_BUILD_TYPE=$(BUILD_TYPE)
# Use Ninja if available. If Ninja is used, pass through parallelism control flags.
USE_NINJA ?= 1
ifeq ($(USE_NINJA), 1)
ifneq ($(shell which ninja), )
GENERATOR := -GNinja
# Ninja makes compilers disable colored output by default.
GENERATOR += -DVELOX_FORCE_COLORED_OUTPUT=ON
endif
endif
ifndef USE_CCACHE
ifneq ($(shell which ccache), )
USE_CCACHE=-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
endif
endif
NUM_THREADS ?= $(shell getconf _NPROCESSORS_CONF 2>/dev/null || echo 1)
CPU_TARGET ?= "avx"
all: release #: Build the release version
clean: #: Delete all build artifacts
rm -rf $(BUILD_BASE_DIR)
submodules:
git submodule sync --recursive
git submodule update --init --recursive
cmake: submodules #: Use CMake to create a Makefile build system
mkdir -p $(BUILD_BASE_DIR)/$(BUILD_DIR) && \
cmake -B \
"$(BUILD_BASE_DIR)/$(BUILD_DIR)" \
${CMAKE_FLAGS} \
$(GENERATOR) \
$(USE_CCACHE) \
${EXTRA_CMAKE_FLAGS}
build: #: Build the software based in BUILD_DIR and BUILD_TYPE variables
cmake --build $(BUILD_BASE_DIR)/$(BUILD_DIR) -j $(NUM_THREADS)
debug: #: Build with debugging symbols
$(MAKE) cmake BUILD_DIR=debug BUILD_TYPE=Debug
$(MAKE) build BUILD_DIR=debug -j ${NUM_THREADS}
release: #: Build the release version
$(MAKE) cmake BUILD_DIR=release BUILD_TYPE=Release && \
$(MAKE) build BUILD_DIR=release
unittest: debug #: Build with debugging and run unit tests
cd $(BUILD_BASE_DIR)/debug && ctest -j ${NUM_THREADS} -VV --output-on-failure
format-fix: #: Fix formatting issues in the main branch
scripts/format-check.py format main --fix
format-check: #: Check for formatting issues on the main branch
clang-format --version
scripts/format-check.py format main
header-fix: #: Fix license header issues in the current branch
scripts/format-check.py header main --fix
header-check: #: Check for license header issues on the main branch
scripts/format-check.py header main
help: #: Show the help messages
@cat $(firstword $(MAKEFILE_LIST)) | \
awk '/^[-a-z]+:/' | \
awk -F: '{ printf("%-20s %s\n", $$1, $$NF) }'