zfcpdbf: test-compile the script during the build using perl -c

For a slightly easier development loop add a pseudo compilation of the
zfcpdbf Perl script. This will run the Perl interpreter in syntax-check
mode:

  -c   causes Perl to check the syntax of the program and then exit
       without executing it.  Actually, it will execute any "BEGIN",
       "UNITCHECK", or "CHECK" blocks and any "use" statements: these are
       considered as occurring outside the execution of your program.
       "INIT" and "END" blocks, however, will be skipped.

Additionally add the `-w` switch when the Make variable `W` is `1`. This
will print additional warnings about dubious constructs (according to
Perl).

So this pseudo compilation only happens whenever the script is changed
during development create a file `.zfcpdbf.ct` as a result so we can
describe the relationship and dependency in Make. This file can be ignored
otherwise.

Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Benjamin Block
2022-09-19 17:45:33 +02:00
committed by Jan Höppner
parent 48d7c6e6d1
commit 4941fc15c0
3 changed files with 26 additions and 0 deletions

View File

@@ -75,6 +75,7 @@ $(eval $(call cmd_define, CAT," CAT ",cat))
$(eval $(call cmd_define, SED," SED ",sed))
$(eval $(call cmd_define, GZIP," GZIP ",gzip))
$(eval $(call cmd_define, MV," MV ",mv))
$(eval $(call cmd_define, PERLC," PERLC ",perl -c))
CHECK = sparse
CHECK_SILENT := $(CHECK)
@@ -113,6 +114,11 @@ ifeq ("${ASAN}","1")
DEFAULT_LDFLAGS += -fsanitize=address
endif
DEFAULT_PERLCFLAGS =
ifeq ("${W}","1")
DEFAULT_PERLCFLAGS += -w
endif
#
# Check for header prerequisite
#
@@ -260,6 +266,8 @@ ALL_CXXFLAGS = -DS390_TOOLS_RELEASE=$(S390_TOOLS_RELEASE) \
ALL_CPPFLAGS = -I $(rootdir)include $(CPPFLAGS)
ALL_LDFLAGS = $(LDFLAGS)
ALL_PERLCFLAGS = $(DEFAULT_PERLCFLAGS)
# make G=1
# Compile tools so that gcov can be used to collect code coverage data.
# See the gcov man page for details.

1
scripts/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/.zfcpdbf.ct

View File

@@ -36,4 +36,21 @@ install:
clean:
.zfcpdbf.ct: zfcpdbf
$(PERLC) $(ALL_PERLCFLAGS) zfcpdbf 2>$(@); \
if [ "$${?}" -ne 0 ]; then \
cat "$(@)" >&2 && rm "$(@)"; \
elif [ "$$(cat '$(@)' | wc -l)" -gt 1 ]; then \
cat "$(@)" >&2; \
elif [ " $(V)" = " 1" ]; then \
cat "$(@)"; \
fi
.PHONY: .zfcpdbf.ct-clean
.zfcpdbf.ct-clean:
rm -f .zfcpdbf.ct
all: .zfcpdbf.ct
clean: .zfcpdbf.ct-clean
.PHONY: all install clean