Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Daniel Hahler February 06, 2014
file 83 lines (67 sloc) 2.217 kb
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
PLUGIN = $(wildcard plugin/*.vim)
SOURCES = $(PLUGIN)
LIB = $(wildcard autoload/*.vim)
SOURCES += $(LIB)
DOC = $(wildcard doc/*.txt)
SOURCES += $(DOC)
#NAME = $(shell basename "$$PWD")
NAME = delimitMate
VERSION = $(shell $(SED) -n -e '/Current \+release/{s/^ \+\([0-9.]\+\).*/\1/;p;}' $(firstword $(DOC)))
FILENAME = $(NAME)-$(VERSION)
DESTDIR = $(HOME)/.vim
VIM = vim
SED = $(shell command -v gsed || command -v sed)
PERL = perl
comma := ,
empty :=
space := $(empty) $(empty)

.PHONY: version clean distclean undo release test install uninstall

all: zip gzip
dist: version all
vimball: $(FILENAME).vmb
zip: $(FILENAME).zip $(FILENAME).vmb.zip
gzip: $(FILENAME).tar.gz $(FILENAME).vmb.gz

clean:
rm -f */*.orig *.~* .VimballRecord *.zip *.gz *.vmb

distclean: clean
-zsh -c 'setopt extendedglob; rm -f ^(README.md|Makefile)'
-zsh -c 'setopt extendedglob; rm -f .^(git|README.md|Makefile)*'

undo:
for i in */*.orig; do mv -f "$$i" "$${i%.*}"; done

version:
$(PERL) -i.orig -pne 'if (/^"\sVersion:/) {s/(\d+\.\S+)/$(VERSION)/}' $(PLUGIN) $(LIB)
$(PERL) -i.orig -pne \
'if (/let\sdelimitMate_version/) {s/"(\d+\.\S+)"/"$(VERSION)"/}' $(PLUGIN)
$(PERL) -i.orig -pne 'if (/beasts/) {s/(v\d+\.\S+)/v$(VERSION)/}' $(DOC)
$(PERL) -i.orig -MPOSIX -pne \
'if (/^"\sModified:/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/e}' \
$(PLUGIN) $(LIB)
$(PERL) -i.orig -MPOSIX -pne \
'if (/^\s+$(VERSION)\s+\d+-\d+-\d+\s+\*/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/}' \
$(DOC)

test:
runVimTests -0 test

install: $(SOURCES)
for dir in $(^D);\
  do install -d -m 0755 $(DESTDIR)$(PREFIX)/$$dir;\
done;\
for file in $^;\
  do install -m 0644 $$file $(DESTDIR)$(PREFIX)/$$file;\
done;

uninstall:
for file in $(SOURCES);\
  do rm -f $(DESTDIR)$(PREFIX)/$$file;\
done;

%.vmb: $(SOURCES)
$(VIM) -N -es -u NORC \
  -c 'call setline(1,["$(subst $(space),"$(comma)",$^)"])'\
  -c "%MkVimball! $(basename $@) ." -c 'q!'

%.vmb.zip: vimball
zip $@ $(basename $@)

%.zip: $(SOURCES)
zip $@ $^

%.vmb.gz: vimball
gzip -f $(basename $@)

%.tar.gz: $(SOURCES)
tar -cvzf $@ $^

# vim:ts=2:sw=2
Something went wrong with that request. Please try again.