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