From 7f3924db77a56e59be65106f6052795b5ce5b02d Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Fri, 28 Jul 2023 22:28:07 +0100 Subject: [PATCH] Added "make analyse" to run analysis tools on the source. --- README.md | 3 ++- autoconf/make/rules.mk | 6 +++++- autoconf/make/unreal.mk | 21 ++++++++++++++------- autoconf/scripts/makemake.sh | 5 +++++ 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 065947f..feb6388 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,8 @@ debugging support to be built in, and the `--enable-profiling` option builds in profiling support (see "`man gprof`"). Also note that running "`make index`" will generate an HTML code index (using _ctags_ and _cproto_); this index lists all files used, all functions defined, and all -TODOs marked in the code. +TODOs marked in the code. Finally, "`make analyse`" will run the "`splint`" +and "`flawfinder`" tools on all C files to generate analysis files ("`*.e`"). Author and acknowledgements diff --git a/autoconf/make/rules.mk b/autoconf/make/rules.mk index 02b6153..66b1a70 100644 --- a/autoconf/make/rules.mk +++ b/autoconf/make/rules.mk @@ -2,7 +2,7 @@ # Compilation rules. # -.SUFFIXES: .c .d .o +.SUFFIXES: .c .d .o .e .c.o: $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< @@ -11,6 +11,10 @@ sh $(srcdir)/autoconf/scripts/depend.sh \ $(CC) $< $(<:%.c=%) $(srcdir) $(CFLAGS) $(CPPFLAGS) > $@ +.c.e: + -splint -badflag $(CPPFLAGS) $< > $@ 2>&1 + -flawfinder $< >> $@ 2>&1 + # # Native language support # diff --git a/autoconf/make/unreal.mk b/autoconf/make/unreal.mk index 7fa3634..93130b8 100644 --- a/autoconf/make/unreal.mk +++ b/autoconf/make/unreal.mk @@ -2,8 +2,8 @@ # Rules for all phony targets. # -.PHONY: all help make dep depend test check \ - clean depclean indentclean distclean cvsclean svnclean \ +.PHONY: all help make dep depend test check analyse \ + clean depclean analysisclean indentclean distclean gitclean \ index manhtml indent update-po \ doc dist release \ install uninstall @@ -22,11 +22,13 @@ help: @echo @echo ' make rebuild the Makefile (after adding new files)' @echo ' dep / depend rebuild .d (dependency) files' - @echo ' clean remove .o (object) and .c~ (backup) files' + @echo ' analyse run analysis tools on all .c files' + @echo ' clean remove .o (object) files' @echo ' depclean remove .d (dependency) files' + @echo ' analysisclean remove .e (analysis) files' @echo ' indentclean remove files left over from "make indent"' @echo ' distclean remove everything not distributed' - @echo ' cvsclean remove everything not in CVS/SVN' + @echo ' gitclean remove everything not in version control' @echo @echo ' index generate an HTML index of source code' @echo ' manhtml output HTML man page to stdout' @@ -54,12 +56,17 @@ dep depend: $(alldep) cat $(alldep) >> $(srcdir)/autoconf/make/depend.mk~ sh ./config.status +analyse: $(allanalysis) + clean: rm -f $(allobj) depclean: rm -f $(alldep) +analysisclean: + rm -f $(allanalysis) + indentclean: cd $(srcdir) && for FILE in $(allsrc); do rm -f ./$${FILE}~; done @@ -78,13 +85,13 @@ update-po: $(srcdir)/src/nls/$(PACKAGE).pot fi; \ done -distclean: clean depclean +distclean: clean depclean analysisclean rm -f $(alltarg) src/include/config.h rm -rf $(package)-$(version).tar* $(package)-$(version) rm -f *.html config.* rm Makefile -cvsclean svnclean: distclean +gitclean: distclean rm -f doc/lsm rm -f doc/quickref.1 rm -f configure @@ -94,7 +101,7 @@ cvsclean svnclean: distclean echo > $(srcdir)/autoconf/make/modules.mk~ doc: - : + -true index: (cd $(srcdir); sh autoconf/scripts/index.sh $(srcdir)) > index.html diff --git a/autoconf/scripts/makemake.sh b/autoconf/scripts/makemake.sh index 7769751..27abad0 100755 --- a/autoconf/scripts/makemake.sh +++ b/autoconf/scripts/makemake.sh @@ -39,6 +39,7 @@ printf "%s" "Scanning for source files: " allsrc=$("${FIND}" src -type f -name "*.c" -print) allobj=$(echo "${allsrc}" | tr ' ' '\n' | sed 's/\.c$/.o/') alldep=$(echo "${allsrc}" | tr ' ' '\n' | sed 's/\.c$/.d/') +allanalysis=$(echo "${allsrc}" | tr ' ' '\n' | sed 's/\.c$/.e/') echo "$(echo "${allsrc}" | wc -w | tr -d ' ') found" @@ -118,6 +119,10 @@ printf "%s" "alldep = " echo "$alldep" | tr '\n' ' ' | sed -e 's/ $//;s/ / \\!/g' | tr '!' '\n' echo echo +printf "%s" "allanalysis = " +echo "$allanalysis" | tr '\n' ' ' | sed -e 's/ $//;s/ / \\!/g' | tr '!' '\n' +echo +echo } >> "${listingsFile}" echo >> "${linkingRulesFile}"