Update lint-robot to support the latest lint-robot-{all,mod,src} targets

Change-Id: I0e2a7c79b28544dfb34be2e1a3dfb6770f644b68
diff --git a/makefiles/lint/groovy/include.mk b/makefiles/lint/groovy/include.mk
index 5bea853..a2406d4 100644
--- a/makefiles/lint/groovy/include.mk
+++ b/makefiles/lint/groovy/include.mk
@@ -54,11 +54,16 @@
 ## Intent: Perform a lint check on command line script sources
 ## -----------------------------------------------------------------------
 lint-groovy-all:
+
+	$(call banner-enter,Target $@)
+
 	$(groovy-check) --version
 	@echo
 	$(HIDE)$(env-clean) find . -iname '*.groovy' -print0 \
   | $(xargs-n1) $(groovy-check) $(groovy-check-args)
 
+	$(call banner-leave,Target $@)
+
 ## -----------------------------------------------------------------------
 ## Intent: On-demand lint checking
 ## -----------------------------------------------------------------------
@@ -72,7 +77,7 @@
 	$(HIDE) $(groovy-check) $(groovy-check-args) $(GROOVY_SRC)
 
 ## -----------------------------------------------------------------------
-## Intent: Perform lint check on a named list of files
+## Intent: Perform lint check on locally modified sources
 ## -----------------------------------------------------------------------
 # lint-groovy-bygit = $(shell git diff --name-only HEAD | grep '\.groovy')
 lint-groovy-bygit = $(git status -s | grep '\.sh' | grep -v -e '^D' -e '^?' | cut -c4-)
