Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
| 3 | # Copyright 2023 Open Networking Foundation (ONF) and the ONF 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 Open Networking Foundation (ONF) and the ONF Contributors |
| 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ----------------------------------------------------------------------- |
| 20 | # https://gerrit.opencord.org/plugins/gitiles/onf-make |
| 21 | # ONF.makefile.version = 1.0 |
| 22 | # ----------------------------------------------------------------------- |
| 23 | # Setup: |
| 24 | # 1) Makefile |
| 25 | # include config.mk |
| 26 | # include makefiles/include.mk |
| 27 | # 2) cd makefiles |
| 28 | # 23 copy makefiles_include_mk.ex into $repo/makefiles/include.mk |
| 29 | # 4) make create-onf-lib |
| 30 | # ----------------------------------------------------------------------- |
| 31 | |
| 32 | $(if $(DEBUG),$(warning ENTER)) |
| 33 | |
| 34 | ## ----------------------------------------------------------------------- |
| 35 | ## Define vars based on relative import (normalize symlinks) |
| 36 | ## Usage: include makefiles/onf/include.mk |
| 37 | ## ----------------------------------------------------------------------- |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame^] | 38 | onf-mk-abs := $(abspath $(lastword $(MAKEFILE_LIST))) |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 39 | onf-mk-top := $(subst /include.mk,$(null),$(onf-mk-abs)) |
| 40 | onf-mk-lib := $(onf-mk-top)/onf-lib/makefiles |
| 41 | onf-mk-loc := $(onf-mk-top)/local |
| 42 | |
| 43 | TOP ?= $(patsubst %/makefiles/include.mk,%,$(onf-mk-abs)) |
| 44 | |
| 45 | ## ------------------------------------------------------ |
| 46 | ## Two distinct vars needed to access library or project |
| 47 | ## ------------------------------------------------------ |
| 48 | ONF_MAKEDIR ?= $(onf-mk-lib) |
| 49 | MAKEDIR ?= $(onf-mk-loc) |
| 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 | ## ----------------------------------------------------------------------- |
| 56 | include $(onf-mk-lib)/include.mk |
| 57 | include $(onf-mk-loc)/include.mk |
| 58 | |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame^] | 59 | ## ----------------------------------------------------------------------- |
| 60 | ## Intent: Helper targets for maintaining git-submodules (repo:onf-make) |
| 61 | ## ----------------------------------------------------------------------- |
| 62 | |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 63 | ## ----------------------------------------- |
| 64 | ## Submodue init target for new repositories |
| 65 | ## ----------------------------------------- |
| 66 | create-onf-lib : $(onf-mk-lib) |
| 67 | $(onf-mk-lib): |
| 68 | mkdir -p $(dir $@)# makefiles |
| 69 | cd $(dir $@) \ |
| 70 | && git submodule https://github.com/opencord/onf-make.git onf-lib |
| 71 | |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame^] | 72 | ## ----------------------------------------------------------------------- |
| 73 | ## Intent: This target will update dependent git-submodule to the latest |
| 74 | ## version available from the remote repository. Subsequently |
| 75 | ## a checkin will be needed to make the submodule update permanent. |
| 76 | ## ----------------------------------------------------------------------- |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 77 | update-submodules: |
| 78 | git submodule foreach git pull |
| 79 | |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame^] | 80 | ## ----------------------------------------------------------------------- |
| 81 | ## Intent: On-demand cloning of git submodule(s). |
| 82 | ## ----------------------------------------------------------------------- |
| 83 | ## Trigger: include $(onf-mk-lib)/include.mk |
| 84 | ## - When the make command attempts to include a makefile from the |
| 85 | ## repo:onf-make submodule, this target/dependency will initialize |
| 86 | ## and checkout all submodules the current repository depends on. |
| 87 | ## ----------------------------------------------------------------------- |
| 88 | $(onf-mk-lib)/include.mk: |
| 89 | @echo |
| 90 | @echo "** Checkout git submodule(s)" |
| 91 | @echo "** -----------------------------------------------------------------------" |
| 92 | git submodule update --init --recursive |
| 93 | @echo "** -----------------------------------------------------------------------" |
| 94 | |
Joey Armstrong | f548adc | 2023-09-08 15:59:42 -0400 | [diff] [blame] | 95 | $(if $(DEBUG),$(warning LEAVE)) |
| 96 | |
| 97 | # [EOF] |