forked from microsoft/demikernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinux.mk
More file actions
216 lines (165 loc) · 7.99 KB
/
linux.mk
File metadata and controls
216 lines (165 loc) · 7.99 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
#=======================================================================================================================
# Default Paths
#=======================================================================================================================
export PREFIX ?= $(HOME)
export INSTALL_PREFIX ?= $(HOME)
export PKG_CONFIG_PATH ?= $(shell find $(PREFIX)/lib/ -name '*pkgconfig*' -type d 2> /dev/null | xargs | sed -e 's/\s/:/g')
export LD_LIBRARY_PATH ?= $(HOME)/lib:$(shell find $(PREFIX)/lib/ -name '*x86_64-linux-gnu*' -type d 2> /dev/null | xargs | sed -e 's/\s/:/g')
#=======================================================================================================================
# Build Configuration
#=======================================================================================================================
export BUILD := release
ifeq ($(DEBUG),yes)
export RUST_LOG ?= trace
export BUILD := dev
endif
#=======================================================================================================================
# Project Directories
#=======================================================================================================================
export BINDIR ?= $(CURDIR)/bin
export INCDIR ?= $(CURDIR)/include
export SRCDIR = $(CURDIR)/src
export BUILD_DIR := $(CURDIR)/target/release
ifeq ($(BUILD),dev)
export BUILD_DIR := $(CURDIR)/target/debug
endif
#=======================================================================================================================
# Toolchain Configuration
#=======================================================================================================================
# Rust
export CARGO ?= $(shell which cargo || echo "$(HOME)/.cargo/bin/cargo" )
export CARGO_FLAGS += --profile $(BUILD)
#=======================================================================================================================
# Libraries
#=======================================================================================================================
export DEMIKERNEL_LIB := $(BUILD_DIR)/libdemikernel.so
export LIBS := $(DEMIKERNEL_LIB)
#=======================================================================================================================
# Build Parameters
#=======================================================================================================================
export LIBOS ?= catnap
export CARGO_FEATURES := --features=$(LIBOS)-libos
# Switch for DPDK
ifeq ($(LIBOS),catnip)
DRIVER ?= $(shell [ ! -z "`lspci | grep -E "ConnectX-[4,5]"`" ] && echo mlx5 || echo mlx4)
CARGO_FEATURES += --features=$(DRIVER)
endif
# Switch for profiler.
export PROFILER=no
ifeq ($(PROFILER),yes)
CARGO_FEATURES += --features=profiler
endif
CARGO_FEATURES += $(FEATURES)
#=======================================================================================================================
all: all-libs all-tests all-examples
# Builds documentation.
doc:
$(CARGO) doc $(FLAGS) --no-deps
# Copies demikernel artifacts to a INSTALL_PREFIX directory.
install:
mkdir -p $(INSTALL_PREFIX)/include $(INSTALL_PREFIX)/lib
cp -rf $(INCDIR)/* $(INSTALL_PREFIX)/include/
cp -f $(DEMIKERNEL_LIB) $(INSTALL_PREFIX)/lib/
cp -f $(CURDIR)/scripts/config/default.yaml $(INSTALL_PREFIX)/config.yaml
#=======================================================================================================================
# Libs
#=======================================================================================================================
# Builds all libraries.
all-libs: all-libs-demikernel
all-libs-demikernel:
@echo "LD_LIBRARY_PATH: $(LD_LIBRARY_PATH)"
@echo "PKG_CONFIG_PATH: $(PKG_CONFIG_PATH)"
@echo "$(CARGO) build --libs $(CARGO_FEATURES) $(CARGO_FLAGS)"
$(CARGO) build --lib $(CARGO_FEATURES) $(CARGO_FLAGS)
clean-libs: clean-libs-demikernel
clean-libs-demikernel:
rm -rf target ; \
rm -f Cargo.lock ; \
$(CARGO) clean
#=======================================================================================================================
# Tests
#=======================================================================================================================
# Builds all tests.
all-tests: all-tests-rust all-tests-c
# Builds all Rust tests.
all-tests-rust: all-libs
@echo "$(CARGO) build --tests $(CARGO_FEATURES) $(CARGO_FLAGS)"
$(CARGO) build --tests $(CARGO_FEATURES) $(CARGO_FLAGS)
# Builds all C tests.
all-tests-c: all-libs
$(MAKE) -C tests all
# Cleans up all build artifactos for tests.
clean-tests: clean-tests-c
# Cleans up all C build artifacts for tests.
clean-tests-c:
$(MAKE) -C tests clean
#=======================================================================================================================
# Examples
#=======================================================================================================================
# Builds all examples.
all-examples: all-examples-c all-examples-rust
# Builds all C examples.
all-examples-c:
$(MAKE) -C examples/c all
# Builds all Rust examples.
all-examples-rust:
$(MAKE) -C examples/rust all
# Cleans all examples.
clean-examples: clean-examples-c clean-examples-rust
# Cleans all C examples.
clean-examples-c:
$(MAKE) -C examples/c clean
# Cleans all Rust examples.
clean-examples-rust:
$(MAKE) -C examples/rust clean
#=======================================================================================================================
# Check
#=======================================================================================================================
# Check code style formatting.
check-fmt: check-fmt-c check-fmt-rust
# Check code style formatting for C.
check-fmt-c:
$(shell find include/ -name "*.h" -name "*.hxx" -name "*.c" -name "*.cpp" -type f -print0 | xargs -0 clang-format --fallback-style=Microsoft --dry-run -Werror )
@exit $(.SHELLSTATUS)
# Check code style formatting for Rust.
check-fmt-rust:
$(CARGO) fmt --all -- --check
#=======================================================================================================================
# Clean
#=======================================================================================================================
# Cleans up all build artifacts.
clean: clean-examples clean-tests clean-libs
#=======================================================================================================================
export CONFIG_PATH ?= $(HOME)/config.yaml
export MTU ?= 1500
export MSS ?= 1500
export PEER ?= server
export TEST ?= udp-push-pop
export TEST_INTEGRATION ?= tcp-test
export TIMEOUT ?= 30
# Runs system tests.
test-system: test-system-rust
# Rust system tests.
test-system-rust:
timeout $(TIMEOUT) $(BINDIR)/examples/rust/$(TEST).elf $(ARGS)
# Runs unit tests.
test-unit: test-unit-rust
# C unit tests.
test-unit-c: $(BINDIR)/syscalls.elf
$(BINDIR)/syscalls.elf
# Rust unit tests.
test-unit-rust:
$(CARGO) test --lib $(CARGO_FLAGS) $(CARGO_FEATURES) -- --nocapture
$(CARGO) test --test udp $(CARGO_FLAGS) $(CARGO_FEATURES) -- --nocapture
$(CARGO) test --test tcp $(CARGO_FLAGS) $(CARGO_FEATURES) -- --nocapture
$(CARGO) test --test sga $(BUILD) $(CARGO_FEATURES) -- --nocapture --test-threads=1 test_unit_sga_alloc_free_single_small
$(CARGO) test --test sga $(BUILD) $(CARGO_FEATURES) -- --nocapture --test-threads=1 test_unit_sga_alloc_free_loop_tight_small
$(CARGO) test --test sga $(BUILD) $(CARGO_FEATURES) -- --nocapture --test-threads=1 test_unit_sga_alloc_free_loop_decoupled_small
$(CARGO) test --test sga $(BUILD) $(CARGO_FEATURES) -- --nocapture --test-threads=1 test_unit_sga_alloc_free_single_big
$(CARGO) test --test sga $(BUILD) $(CARGO_FEATURES) -- --nocapture --test-threads=1 test_unit_sga_alloc_free_loop_tight_big
$(CARGO) test --test sga $(BUILD) $(CARGO_FEATURES) -- --nocapture --test-threads=1 test_unit_sga_alloc_free_loop_decoupled_big
# Runs Rust integration tests.
test-integration-rust:
$(CARGO) test --test $(TEST_INTEGRATION) $(CARGO_FLAGS) $(CARGO_FEATURES) -- $(ARGS)