[VOL-5285] - JJB Upgrade toward v5

makefiles/include.mk
--------------------
  o Define new lib var sandbox-root= pointing at the build directory.
  o Added a comment section at the bottom to document declared vars.

makefiles/virtualenv/requirements-txt.mk
----------------------------------------
  o Rework pip -r requirements.txt logic to be dependency driven.
  o pip install will be run when requirements.txt is modified.

makefiles/virtualenv/include.mk
-------------------------------
  o Populate venv-abs-path= with sandbox-root= to insulate against
    $(PWD) path changes.
  o Split logic into separate makefiles so include.mk remains small.
  o Rework dependencies to leverage the new requirements-txt.mk logic.

Misc
----
  o Rework help help-* targets to not display everything, all the time.
  o make help      : display venv (primary target).
  o make venv-help : display exteneded help, venv targets and flags.

[HOWTO: test]
  % git clone onf-make
  % cd onf-make
  % touch requirements.txt

  % make help | grep venv
  % make venv-help

  % make venv
  % make venv-requirements

  % touch requirements.txt
  % make venv-requirements

Change-Id: I9e12bc45c73a0e2bc90b1fd11c87ccffc7ebe57a
diff --git a/makefiles/include.mk b/makefiles/include.mk
index 1bea64e..e9021ba 100644
--- a/makefiles/include.mk
+++ b/makefiles/include.mk
@@ -29,6 +29,9 @@
 ## -----------------------------------------------------------------------
 ## [LOADER] Define path vars based on library include directory
 ## -----------------------------------------------------------------------
