Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | db844cd | 2024-08-23 15:23:44 -0400 | [diff] [blame] | 3 | # Copyright 2023-2024 Open Networking Foundation Contributors |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -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. |
| 16 | # |
Joey Armstrong | db844cd | 2024-08-23 15:23:44 -0400 | [diff] [blame] | 17 | # SPDX-FileCopyrightText: 2023 Open Networking Foundation Contributors |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ----------------------------------------------------------------------- |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 20 | # Setup: |
| 21 | # 1) Makefile |
| 22 | # include config.mk |
| 23 | # include makefiles/include.mk |
| 24 | # 2) cd makefiles |
| 25 | # 23 copy makefiles_include_mk.ex into $repo/makefiles/include.mk |
| 26 | # 4) make create-onf-lib |
| 27 | # ----------------------------------------------------------------------- |
| 28 | |
| 29 | $(if $(DEBUG),$(warning ENTER)) |
| 30 | |
| 31 | ## ----------------------------------------------------------------------- |
Joey Armstrong | db844cd | 2024-08-23 15:23:44 -0400 | [diff] [blame] | 32 | ## Infer path to cloned sandbox root |
| 33 | ## [TODO] Deprecate TOP= |
| 34 | ## ----------------------------------------------------------------------- |
| 35 | lf-sbx-root := $(abspath $(lastword $(MAKEFILE_LIST))) |
| 36 | lf-sbx-root := $(subst /lf/include.mk,$(null),$(lf-sbx-root)) |
| 37 | |
| 38 | ## ----------------------------------------------------------------------- |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 39 | ## Define vars based on relative import (normalize symlinks) |
| 40 | ## Usage: include makefiles/onf/include.mk |
| 41 | ## ----------------------------------------------------------------------- |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 42 | onf-mk-abs := $(abspath $(lastword $(MAKEFILE_LIST))) |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 43 | onf-mk-top := $(subst /include.mk,$(null),$(onf-mk-abs)) |
Joey Armstrong | db844cd | 2024-08-23 15:23:44 -0400 | [diff] [blame] | 44 | onf-mk-lib := $(onf-mk-top)/onf-make/makefiles |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 45 | onf-mk-loc := $(onf-mk-top)/local |
| 46 | |
| 47 | TOP ?= $(patsubst %/makefiles/include.mk,%,$(onf-mk-abs)) |
| 48 | |
Joey Armstrong | db844cd | 2024-08-23 15:23:44 -0400 | [diff] [blame] | 49 | ## ----------------------------------------------------------------------- |
| 50 | ## This variable is a bridge to help transition away from legacy makefiles. |
| 51 | ## ----------------------------------------------------------------------- |
| 52 | legacy-mk := $(lf-sbx-root)/makefiles |
| 53 | |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 54 | ## ------------------------------------------------------ |
| 55 | ## Two distinct vars needed to access library or project |
| 56 | ## ------------------------------------------------------ |
| 57 | ONF_MAKEDIR ?= $(onf-mk-lib) |
| 58 | MAKEDIR ?= $(onf-mk-loc) |
| 59 | |
Joey Armstrong | db844cd | 2024-08-23 15:23:44 -0400 | [diff] [blame] | 60 | # ----------------------------------------------------------------------- |
| 61 | # Load per-repository conditionals |
| 62 | # Load late else alter MAKEFILE_LIST |
| 63 | # NOTE: config.mk can be removed if dynamic feature detection by |
| 64 | # file extension is added. |
| 65 | # ----------------------------------------------------------------------- |
| 66 | include $(wildcard $(lf-sbx-root)/config.mk $(lf-sbx-root)/lf/config.mk) |
| 67 | |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 68 | ## ----------------------------------------------------------------------- |
| 69 | ## Load makefiles in order: |
| 70 | ## 1) Library constants and logic loaded first |
| 71 | ## 2) Parameterize and augment targets from local (repo specific) |
| 72 | ## ----------------------------------------------------------------------- |
| 73 | include $(onf-mk-lib)/include.mk |
| 74 | include $(onf-mk-loc)/include.mk |
| 75 | |
Joey Armstrong | db844cd | 2024-08-23 15:23:44 -0400 | [diff] [blame] | 76 | ## Define late so caller (?- env --ignore-environment -?) |
| 77 | GIT ?= /usr/bin/env git |
| 78 | |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 79 | ## ----------------------------------------------------------------------- |
| 80 | ## Intent: Helper targets for maintaining git-submodules (repo:onf-make) |
| 81 | ## ----------------------------------------------------------------------- |
| 82 | |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 83 | ## ----------------------------------------- |
| 84 | ## Submodue init target for new repositories |
| 85 | ## ----------------------------------------- |
| 86 | create-onf-lib : $(onf-mk-lib) |
| 87 | $(onf-mk-lib): |
| 88 | mkdir -p $(dir $@)# makefiles |
| 89 | cd $(dir $@) \ |
| 90 | && git submodule https://github.com/opencord/onf-make.git onf-lib |
| 91 | |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 92 | ## ----------------------------------------------------------------------- |
| 93 | ## Intent: This target will update dependent git-submodule to the latest |
| 94 | ## version available from the remote repository. Subsequently |
| 95 | ## a checkin will be needed to make the submodule update permanent. |
| 96 | ## ----------------------------------------------------------------------- |
Joey Armstrong | db844cd | 2024-08-23 15:23:44 -0400 | [diff] [blame] | 97 | .PHONY: update-git-submodules |
| 98 | update-git-submodules: |
| 99 | $(GIT) submodule foreach git pull |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 100 | |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 101 | ## ----------------------------------------------------------------------- |
| 102 | ## Intent: On-demand cloning of git submodule(s). |
| 103 | ## ----------------------------------------------------------------------- |
| 104 | ## Trigger: include $(onf-mk-lib)/include.mk |
| 105 | ## - When the make command attempts to include a makefile from the |
| 106 | ## repo:onf-make submodule, this target/dependency will initialize |
| 107 | ## and checkout all submodules the current repository depends on. |
| 108 | ## ----------------------------------------------------------------------- |
Joey Armstrong | db844cd | 2024-08-23 15:23:44 -0400 | [diff] [blame] | 109 | .PHONY: git-submodules |
| 110 | git-submodules : $(onf-mk-lib)/include.mk |
| 111 | |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 112 | $(onf-mk-lib)/include.mk: |
Joey Armstrong | db844cd | 2024-08-23 15:23:44 -0400 | [diff] [blame] | 113 | |
| 114 | $(call banner-enter,(Checkout git submodules)) |
| 115 | |
| 116 | $(GIT) submodule update --init --recursive |
| 117 | |
| 118 | $(call banner-leave,(Checkout git submodules)) |
| 119 | |
| 120 | ## ----------------------------------------------------------------------- |
| 121 | ## ----------------------------------------------------------------------- |
| 122 | help-git : |
| 123 | @printf ' %-33.33s %s\n' 'git-submodules' \ |
| 124 | 'Init and recursive checkout of git submodule(s)' |
| 125 | @printf ' %-33.33s %s\n' 'update-git-submodules' \ |
| 126 | 'Update git submodule(s) to the latest version' |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 127 | |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 128 | $(if $(DEBUG),$(warning LEAVE)) |
| 129 | |
| 130 | # [EOF] |