daemon: allow more than one host address given via --listen
[gitweb.git] / templates / Makefile
index b8352e731bf4baffbda780a1420f52ca4670b828..d22a71a3999b3dc0e99f5e36053447b33f967bd7 100644 (file)
@@ -6,13 +6,24 @@ endif
 
 INSTALL ?= install
 TAR ?= tar
+RM ?= rm -f
 prefix ?= $(HOME)
-template_dir ?= $(prefix)/share/git-core/templates/
+template_instdir ?= $(prefix)/share/git-core/templates
 # DESTDIR=
 
+ifndef SHELL_PATH
+       SHELL_PATH = /bin/sh
+endif
+ifndef PERL_PATH
+       PERL_PATH = perl
+endif
+
+SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
+PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
+
 # 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
 
@@ -22,7 +33,7 @@ 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 && \
@@ -30,9 +41,14 @@ boilerplates.made : $(bpsrc)
                dir=`expr "$$dst" : '\(.*\)/'` && \
                mkdir -p blt/$$dir && \
                case "$$boilerplate" in \
-               *--) ;; \
-               *) cp $$boilerplate blt/$$dst ;; \
-               esac || exit; \
+               *--) continue;; \
+               esac && \
+               sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
+                   -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
+                   -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' $$boilerplate > \
+                       blt/$$dst && \
+               if test -x "$$boilerplate"; then rx=rx; else rx=r; fi && \
+               chmod a+$$rx "blt/$$dst" || exit; \
        done && \
        date >$@
 
@@ -42,9 +58,9 @@ custom:
        $(QUIET): no custom templates yet
 
 clean:
-       rm -rf blt boilerplates.made
+       $(RM) -r blt boilerplates.made
 
 install: all
-       $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(template_dir_SQ)'
+       $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)'
        (cd blt && $(TAR) cf - .) | \
-       (cd '$(DESTDIR_SQ)$(template_dir_SQ)' && $(TAR) xf -)
+       (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xof -)