templates / Makefileon commit Merge git://git.kernel.org/pub/scm/gitk/gitk (d69dc37)
   1# make and install sample templates
   2
   3INSTALL ?= install
   4TAR ?= tar
   5prefix ?= $(HOME)
   6template_dir ?= $(prefix)/share/git-core/templates/
   7# DESTDIR=
   8
   9# Shell quote;
  10# Result of this needs to be placed inside ''
  11shq = $(subst ','\'',$(1))
  12# This has surrounding ''
  13shellquote = '$(call shq,$(1))'
  14
  15all: boilerplates.made custom
  16
  17# Put templates that can be copied straight from the source
  18# in a file direc--tory--file in the source.  They will be
  19# just copied to the destination.
  20
  21bpsrc = $(filter-out %~,$(wildcard *--*))
  22boilerplates.made : $(bpsrc)
  23        ls *--* 2>/dev/null | \
  24        while read boilerplate; \
  25        do \
  26                case "$$boilerplate" in *~) continue ;; esac && \
  27                dst=`echo "$$boilerplate" | sed -e 's|^this|.|;s|--|/|g'` && \
  28                dir=`expr "$$dst" : '\(.*\)/'` && \
  29                mkdir -p blt/$$dir && \
  30                case "$$boilerplate" in \
  31                *--) ;; \
  32                *) cp $$boilerplate blt/$$dst ;; \
  33                esac || exit; \
  34        done || exit
  35        date >$@
  36
  37# If you need build-tailored templates, build them into blt/
  38# directory yourself here.
  39custom:
  40        : no custom templates yet
  41
  42clean:
  43        rm -rf blt boilerplates.made
  44
  45install: all
  46        $(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(template_dir))
  47        (cd blt && $(TAR) cf - .) | \
  48        (cd $(call shellquote,$(DESTDIR)$(template_dir)) && $(TAR) xf -)