blob: 19a71754449e5105aeac7be812a7e089a6b67bfb [file] [log] [blame]
Carmelo Cascone97efefb2019-12-05 16:40:45 -08001PROFILES ?= all
2ONOS_HOST ?= localhost
Carmelo Cascone25b167f2020-07-15 22:06:41 -07003P4CFLAGS ?=
Carmelo Cascone97efefb2019-12-05 16:40:45 -08004
5mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
6curr_dir := $(patsubst %/,%,$(dir $(mkfile_path)))
7curr_dir_sha := $(shell echo -n "$(curr_dir)" | shasum | cut -c1-7)
8
9mvn_image := maven:3.6.1-jdk-11-slim
10mvn_container := mvn-build-${curr_dir_sha}
11
12onos_url := http://${ONOS_HOST}:8181/onos
13onos_curl := curl --fail -sSL --user onos:rocks --noproxy localhost
14
15pipeconf_app_name := org.opencord.fabric-tofino
Yi Tsengc3e2d4b2020-01-31 16:19:52 -080016pipeconf_oar_file := $(shell ls -1 ${curr_dir}/target/fabric-tofino-*.oar)
Carmelo Cascone97efefb2019-12-05 16:40:45 -080017
Carmelo Cascone91d92fb2019-12-16 18:34:26 -080018p4-build := ./src/main/p4/build.sh
Carmelo Cascone97efefb2019-12-05 16:40:45 -080019
20.PHONY: pipeconf
21
Carmelo Cascone21e72a22019-12-18 10:01:08 -080022build: clean $(PROFILES) pipeconf p4-changelog
Carmelo Cascone97efefb2019-12-05 16:40:45 -080023
24all: fabric fabric-bng fabric-spgw fabric-int fabric-spgw-int
25
26fabric:
Carmelo Cascone25b167f2020-07-15 22:06:41 -070027 @${p4-build} fabric $(P4CFLAGS)
Carmelo Cascone97efefb2019-12-05 16:40:45 -080028
29fabric-simple:
Carmelo Cascone25b167f2020-07-15 22:06:41 -070030 @${p4-build} fabric-simple -DWITH_SIMPLE_NEXT $(P4CFLAGS)
Carmelo Cascone97efefb2019-12-05 16:40:45 -080031
32fabric-bng:
Carmelo Cascone25b167f2020-07-15 22:06:41 -070033 @${p4-build} fabric-bng -DWITH_BNG -DWITHOUT_XCONNECT $(P4CFLAGS)
Carmelo Cascone97efefb2019-12-05 16:40:45 -080034
35fabric-int:
Carmelo Cascone25b167f2020-07-15 22:06:41 -070036 @${p4-build} fabric-int -DWITH_INT_SOURCE -DWITH_INT_TRANSIT $(P4CFLAGS)
Carmelo Cascone97efefb2019-12-05 16:40:45 -080037
38fabric-spgw:
Carmelo Cascone25b167f2020-07-15 22:06:41 -070039 @${p4-build} fabric-spgw -DWITH_SPGW $(P4CFLAGS)
Carmelo Cascone97efefb2019-12-05 16:40:45 -080040
41fabric-spgw-int:
Carmelo Cascone25b167f2020-07-15 22:06:41 -070042 @${p4-build} fabric-spgw-int -DWITH_SPGW -DWITH_INT_SOURCE -DWITH_INT_TRANSIT $(P4CFLAGS)
Carmelo Cascone97efefb2019-12-05 16:40:45 -080043
Carmelo Cascone21e72a22019-12-18 10:01:08 -080044p4-changelog:
45 ./src/main/p4/gen_changelog.sh > P4_CHANGELOG
46
Carmelo Cascone97efefb2019-12-05 16:40:45 -080047# Reuse the same container to persist mvn repo cache.
48_create_mvn_container:
49 @if ! docker container ls -a --format '{{.Names}}' | grep -q ${mvn_container} ; then \
50 docker create -v ${curr_dir}:/mvn-src -w /mvn-src --name ${mvn_container} ${mvn_image} mvn clean package verify; \
51 fi
52
53_mvn_package:
54 $(info *** Building ONOS app...)
55 @mkdir -p target
56 @docker start -a -i ${mvn_container}
57
58pipeconf: _create_mvn_container _mvn_package
59 $(info *** ONOS pipeconf .oar package created succesfully)
60 @ls -1 ${curr_dir}/target/*.oar
61
62pipeconf-install:
63 $(info *** Installing and activating pipeconf app in ONOS at ${ONOS_HOST}...)
64 ${onos_curl} -X POST -HContent-Type:application/octet-stream \
65 '${onos_url}/v1/applications?activate=true' \
Yi Tsengc3e2d4b2020-01-31 16:19:52 -080066 --data-binary @${pipeconf_oar_file}
Carmelo Cascone97efefb2019-12-05 16:40:45 -080067 @echo
68
69pipeconf-uninstall:
70 $(info *** Uninstalling pipeconf app from ONOS (if present) at ${ONOS_HOST}...)
71 -${onos_curl} -X DELETE ${onos_url}/v1/applications/${pipeconf_app_name}
72 @echo
73
74netcfg:
75 $(info *** Pushing tofino-netcfg.json to ONOS at ${ONOS_HOST}...)
76 ${onos_curl} -X POST -H 'Content-Type:application/json' \
77 ${onos_url}/v1/network/configuration -d@./tofino-netcfg.json
78 @echo
79
80clean:
81 -rm -rf src/main/resources/p4c-out
82
83deep-clean: clean
84 -rm -rf target
85 -rm -rf p4c-out
86 -docker rm ${mvn_container} > /dev/null 2>&1