summaryrefslogtreecommitdiff
path: root/templates/Makefile
diff options
context:
space:
mode:
authorBen Walton <bwalton@artsci.utoronto.ca>2010-03-20 10:48:08 -0400
committerJunio C Hamano <gitster@pobox.com>2010-03-20 09:03:52 -0700
commit502be959531b34e2d9283213b7bca51842639240 (patch)
treedfa1e75d548773be3c947021cbb7bbabb070a3e5 /templates/Makefile
parentf1ba1c90e1704e937ff59ee510a8d46a5ab52a1a (diff)
downloadgit-502be959531b34e2d9283213b7bca51842639240.tar.gz
Make templates honour SHELL_PATH and PERL_PATH
The hook script templates were hard coded to use /bin/sh and perl. This patch ensures that they use the same tools specified for the rest of the suite. The impetus for the change was noticing that, as shipped, some of the hooks used shell constructs that wouldn't work under Solaris' /bin/sh (eg: $(cmd...) substitutions). Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'templates/Makefile')
-rw-r--r--templates/Makefile17
1 files changed, 15 insertions, 2 deletions
diff --git a/templates/Makefile b/templates/Makefile
index 408f0137a8..d22a71a399 100644
--- a/templates/Makefile
+++ b/templates/Makefile
@@ -11,6 +11,16 @@ prefix ?= $(HOME)
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_instdir_SQ = $(subst ','\'',$(template_instdir))
@@ -33,8 +43,11 @@ boilerplates.made : $(bpsrc)
case "$$boilerplate" in \
*--) continue;; \
esac && \
- cp $$boilerplate blt/$$dst && \
- if test -x "blt/$$dst"; then rx=rx; else rx=r; fi && \
+ 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 >$@