Edits to help support repo:onf-make as a git submodule.

transition.mk
-------------
  o Basic bridge logic for transition to repo:onf-make.
  o Include costs.mk and virtualenv targets.
  o Conditional include.mk logic to inline into Makefile
    appended at the end.

makefiles/detect
----------------
  o WIP
  o Add detection logic to enable makefile features based on extension.
  o Targets and logic can be loaded on demand based on available source.
    VS kitchen sink/load everything that happens now.

Signed-off-by: Joey Armstrong <jarmstrong@linuxfoundation.org>
Change-Id: I0d9af7bc15d7556ae7e15c5410b36189160c875d
diff --git a/Makefile b/Makefile
index b6cd637..4a7ca9f 100644
--- a/Makefile
+++ b/Makefile
@@ -30,6 +30,8 @@
 onf-mk-top    := $(dir $(onf-mk-abs))
 onf-mk-top    := $(patsubst %/,%,$(onf-mk-top))
 
+onf-mk-dir    := $(onf-mk-top)/makefiles
+
 ##-------------------##
 ##---]  GLOBALS  [---##
 ##-------------------##
@@ -39,7 +41,7 @@
 ##---]  INCLUDES  [---##
 ##--------------------##
 include config.mk
-include $(onf-mk-top)/makefiles/include.mk
+include $(onf-mk-dir)/include.mk
 
 ## -----------------------------------------------------------------------
 ## Intent: Helper target for interactive README.md viewing