diff --git a/makefiles/lint/robot.mk b/makefiles/lint/robot.mk
deleted file mode 100644
index d9ce670..0000000
--- a/makefiles/lint/robot.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-# -*- makefile -*-
-# -----------------------------------------------------------------------
-# Copyright 2017-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.
-# -----------------------------------------------------------------------
-
-ROBOT_FILES ?= $(error ROBOT_FILES= is required)
-
-LINT_ARGS ?= --verbose --configure LineTooLong:130 -e LineTooLong \
-             --configure TooManyTestSteps:65 -e TooManyTestSteps \
-             --configure TooManyTestCases:50 -e TooManyTestCases \
-             --configure TooFewTestSteps:1 \
-             --configure TooFewKeywordSteps:1 \
-             --configure FileTooLong:2000 -e FileTooLong \
-             -e TrailingWhitespace
-
-
-.PHONY: lint-robot
-
-ifndef NO-LINT-ROBOT
-  lint : lint-robot
-endif
-
-lint-robot: vst_venv
-	source ./$</bin/activate \
-	    ; set -u \
-	    ; rflint $(LINT_ARGS) $(ROBOT_FILES)
-
-help::
-	@echo "  lint-robot           Syntax check robot sources using rflint"
-
-# [EOF]
diff --git a/makefiles/lint/robot/help.mk b/makefiles/lint/robot/help.mk
new file mode 100644
index 0000000..5995589
--- /dev/null
+++ b/makefiles/lint/robot/help.mk
@@ -0,0 +1,53 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-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.
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+## -----------------------------------------------------------------------
+## Intent: Display topic help
+## -----------------------------------------------------------------------
+help-summary ::
+	@printf '  %-30s %s\n' 'lint-robot'\
+      'Style check ReStructed Text (rst) documents'
+	@printf '  %-30s %s\n' 'lint-robot-help'\
+	  'Show verbose target help'
+  ifdef VERBOSE
+	@$(MAKE) --no-print-directory lint-robot-help
+  endif
+
+## -----------------------------------------------------------------------
+## Intent: Display extended topic help
+## -----------------------------------------------------------------------
+.PHONY: lint-robot-help
+lint-robot-help ::
+	@printf '  %-30s %s\n' 'lint-robot-all'\
+	  'Robot check available sources'
+	@printf '  %-30s %s\n' 'lint-robot-mod'\
+	  'Robot check locally modified files (git status)'
+	@printf '  %-30s %s\n' 'lint-robot-src'\
+      'Robot check a list of files passed in'
+
+	@printf '  %-30s %s\n' 'lint-robot-install'\
+	  'Install robot lint command rflint'
+
+	@printf '  %-30s %s\n' 'rflint-cmd-help'\
+      'Display rflint command usage'
+
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/lint/robot/include.mk b/makefiles/lint/robot/include.mk
new file mode 100644
index 0000000..0aa2914
--- /dev/null
+++ b/makefiles/lint/robot/include.mk
@@ -0,0 +1,29 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2017-2024 Open Networking Foundation
+#
+# 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.
+# -----------------------------------------------------------------------
+# NOTE: The doc8 command runs recursively on directories so targets
+#       *-mod and *-src are not yet supported.
+# -----------------------------------------------------------------------
+
+##--------------------##
+##---]  INCLUDES  [---##
+##--------------------##
+include $(ONF_MAKEDIR)/lint/robot/robot.mk
+# include $(ONF_MAKEDIR)/lint/robot/excl.mk
+include $(ONF_MAKEDIR)/lint/robot/help.mk
+include $(ONF_MAKEDIR)/lint/robot/install.mk
+
+# [EOF]
diff --git a/makefiles/lint/robot/install.mk b/makefiles/lint/robot/install.mk
new file mode 100644
index 0000000..b1f871c
--- /dev/null
+++ b/makefiles/lint/robot/install.mk
@@ -0,0 +1,45 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-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.
+# -----------------------------------------------------------------------
+
+##-------------------##
+##---]  GLOBALS  [---##
+##-------------------##
+lint-robot-cmd := $(venv-name)/bin/rflint
+
+##-------------------##
+##---]  TARGETS  [---##
+##-------------------##
+
+## -----------------------------------------------------------------------
+## Intent: Install rflint python virtualenv package
+## -----------------------------------------------------------------------
+$(lint-robot-cmd) : lint-robot-install
+lint-robot-install: venv-activate-patched
+    # Verify package mentioned in requirements.txt
+    # grep 'robotframework-lint' requirements.txt
+	$(activate) && pip freeze | grep 'robotframework-lint'
+
+## ---------------------------------------1--------------------------------
+## Intent: Display command line tool version
+##   - Dependency will install when needed
+## -----------------------------------------------------------------------
+lint-robot-version : lint-robot-install
+	$(activate) && rflint --version
+	@echo
+
+# [EOF]
+
diff --git a/makefiles/lint/robot/robot.mk b/makefiles/lint/robot/robot.mk
new file mode 100644
index 0000000..19a007b
--- /dev/null
+++ b/makefiles/lint/robot/robot.mk
@@ -0,0 +1,90 @@
+# -*- 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.
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---]  GLOBALS  [---##
+##-------------------##
+.PHONY: lint-robot lint-robot-all lint-robot-mod lint-robot-src
+
+have-robot-files := $(if $(strip $(ROBOT_FILES)),true)
+ROBOT_FILES      ?= $(error ROBOT_FILES= is required)
+
+robot-check      = $(activate) && rflint
+robot-check-args ?= --verbose --configure LineTooLong:130 -e LineTooLong \
+             --configure TooManyTestSteps:65 -e TooManyTestSteps \
+             --configure TooManyTestCases:50 -e TooManyTestCases \
+             --configure TooFewTestSteps:1 \
+             --configure TooFewKeywordSteps:1 \
+             --configure FileTooLong:2000 -e FileTooLong \
+             -e TrailingWhitespace
+
+## -----------------------------------------------------------------------
+## Intent: Use the robot command to perform syntax checking.
+## -----------------------------------------------------------------------
+ifndef NO-LINT-ROBOT
+  lint-robot-mode := $(if $(have-robot-files),mod,all)
+  lint       : lint-robot
+  lint-robot : lint-robot-$(lint-robot-mode)
+endif# NO-LINT-ROBOT
+
+## -----------------------------------------------------------------------
+## Intent: exhaustive robot syntax checking
+## -----------------------------------------------------------------------
+lint-robot-all:
+
+	$(call banner-enter,Target $@)
+
+	$(HIDE)$(MAKE) --no-print-directory lint-robot-version
+	@find . -iname '*.robot' -print0 \
+        | $(xargs-n1) bash -c "$(robot-check) $(robot-check-args)"
+	@echo "DONE"
+
+	$(call banner-leave,Target $@)
+
+## -----------------------------------------------------------------------
+## Intent: On-demand lint checking
+## -----------------------------------------------------------------------
+lint-robot-src:
+  ifndef ROBOT_SRC
+	@echo "ERROR: Usage: $(MAKE) $@ ROBOT_SRC="
+	@exit 1
+  endif
+
+	$(call banner-enter,Target $@)
+
+	$(HIDE)$(MAKE) --no-print-directory lint-robot-version
+	$(HIDE) $(robot-check-args) $(robot-check-args) $(ROBOT_SRC)
+
+	$(call banner-leave,Target $@)
+
+## -----------------------------------------------------------------------
+## Intent: Perform lint check on locally modified sources
+## -----------------------------------------------------------------------
+lint-robot-bygit = $(shell git ls-files -m -o | grep -i '\.robot')
+lint-robot-mod:
+	$(call banner-enter,Target $@)
+
+	$(HIDE)$(MAKE) --no-print-directory lint-robot-version
+	$(foreach fyl,$(lint-robot-bygit),$(robot-check) $(robot-check-args) $(fyl))
+
+	$(call banner-leave,Target $@)
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]