forked from vigor-nf/vigor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
97 lines (83 loc) · 3.38 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
# Skeleton Makefile for Vigor NFs
# This file dispatches the build process to the other Makefiles
#
# Variables that should be defined by inheriting Makefiles:
# - NF_AUTOGEN_SRCS := <NF files that are inputs to auto-generation>
# - NF_FILES := <NF files for both runtime and verif-time,
# automatically includes state and autogenerated files,
# and shared NF files>
# - NF_LAYER := <network stack layer at which the NF operates, default 2>
# - NF_BENCH_NEEDS_REVERSE_TRAFFIC := <whether the NF needs reverse traffic
# for meaningful benchmarks, default false>
# - NF_PROCESS_NAME := <process name to kill after a benchmark is done>
# Variables that can be passed when running:
# - NF_DPDK_ARGS - will be passed as DPDK part of the arguments
# See Makefile for the rest of the variables
SELF_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
NF_DIR := $(shell if [ '$(notdir $(shell pwd))' = 'build' ]; \
then echo '..'; \
else echo '.'; fi)
# Check that the NF doesn't use clock_gettime directly,
# which would violate Vigor's expectations
# note: 'nf.c' is there for invocations of `make verifast`
# outside of any nf directory, which is perfectly valid.
# otherwise grep with empty argument list will wait on stdin
ifeq (true,$(shell if grep -q clock_gettime \
$(SELF_DIR)/nf.c \
$(addprefix $(NF_DIR)/,$(NF_FILES)); \
then echo 'true'; \
fi))
$(error Please use the vigor_time header instead of clock_gettime)
endif
# Default values for arguments
NF_LAYER ?= 2
NF_BENCH_NEEDS_REVERSE_TRAFFIC ?= false
NF_FILES += $(subst .h,.h.gen.c,$(NF_AUTOGEN_SRCS))
# Add state.c to the NF files,
# but only if it will be generated (so that we can compile stateless NFs)
ifneq (,$(wildcard $(NF_DIR)/dataspec.ml))
NF_FILES += state.c
endif
# Define this for the dpdk and nfos makefiles
# Strip spaces in case NF_DPDK_ARGS is not used
NF_ARGS := $(strip --no-shconf --no-telemetry $(NF_DPDK_ARGS) -- $(NF_ARGS))
ifeq (click,$(findstring click,$(shell pwd)))
# Click baselines
include $(SELF_DIR)/Makefile.click
else ifeq (nfos-,$(findstring nfos-,$(MAKECMDGOALS)))
# NFOS-related targets
include $(SELF_DIR)/Makefile.nfos
else ifeq (,$(findstring moonpol,$(abspath $(NF_DIR))))
# DPDK-based NFs
include $(SELF_DIR)/Makefile.dpdk
endif
# =======
# Autogen
# =======
# note that DPDK's weird makefiles call this twice,
# once in the proper dir and once in build/, we only care about the former
autogen:
@if [ '$(NF_DIR)' == '.' ]; then \
if [ -e dataspec.ml ]; then \
cp dataspec.ml fspec_gen.ml ; \
fi; \
$(SELF_DIR)/codegen/generate.sh $(NF_AUTOGEN_SRCS); \
if [ -e dataspec.ml ]; then \
$(SELF_DIR)/codegen/gen-loop-boilerplate.sh fspec_gen.ml; \
fi; \
fi
# ============
# Benchmarking
# ============
benchmark-%:
@export VIGOR_USE_BATCH=$(VIGOR_USE_BATCH); cd "$(SELF_DIR)/bench"; \
./bench.sh "$(shell pwd)" $(subst benchmark-,,$@) || true
@mv ../bench/[email protected] . || true
@printf '\n\nDone! Results are in [email protected], log file in [email protected]\n\n'
# bench scripts use these to autodetect the NF type
_print-layer:
@echo $(NF_LAYER)
_print-needsreverse:
@echo $(NF_BENCH_NEEDS_REVERSE_TRAFFIC)
_print-processname:
@echo $(NF_PROCESS_NAME)