-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (35 loc) · 994 Bytes
/
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
BMV2_SWITCH_EXE = simple_switch_grpc
NO_P4 = true
P4C_ARGS = --p4runtime-file $(basename $@).p4info --p4runtime-format text
BUILD_DIR = build
PCAP_DIR = pcaps
LOG_DIR = logs
TOPO = topology.json
P4C = p4c-bm2-ss
RUN_SCRIPT = utils/ipv6_run_exercise.py
source := $(wildcard *.p4)
outfile := $(source:.p4=.json)
compiled_json := $(BUILD_DIR)/$(outfile)
# Define NO_P4 to start BMv2 without a program
ifndef NO_P4
run_args += -j $(compiled_json)
endif
# Set BMV2_SWITCH_EXE to override the BMv2 target
ifdef BMV2_SWITCH_EXE
run_args += -b $(BMV2_SWITCH_EXE)
endif
all: run
run: build
sudo python $(RUN_SCRIPT) -t $(TOPO) $(run_args)
stop:
sudo mn -c
build: dirs build/basic.json build/switch.json
build/basic.json: basic.p4
$(P4C) --p4v 16 $(P4C_ARGS) -o build/basic.json $<
build/switch.json: switch.p4
$(P4C) --p4v 16 $(P4C_ARGS) -o build/switch.json $<
dirs:
mkdir -p $(BUILD_DIR) $(PCAP_DIR) $(LOG_DIR)
clean: stop
rm -f *.pcap
rm -rf $(BUILD_DIR) $(PCAP_DIR) $(LOG_DIR)