Merge branch 'sg/t3701-tighten-trace' into maint
[git/git.git] / templates / Makefile
1 # make and install sample templates
2
3 ifndef V
4 QUIET = @
5 endif
6
7 INSTALL ?= install
8 TAR ?= tar
9 RM ?= rm -f
10 prefix ?= $(HOME)
11 template_instdir ?= $(prefix)/share/git-core/templates
12 # DESTDIR=
13
14 ifndef SHELL_PATH
15 SHELL_PATH = /bin/sh
16 endif
17 ifndef PERL_PATH
18 PERL_PATH = perl
19 endif
20
21 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
22 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
23
24 # Shell quote (do not use $(call) to accommodate ancient setups);
25 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
26 template_instdir_SQ = $(subst ','\'',$(template_instdir))
27
28 all: boilerplates.made custom
29
30 # Put templates that can be copied straight from the source
31 # in a file direc--tory--file in the source. They will be
32 # just copied to the destination.
33
34 bpsrc = $(filter-out %~,$(wildcard *--*))
35 boilerplates.made : $(bpsrc)
36 $(QUIET)umask 022 && ls *--* 2>/dev/null | \
37 while read boilerplate; \
38 do \
39 case "$$boilerplate" in *~) continue ;; esac && \
40 dst=`echo "$$boilerplate" | sed -e 's|^this|.|;s|--|/|g'` && \
41 dir=`expr "$$dst" : '\(.*\)/'` && \
42 mkdir -p blt/$$dir && \
43 case "$$boilerplate" in \
44 *--) continue;; \
45 esac && \
46 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
47 -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
48 -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' $$boilerplate > \
49 blt/$$dst && \
50 if test -x "$$boilerplate"; then rx=rx; else rx=r; fi && \
51 chmod a+$$rx "blt/$$dst" || exit; \
52 done && \
53 date >$@
54
55 # If you need build-tailored templates, build them into blt/
56 # directory yourself here.
57 custom:
58 $(QUIET): no custom templates yet
59
60 clean:
61 $(RM) -r blt boilerplates.made
62
63 install: all
64 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)'
65 (cd blt && $(TAR) cf - .) | \
66 (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xof -)