2022-03-03 17:04:14 +01:00
|
|
|
### 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.%
|
|
|
|
|
Makefile: move ".SUFFIXES" rule to shared.mak
This was added in 30248886ce8 (Makefile: disable default implicit
rules, 2010-01-26), let's move it to the top of "shared.mak" so it'll
apply to all our Makefiles.
This doesn't benefit the main Makefile at all, since it already had
the rule, but since we're including shared.mak in other Makefiles
starts to benefit them. E.g. running the 'man" target is now faster:
$ git -c hyperfine.hook.setup= hyperfine -L rev HEAD~1,HEAD~0 -s 'make -C Documentation man' 'make -C Documentation -j1 man'
Benchmark 1: make -C Documentation -j1 man' in 'HEAD~1
Time (mean ± σ): 121.7 ms ± 8.8 ms [User: 105.8 ms, System: 18.6 ms]
Range (min … max): 112.8 ms … 148.4 ms 26 runs
Benchmark 2: make -C Documentation -j1 man' in 'HEAD~0
Time (mean ± σ): 97.5 ms ± 8.0 ms [User: 80.1 ms, System: 20.1 ms]
Range (min … max): 89.8 ms … 111.8 ms 32 runs
Summary
'make -C Documentation -j1 man' in 'HEAD~0' ran
1.25 ± 0.14 times faster than 'make -C Documentation -j1 man' in 'HEAD~1'
The reason for that can be seen when comparing that run with
"--debug=a". Without this change making a target like "git-status.1"
will cause "make" to consider not only "git-status.txt", but
"git-status.txt.o", as well as numerous other implicit suffixes such
as ".c", ".cc", ".cpp" etc. See [1] for a more detailed before/after
example.
So this is causing us to omit a bunch of work we didn't need to
do. For making "git-status.1" the "--debug=a" output is reduced from
~140k lines to ~6k.
1. https://lore.kernel.org/git/220222.86bkyz875k.gmgdl@evledraar.gmail.com/
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-03-03 17:04:16 +01:00
|
|
|
## Likewise delete default $(SUFFIXES). See:
|
|
|
|
##
|
|
|
|
## info make --index-search=.SUFFIXES
|
|
|
|
.SUFFIXES:
|
|
|
|
|
Makefiles: add "shared.mak", move ".DELETE_ON_ERROR" to it
We have various behavior that's shared across our Makefiles, or that
really should be (e.g. via defined templates). Let's create a
top-level "shared.mak" to house those sorts of things, and start by
adding the ".DELETE_ON_ERROR" flag to it.
See my own 7b76d6bf221 (Makefile: add and use the ".DELETE_ON_ERROR"
flag, 2021-06-29) and db10fc6c09f (doc: simplify Makefile using
.DELETE_ON_ERROR, 2021-05-21) for the addition and use of the
".DELETE_ON_ERROR" flag.
I.e. this changes the behavior of existing rules in the altered
Makefiles (except "Makefile" & "Documentation/Makefile"). I'm
confident that this is safe having read the relevant rules in those
Makfiles, and as the GNU make manual notes that it isn't the default
behavior is out of an abundance of backwards compatibility
caution. From edition 0.75 of its manual, covering GNU make 4.3:
[Enabling '.DELETE_ON_ERROR' is] almost always what you want
'make' to do, but it is not historical practice; so for
compatibility, you must explicitly request it.
This doesn't introduce a bug by e.g. having this
".DELETE_ON_ERROR" flag only apply to this new shared.mak, Makefiles
have no such scoping semantics.
It does increase the danger that any Makefile without an explicit "The
default target of this Makefile is..." snippet to define the default
target as "all" could have its default rule changed if our new
shared.mak ever defines a "real" rule. In subsequent commits we'll be
careful not to do that, and such breakage would be obvious e.g. in the
case of "make -C t".
We might want to make that less fragile still (e.g. by using
".DEFAULT_GOAL" as noted in the preceding commit), but for now let's
simply include "shared.mak" without adding that boilerplate to all the
Makefiles that don't have it already. Most of those are already
exposed to that potential caveat e.g. due to including "config.mak*".
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-03-03 17:04:13 +01:00
|
|
|
### 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:
|
2022-03-03 17:04:17 +01:00
|
|
|
|
|
|
|
### 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)
|
2022-03-03 17:04:18 +01:00
|
|
|
|
|
|
|
### 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 $@;
|
|
|
|
|
|
|
|
## Used in "Makefile"
|
|
|
|
QUIET_CC = @echo ' ' CC $@;
|
|
|
|
QUIET_AR = @echo ' ' AR $@;
|
|
|
|
QUIET_LINK = @echo ' ' LINK $@;
|
|
|
|
QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
|
|
|
|
QUIET_LNCP = @echo ' ' LN/CP $@;
|
|
|
|
QUIET_XGETTEXT = @echo ' ' XGETTEXT $@;
|
|
|
|
QUIET_MSGFMT = @echo ' ' MSGFMT $@;
|
|
|
|
QUIET_GCOV = @echo ' ' GCOV $@;
|
|
|
|
QUIET_SP = @echo ' ' SP $<;
|
|
|
|
QUIET_HDR = @echo ' ' HDR $(<:hcc=h);
|
|
|
|
QUIET_RC = @echo ' ' RC $@;
|
|
|
|
QUIET_SPATCH = @echo ' ' SPATCH $<;
|
|
|
|
|
|
|
|
## 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
|