logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: 292ee09aacd706913cbb8f2c9272dd928e21b4ac
parent 8eb74955a5d1bdd3923e476c288d81a06208c3e6
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu, 10 Feb 2022 01:08:13 +0100

Lint manpages and scripts

Diffstat:

MMakefile5+++++
MMakefile.common3---
Mbin/Makefile9++++++++-
Mconfigure29++++++++++++++++++++++++++++-
Msbin/Makefile3+++
5 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,9 +1,14 @@ +include config.mk + all: cd bin ; $(MAKE) cd sbin ; $(MAKE) test: all + $(SHELLCHECK) ./configure POSIX_ME_HARDER=1 POSIXLY_CORRECT=1 kyua test || (kyua report --verbose; false) + cd bin ; $(MAKE) test + cd sbin ; $(MAKE) test clean: cd bin ; $(MAKE) clean diff --git a/Makefile.common b/Makefile.common @@ -1,8 +1,5 @@ all: $(EXE) -.PHONY: test -test: - .c: $(CC) -std=c99 $(CFLAGS) -o $@ $< $(LDFLAGS) diff --git a/bin/Makefile b/bin/Makefile @@ -2,7 +2,14 @@ include config.mk include ../config.mk include ../Makefile.common -SCRIPTS = archive-tags dmenu_path wordsort zalgo +SH_SCRIPTS = archive-tags dmenu_path wordsort +PL_SCRIPTS = zalgo +SCRIPTS = $(SH_SCRIPTS) $(PL_SCRIPTS) + +.PHONY: test +test: all + $(MANDOC) -Tlint -Wunsupp,error,warning $(MAN1) + $(SHELLCHECK) $(SH_SCRIPTS) lolcat: lolcat.c Makefile $(CC) -std=c99 $(CFLAGS) -o $@ $< -lm $(LDFLAGS) diff --git a/configure b/configure @@ -15,6 +15,9 @@ Variables: PKGCONFIG=BIN MSGFMT=BIN CC=BIN + MANDOC=BIN + SHELLCHECK=BIN + CFLAGS=OPTIONS LDFLAGS=OPTIONS EXTRA_CFLAGS=OPTIONS @@ -24,6 +27,8 @@ Variables are set in the following order: Default, Environment, Arguments Dependencies: - libbsd (optionnal), for strings(1) and humanize(1) - kyua + atf (optional, test dep) +- mandoc: for linting the manual pages (optional, test dep) +- shellcheck: for linting ./configure and shell scripts (optional, test dep) END } @@ -69,6 +74,8 @@ MSGFMT="${MSGFMT:-msgfmt}" CC="${CC:-cc}" CFLAGS="${CFLAGS:--g -O2 -pie -fPIE}" LDFLAGS="${LDFLAGS:--Wl,--as-needed}" +MANDOC="${MANDOC:-mandoc}" +SHELLCHECK="${SHELLCHECK:-shellcheck}" # Also allow variables through arguments for i; do @@ -101,7 +108,7 @@ SBINDIR="${SBINDIR:-${PREFIX}/sbin}" MANDIR="${MANDIR:-${PREFIX}/share/man}" # Add some extra CFLAGS -CFLAGS="${CFLAGS} -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wconversion -Wsign-conversion -Werror=implicit-function-declaration -Werror=implicit-int -Werror=vla ${EXTRA_CFLAGS}" +CFLAGS="${CFLAGS} -fstack-protector-strong -Wall -Wextra -Wconversion -Wsign-conversion -Werror=implicit-function-declaration -Werror=implicit-int -Werror=vla ${EXTRA_CFLAGS}" printf 'Pruning old configurations ...' rm -f config.mk bin/config.mk sbin/config.mk \ @@ -117,6 +124,24 @@ command -v "${PKGCONFIG}" >/dev/null ; or_die printf 'Checking %s command existance ...' "${CC}" command -v "${CC}" >/dev/null ; or_die +printf 'Checking %s command existance ...' "${MANDOC}" +if command -v "${MANDOC}" >/dev/null ; is_ok +then + : +else + printf 'Warning: Tests depending on mandoc disabled' + MANDOC="true" +fi + +printf 'Checking %s command existance ...' "${SHELLCHECK}" +if command -v "${SHELLCHECK}" >/dev/null ; is_ok +then + : +else + printf 'Warning: Tests depending on shellcheck disabled' + SHELLCHECK="true" +fi + echo # pkg-config @@ -155,6 +180,8 @@ MANDIR = ${MANDIR} PKGCONFIG = ${PKGCONFIG} CC = ${CC} +MANDOC = ${MANDOC} +SHELLCHECK = ${SHELLCHECK} MSGFMT = ${MSGFMT} DBG = ${DBG} diff --git a/sbin/Makefile b/sbin/Makefile @@ -2,6 +2,9 @@ include config.mk include ../config.mk include ../Makefile.common +test: all + : + install: mkdir -p ${DESTDIR}${SBINDIR}/ cp -p memsys ${DESTDIR}${SBINDIR}/