1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
NAME=zsh-syntax-highlighting
include /usr/share/dpkg/pkg-info.mk
# Munge $(DEB_VERSION) in accordance with DEP-14. (This isn't a complete
# DEP-14 implementation — we don't handle adjacent dots and trailing dots — but
# what we do should be sufficient in practice.)
DEB_VERSION_FOR_GIT_TAGS=$(shell printf %s "$(DEB_VERSION)" | tr \~ _ | tr : %)
DPKG_VENDOR=$(shell dpkg-vendor --query vendor | env LC_ALL=C tr A-Z a-z | env LC_ALL=C tr -d -c '[:alnum:]')
ifeq "$(shell dpkg-parsechangelog -SDistribution)" "UNRELEASED"
DOTVERSION_SUFFIX="+unreleased"
else
DOTVERSION_SUFFIX=""
endif
INSTALL?=install -c
PREFIX?=/usr/local
SHARE_DIR?=$(DESTDIR)$(PREFIX)/share/$(NAME)
DOC_DIR?=$(DESTDIR)$(PREFIX)/share/doc/$(NAME)
ZSH?=zsh # zsh binary to run tests with
all:
cd docs && \
cp highlighters.md all.md && \
printf '\n\nIndividual highlighters documentation\n=====================================' >> all.md && \
for doc in highlighters/*.md; do printf '\n\n'; cat "$$doc"; done >> all.md
install: all
$(INSTALL) -d $(SHARE_DIR)
$(INSTALL) -d $(DOC_DIR)
cp .version zsh-syntax-highlighting.zsh $(SHARE_DIR)
cp COPYING.md README.md changelog.md $(DOC_DIR)
sed -e '1s/ .*//' -e '/^\[build-status-[a-z]*\]: /d' < README.md > $(DOC_DIR)/README.md
printf "%s_%s%s\n" "$(DEB_VERSION)" "$(DPKG_VENDOR)" "$(DOTVERSION_SUFFIX)" \
> $(SHARE_DIR)/.version
ifeq "$(shell dpkg-parsechangelog -SDistribution)" "UNRELEASED"
# Unreleased means we're inside the packaging's git repository; assert that:
[ x"true" = x"`git rev-parse --is-inside-work-tree 2>/dev/null`" ]
git rev-parse HEAD > $(SHARE_DIR)/.revision-hash
else
# We're building a released package. That means git might not be available,
# but also means the code we are building has been tagged. That allows us
# to set .revision-hash to a valid gitrevisions(7) expression: we set it to
# "debian/0.3.0-1", the tag name of the release we are building.
printf "%s/%s\n" "$(DPKG_VENDOR)" "$(DEB_VERSION_FOR_GIT_TAGS)" \
> $(SHARE_DIR)/.revision-hash
endif
:
# The [ -e ] check below is to because sh evaluates this with (the moral
# equivalent of) NONOMATCH in effect, and highlighters/*.zsh has no matches.
for dirname in highlighters highlighters/*/ ; do \
$(INSTALL) -d $(SHARE_DIR)/"$$dirname"; \
for fname in "$$dirname"/*.zsh ; do [ -e "$$fname" ] && cp "$$fname" $(SHARE_DIR)"/$$dirname"; done; \
done
cp -R docs/* $(DOC_DIR)
clean:
rm -f docs/all.md
test:
@$(ZSH) -fc 'echo ZSH_PATCHLEVEL=$$ZSH_PATCHLEVEL'
@result=0; \
for test in highlighters/*; do \
if [ -d $$test/test-data ]; then \
echo "Running test $${test##*/}"; \
env -i QUIET=$$QUIET $${TERM:+"TERM=$$TERM"} $(ZSH) -f tests/test-highlighting.zsh "$${test##*/}"; \
: $$(( result |= $$? )); \
fi \
done; \
exit $$result
quiet-test:
$(MAKE) test QUIET=y
perf:
@result=0; \
for test in highlighters/*; do \
if [ -d $$test/test-data ]; then \
echo "Running test $${test##*/}"; \
$(ZSH) -f tests/test-perfs.zsh "$${test##*/}"; \
: $$(( result |= $$? )); \
fi \
done; \
exit $$result
.PHONY: all install clean test perf
|