| 1 | # The default target of this Makefile is... |
| 2 | all:: |
| 3 | |
| 4 | # Import tree-wide shared Makefile behavior and libraries |
| 5 | include ../shared.mak |
| 6 | |
| 7 | # make and install sample templates |
| 8 | INSTALL ?= install |
| 9 | TAR ?= tar |
| 10 | RM ?= rm -f |
| 11 | prefix ?= $(HOME) |
| 12 | template_instdir ?= $(prefix)/share/git-core/templates |
| 13 | # DESTDIR= |
| 14 | |
| 15 | ifndef SHELL_PATH |
| 16 | SHELL_PATH = /bin/sh |
| 17 | endif |
| 18 | ifndef PERL_PATH |
| 19 | PERL_PATH = perl |
| 20 | endif |
| 21 | |
| 22 | SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) |
| 23 | PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) |
| 24 | |
| 25 | # Shell quote (do not use $(call) to accommodate ancient setups); |
| 26 | DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) |
| 27 | template_instdir_SQ = $(subst ','\'',$(template_instdir)) |
| 28 | |
| 29 | all:: boilerplates.made custom |
| 30 | |
| 31 | # Put templates that can be copied straight from the source |
| 32 | # in a file direc--tory--file in the source. They will be |
| 33 | # just copied to the destination. |
| 34 | |
| 35 | TEMPLATES = |
| 36 | TEMPLATES += description |
| 37 | TEMPLATES += hooks/applypatch-msg.sample |
| 38 | TEMPLATES += hooks/commit-msg.sample |
| 39 | TEMPLATES += hooks/fsmonitor-watchman.sample |
| 40 | TEMPLATES += hooks/post-update.sample |
| 41 | TEMPLATES += hooks/pre-applypatch.sample |
| 42 | TEMPLATES += hooks/pre-commit.sample |
| 43 | TEMPLATES += hooks/pre-merge-commit.sample |
| 44 | TEMPLATES += hooks/prepare-commit-msg.sample |
| 45 | TEMPLATES += hooks/pre-push.sample |
| 46 | TEMPLATES += hooks/pre-rebase.sample |
| 47 | TEMPLATES += hooks/pre-receive.sample |
| 48 | TEMPLATES += hooks/push-to-checkout.sample |
| 49 | TEMPLATES += hooks/sendemail-validate.sample |
| 50 | TEMPLATES += hooks/update.sample |
| 51 | TEMPLATES += info/exclude |
| 52 | |
| 53 | boilerplates.made: $(TEMPLATES) |
| 54 | $(QUIET)umask 022 && for template in $(TEMPLATES); \ |
| 55 | do \ |
| 56 | dir=$$(dirname "$$template") && \ |
| 57 | mkdir -p blt/$$dir && \ |
| 58 | sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ |
| 59 | -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \ |
| 60 | -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' $$template > \ |
| 61 | blt/$$template && \ |
| 62 | if test -x "$$template"; then rx=rx; else rx=r; fi && \ |
| 63 | chmod a+$$rx "blt/$$template" || exit; \ |
| 64 | done && \ |
| 65 | date >$@ |
| 66 | |
| 67 | # If you need build-tailored templates, build them into blt/ |
| 68 | # directory yourself here. |
| 69 | custom: |
| 70 | $(QUIET): no custom templates yet |
| 71 | |
| 72 | clean: |
| 73 | $(RM) -r blt boilerplates.made |
| 74 | |
| 75 | install: all |
| 76 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)' |
| 77 | (cd blt && $(TAR) cf - .) | \ |
| 78 | (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xof -) |