Joey Armstrong | a689034 | 2023-06-01 17:07:51 -0400 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | 78fca2d | 2024-05-01 16:51:58 -0400 | [diff] [blame] | 3 | # Copyright 2022-2024 Open Networking Foundation Contributors |
Joey Armstrong | a689034 | 2023-06-01 17:07:51 -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 | 78fca2d | 2024-05-01 16:51:58 -0400 | [diff] [blame] | 16 | # ----------------------------------------------------------------------- |
| 17 | # SPDX-FileCopyrightText: 2022-2024 Open Networking Foundation Contributors |
Joey Armstrong | a689034 | 2023-06-01 17:07:51 -0400 | [diff] [blame] | 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ----------------------------------------------------------------------- |
Joey Armstrong | 78fca2d | 2024-05-01 16:51:58 -0400 | [diff] [blame] | 20 | # Intent: This makefile will gather available sources from a filesystem |
| 21 | # then enable targets and functionality based on extensions. |
| 22 | # ----------------------------------------------------------------------- |
Joey Armstrong | a689034 | 2023-06-01 17:07:51 -0400 | [diff] [blame] | 23 | |
| 24 | $(if $(DEBUG),$(warning ENTER)) |
| 25 | |
Joey Armstrong | 78fca2d | 2024-05-01 16:51:58 -0400 | [diff] [blame] | 26 | ##-------------------## |
| 27 | ##---] GLOBALS [---## |
| 28 | ##-------------------## |
| 29 | |
| 30 | ##--------------------## |
| 31 | ##---] INCLUDES [---## |
| 32 | ##--------------------## |
| 33 | |
Joey Armstrong | a689034 | 2023-06-01 17:07:51 -0400 | [diff] [blame] | 34 | # usage: $(call if-not,false,5) |
| 35 | if-not = $(info 1=$(1), 2=$(2), 3=$(3))\ |
| 36 | $(if $(1),$(null),$(2)) |
| 37 | |
Joey Armstrong | a3f9aca | 2024-02-11 11:58:11 -0500 | [diff] [blame] | 38 | ## ----------------------------------------------------------------------- |
| 39 | ## Intent: Derive a filesystem path relative to the active makefile. |
| 40 | ## Primary use is loading adjacent tool config files. |
| 41 | ## Immediate evaluation (:=) needed to preserve path context. |
| 42 | ## Note: We could pass in var=MAKEFILE_LIST |
| 43 | ## ----------------------------------------------------------------------- |
| 44 | ## Given: |
| 45 | ## scalar Filename to construct a path for |
| 46 | ## Return: |
| 47 | ## scalar Constructed path for the given filename |
| 48 | ## ----------------------------------------------------------------------- |
| 49 | ## Usage: |
| 50 | ## groovy-check-conf := $(call path-by-makefile,.groovylintrc.json) |
| 51 | ## groovy-cmd = npm-groovy-lint --config "$(groovy-check-conf)" |
| 52 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 7ebfb1f | 2024-02-29 12:24:08 -0500 | [diff] [blame] | 53 | path-by-makefilepath-by-makefile = $(strip \ |
Joey Armstrong | a3f9aca | 2024-02-11 11:58:11 -0500 | [diff] [blame] | 54 | $(foreach filename,$(1),\ |
| 55 | $(foreach makefile,$(lastword $(MAKEFILE_LIST)),\ |
Joey Armstrong | 7ebfb1f | 2024-02-29 12:24:08 -0500 | [diff] [blame] | 56 | $(foreach makedir,$(dir $(makefile)),\ |
| 57 | $(makedir)$(filename)\ |
Joey Armstrong | a3f9aca | 2024-02-11 11:58:11 -0500 | [diff] [blame] | 58 | )\ |
| 59 | ))\ |
| 60 | ) |
| 61 | |
Joey Armstrong | 7ebfb1f | 2024-02-29 12:24:08 -0500 | [diff] [blame] | 62 | ## ----------------------------------------------------------------------- |
| 63 | ## Intent: Improve function usability for path-by-makefilepath-by-makefile |
| 64 | ## ----------------------------------------------------------------------- |
| 65 | ## Given: |
| 66 | ## scalar A makefile variable name to define |
| 67 | ## scalar Path within a makefile subdirectory to construct |
| 68 | ## Return: |
| 69 | ## scalar Constructed path for the given filename |
| 70 | ## ----------------------------------------------------------------------- |
| 71 | ## Usage: |
| 72 | ## $(call genpath-makefiles,tox-ini,tox.ini) |
| 73 | ## $(info tox-ini = $(tox-ini)) |
| 74 | ## ----------------------------------------------------------------------- |
| 75 | genpath-makefiles = $(strip \ |
| 76 | \ |
| 77 | $(foreach var,$(1),\ |
| 78 | $(foreach fyl,$(2),\ |
Joey Armstrong | 7ebfb1f | 2024-02-29 12:24:08 -0500 | [diff] [blame] | 79 | $(eval $(var) := $(call path-by-makefilepath-by-makefile,$(fyl)))\ |
| 80 | ))\ |
| 81 | $(var)\ |
| 82 | ) |
| 83 | |
Joey Armstrong | a689034 | 2023-06-01 17:07:51 -0400 | [diff] [blame] | 84 | $(if $(DEBUG),$(warning LEAVE)) |
| 85 | |
| 86 | # [EOF] |