Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
| 3 | # Copyright 2016-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 4 | # |
| 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 Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 16 | # ----------------------------------------------------------------------- |
| 17 | |
| 18 | .PHONY: help |
| 19 | .DEFAULT_GOAL := help |
| 20 | |
| 21 | TOP ?= . |
| 22 | MAKEDIR ?= $(TOP)/makefiles |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 23 | |
| 24 | # set default shell |
| 25 | SHELL = bash -e -o pipefail |
| 26 | |
Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 27 | ##--------------------## |
| 28 | ##---] INCLUDES [---## |
| 29 | ##--------------------## |
| 30 | include $(MAKEDIR)/include.mk |
| 31 | |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 32 | # Variables |
| 33 | VERSION ?= $(shell cat ./VERSION) |
| 34 | |
| 35 | ## Docker related |
| 36 | DOCKER_REGISTRY ?= |
| 37 | DOCKER_REPOSITORY ?= |
| 38 | DOCKER_BUILD_ARGS ?= |
| 39 | DOCKER_TAG ?= ${VERSION} |
| 40 | ONOS_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-onos:${DOCKER_TAG} |
| 41 | |
| 42 | ## Docker labels. Only set ref and commit date if committed |
| 43 | DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 44 | DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") |
Matt Jeanneret | 805f76e | 2019-05-16 16:18:26 -0400 | [diff] [blame] | 45 | DOCKER_LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD) |
| 46 | |
| 47 | ifeq ($(shell git ls-files --others --modified --exclude-standard 2>/dev/null | wc -l | sed -e 's/ //g'),0) |
| 48 | DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD) |
| 49 | else |
| 50 | DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD)+dirty |
| 51 | endif |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 52 | |
| 53 | .PHONY: docker-build |
| 54 | |
Matteo Scandolo | c209e80 | 2021-06-07 16:59:30 +0200 | [diff] [blame] | 55 | # For each makefile target, add ## <description> on the target line and it will be listed by 'make help' |
Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 56 | help :: ## Print help for each Makefile target |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 57 | @echo |
Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 58 | @grep --no-filename '^[[:alpha:]_-]*:.* ##' $(MAKEFILE_LIST) \ |
| 59 | | sort \ |
| 60 | | awk 'BEGIN {FS=":.* ## "}; {printf " %-25s : %s\n", $$1, $$2};' |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 61 | |
| 62 | ## Docker targets |
| 63 | |
Matteo Scandolo | c209e80 | 2021-06-07 16:59:30 +0200 | [diff] [blame] | 64 | build: docker-build ## alias for "docker-build" |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 65 | |
Matteo Scandolo | c209e80 | 2021-06-07 16:59:30 +0200 | [diff] [blame] | 66 | local-onosapps: ## if LOCAL_ONOSAPPS=true runs the get-local-oars.sh |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 67 | mkdir -p local_imports/oar |
| 68 | ifdef LOCAL_ONOSAPPS |
Joey Armstrong | 4048c1f | 2022-12-17 22:24:42 -0500 | [diff] [blame] | 69 | $(RM) -r local_imports/oar |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 70 | ./get-local-oars.sh |
| 71 | endif |
| 72 | |
Matteo Scandolo | c209e80 | 2021-06-07 16:59:30 +0200 | [diff] [blame] | 73 | docker-build: local-onosapps ## build docker image: use DOCKER_REGISTRY, DOCKER_REPOSITORY and DOCKER_TAG to customize |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 74 | docker build $(DOCKER_BUILD_ARGS) \ |
| 75 | -t ${ONOS_IMAGENAME} \ |
| 76 | --build-arg LOCAL_ONOSAPPS=$(LOCAL_ONOSAPPS) \ |
| 77 | --build-arg org_label_schema_version="${VERSION}" \ |
| 78 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 79 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 80 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 81 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 82 | -f Dockerfile.voltha-onos . |
| 83 | |
Matteo Scandolo | c209e80 | 2021-06-07 16:59:30 +0200 | [diff] [blame] | 84 | test: ## verify that if the version is released we're not pointing to SNAPSHOT apps |
| 85 | bash tests/version-check.sh |
| 86 | |
| 87 | docker-push: ## push to docker registy: use DOCKER_REGISTRY, DOCKER_REPOSITORY and DOCKER_TAG to customize |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 88 | docker push ${ONOS_IMAGENAME} |
| 89 | |
Matteo Scandolo | c209e80 | 2021-06-07 16:59:30 +0200 | [diff] [blame] | 90 | clean: ## clean the build environment |
Joey Armstrong | 4048c1f | 2022-12-17 22:24:42 -0500 | [diff] [blame] | 91 | $(RM) -r local_imports |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 92 | |
| 93 | # end file |