templates / Makefileon commit i18n: git-log basic messages (5c5f1d7)
   1# make and install sample templates
   2
   3ifndef V
   4        QUIET = @
   5endif
   6
   7INSTALL ?= install
   8TAR ?= tar
   9RM ?= rm -f
  10prefix ?= $(HOME)
  11template_instdir ?= $(prefix)/share/git-core/templates
  12# DESTDIR=
  13
  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
  24# Shell quote (do not use $(call) to accommodate ancient setups);
  25DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
  26template_instdir_SQ = $(subst ','\'',$(template_instdir))
  27
  28all: 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
  34bpsrc = $(filter-out %~,$(wildcard *--*))
  35boilerplates.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.
  57custom:
  58        $(QUIET): no custom templates yet
  59
  60clean:
  61        $(RM) -r blt boilerplates.made
  62
  63install: 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 -)