git-send-email: add a new sendemail.to configuration variable
[gitweb.git] / templates / Makefile
index 12433519eefef9bbef1c74729a1df11fa8ab34f4..6f4dbd362fffdd85570c2223ad7d98015e7970ae 100644 (file)
@@ -1,19 +1,51 @@
-# make
+# make and install sample templates
 
-INSTALL=install
-prefix=$(HOME)
-etcdir=$(prefix)/etc
-etcgitdir=$(etcdir)/git-core
-templatedir=$(etcgitdir)/templates
-# dest=
+ifndef V
+       QUIET = @
+endif
+
+INSTALL ?= install
+TAR ?= tar
+RM ?= rm -f
+prefix ?= $(HOME)
+template_dir ?= $(prefix)/share/git-core/templates
+# DESTDIR=
+
+# Shell quote (do not use $(call) to accommodate ancient setups);
+DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
+template_dir_SQ = $(subst ','\'',$(template_dir))
+
+all: boilerplates.made custom
+
+# Put templates that can be copied straight from the source
+# in a file direc--tory--file in the source.  They will be
+# just copied to the destination.
+
+bpsrc = $(filter-out %~,$(wildcard *--*))
+boilerplates.made : $(bpsrc)
+       $(QUIET)ls *--* 2>/dev/null | \
+       while read boilerplate; \
+       do \
+               case "$$boilerplate" in *~) continue ;; esac && \
+               dst=`echo "$$boilerplate" | sed -e 's|^this|.|;s|--|/|g'` && \
+               dir=`expr "$$dst" : '\(.*\)/'` && \
+               mkdir -p blt/$$dir && \
+               case "$$boilerplate" in \
+               *--) ;; \
+               *) cp $$boilerplate blt/$$dst ;; \
+               esac || exit; \
+       done && \
+       date >$@
+
+# If you need build-tailored templates, build them into blt/
+# directory yourself here.
+custom:
+       $(QUIET): no custom templates yet
 
-all:
 clean:
+       $(RM) -r blt boilerplates.made
 
-install:
-       $(INSTALL) -d -m755 $(dest)$(templatedir)/hooks/
-       $(foreach s,$(wildcard hooks--*),\
-               $(INSTALL) -m644 $s \
-               $(dest)$(templatedir)/hooks/$(patsubst hooks--%,%,$s);)
-       $(INSTALL) -d -m755 $(dest)$(templatedir)/info
-       $(INSTALL) -d -m755 $(dest)$(templatedir)/branches
+install: all
+       $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(template_dir_SQ)'
+       (cd blt && $(TAR) cf - .) | \
+       (cd '$(DESTDIR_SQ)$(template_dir_SQ)' && $(TAR) xf -)