]>
Commit | Line | Data |
---|---|---|
8df786d2 ÆAB |
1 | # Import tree-wide shared Makefile behavior and libraries |
2 | include ../shared.mak | |
3 | ||
d3af621b | 4 | # make and install sample templates |
229a7ed7 JH |
5 | INSTALL ?= install |
6 | TAR ?= tar | |
4cb08df5 | 7 | RM ?= rm -f |
229a7ed7 | 8 | prefix ?= $(HOME) |
0b50b860 | 9 | template_instdir ?= $(prefix)/share/git-core/templates |
a682ef9f | 10 | # DESTDIR= |
8d5afef0 | 11 | |
502be959 BW |
12 | ifndef SHELL_PATH |
13 | SHELL_PATH = /bin/sh | |
14 | endif | |
15 | ifndef PERL_PATH | |
16 | PERL_PATH = perl | |
17 | endif | |
18 | ||
19 | SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) | |
20 | PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) | |
21 | ||
3dff5379 | 22 | # Shell quote (do not use $(call) to accommodate ancient setups); |
7ffe7098 | 23 | DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) |
0b50b860 | 24 | template_instdir_SQ = $(subst ','\'',$(template_instdir)) |
4769948a | 25 | |
8c512428 | 26 | all: boilerplates.made custom |
d3af621b JH |
27 | |
28 | # Put templates that can be copied straight from the source | |
29 | # in a file direc--tory--file in the source. They will be | |
30 | # just copied to the destination. | |
8c512428 JH |
31 | |
32 | bpsrc = $(filter-out %~,$(wildcard *--*)) | |
33 | boilerplates.made : $(bpsrc) | |
d8bdc492 | 34 | $(QUIET)umask 022 && ls *--* 2>/dev/null | \ |
d3af621b JH |
35 | while read boilerplate; \ |
36 | do \ | |
37 | case "$$boilerplate" in *~) continue ;; esac && \ | |
38 | dst=`echo "$$boilerplate" | sed -e 's|^this|.|;s|--|/|g'` && \ | |
39 | dir=`expr "$$dst" : '\(.*\)/'` && \ | |
d8bdc492 | 40 | mkdir -p blt/$$dir && \ |
d3af621b | 41 | case "$$boilerplate" in \ |
d8bdc492 JH |
42 | *--) continue;; \ |
43 | esac && \ | |
502be959 BW |
44 | sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ |
45 | -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \ | |
46 | -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' $$boilerplate > \ | |
47 | blt/$$dst && \ | |
48 | if test -x "$$boilerplate"; then rx=rx; else rx=r; fi && \ | |
d8bdc492 | 49 | chmod a+$$rx "blt/$$dst" || exit; \ |
74f2b2a8 | 50 | done && \ |
8c512428 | 51 | date >$@ |
d3af621b JH |
52 | |
53 | # If you need build-tailored templates, build them into blt/ | |
54 | # directory yourself here. | |
55 | custom: | |
74f2b2a8 | 56 | $(QUIET): no custom templates yet |
d3af621b | 57 | |
8d5afef0 | 58 | clean: |
4cb08df5 | 59 | $(RM) -r blt boilerplates.made |
8d5afef0 | 60 | |
d3af621b | 61 | install: all |
0b50b860 | 62 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)' |
229a7ed7 | 63 | (cd blt && $(TAR) cf - .) | \ |
36e56106 | 64 | (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xof -) |