Fix a couple of issues in the recently merged 0f3c55d4c2b (Merge
branch 'ab/coccicheck-incremental' into next, 2022-11-08):
In copying over the "contrib/coccinelle/" rules to
".build/contrib/coccinelle/" we inadvertently ended up with a
".build/.build/contrib/coccinelle/" as well. We'd generate the
per-file patches in the former, and keep the rule and overall result
in the latter. E.g. running:
make contrib/coccinelle/free.cocci.patch COCCI_SOURCES="attr.c grep.c"
Would, per "tree -a .build" yield the following result:
.build
├── .build
│ └── contrib
│ └── coccinelle
│ └── free.cocci.patch
│ ├── attr.c
│ ├── attr.c.log
│ ├── grep.c
│ └── grep.c.log
└── contrib
└── coccinelle
├── FOUND_H_SOURCES
├── free.cocci
└── free.cocci.patch
Now we'll instead generate all of our files in
".build/contrib/coccinelle/". Fixing this required renaming the
directory where we keep our per-file patches, as we'd otherwise
conflict with the result.
Now the per-file patch directory is named e.g. "free.cocci.d". And the
end result will now be:
.build
└── contrib
└── coccinelle
├── FOUND_H_SOURCES
├── free.cocci
├── free.cocci.d
│ ├── attr.c.patch
│ ├── attr.c.patch.log
│ ├── grep.c.patch
│ └── grep.c.patch.log
└── free.cocci.patch
The per-file patches now have a ".patch" file suffix, which fixes
another issue reported against 0f3c55d4c2b: The summary output was
confusing. Before for the "make" command above we'd emit:
[...]
MKDIR -p .build/contrib/coccinelle
CP contrib/coccinelle/free.cocci .build/contrib/coccinelle/free.cocci
GEN .build/contrib/coccinelle/FOUND_H_SOURCES
MKDIR -p .build/.build/contrib/coccinelle/free.cocci.patch
SPATCH .build/.build/contrib/coccinelle/free.cocci.patch/grep.c
SPATCH .build/.build/contrib/coccinelle/free.cocci.patch/attr.c
SPATCH CAT $^ >.build/contrib/coccinelle/free.cocci.patch
CP .build/contrib/coccinelle/free.cocci.patch contrib/coccinelle/free.cocci.patch
But now we'll instead emit (identical output at the start omitted):
[...]
MKDIR -p .build/contrib/coccinelle/free.cocci.d
SPATCH grep.c >.build/contrib/coccinelle/free.cocci.d/grep.c.patch
SPATCH attr.c >.build/contrib/coccinelle/free.cocci.d/attr.c.patch
SPATCH CAT .build/contrib/coccinelle/free.cocci.d/**.patch >.build/contrib/coccinelle/free.cocci.patch
CP .build/contrib/coccinelle/free.cocci.patch contrib/coccinelle/free.cocci.patch
I.e. we have an "SPATCH" line that makes it clear that we're running
against the "{attr,grep}.c" file. The "SPATCH CAT" is then altered to
correspond to it, showing that we're concatenating the
"free.cocci.d/**.patch" files into one generated "free.cocci.patch" at
the end.
Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
111 lines
3.2 KiB
Makefile
111 lines
3.2 KiB
Makefile
### Remove GNU make implicit rules
|
|
|
|
## This speeds things up since we don't need to look for and stat() a
|
|
## "foo.c,v" every time a rule referring to "foo.c" is in play. See
|
|
## "make -p -f/dev/null | grep ^%::'".
|
|
%:: %,v
|
|
%:: RCS/%,v
|
|
%:: RCS/%
|
|
%:: s.%
|
|
%:: SCCS/s.%
|
|
|
|
## Likewise delete default $(SUFFIXES). See:
|
|
##
|
|
## info make --index-search=.SUFFIXES
|
|
.SUFFIXES:
|
|
|
|
### Flags affecting all rules
|
|
|
|
# A GNU make extension since gmake 3.72 (released in late 1994) to
|
|
# remove the target of rules if commands in those rules fail. The
|
|
# default is to only do that if make itself receives a signal. Affects
|
|
# all targets, see:
|
|
#
|
|
# info make --index-search=.DELETE_ON_ERROR
|
|
.DELETE_ON_ERROR:
|
|
|
|
### Global variables
|
|
|
|
## comma, empty, space: handy variables as these tokens are either
|
|
## special or can be hard to spot among other Makefile syntax.
|
|
comma := ,
|
|
empty :=
|
|
space := $(empty) $(empty)
|
|
|
|
### Quieting
|
|
## common
|
|
QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
|
|
QUIET_SUBDIR1 =
|
|
|
|
ifneq ($(findstring w,$(MAKEFLAGS)),w)
|
|
PRINT_DIR = --no-print-directory
|
|
else # "make -w"
|
|
NO_SUBDIR = :
|
|
endif
|
|
|
|
ifneq ($(findstring s,$(MAKEFLAGS)),s)
|
|
ifndef V
|
|
## common
|
|
QUIET_SUBDIR0 = +@subdir=
|
|
QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
|
|
$(MAKE) $(PRINT_DIR) -C $$subdir
|
|
|
|
QUIET = @
|
|
QUIET_GEN = @echo ' ' GEN $@;
|
|
|
|
QUIET_MKDIR_P_PARENT = @echo ' ' MKDIR -p $(@D);
|
|
|
|
## Used in "Makefile"
|
|
QUIET_CC = @echo ' ' CC $@;
|
|
QUIET_AR = @echo ' ' AR $@;
|
|
QUIET_LINK = @echo ' ' LINK $@;
|
|
QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
|
|
QUIET_CP = @echo ' ' CP $< $@;
|
|
QUIET_LNCP = @echo ' ' LN/CP $@;
|
|
QUIET_XGETTEXT = @echo ' ' XGETTEXT $@;
|
|
QUIET_MSGINIT = @echo ' ' MSGINIT $@;
|
|
QUIET_MSGFMT = @echo ' ' MSGFMT $@;
|
|
QUIET_MSGMERGE = @echo ' ' MSGMERGE $@;
|
|
QUIET_GCOV = @echo ' ' GCOV $@;
|
|
QUIET_SP = @echo ' ' SP $<;
|
|
QUIET_HDR = @echo ' ' HDR $(<:hcc=h);
|
|
QUIET_RC = @echo ' ' RC $@;
|
|
|
|
## Used in "Makefile": SPATCH
|
|
QUIET_SPATCH = @echo ' ' SPATCH $< \>$@;
|
|
QUIET_SPATCH_TEST = @echo ' ' SPATCH TEST $(@:.build/%=%);
|
|
QUIET_SPATCH_CAT = @echo ' ' SPATCH CAT $(@:%.patch=%.d/)\*\*.patch \>$@;
|
|
|
|
## Used in "Documentation/Makefile"
|
|
QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
|
|
QUIET_XMLTO = @echo ' ' XMLTO $@;
|
|
QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
|
|
QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
|
|
QUIET_DBLATEX = @echo ' ' DBLATEX $@;
|
|
QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
|
|
QUIET_GEN = @echo ' ' GEN $@;
|
|
QUIET_STDERR = 2> /dev/null
|
|
|
|
QUIET_LINT_GITLINK = @echo ' ' LINT GITLINK $<;
|
|
QUIET_LINT_MANSEC = @echo ' ' LINT MAN SEC $<;
|
|
QUIET_LINT_MANEND = @echo ' ' LINT MAN END $<;
|
|
|
|
export V
|
|
endif
|
|
endif
|
|
|
|
### Templates
|
|
|
|
## mkdir_p_parent: lazily "mkdir -p" the path needed for a $@
|
|
## file. Uses $(wildcard) to avoid the "mkdir -p" if it's not
|
|
## needed.
|
|
##
|
|
## Is racy, but in a good way; we might redundantly (and safely)
|
|
## "mkdir -p" when running in parallel, but won't need to exhaustively create
|
|
## individual rules for "a" -> "prefix" -> "dir" -> "file" if given a
|
|
## "a/prefix/dir/file". This can instead be inserted at the start of
|
|
## the "a/prefix/dir/file" rule.
|
|
define mkdir_p_parent_template
|
|
$(if $(wildcard $(@D)),,$(QUIET_MKDIR_P_PARENT)$(shell mkdir -p $(@D)))
|
|
endef
|