Support distinct project and library makefile includes.
Makefile
makefiles/include.mk
makefiles/lint/include.mk
makefiles/python/include.mk
---------------------------
O Library makefiles only require an include directory var.
o Project makefiles require two vars, one for derived paths (TOP=).
o Infer library makefile path from the included makefile.
o Maintain MAKEDIR= and ONF_MAKEDIR= so caller can selectively
include what they want to use.
Change-Id: Id1a6d76a278edc130729dd641688c9e5793e90f4
diff --git a/Makefile b/Makefile
index c2b40ed..d397fb9 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,6 @@
# limitations under the License.
# -----------------------------------------------------------------------
-# Makefile for testing JJB jobs in a virtualenv
.PHONY: help clean help test
.DEFAULT_GOAL := help
@@ -25,6 +24,9 @@
TOP ?= .
MAKEDIR ?= $(TOP)/makefiles
+# ONF_MAKEDIR ?= $(HOME)/repo/onf-make/makefiles
+# include $(ONF_MAKEDIR)/include.mk
+
##--------------------##
##---] INCLUDES [---##
##--------------------##
@@ -32,6 +34,6 @@
include $(MAKEDIR)/include.mk # top level include
## Display make help text late
-include $(ONF_MAKE)/help/trailer.mk
+include $(ONF_MAKEDIR)/help/trailer.mk
# [EOF]
diff --git a/makefiles/include.mk b/makefiles/include.mk
index 806020a..2e4af37 100644
--- a/makefiles/include.mk
+++ b/makefiles/include.mk
@@ -14,48 +14,50 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# SPDX-FileCopyrightText: 2022 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-FileCopyrightText: 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
# SPDX-License-Identifier: Apache-2.0
# -----------------------------------------------------------------------
+# https://gerrit.opencord.org/plugins/gitiles/onf-make
+# ONF.makefile.version = 1.0
+# -----------------------------------------------------------------------
-ifndef mk-include--onf-make
+ifndef mk-include--onf-make # single-include guard macor
$(if $(DEBUG),$(warning ENTER))
-TOP ?= .
-MAKEDIR ?= $(TOP)/makefiles
+## -----------------------------------------------------------------------
+## Define vars based on relative import (normalize symlinks)
+## Usage: include makefiles/onf/include.mk
+## -----------------------------------------------------------------------
+onf-mk-abs ?= $(abspath $(lastword $(MAKEFILE_LIST)))
+onf-mk-top := $(subst /include.mk,$(null),$(onf-mk-abs))
+ONF_MAKEDIR := $(onf-mk-top)
-ONF_ROOT ?= $(TOP)/../onf-make/makefiles
-ONF_MAKEDIR ?= $(ONF_ROOT)/makefiles
+include $(ONF_MAKEDIR)/consts.mk
+include $(ONF_MAKEDIR)/help/include.mk # render target help
+include $(ONF_MAKEDIR)/utils/include.mk # dependency-less helper macros
+include $(ONF_MAKEDIR)/etc/include.mk # banner macros
-ONF_MAKE ?= $(MAKEDIR)# fix this -- two distinct makefiles/ directories are needed
-ONF_MAKE ?= $(error ONF_MAKE= is required)
+include $(ONF_MAKEDIR)/virtualenv.mk# # lint-{jjb,python} depends on venv
+include $(ONF_MAKEDIR)/lint/include.mk
+# include $(ONF_MAKEDIR)/git-submodules.mk
+# include $(ONF_MAKEDIR)/gerrit/include.mk
-include $(ONF_MAKE)/consts.mk
-include $(ONF_MAKE)/help/include.mk # render target help
-include $(ONF_MAKE)/utils/include.mk # dependency-less helper macros
-include $(ONF_MAKE)/etc/include.mk # banner macros
-
-include $(ONF_MAKE)/virtualenv.mk# # lint-{jjb,python} depends on venv
-include $(ONF_MAKE)/lint/include.mk
-# include $(ONF_MAKE)/git-submodules.mk
-# include $(ONF_MAKE)/gerrit/include.mk
-
-include $(ONF_MAKE)/todo.mk
-include $(ONF_MAKE)/help/variables.mk
+include $(ONF_MAKEDIR)/todo.mk
+include $(ONF_MAKEDIR)/help/variables.mk
##---------------------##
##---] ON_DEMAND [---##
##---------------------##
-$(if $(USE_DOCKER_MK),$(eval $(ONF_MAKE)/docker/include.mk))
+$(if $(USE_DOCKER_MK),$(eval $(ONF_MAKEDIR)/docker/include.mk))
##-------------------##
##---] TARGETS [---##
##-------------------##
-include $(ONF_MAKE)/targets/clean.mk
-# include $(ONF_MAKE)/targets/check.mk
-include $(ONF_MAKE)/targets/sterile.mk
-# include $(ONF_MAKE)/targets/test.mk
+include $(ONF_MAKEDIR)/targets/clean.mk
+# include $(ONF_MAKEDIR)/targets/check.mk
+include $(ONF_MAKEDIR)/targets/sterile.mk
+# include $(ONF_MAKEDIR)/targets/test.mk
$(if $(DEBUG),$(warning LEAVE))
diff --git a/makefiles/lint/include.mk b/makefiles/lint/include.mk
index f011e31..95059fe 100644
--- a/makefiles/lint/include.mk
+++ b/makefiles/lint/include.mk
@@ -2,6 +2,9 @@
# -----------------------------------------------------------------------
# Copyright 2022 Open Networking Foundation (ONF) and the ONF Contributors
# -----------------------------------------------------------------------
+# https://gerrit.opencord.org/plugins/gitiles/onf-make
+# ONF.makefile.version = 1.1
+# -----------------------------------------------------------------------
$(if $(DEBUG),$(warning ENTER))
@@ -9,16 +12,16 @@
@echo
@echo "[LINT]"
-include $(ONF_MAKE)/lint/groovy.mk
-include $(ONF_MAKE)/lint/jjb.mk
-include $(ONF_MAKE)/lint/json.mk
-include $(ONF_MAKE)/lint/license/include.mk
-include $(ONF_MAKE)/lint/makefile.mk
-include $(ONF_MAKE)/lint/python.mk
-include $(ONF_MAKE)/lint/shell.mk
-include $(ONF_MAKE)/lint/yaml.mk
+include $(ONF_MAKEDIR)/lint/groovy.mk
+include $(ONF_MAKEDIR)/lint/jjb.mk
+include $(ONF_MAKEDIR)/lint/json.mk
+include $(ONF_MAKEDIR)/lint/license/include.mk
+include $(ONF_MAKEDIR)/lint/makefile.mk
+include $(ONF_MAKEDIR)/lint/python.mk
+include $(ONF_MAKEDIR)/lint/shell.mk
+include $(ONF_MAKEDIR)/lint/yaml.mk
-include $(ONF_MAKE)/lint/help.mk
+include $(ONF_MAKEDIR)/lint/help.mk
$(if $(DEBUG),$(warning LEAVE))
diff --git a/makefiles/python/include.mk b/makefiles/python/include.mk
index 24f3426..70b5ca1 100644
--- a/makefiles/python/include.mk
+++ b/makefiles/python/include.mk
@@ -19,9 +19,9 @@
# -----------------------------------------------------------------------
ifdef PYTHON_FILES
- include $(ONF_MAKE)/python/test/include.mk
+ include $(ONF_MAKEDIR)/python/test/include.mk
else
- include $(ONF_MAKE)/python/test/include.mk
+ include $(ONF_MAKEDIR)/python/test/include.mk
endif
# [EOF]
diff --git a/makefiles/virtualenv.mk b/makefiles/virtualenv.mk
index 93eb29d..c6904da 100644
--- a/makefiles/virtualenv.mk
+++ b/makefiles/virtualenv.mk
@@ -13,7 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-## -----------------------------------------------------------------------
+# -----------------------------------------------------------------------
# https://gerrit.opencord.org/plugins/gitiles/onf-make
# ONF.makefile.version = 1.0
# -----------------------------------------------------------------------