blob: de7093ab8e27279b1366b6b0b3aef984b31b9b81 [file] [log] [blame]
Joey Armstrong695ba5c2023-01-20 11:17:49 -05001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrong6f63edf2024-01-12 11:30:08 -05003# Copyright 2016-2024 Open Networking Foundation (ONF) and the ONF Contributors
Matt Jeanneretc7b437c2019-05-13 12:33:08 -04004#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
Joey Armstrong695ba5c2023-01-20 11:17:49 -050016# -----------------------------------------------------------------------
17
18.PHONY: help
19.DEFAULT_GOAL := help
20
Joey Armstrong695ba5c2023-01-20 11:17:49 -050021##--------------------##
22##---] INCLUDES [---##
23##--------------------##
Joey Armstrong99a72d02023-06-09 10:26:42 -040024include config.mk
25include makefiles/include.mk
Joey Armstrong695ba5c2023-01-20 11:17:49 -050026
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040027# Variables
28VERSION ?= $(shell cat ./VERSION)
29
30## Docker related
31DOCKER_REGISTRY ?=
32DOCKER_REPOSITORY ?=
33DOCKER_BUILD_ARGS ?=
34DOCKER_TAG ?= ${VERSION}
35ONOS_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-onos:${DOCKER_TAG}
36
37## Docker labels. Only set ref and commit date if committed
38DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040039DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
Matt Jeanneret805f76e2019-05-16 16:18:26 -040040DOCKER_LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD)
41
42ifeq ($(shell git ls-files --others --modified --exclude-standard 2>/dev/null | wc -l | sed -e 's/ //g'),0)
43 DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD)
44else
45 DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD)+dirty
46endif
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040047
48.PHONY: docker-build
49
Matteo Scandoloc209e802021-06-07 16:59:30 +020050# For each makefile target, add ## <description> on the target line and it will be listed by 'make help'
Joey Armstrong695ba5c2023-01-20 11:17:49 -050051help :: ## Print help for each Makefile target
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040052 @echo
Joey Armstrong695ba5c2023-01-20 11:17:49 -050053 @grep --no-filename '^[[:alpha:]_-]*:.* ##' $(MAKEFILE_LIST) \
54 | sort \
55 | awk 'BEGIN {FS=":.* ## "}; {printf " %-25s : %s\n", $$1, $$2};'
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040056
57## Docker targets
58
Joey Armstrong7c3a1e02023-07-01 16:21:24 -040059## -----------------------------------------------------------------------
60## -----------------------------------------------------------------------
Matteo Scandoloc209e802021-06-07 16:59:30 +020061build: docker-build ## alias for "docker-build"
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040062
Joey Armstrong7c3a1e02023-07-01 16:21:24 -040063## -----------------------------------------------------------------------
64## -----------------------------------------------------------------------
Matteo Scandoloc209e802021-06-07 16:59:30 +020065local-onosapps: ## if LOCAL_ONOSAPPS=true runs the get-local-oars.sh
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040066 mkdir -p local_imports/oar
67ifdef LOCAL_ONOSAPPS
Joey Armstrong4048c1f2022-12-17 22:24:42 -050068 $(RM) -r local_imports/oar
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040069 ./get-local-oars.sh
70endif
71
Joey Armstrong7c3a1e02023-07-01 16:21:24 -040072## -----------------------------------------------------------------------
73## Intent: build docker image
74## use DOCKER_REGISTRY, DOCKER_REPOSITORY and DOCKER_TAG to customize
75## -----------------------------------------------------------------------
76docker-build: local-onosapps ## build docker image
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040077 docker build $(DOCKER_BUILD_ARGS) \
78 -t ${ONOS_IMAGENAME} \
79 --build-arg LOCAL_ONOSAPPS=$(LOCAL_ONOSAPPS) \
80 --build-arg org_label_schema_version="${VERSION}" \
81 --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
82 --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
83 --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
84 --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \
85 -f Dockerfile.voltha-onos .
86
Joey Armstrong7c3a1e02023-07-01 16:21:24 -040087## -----------------------------------------------------------------------
88## -----------------------------------------------------------------------
Matteo Scandoloc209e802021-06-07 16:59:30 +020089test: ## verify that if the version is released we're not pointing to SNAPSHOT apps
90 bash tests/version-check.sh
91
92docker-push: ## push to docker registy: use DOCKER_REGISTRY, DOCKER_REPOSITORY and DOCKER_TAG to customize
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040093 docker push ${ONOS_IMAGENAME}
94
Joey Armstrong99a72d02023-06-09 10:26:42 -040095clean :: ## clean the build environment
Joey Armstrong4048c1f2022-12-17 22:24:42 -050096 $(RM) -r local_imports
Matt Jeanneretc7b437c2019-05-13 12:33:08 -040097
98# end file