Merge branch 'cc/partial-clone-doc-typofix'
[git/git.git] / templates / Makefile
CommitLineData
d3af621b 1# make and install sample templates
8d5afef0 2
2314c947 3ifndef V
74f2b2a8
SP
4 QUIET = @
5endif
6
229a7ed7
JH
7INSTALL ?= install
8TAR ?= tar
4cb08df5 9RM ?= rm -f
229a7ed7 10prefix ?= $(HOME)
0b50b860 11template_instdir ?= $(prefix)/share/git-core/templates
a682ef9f 12# DESTDIR=
8d5afef0 13
502be959
BW
14ifndef SHELL_PATH
15 SHELL_PATH = /bin/sh
16endif
17ifndef PERL_PATH
18 PERL_PATH = perl
19endif
20
21SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
22PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
23
3dff5379 24# Shell quote (do not use $(call) to accommodate ancient setups);
7ffe7098 25DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
0b50b860 26template_instdir_SQ = $(subst ','\'',$(template_instdir))
4769948a 27
8c512428 28all: boilerplates.made custom
d3af621b
JH
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.
8c512428
JH
33
34bpsrc = $(filter-out %~,$(wildcard *--*))
35boilerplates.made : $(bpsrc)
d8bdc492 36 $(QUIET)umask 022 && ls *--* 2>/dev/null | \
d3af621b
JH
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" : '\(.*\)/'` && \
d8bdc492 42 mkdir -p blt/$$dir && \
d3af621b 43 case "$$boilerplate" in \
d8bdc492
JH
44 *--) continue;; \
45 esac && \
502be959
BW
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 && \
d8bdc492 51 chmod a+$$rx "blt/$$dst" || exit; \
74f2b2a8 52 done && \
8c512428 53 date >$@
d3af621b
JH
54
55# If you need build-tailored templates, build them into blt/
56# directory yourself here.
57custom:
74f2b2a8 58 $(QUIET): no custom templates yet
d3af621b 59
8d5afef0 60clean:
4cb08df5 61 $(RM) -r blt boilerplates.made
8d5afef0 62
d3af621b 63install: all
0b50b860 64 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)'
229a7ed7 65 (cd blt && $(TAR) cf - .) | \
36e56106 66 (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xof -)