Enhance shellcheck lint target (2 of 3 -- installer)

makefiles/lint/shell/help.mk
----------------------------
  o Top level include used to source all lint-shell library makefiles.
  o Loosely based on makefiles/{groovy,doc8}/*.
  o Currently library makefile makefiles/shell.mk deprecation pending.
  o Prefix yet-to-be-added makefile includes with hyphen to prevent errors.

makefiles/lint/shell/install.mk
-------------------------------
  o Adding a tool makefile for installing shellcheck via dependency.
  o NOP if shellcheck exists else install the latest v0.9.0.
  o Added library target lint-shell-cmd-version
    - Dependency for lint-shell-* makefile targets
    - Used for central logging to display shellcheck command in use.
  o lint-shell-install
    - Install makefile target is dependency driven.
    - Prefer system installed command with fallback to installation
      of the 'latest' shellcheck version v0.9.0.

Unit testing:
  - mkcheck.sh script will setup a usable sandbox to try out
    lint-shell makefile targets.

https://wiki.opennetworking.org/display/VOLTHA/repo%3Aonf-make

Change-Id: Ica33f4c2c01cd63bc400a7db3c1e299cbcc030e7
diff --git a/makefiles/lint/shell/include.mk b/makefiles/lint/shell/include.mk
index 63797d5..293947f 100644
--- a/makefiles/lint/shell/include.mk
+++ b/makefiles/lint/shell/include.mk
@@ -21,7 +21,7 @@
 ##---]  INCLUDES  [---##
 ##--------------------##
 -include $(ONF_MAKEDIR)/lint/shell/help.mk
--include $(ONF_MAKEDIR)/lint/shell/install.mk
+include $(ONF_MAKEDIR)/lint/shell/install.mk
 include $(ONF_MAKEDIR)/lint/shell/shellcheck.mk
 
 $(if $(DEBUG),$(warning LEAVE))
diff --git a/makefiles/lint/shell/install.mk b/makefiles/lint/shell/install.mk
new file mode 100644
index 0000000..fd3e462
--- /dev/null
+++ b/makefiles/lint/shell/install.mk
@@ -0,0 +1,110 @@
+# -*- 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-shell-dflt := $(venv-activate-bin)/shellcheck
+
+lint-shell-cmds += $(shell which shellcheck)
+lint-shell-cmds += $(lint-shell-dflt)
+lint-shell-cmds += /usr/bin/shellcheck
+
+lint-shell-cmd = \
+  $(strip \
+    $(firstword \
+      $(wildcard $(lint-shell-cmds)) \
+      $(lint-shell-dflt) \
+  ))
+lint-shell-cmd := $(venv-activate-bin)/shellcheck
+
+##-------------------##
+##---]  TARGETS  [---##
+##-------------------##
+
+## -----------------------------------------------------------------------
+## Intent: Display shellcheck command version string.
+##   Note: As a side effect, install shellcheck by dependency
+## -----------------------------------------------------------------------
+## Verified: v0.8.0
+## -----------------------------------------------------------------------
+.PHONY: lint-shellcheck-cmd-version
+lint-shellcheck-cmd-version : $(lint-shell-cmd)
+
+	$(HIDE) echo
+	$< --version
+
+## -----------------------------------------------------------------------
+## Intent: Install shellcheck
+## -----------------------------------------------------------------------
+## Note: .venv/bin is somewhat odd for an install directory but:
+##   o avoids existence and conflict problems with ./bin.
+##   o auto-exclude from consideration by lint and test targets.
+## -----------------------------------------------------------------------
+## Verified: v0.8.0
+## -----------------------------------------------------------------------
+
+lint-shell-download = https://github.com/koalaman/shellcheck/releases/download/$(1)/shellcheck-$(1).$(2).x86_64.tar.xz
+
+lint-shell-downloads=\
+	$(call lint-shell-download,v0.9.0,darwin)\
+	$(call lint-shell-download,v0.9.0,linux)
+
+## -----------------------------------------------------------------------
+## Intent: Retrieve and install the shellcheck command.
+## -----------------------------------------------------------------------
+## Cannot pass wildcards to wget, download endpoint must be dynamic.
+## Attempts to glob using curl or wget returns "not found".
+##   wget -r -l1 --no-parent -A.xz \
+##     'https://github.com/koalaman/shellcheck/releases/download/v0.9.0
+## -----------------------------------------------------------------------
+
+.PHONY: lint-shell-install
+lint-shell-install : $(lint-shell-cmd)
+$(lint-shell-cmd)  :
+
+	$(call banner-enter,(Target $@))
+
+	$(call banner,(shellcheck: Download))
+	$(HIDE)wget --quiet --unlink $(lint-shell-downloads)
+	$(HIDE)umask 022 && mkdir -p $(dir $@)
+
+	$(call banner,(shellcheck: Unpack and install))
+	$(HIDE)case "$(uname -s)" in \
+	    *arwin*) tar Jxf *darwin*.tar.xz -C $(dir $@) --strip-components=1 ;; \
+	          *) tar Jxf *linux*.tar.xz  -C $(dir $@) --strip-components=1 ;; \
+	esac
+
+	$(HIDE)$(RM) $(notdir $(lint-shell-downloads))
+
+	$(call banner-leave,(Target $@))
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+sterile ::
+	$(RM) $(lint-shell-downloads)
+
+## -----------------------------------------------------------------------
+## Intent: Display command help
+## -----------------------------------------------------------------------
+lint-shell-help ::
+	@printf '  %-30s %s\n' 'lint-shell-install' \
+      'Install syntax checking tool shellcheck'
+	@printf '  %-30s %s\n' 'lint-shellcheck-cmd-version' \
+	  'Library target able to display version of shellcheck command'
+
+# [EOF]