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 16:04:13 +00:00
|
|
|
# Import tree-wide shared Makefile behavior and libraries
|
|
|
|
include ../shared.mak
|
|
|
|
|
2005-08-06 19:50:14 +00:00
|
|
|
# make and install sample templates
|
2005-09-23 17:41:40 +00:00
|
|
|
INSTALL ?= install
|
|
|
|
TAR ?= tar
|
2007-07-14 17:51:44 +00:00
|
|
|
RM ?= rm -f
|
2005-09-23 17:41:40 +00:00
|
|
|
prefix ?= $(HOME)
|
2008-01-01 21:15:21 +00:00
|
|
|
template_instdir ?= $(prefix)/share/git-core/templates
|
2005-08-04 23:56:38 +00:00
|
|
|
# DESTDIR=
|
2005-08-02 23:45:21 +00:00
|
|
|
|
2010-03-20 14:48:08 +00:00
|
|
|
ifndef SHELL_PATH
|
|
|
|
SHELL_PATH = /bin/sh
|
|
|
|
endif
|
|
|
|
ifndef PERL_PATH
|
|
|
|
PERL_PATH = perl
|
|
|
|
endif
|
|
|
|
|
|
|
|
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
|
|
|
|
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
|
|
|
|
|
2007-02-04 04:49:16 +00:00
|
|
|
# Shell quote (do not use $(call) to accommodate ancient setups);
|
2006-07-29 16:25:03 +00:00
|
|
|
DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
|
2008-01-01 21:15:21 +00:00
|
|
|
template_instdir_SQ = $(subst ','\'',$(template_instdir))
|
2005-10-10 20:50:01 +00:00
|
|
|
|
2005-10-09 01:01:24 +00:00
|
|
|
all: boilerplates.made custom
|
2005-08-06 19:50:14 +00:00
|
|
|
|
|
|
|
# Put templates that can be copied straight from the source
|
|
|
|
# in a file direc--tory--file in the source. They will be
|
|
|
|
# just copied to the destination.
|
2005-10-09 01:01:24 +00:00
|
|
|
|
|
|
|
bpsrc = $(filter-out %~,$(wildcard *--*))
|
|
|
|
boilerplates.made : $(bpsrc)
|
2008-08-22 00:31:50 +00:00
|
|
|
$(QUIET)umask 022 && ls *--* 2>/dev/null | \
|
2005-08-06 19:50:14 +00:00
|
|
|
while read boilerplate; \
|
|
|
|
do \
|
|
|
|
case "$$boilerplate" in *~) continue ;; esac && \
|
|
|
|
dst=`echo "$$boilerplate" | sed -e 's|^this|.|;s|--|/|g'` && \
|
|
|
|
dir=`expr "$$dst" : '\(.*\)/'` && \
|
2008-08-22 00:31:50 +00:00
|
|
|
mkdir -p blt/$$dir && \
|
2005-08-06 19:50:14 +00:00
|
|
|
case "$$boilerplate" in \
|
2008-08-22 00:31:50 +00:00
|
|
|
*--) continue;; \
|
|
|
|
esac && \
|
2010-03-20 14:48:08 +00:00
|
|
|
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
|
|
|
|
-e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
|
|
|
|
-e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' $$boilerplate > \
|
|
|
|
blt/$$dst && \
|
|
|
|
if test -x "$$boilerplate"; then rx=rx; else rx=r; fi && \
|
2008-08-22 00:31:50 +00:00
|
|
|
chmod a+$$rx "blt/$$dst" || exit; \
|
2007-03-06 06:35:01 +00:00
|
|
|
done && \
|
2005-10-09 01:01:24 +00:00
|
|
|
date >$@
|
2005-08-06 19:50:14 +00:00
|
|
|
|
|
|
|
# If you need build-tailored templates, build them into blt/
|
|
|
|
# directory yourself here.
|
|
|
|
custom:
|
2007-03-06 06:35:01 +00:00
|
|
|
$(QUIET): no custom templates yet
|
2005-08-06 19:50:14 +00:00
|
|
|
|
2005-08-02 23:45:21 +00:00
|
|
|
clean:
|
2007-07-14 17:51:44 +00:00
|
|
|
$(RM) -r blt boilerplates.made
|
2005-08-02 23:45:21 +00:00
|
|
|
|
2005-08-06 19:50:14 +00:00
|
|
|
install: all
|
2008-01-01 21:15:21 +00:00
|
|
|
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)'
|
2005-09-23 17:41:40 +00:00
|
|
|
(cd blt && $(TAR) cf - .) | \
|
2009-10-24 13:06:57 +00:00
|
|
|
(cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xof -)
|