aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorнаб <[email protected]>2021-05-21 23:43:38 +0200
committerBrian Behlendorf <[email protected]>2021-06-09 13:05:34 -0700
commit132240507d0ab2999e764537b181e89ecc3c2b0e (patch)
tree3450e3a8132bbdc611944445146f259e541a0261 /config
parentd6f8f41c21b42a1b5a36850c0f7b18be9a05ecd9 (diff)
Turn shellcheck into a normal make target. Fix new files it caught
This checks every file it checked (and a few more), but explicitly instead of "if it works it works" best-effort (which wasn't that good anyway) Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #10512 Closes #12101
Diffstat (limited to 'config')
-rw-r--r--config/Shellcheck.am8
-rw-r--r--config/always-shellcheck.m47
-rw-r--r--config/zfs-build.m41
3 files changed, 16 insertions, 0 deletions
diff --git a/config/Shellcheck.am b/config/Shellcheck.am
new file mode 100644
index 000000000..a22333ac4
--- /dev/null
+++ b/config/Shellcheck.am
@@ -0,0 +1,8 @@
+.PHONY: shellcheck
+shellcheck: $(SCRIPTS) $(SHELLCHECKSCRIPTS)
+if HAVE_SHELLCHECK
+ [ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; shellcheck $$([ -n "$(SHELLCHECK_SHELL)" ] && echo "--shell=$(SHELLCHECK_SHELL)") --exclude=SC1090,SC1091$(SHELLCHECK_IGNORE) --format=gcc $(SCRIPTS) $(SHELLCHECKSCRIPTS)
+else
+ @[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; echo "skipping shellcheck of" $(SCRIPTS) $(SHELLCHECKSCRIPTS) "because shellcheck is not installed"
+endif
+ @set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir shellcheck; done
diff --git a/config/always-shellcheck.m4 b/config/always-shellcheck.m4
new file mode 100644
index 000000000..1e154e1c5
--- /dev/null
+++ b/config/always-shellcheck.m4
@@ -0,0 +1,7 @@
+dnl #
+dnl # Check if shellcheck is available.
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_SHELLCHECK], [
+ AC_CHECK_PROG([SHELLCHECK], [shellcheck], [yes])
+ AM_CONDITIONAL([HAVE_SHELLCHECK], [test "x$SHELLCHECK" = "xyes"])
+])
diff --git a/config/zfs-build.m4 b/config/zfs-build.m4
index cee5c87e7..c4fe07c81 100644
--- a/config/zfs-build.m4
+++ b/config/zfs-build.m4
@@ -207,6 +207,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
ZFS_AC_CONFIG_ALWAYS_PYZFS
ZFS_AC_CONFIG_ALWAYS_SED
ZFS_AC_CONFIG_ALWAYS_CPPCHECK
+ ZFS_AC_CONFIG_ALWAYS_SHELLCHECK
])
AC_DEFUN([ZFS_AC_CONFIG], [