[VOL-5194] - Update repo to use library makefiles.
https://gerrit.opencord.org/plugins/gitiles/onf-make
----------------------------------------------------
This patch will begin replacing the makefiles/ directory (target and logic
duplication) with centrally maintained library makefiles. repo:onf-make
has been added as a git-submodule.
Simplest patch given the amount of changes needed.
It will only alter where duplicate target logic is included from.
.gitmodules
makefiles/onf-lib
-----------------
o Checkout repo:onf-make as a submodule of voltha-docs.
makefiles/local/include.mk
--------------------------
o Add a directory for per-repository makefile targets and overrides.
config.mk
makefiles/config.mk
-------------------
o Relocate config.mk to avoid cluttering the repository root.
Makefile
--------
o Replace high level imports with a single library makefile include.
makefiles-orig/virtualenv.mk
----------------------------
o Help target cleanups, edits will migrate into repo:onf-make
prior to removal of the local virtualenv.mk makefile.
makefiles/include.mk
--------------------
o Added new install.mk include used to load onf-lib and local makefiles.
o Staging: define onf-mk-lib as makefiles-orig/ for now.
o Legacy makefile cleanup still needed before makefiles/local can be used
howto/index.rst
howto/nop.rst
---------------
o Cosmetic edit to force a build/license check.
o Last recheck attempt reported "No Builds Executed".
Depends-On: I7c83bd48d26510e79fd32f8bb97887cace67b55f
Depends-On: If75417c45363ee5c6a514fe9ebd4414ba8cf0cf7
Depends-On: I637d58f3e983b6cb1b7f08d19f16da925a579668
Change-Id: I8d7e53da91e52642726f1c8b997952765cbc1c23
Signed-off-by: Jan Klare <jan.klare@bisdn.de>
diff --git a/makefiles/config.mk b/makefiles/config.mk
new file mode 100644
index 0000000..72b2e9a
--- /dev/null
+++ b/makefiles/config.mk
@@ -0,0 +1,140 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2023 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.makefiles.include.version = 1.1
+# ONF.confg.mk = 1.5
+# -----------------------------------------------------------------------
+
+--repo-name-- := voltha-docs
+--repo-name-- ?= $(error --repo-name--= is required)
+
+##--------------------------------##
+##---] Disable lint targets [---##
+##--------------------------------##
+# NO-LINT-DOC8 := true
+# NO-LINT-GOLANG := true
+NO-LINT-GROOVY := true# # Note[1]
+# NO-LINT-JJB := true# # Note[2]
+# NO-LINT-JSON := true# # Note[1]
+NO-LINT-MAKEFILE := true# # Note[1]
+NO-LINT-REUSE := true # License check
+# NO-LINT-ROBOT := true
+NO-LINT-SHELL := true# # Note[1]
+# NO-LINT-TOX := true# # Note[1]
+NO-LINT-YAML := true# # Note[1]
+
+NO-LINT-FLAKE8 := true# # Note[1]
+# NO-LINT-PYTHON := true# # Note[1]
+NO-LINT-PYLINT := true# # Note[1]
+
+# Note[1] - A boatload of source to cleanup prior to enable.
+# Note[2] - No sources available
+
+##---------------------------------##
+##---] Conditional make logic [---##
+##---------------------------------##
+# USE-ONF-DOCKER-MK := true
+# USE-ONF-GERRIT-MK := true
+# USE-ONF-GIT-MK := true
+# USE-ONF-JJB-MK := true
+# USE-VOLTHA-RELEASE-MK := true
+
+##----------------------##
+##---] Debug Mode [---##
+##----------------------##
+# export DEBUG := 1 # makefile debug
+# export DISTUTILS_DEBUG := 1 # verbose: pip
+# export DOCKER_DEBUG := 1 # verbose: docker
+# export VERBOSE := 1 # makefile debug
+
+##-----------------------------------##
+##---] JJB/Jenkins Job Builder [---##
+##-----------------------------------##
+JJB_VERSION ?= 2.8.0
+JOBCONFIG_DIR ?= job-configs
+
+##---------------------------------##
+##---] Filesystem exclusions [---##
+##---------------------------------##
+onf-excl-dirs := $(null) # make clean: dirs=
+onf-excl-dirs += .venv# # $(venv-name)
+onf-excl-dirs += vendor# # golang / voltha*-go
+onf-excl-dirs += patches# # voltha docs - python upgrade
+onf-excl-dirs += .tox # also a python dependency
+
+ifeq ($(--repo-name--),voltha-docs)
+ lint-doc8-excl += '_build' # generated
+# lint-groovy-excl += 'bbsim' # external repo
+endif
+
+onf-excl-dirs ?= $(error onf-excl-dirs= is required)
+
+##-----------------------------##
+##---] Feature Detection [---##
+##-----------------------------##
+# [TODO] include makefiles/features/include.mk
+# [TODO] All logic below can migrate there.
+
+$(if $(filter %ci-management,$(--repo-name--)),\
+ $(eval --REPO-IS-CI-MANAGEMENT-- := true)\
+)
+$(if $(filter %voltha-docs,$(--repo-name--)),\
+ $(eval --REPO-IS-VOLTHA-DOCS-- := true)\
+)
+
+# create makefiles/config/byrepo/{--repo-name--}.mk for one-off snowflakes ?
+# $(if $(wildcard docker),$(eval USE-ONF-DOCKER-MK := true))
+
+##-------------------------##
+##---] Derived Flags [---##
+##-------------------------##
+ifdef --REPO-IS-CI-MANAGEMENT--
+ USE-ONF-JJB := true
+
+ onf-excl-dirs += global-jjb
+ onf-excl-dirs += lf-ansible
+ onf-excl-dirs += packer
+endif
+
+ifdef --REPO-IS-VOLTHA-DOCS--
+ onf-excl-dirs += _build
+ onf-excl-dirs += repos
+endif
+
+ifdef NO-LINT-PYTHON
+ NO-LINT-FLAKE8 := true
+ NO-LINT-PYLINT := true
+endif
+
+ifndef USE-ONF-JJB
+ NO-LINT-JJB := true
+endif
+
+onf-excl-dirs := $(sort $(strip $(onf-excl-dirs)))
+
+# [TODO]#
+# --------------------------------------------------------------------
+# o two distinct makefiles directories are needed, one for onf-make
+# o second for repository specific configs and logic.
+# o Two independent vars specify path:
+# ONF_MAKEDIR = library makefiles
+# MAKEDIR = repository specific content
+# o Conditional repository testing above can crush down into
+# include $(MAKEDIR)/config.mk # repo:$(--repo-name--)
+# --------------------------------------------------------------------
+
+# [EOF]
diff --git a/makefiles/include.mk b/makefiles/include.mk
new file mode 100644
index 0000000..44872b4
--- /dev/null
+++ b/makefiles/include.mk
@@ -0,0 +1,81 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2023 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.
+#
+# SPDX-FileCopyrightText: 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
+# -----------------------------------------------------------------------
+# Setup:
+# 1) Makefile
+# include config.mk
+# include makefiles/include.mk
+# 2) cd makefiles
+# 23 copy makefiles_include_mk.ex into $repo/makefiles/include.mk
+# 4) make create-onf-lib
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+## -----------------------------------------------------------------------
+## 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 makefiles/include.mk,$(null),$(onf-mk-abs))
+
+LEGACY := 1
+ifdef LEGACY
+ # Cleanup patch forthcoming
+ onf-mk-lib := $(onf-mk-top)/makefiles-orig
+else
+ onf-mk-lib := $(onf-mk-top)/makefiles/onf-lib/makefiles
+endif
+
+onf-mk-loc := $(onf-mk-top)/makefiles/local
+TOP ?= $(onf-mk-top)
+
+## ------------------------------------------------------
+## Two distinct vars needed to access library or project
+## ------------------------------------------------------
+ONF_MAKEDIR ?= $(onf-mk-lib)
+MAKEDIR ?= $(onf-mk-loc)
+
+## -----------------------------------------------------------------------
+## Load makefiles in order:
+## 1) Library constants and logic loaded first
+## 2) Parameterize and augment targets from local (repo specific)
+## -----------------------------------------------------------------------
+include $(onf-mk-top)/makefiles/config.mk
+include $(onf-mk-lib)/include.mk
+include $(onf-mk-loc)/include.mk
+
+## -----------------------------------------
+## Submodue init target for new repositories
+## -----------------------------------------
+create-onf-lib : $(onf-mk-lib)
+$(onf-mk-lib):
+ mkdir -p $(dir $@)# makefiles
+ cd $(dir $@) \
+ && git submodule https://github.com/opencord/onf-make.git onf-lib
+
+update-submodules:
+ git submodule foreach git pull
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/local/include.mk b/makefiles/local/include.mk
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/makefiles/local/include.mk
diff --git a/makefiles/onf-lib b/makefiles/onf-lib
new file mode 160000
index 0000000..0003f1a
--- /dev/null
+++ b/makefiles/onf-lib
@@ -0,0 +1 @@
+Subproject commit 0003f1a36b973973b5fc627363590d007d064cad