Code

Merge branch 'jc/maint-diff-quiet' into maint
[git.git] / templates / Makefile
index bda9d13505f9dbec8a7864d14c52bbb4827b4f52..a12c6e214e65d39136b1ed41a8ff0ea25e28f91b 100644 (file)
@@ -8,12 +8,12 @@ INSTALL ?= install
 TAR ?= tar
 RM ?= rm -f
 prefix ?= $(HOME)
-template_dir ?= $(prefix)/share/git-core/templates
+template_instdir ?= $(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))
+template_instdir_SQ = $(subst ','\'',$(template_instdir))
 
 all: boilerplates.made custom
 
@@ -23,17 +23,19 @@ all: boilerplates.made custom
 
 bpsrc = $(filter-out %~,$(wildcard *--*))
 boilerplates.made : $(bpsrc)
-       $(QUIET)ls *--* 2>/dev/null | \
+       $(QUIET)umask 022 && 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" : '\(.*\)/'` && \
-               $(INSTALL) -d -m 755 blt/$$dir && \
+               mkdir -p blt/$$dir && \
                case "$$boilerplate" in \
-               *--) ;; \
-               *) cp -p $$boilerplate blt/$$dst ;; \
-               esac || exit; \
+               *--) continue;; \
+               esac && \
+               cp $$boilerplate blt/$$dst && \
+               if test -x "blt/$$dst"; then rx=rx; else rx=r; fi && \
+               chmod a+$$rx "blt/$$dst" || exit; \
        done && \
        date >$@
 
@@ -46,6 +48,6 @@ clean:
        $(RM) -r blt boilerplates.made
 
 install: all
-       $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_dir_SQ)'
+       $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)'
        (cd blt && $(TAR) cf - .) | \
-       (cd '$(DESTDIR_SQ)$(template_dir_SQ)' && umask 022 && $(TAR) xf -)
+       (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xfo -)