+sandbox-root := $(dir $(abspath $(firstword $(MAKEFILE_LIST))))
+sandbox-root := $(patsubst %/,%,$(sandbox-root))
+
 $(foreach makefile,$(lastword $(MAKEFILE_LIST)),\
   $(foreach makedir,$(abspath $(dir $(makefile))),\
     $(eval include $(makedir)/library-makefiles.mk)\
@@ -90,4 +93,15 @@
 
 $(if $(DEBUG),$(warning LEAVE))
 
+## -----------------------------------------------------------------------
+## [VARS]
+##   sandbox-root     Path to top level directory containing [mM]akefile
+##
+##   onf-mk-top       Path to makefiles/ containing onf-make/ and local/
+##   onf-mk-tmp       Limited scratch area for repo:onf-make use
+##
+## [DEPRECATE]
+##   ONF_MAKEDIR      Replace with onf-mk-top/ {onf-mk}
+##   MAKEDIR          Replace with onf-mk-top/ {local}
+## -----------------------------------------------------------------------
 # [EOF]
diff --git a/makefiles/utils/include.mk b/makefiles/utils/include.mk
index e3e9ae0..7668bba 100644
--- a/makefiles/utils/include.mk
+++ b/makefiles/utils/include.mk
@@ -65,8 +65,6 @@
 \
   $(foreach var,$(1),\
   $(foreach fyl,$(2),\
-    $(if true$(DEBUG),\
-      $(info $$(eval $(var) := $$(call path-by-makefilepath-by-makefile,$(fyl)))))\
     $(eval $(var) := $(call path-by-makefilepath-by-makefile,$(fyl)))\
 	))\
     $(var)\
diff --git a/makefiles/virtualenv/include.mk b/makefiles/virtualenv/include.mk
index 2ce04d2..8e85e1f 100644
--- a/makefiles/virtualenv/include.mk
+++ b/makefiles/virtualenv/include.mk
@@ -14,7 +14,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 # -----------------------------------------------------------------------
-# -----------------------------------------------------------------------
 # Intent:
 #   This makefile defines dependencies that will install a python virtualenv
 #   beneath $(sandbox)/.venv/.  The $(activate) macro is used to source
@@ -51,12 +50,19 @@
 ##---]  LOCALS  [---##
 ##------------------##
 venv-name            ?= .venv#                            # default install directory
-venv-abs-path        := $(PWD)/$(venv-name)#              #
+venv-abs-path        := $(sandbox-root)/$(venv-name)#     # Install directory
 venv-activate-bin    := $(venv-name)/bin#                 # no whitespace
 venv-activate-script := $(venv-activate-bin)/activate#    # dependency
 
+##--------------------##
+##---]  INCLUDES  [---##
+##--------------------##
+include $(ONF_MAKEDIR)/virtualenv/requirements-txt.mk
+include $(ONF_MAKEDIR)/virtualenv/version.mk
+
 # ------------------------------------------------------------------------
 # Intent: Define macro activate= to access virtualenv activation script.
+## -----------------------------------------------------------------------
 #  Usage:
 #    - $(activate) && python             # Syntax inlined within a target
 #    - PYTHON := $(activate) && python   # Define a named command macro
@@ -64,24 +70,33 @@
 activate             ?= set +u && source $(venv-activate-script) && set -u
 
 ## -----------------------------------------------------------------------
+## Intent: Explicit named installer target w/o dependencies.
+##         Makefile targets should depend on venv-activate-script.
+## -----------------------------------------------------------------------
+venv := $(null)
+venv += $(venv-activate-script)#        # virtualenv -p python3
+venv += $(venv-requirements-txt)#       # pip install -r requirements.txt
+venv: $(venv)
+
+venv-patched : $(venv-activate-patched)
+
+## -----------------------------------------------------------------------
 ## Intent: Activate script path dependency
 ## Usage:
 ##    o place on the right side of colon as a target dependency
 ##    o When the script does not exist install the virtual env and display.
 ## -----------------------------------------------------------------------
 $(venv-activate-script):
-	@echo
-	@echo '============================='
-	@echo 'Installing python virtual env'
-	@echo '============================='
+
+	$(call banner-enter,(virtualenv -p python))
+
 	virtualenv -p python3 $(venv-name)
 	$(activate) && python -m pip install --upgrade pip
 	$(activate) && pip install --upgrade setuptools
-	$(activate) && [[ -r requirements.txt ]] \
-	    && { python -m pip install -r requirements.txt; } \
-	    || { /bin/true; }
 
-	$(activate) && python --version
+	$(HIDE)$(MAKE) --no-print-directory venv-requirements venv-version
+
+	$(call banner-leave,(virtualenv -t python))
 
 ## -----------------------------------------------------------------------
 ## Intent: Explicit named installer target w/o dependencies.
@@ -99,8 +114,7 @@
 ## Intent: Explicit named installer target w/o dependencies.
 ##         Makefile targets should depend on venv-activate-script.
 ## -----------------------------------------------------------------------
-venv         : $(venv-activate-script)
-venv-patched : $(venv-activate-patched)
+# venv         : $(venv-activate-script)
 
 ## -----------------------------------------------------------------------
 ## Intent: Revert installation to a clean checkout
@@ -111,13 +125,29 @@
 ## -----------------------------------------------------------------------
 ## -----------------------------------------------------------------------
 help ::
+	@printf '  %-33.33s %s\n' 'venv'         \
+	  'Create a python virtual environment'
+	@printf '  %-33.33s %s\n' 'venv-help'    \
+	  'Extended target help'
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+venv-help ::
+	@printf '  %-33.33s %s\n' 'venv-patched' \
+	  'venv patched for v3.10.6+ use'
+
+	@printf '  %-33.33s %s\n' 'venv' \
+	  'Create a python virtual environment'
+	@printf '  %-33.33s %s\n' '  venv-name' \
+	  'virtualenv installation directory name'
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+todo ::
+	@echo "Rename include.mk into virtualenv.mk"
+	@echo "Create include.mk as a simple primary include file for the directory"
 	@echo
-	@echo '[VIRTUAL ENV]'
-	@echo '  venv                Create a python virtual environment'
-	@echo '    venv-name=        Subdir name for virtualenv install'
-	@echo '  venv-activate-script         make macro name'
-	@echo '      $$(target) dependency    install python virtualenv'
-	@echo '      source $$(macro) && cmd  configure env and run cmd'
+	@echo "Extract venv patch logic into a separate makefile'
 
 $(if $(DEBUG),$(warning LEAVE))
 
diff --git a/makefiles/virtualenv/requirements-txt.mk b/makefiles/virtualenv/requirements-txt.mk
new file mode 100644
index 0000000..c524449
--- /dev/null
+++ b/makefiles/virtualenv/requirements-txt.mk
@@ -0,0 +1,59 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2024 Open Networking Foundation Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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.
+# -----------------------------------------------------------------------
+# SPDX-FileCopyrightText: 2024 Open Networking Foundation Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+## Intent: pip install with dependencies
+## ----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---]  GLOBALS  [---##
+##-------------------##
+venv-requirements := $(venv-abs-path)/makedep/requirements.txt.ts
+
+## -----------------------------------------------------------------------
+## Intent: Define a makefile target able to install venv python modules
+##   when changes are made within the requirements.txt file.
+## -----------------------------------------------------------------------
+## [MAKEFILE TARGETS]
+## venv-requirements
+##   Named target used to abstract underlying dependency filename.
+## $(venv-requirements-txt)
+##   Make macro used to detect changes in requirements.txt file.
+##   Timestamp filename is also the primary target for invoking pip install.
+## -----------------------------------------------------------------------
+.PHONY: venv-requirements
+venv-requirements    : $(venv-requirements)
+$(venv-requirements) : requirements.txt
+
+	$(call banner-enter,venv-requirements)
+
+	$(activate) && python -m pip install -r 'requirements.txt'
+	@mkdir -p $(dir $@)
+	@touch $@
+
+	$(call banner-leave,venv-requirements)
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+venv-help ::
+	@printf '  %-33.33s %s\n' 'venv-requirements' \
+	  'pip install -r requirements.txt (dependency driven)'
+
+# [EOF]
diff --git a/makefiles/virtualenv/version.mk b/makefiles/virtualenv/version.mk
new file mode 100644
index 0000000..e2f3af6
--- /dev/null
+++ b/makefiles/virtualenv/version.mk
@@ -0,0 +1,40 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2024 Open Networking Foundation Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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.
+# -----------------------------------------------------------------------
+# SPDX-FileCopyrightText: 2024 Open Networking Foundation Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---]  GLOBALS  [---##
+##-------------------##
+
+## ----------------------------------------------------------------------
+## Intent: Display installed python interpreter version
+## ----------------------------------------------------------------------
+.PHONY: venv-version
+venv-version :
+	$(activate) && python --version
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+venv-help ::
+	@printf '  %-33.33s %s\n' 'venv-version' \
+	  'Display installed python interpreter version'
+
+# [EOF]
diff --git a/makefiles/virtualenv/virtualenv.mk b/makefiles/virtualenv/virtualenv.mk
new file mode 100644
index 0000000..0667f68
--- /dev/null
+++ b/makefiles/virtualenv/virtualenv.mk
@@ -0,0 +1,138 @@
+# -*- makefile -*-
+## -----------------------------------------------------------------------
+# Copyright 2017-2024 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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.2
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---]  GLOBALS  [---##
+##-------------------##
+.PHONY: venv
+
+##------------------##
+##---]  LOCALS  [---##
+##------------------##
+venv-name             ?= .venv#                            # default install directory
+venv-abs-path         := $(PWD)/$(venv-name)
+venv-activate-bin     := $(venv-name)/bin
+venv-activate-script  := $(venv-activate-bin)/activate#    # dependency
+
+# Intent: activate= is a macro for accessing the virtualenv activation script#
+#  Usage: $(activate) && python
+activate             ?= set +u && source $(venv-activate-script) && set -u
+
+venv-version      : venv-requirements
+venv-requirements : venv-install
+venv-install      : $(venv-activate-script)
+
+## -----------------------------------------------------------------------
+## Intent: Activate script path dependency
+## Usage:
+##    o place on the right side of colon as a target dependency
+##    o When the script does not exist install the virtual env and display.
+## -----------------------------------------------------------------------
+$(venv-activate-script) :
+
+	$(call banner-enter,(virtualenv -p python))
+	virtualenv -p python3 $(venv-name)
+	$(activate) && python -m pip install --upgrade pip
+	$(activate) && pip install --upgrade setuptools
+
+	@$(MAKE) --no-print-directory venv-requirements venv-version
+	$(call banner-leave,(virtualenv -t python))
+
+## ----------------------------------------------------------------------
+## Intent: pip install with dependencies
+## ----------------------------------------------------------------------
+# venv-requirements-txt    := .venv/makedep/requirements.txt.ts
+# venv-requirements        : $(venv-requirements-txt)
+# venv-install             : $(venv-activate-script)
+# venv-requirements        : venv-install
+
+$(venv-requirements-txt) : requirements.txt
+
+	$(activate) && python -m pip install -r requirements.txt
+	@mkdir -p $(dir $@)
+	@touch $@
+
+## ----------------------------------------------------------------------
+## ----------------------------------------------------------------------
+venv-version :
+	$(activate) && python --version
+
+## -----------------------------------------------------------------------
+## Intent: Activate script path dependency
+## Usage:
+##    o place on the right side of colon as a target dependency
+##    o When the script does not exist install the virtual env and display.
+## ----------------------------------------------------------------------
+$(venv-activate-script)-orig :
+	@echo
+	@echo "============================="
+	@echo "Installing python virtual env"
+	@echo "============================="
+	virtualenv -p python3 $(venv-name)
+	$(activate) && python -m pip install --upgrade pip
+	$(activate) && pip install --upgrade setuptools
+	$(activate) && [[ -r requirements.txt ]] \
+	    && { python -m pip install -r requirements.txt; } \
+	    || { /bin/true; }
+
+	$(activate) && python --version
+
+## -----------------------------------------------------------------------
+## Intent: Explicit named installer target w/o dependencies.
+##         Makefile targets should depend on venv-activate-script.
+## -----------------------------------------------------------------------
+venv-activate-patched := $(venv-activate-script).patched
+venv-activate-patched : $(venv-activate-patched)
+$(venv-activate-patched) : $(venv-activate-script)
+	$(call banner-enter,Target $@)
+	$(onf-mk-top)/../patches/python_310_migration.sh --venv "$(venv-name)" 'apply'
+	touch $@
+	$(call banner-leave,Target $@)
+
+## -----------------------------------------------------------------------
+## Intent: Explicit named installer target w/o dependencies.
+##         Makefile targets should depend on venv-activate-script.
+## -----------------------------------------------------------------------
+venv += $(venv-activate-script)
+venv += $(venv-requirements-txt)
+venv: $(venv)
+
+## -----------------------------------------------------------------------
+## Intent: Revert installation to a clean checkout
+## -----------------------------------------------------------------------
+sterile :: clean
+	$(RM) -r "$(venv-abs-path)"
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+help ::
+	@echo
+	@echo '[VIRTUAL ENV]'
+	@echo '  venv                Create a python virtual environment'
+	@echo '    venv-name=        Subdir name for virtualenv install'
+	@echo '  venv-activate-script         make macro name'
+	@echo '      $$(target) dependency    install python virtualenv'
+	@echo '      source $$(macro) && cmd  configure env and run cmd'
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]