blob: 0fda66a93eaedd4cad67bbbd20f8ca39073882aa [file] [log] [blame]
Joey Armstrong56fdfec2024-03-01 13:43:36 -05001# -*- makefile -*-
2# -----------------------------------------------------------------------
3# Copyright 2023-2024 Open Networking Foundation Contributors
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.
16# -----------------------------------------------------------------------
17# SPDX-FileCopyrightText: 2023-2024 Open Networking Foundation Contributors
18# SPDX-License-Identifier: Apache-2.0
19# -----------------------------------------------------------------------
20
21$(if $(DEBUG),$(warning ENTER))
22
23## -----------------------------------------------------------------------
24## Infer path to cloned sandbox root
25## [TODO] Deprecate TOP=
26## -----------------------------------------------------------------------
27lf-sbx-root := $(abspath $(lastword $(MAKEFILE_LIST)))
28lf-sbx-root := $(subst /lf/include.mk,$(null),$(lf-sbx-root))
29
30## -----------------------------------------------------------------------
31## Define vars based on relative import (normalize symlinks)
32## Usage: include makefiles/onf/include.mk
33## -----------------------------------------------------------------------
34onf-mk-abs := $(abspath $(lastword $(MAKEFILE_LIST)))
35onf-mk-top := $(subst /include.mk,$(null),$(onf-mk-abs))
36onf-mk-lib := $(onf-mk-top)/onf-make/makefiles
37onf-mk-loc := $(onf-mk-top)/local
38
39TOP ?= $(patsubst %/makefiles/include.mk,%,$(onf-mk-abs))
40
41## ------------------------------------------------------
42## Two distinct vars needed to access library or project
43## ------------------------------------------------------
44ONF_MAKEDIR ?= $(onf-mk-lib)
45MAKEDIR ?= $(onf-mk-loc)
46
47# Load per-repository conditionals
48# Load late else alter MAKEFILE_LIST
49include $(lf-sbx-root)/lf/config.mk
50
51## -----------------------------------------------------------------------
52## Load makefiles in order:
53## 1) Library constants and logic loaded first
54## 2) Parameterize and augment targets from local (repo specific)
55## -----------------------------------------------------------------------
56include $(onf-mk-lib)/include.mk
57include $(onf-mk-loc)/include.mk
58
59## -----------------------------------------------------------------------
60## Intent: This target will update dependent git-submodule to the latest
61## version available from the remote repository. Subsequently
62## a checkin will be needed to make the submodule update permanent.
63## -----------------------------------------------------------------------
Joey Armstronge7110872024-03-22 14:23:34 -040064.PHONY: update-git-submodules
65update-git-submodules:
Joey Armstrong56fdfec2024-03-01 13:43:36 -050066 git submodule foreach git pull
67
68## -----------------------------------------------------------------------
69## Intent: On-demand cloning of git submodule(s).
70## -----------------------------------------------------------------------
71## Trigger: include $(onf-mk-lib)/include.mk
72## - When the make command attempts to include a makefile from the
73## repo:onf-make submodule, this target/dependency will initialize
74## and checkout all submodules the current repository depends on.
75## -----------------------------------------------------------------------
Joey Armstrong8a765ba2024-03-27 10:27:29 -040076GIT ?= $(shell which git)
Joey Armstronge7110872024-03-22 14:23:34 -040077.PHONY: git-submodules
78git-submodules : $(onf-mk-lib)/include.mk
79
Joey Armstrong56fdfec2024-03-01 13:43:36 -050080$(onf-mk-lib)/include.mk:
Joey Armstronge7110872024-03-22 14:23:34 -040081
82 $(call banner-enter,(Checkout git submodules))
83
Joey Armstrong8a765ba2024-03-27 10:27:29 -040084 $(GIT) submodule update --init --recursive
Joey Armstronge7110872024-03-22 14:23:34 -040085
86 $(call banner-leave,(Checkout git submodules))
87
88## -----------------------------------------------------------------------
89## -----------------------------------------------------------------------
90help-git :
91 @printf ' %-33.33s %s\n' 'git-submodules' \
92 'Init and recursive checkout of git submodule(s)'
93 @printf ' %-33.33s %s\n' 'update-git-submodules' \
94 'Update git submodule(s) to the latest version'
Joey Armstrong56fdfec2024-03-01 13:43:36 -050095
96$(if $(DEBUG),$(warning LEAVE))
97
98# [EOF]