blob: 7cb0f933a810c822cea626704947d83783a0634c [file] [log] [blame]
Carmelo Cascone97efefb2019-12-05 16:40:45 -08001PROFILES ?= all
2ONOS_HOST ?= localhost
3
4mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
5curr_dir := $(patsubst %/,%,$(dir $(mkfile_path)))
6curr_dir_sha := $(shell echo -n "$(curr_dir)" | shasum | cut -c1-7)
7
8mvn_image := maven:3.6.1-jdk-11-slim
9mvn_container := mvn-build-${curr_dir_sha}
10
11onos_url := http://${ONOS_HOST}:8181/onos
12onos_curl := curl --fail -sSL --user onos:rocks --noproxy localhost
13
14pipeconf_app_name := org.opencord.fabric-tofino
Carmelo Cascone97efefb2019-12-05 16:40:45 -080015
Carmelo Cascone91d92fb2019-12-16 18:34:26 -080016p4-build := ./src/main/p4/build.sh
Carmelo Cascone97efefb2019-12-05 16:40:45 -080017
18.PHONY: pipeconf
19
Carmelo Cascone21e72a22019-12-18 10:01:08 -080020build: clean $(PROFILES) pipeconf p4-changelog
Carmelo Cascone97efefb2019-12-05 16:40:45 -080021
22all: fabric fabric-bng fabric-spgw fabric-int fabric-spgw-int
23
24fabric:
Carmelo Cascone91d92fb2019-12-16 18:34:26 -080025 @${p4-build} fabric ""
Carmelo Cascone97efefb2019-12-05 16:40:45 -080026
27fabric-simple:
Carmelo Cascone91d92fb2019-12-16 18:34:26 -080028 @${p4-build} fabric-simple "-DWITH_SIMPLE_NEXT"
Carmelo Cascone97efefb2019-12-05 16:40:45 -080029
30fabric-bng:
Daniele Moro8de7a8d2020-01-30 17:05:37 -080031 @${p4-build} fabric-bng "-DWITH_BNG -DWITHOUT_XCONNECT"
Carmelo Cascone97efefb2019-12-05 16:40:45 -080032
33fabric-int:
Carmelo Cascone91d92fb2019-12-16 18:34:26 -080034 @${p4-build} fabric-int "-DWITH_INT_SOURCE -DWITH_INT_TRANSIT"
Carmelo Cascone97efefb2019-12-05 16:40:45 -080035
36fabric-spgw:
Carmelo Cascone91d92fb2019-12-16 18:34:26 -080037 @${p4-build} fabric-spgw "-DWITH_SPGW"
Carmelo Cascone97efefb2019-12-05 16:40:45 -080038
39fabric-spgw-int:
Carmelo Cascone91d92fb2019-12-16 18:34:26 -080040 @${p4-build} fabric-spgw-int "-DWITH_SPGW -DWITH_INT_SOURCE -DWITH_INT_TRANSIT"
Carmelo Cascone97efefb2019-12-05 16:40:45 -080041
Carmelo Cascone21e72a22019-12-18 10:01:08 -080042p4-changelog:
43 ./src/main/p4/gen_changelog.sh > P4_CHANGELOG
44
Carmelo Cascone97efefb2019-12-05 16:40:45 -080045# Reuse the same container to persist mvn repo cache.
46_create_mvn_container:
47 @if ! docker container ls -a --format '{{.Names}}' | grep -q ${mvn_container} ; then \
48 docker create -v ${curr_dir}:/mvn-src -w /mvn-src --name ${mvn_container} ${mvn_image} mvn clean package verify; \
49 fi
50
51_mvn_package:
52 $(info *** Building ONOS app...)
53 @mkdir -p target
54 @docker start -a -i ${mvn_container}
55
56pipeconf: _create_mvn_container _mvn_package
57 $(info *** ONOS pipeconf .oar package created succesfully)
58 @ls -1 ${curr_dir}/target/*.oar
59
60pipeconf-install:
61 $(info *** Installing and activating pipeconf app in ONOS at ${ONOS_HOST}...)
62 ${onos_curl} -X POST -HContent-Type:application/octet-stream \
63 '${onos_url}/v1/applications?activate=true' \
Carmelo Cascone21e72a22019-12-18 10:01:08 -080064 --data-binary @target/fabric-tofino-*.oar
Carmelo Cascone97efefb2019-12-05 16:40:45 -080065 @echo
66
67pipeconf-uninstall:
68 $(info *** Uninstalling pipeconf app from ONOS (if present) at ${ONOS_HOST}...)
69 -${onos_curl} -X DELETE ${onos_url}/v1/applications/${pipeconf_app_name}
70 @echo
71
72netcfg:
73 $(info *** Pushing tofino-netcfg.json to ONOS at ${ONOS_HOST}...)
74 ${onos_curl} -X POST -H 'Content-Type:application/json' \
75 ${onos_url}/v1/network/configuration -d@./tofino-netcfg.json
76 @echo
77
78clean:
79 -rm -rf src/main/resources/p4c-out
80
81deep-clean: clean
82 -rm -rf target
83 -rm -rf p4c-out
84 -docker rm ${mvn_container} > /dev/null 2>&1