-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
93 lines (75 loc) · 3.09 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
#
# Top Makefile
# ============
#
# This is the top-level makefile of the project
#
SUBMODULE =
PYTHON_EXEC ?= python3
ifeq ($(origin CMAKE_COMMAND),undefined)
CMAKE_COMMAND := cmake
else
CMAKE_COMMAND := ${CMAKE_COMMAND}
endif
ifeq ($(CPU_CORES),)
CPU_CORES := $(shell nproc)
ifeq ($(CPU_CORES),)
CPU_CORES := $(shell sysctl -n hw.physicalcpu)
endif
ifeq ($(CPU_CORES),)
CPU_CORES := 2 # Good minimum assumption
endif
endif
.SILENT:
# Put it first so that "make" without argument is like "make help".
export COMMENT_EXTRACT
# Put it first so that "make" without argument is like "make help".
help:
@${PYTHON_EXEC} -c "$$COMMENT_EXTRACT"
.PHONY: all checkout compile
release: run-cmake-release
cmake --build build -j $(CPU_CORES)
release_no_tcmalloc: run-cmake-release_no_tcmalloc
cmake --build build -j $(CPU_CORES)
debug: run-cmake-debug
cmake --build dbuild -j $(CPU_CORES)
run-cmake-release:
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DCMAKE_RULE_MESSAGES=$(RULE_MESSAGES) -DPRODUCTION_BUILD=$(PRODUCTION_BUILD) $(ADDITIONAL_CMAKE_OPTIONS) -S . -B build
run-cmake-release_no_tcmalloc:
cmake -DNO_TCMALLOC=On -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DCMAKE_RULE_MESSAGES=$(RULE_MESSAGES) $(ADDITIONAL_CMAKE_OPTIONS) -S . -B build
run-cmake-debug:
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DCMAKE_RULE_MESSAGES=$(RULE_MESSAGES) -DPRODUCTION_BUILD=$(PRODUCTION_BUILD) -DNO_TCMALLOC=On $(ADDITIONAL_CMAKE_OPTIONS) -S . -B dbuild
run-cmake-coverage:
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DCMAKE_RULE_MESSAGES=$(RULE_MESSAGES) -DMY_CXX_WARNING_FLAGS="--coverage" $(ADDITIONAL_CMAKE_OPTIONS) -S . -B coverage-build
clean:
$(RM) -r build dbuild coverage-build dist tests/TestInstall/build
checkout:
# This command will checkout all the submodules when no other options are provided
# Available variables
#
# - SUBMODULE: Specify the submodule to checkout. For example, SUBMODULE=OpenFPGA
@echo "Backend make checkout: pulling submodules"
git submodule update --init Raptor_Tools OpenFPGA vpr_latest
@echo " submodule init/update in OpenFPGA"
cd OpenFPGA && git submodule update --init
@echo " submodule init/update in OpenFPGA/vtr-verilog-to-routing"
cd OpenFPGA/vtr-verilog-to-routing && git submodule update --init
@echo " submodule init/update in Raptor_Tools"
cd Raptor_Tools && git submodule update --init --recursive
@echo " submodule init/update in vpr_latest/vtr"
cd vpr_latest/vtr && git submodule update --init --recursive
compile:
# This command will compile the codebase
mkdir -p build && cd build && $(CMAKE_COMMAND) ${CMAKE_FLAGS} ..
cd build && $(MAKE)
all: checkout compile
# This is a shortcut command to checkout all the submodules and compile the codebase
# Functions to extract comments from Makefiles
define COMMENT_EXTRACT
import re
with open ('Makefile', 'r' ) as f:
matches = re.finditer('^([a-zA-Z-_]*):.*\n#(.*)', f.read(), flags=re.M)
for _, match in enumerate(matches, start=1):
header, content = match[1], match[2]
print(f" {header:10} {content}")
endef