templates / Makefileon commit Merge branch 'sp/maint-bash-completion-optim' (10ce020)
   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
  14# Shell quote (do not use $(call) to accommodate ancient setups);
  15DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
  16template_instdir_SQ = $(subst ','\'',$(template_instdir))
  17
  18all: boilerplates.made custom
  19
  20# Put templates that can be copied straight from the source
  21# in a file direc--tory--file in the source.  They will be
  22# just copied to the destination.
  23
  24bpsrc = $(filter-out %~,$(wildcard *--*))
  25boilerplates.made : $(bpsrc)
  26        $(QUIET)ls *--* 2>/dev/null | \
  27        while read boilerplate; \
  28        do \
  29                case "$$boilerplate" in *~) continue ;; esac && \
  30                dst=`echo "$$boilerplate" | sed -e 's|^this|.|;s|--|/|g'` && \
  31                dir=`expr "$$dst" : '\(.*\)/'` && \
  32                $(INSTALL) -d -m 755 blt/$$dir && \
  33                case "$$boilerplate" in \
  34                *--) ;; \
  35                *) cp -p $$boilerplate blt/$$dst ;; \
  36                esac || exit; \
  37        done && \
  38        date >$@
  39
  40# If you need build-tailored templates, build them into blt/
  41# directory yourself here.
  42custom:
  43        $(QUIET): no custom templates yet
  44
  45clean:
  46        $(RM) -r blt boilerplates.made
  47
  48install: all
  49        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)'
  50        (cd blt && $(TAR) cf - .) | \
  51        (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xf -)