diff --git a/makefiles/detect/detect.mk b/makefiles/detect/detect.mk
new file mode 100644
index 0000000..cc121c5
--- /dev/null
+++ b/makefiles/detect/detect.mk
@@ -0,0 +1,53 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-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: 2022-2024 Open Networking Foundation Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+# Intent: This makefile will gather sources from the filesystem and
+#         dynamically enable targets and functionality based on extension.
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---]  GLOBALS  [---##
+##-------------------##
+
+##--------------------##
+##---]  INCLUDES  [---##
+##--------------------##
+
+# -----------------------------------------------------------------------
+# {shell,find} are expensive for every makefile invocation.
+# wildcard is intended for recursive make calls.
+# Define USE_xxx := 1 when sources are nested within subdirs
+# .* => also glob hidden directories
+# -----------------------------------------------------------------------
+_raw_		    := $(wildcard * .* */*)
+_allfiles_	    := $(filter-out %~,$(_raw_))
+_hiddenfiles_	:= $(filter-out . ..,$(filter .%,$(_allfiles_)))
+
+# Enable functionality based on file detection
+$(call useEnable,GO)
+$(call useEnable,HTML)
+$(call useEnable,JAVA)
+$(call useEnable,PYTHON)
+$(call useEnable,RST)
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/detect/include.mk b/makefiles/detect/include.mk
new file mode 100644
index 0000000..16c723d
--- /dev/null
+++ b/makefiles/detect/include.mk
@@ -0,0 +1,37 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-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: 2022-2024 Open Networking Foundation Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+# Intent: This makefile will gather sources from the filesystem and
+#         dynamically enable targets and functionality based on extension.
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##--------------------##
+##---]  INCLUDES  [---##
+##--------------------##
+# include $(onf-mk-dir)/detect/macros.mk
+# include $(onf-mk-dir)/detect/src-by-ext.mk
+# include $(onf-mk-dir)/detect/detect.mk
+
+# $(error outa here)
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/detect/macros.mk b/makefiles/detect/macros.mk
new file mode 100644
index 0000000..52e8f53
--- /dev/null
+++ b/makefiles/detect/macros.mk
@@ -0,0 +1,80 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-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: 2022-2024 Open Networking Foundation Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+# Intent: This makefile will gather sources from the filesystem and
+#         dynamically enable targets and functionality based on extension.
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---]  GLOBALS  [---##
+##-------------------##
+
+##--------------------##
+##---]  INCLUDES  [---##
+##--------------------##
+
+##---------------------##
+##---]  FUNCTIONS  [---##
+##---------------------##
+
+# -----------------------------------------------------------------------
+# Intent: Given a source type determine if sources are available:
+# -----------------------------------------------------------------------
+# Given:
+#   scalar  One of {GO,PYTHON,RST} - patterns from detect/src-by-ext.mk
+# Return:
+#   array - a list of files matching pattern:
+#     TRUE  - when files match pattern
+#     FALSE - otherwise (NULL/empty list)
+# -----------------------------------------------------------------------
+# Usage:
+#   getfiles()       - Raise an execption when files are unavailable.
+#   getfiles_noerr() - Used for iteration, NOP when source unavailable.
+#
+#   $(call getfiles,GO)
+#   files := $(call getfiles,GO)
+#
+#   $(foreach src,$(call getfiles_noerr,PYTHON),$(info ** SOURCE: $(src)))
+# -----------------------------------------------------------------------
+getfiles_noerr = $(filter $($(1)_ext),$(_raw_))
+getfiles = $(or $(filter $($(1)_ext),$(_raw_)),\
+  $(error File by extension $(1)=[$($(1)_ext)] not found))
+
+# -----------------------------------------------------------------------
+# Intent: Conditionally invoke a make function when sources are available
+# -----------------------------------------------------------------------
+# Usage:
+#    $(call if_enabled_call,GO,$(shell $(MAKE) lint-golang))
+# -----------------------------------------------------------------------
+if_enabled_call = $(if $(USE_$(1)),$(call $(2)))
+
+# -----------------------------------------------------------------------
+# Intent: Define a named variable when sources are detected.
+#   - If source type 'GO'     define USE_GO=
+#   - If source type 'PYTHON' define USE_PYTHON=
+# -----------------------------------------------------------------------
+# Usage:
+#    $(call useEnable,GO)
+#    $(info ** Golang source detection: USE_GO=$(USE_GO))
+# -----------------------------------------------------------------------
+useEnable	    = $(if $(call getfiles_noerr,$(1))$(USE_$(1)),$(eval USE_$(1):=1))
+
+# [EOF]
diff --git a/makefiles/detect/src-by-ext.mk b/makefiles/detect/src-by-ext.mk
new file mode 100644
index 0000000..859ca95
--- /dev/null
+++ b/makefiles/detect/src-by-ext.mk
@@ -0,0 +1,36 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-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: 2022-2024 Open Networking Foundation Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+# Intent: This makefile will gather sources from the filesystem and
+#         dynamically enable targets and functionality based on extension.
+# -----------------------------------------------------------------------
+
+GRAPHVIZ_ext    = %.graphml
+GO_ext		    = %.go
+HTML_ext 	    = %.html
+JAVA_ext 	    = %.java
+PERL_ext 	    = %.pl %.pm
+PYTHON_ext 	    = %.py
+RST_ext 	    = %.rst
+SQL_ext 	    = %.sql
+SPREADSHEET_ext = %.ods %.xlsx
+VIEW_ext  	    = urls
+WORD_ext	    = %.odt %.docx
+
+# [EOF]
diff --git a/makefiles/include.mk b/makefiles/include.mk
index e2a1220..ee2792d 100644
--- a/makefiles/include.mk
+++ b/makefiles/include.mk
@@ -2,7 +2,7 @@
 # -----------------------------------------------------------------------
 # Copyright 2017-2024 Open Networking Foundation (ONF) and the ONF Contributors
 #
-# Licensed under the Apache License, Version 2.0 (the "License");
+# Licensed unde 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
 #
@@ -50,9 +50,12 @@
 
 ONF_MAKEDIR   := $(onf-mk-dir)#   # TODO: Deprecate ONF_MAKEDIR and MAKEDIR
 
-#--------------------##
+##--------------------##
 ##---]  INCLUDES  [---##
 ##--------------------##
+
+include $(onf-mk-dir)/detect/include.mk     # Dynamic features based on source
+
 include $(onf-mk-dir)/lint/make/warn-undef-vars.mk  # target lint-make helper
 
 include $(onf-mk-dir)/consts.mk
diff --git a/makefiles/utils/include.mk b/makefiles/utils/include.mk
index 7668bba..110732e 100644
--- a/makefiles/utils/include.mk
+++ b/makefiles/utils/include.mk
@@ -1,6 +1,6 @@
 # -*- makefile -*-
 # -----------------------------------------------------------------------
-# Copyright 2022-2024 Open Networking Foundation (ONF) and the ONF Contributors
+# Copyright 2022-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.
@@ -13,13 +13,24 @@
 # 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: 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# -----------------------------------------------------------------------
+# SPDX-FileCopyrightText: 2022-2024 Open Networking Foundation Contributors
 # SPDX-License-Identifier: Apache-2.0
 # -----------------------------------------------------------------------
+# Intent: This makefile will gather available sources from a filesystem
+#         then enable targets and functionality based on extensions.
+# -----------------------------------------------------------------------
 
 $(if $(DEBUG),$(warning ENTER))
 
+##-------------------##
+##---]  GLOBALS  [---##
+##-------------------##
+
+##--------------------##
+##---]  INCLUDES  [---##
+##--------------------##
+
 # usage: $(call if-not,false,5)
 if-not = $(info 1=$(1), 2=$(2), 3=$(3))\
   $(if $(1),$(null),$(2))
diff --git a/transition.mk b/transition.mk
new file mode 100644
index 0000000..a1fb461
--- /dev/null
+++ b/transition.mk
@@ -0,0 +1,65 @@
+# -*- 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  [---##
+##-------------------##
+lf-sbx-root   := $(abspath $(lastword $(MAKEFILE_LIST)))
+lf-sbx-root   := $(subst /lf/transition.mk,$(null),$(lf-sbx-root))
+
+legacy-mk   ?= $(lf-sbx-root)/makefiles
+onf-mk-dir  ?= $(lf-sbx-root)/lf/onf-make/makefiles
+
+sandbox-root := $(lf-sbx-root)
+
+# set default shell options
+SHELL = bash -e -o pipefail
+
+# dependency of virtualenv::sterile
+clean ::
+
+##--------------------##
+##---]  INCLUDES  [---##
+##--------------------##
+include $(lf-sbx-root)/lf/config.mk
+include $(onf-mk-dir)/consts.mk
+# include.mk depends on ONF_MAKEDIR
+include $(onf-mk-dir)/etc/features.mk
+include $(onf-mk-dir)/virtualenv/include.mk
+
+# [EOF]
+
+ifdef paste-into-repository-makefile
+
+$(if $(findstring disabled-joey,$(USER)),\
+   $(eval USE_LF_MK := 1)) # special snowflake
+
+##--------------------##
+##---]  INCLUDES  [---##
+##--------------------##
+ifdef USE_LF_MK
+  include lf/include.mk
+else
+  include lf/transition.mk
+endif # ifdef USE_LF_MK
+
+endif # paste-into-repository-makefile