Makefile 3.05 KB
Newer Older
François Perrad's avatar
François Perrad committed
1

François Perrad's avatar
François Perrad committed
2
3
4
ifeq ($(wildcard bed),bed)
LUA     := $(CURDIR)/bed/bin/lua
else
François Perrad's avatar
François Perrad committed
5
LUA     := lua
François Perrad's avatar
François Perrad committed
6
endif
François Perrad's avatar
François Perrad committed
7
VERSION := $(shell LUA_PATH=";;src/?.lua" $(LUA) -e "m = require [[MessagePack]]; print(m._VERSION)")
François Perrad's avatar
François Perrad committed
8
9
10
TARBALL := lua-messagepack-$(VERSION).tar.gz
REV     := 1

François Perrad's avatar
François Perrad committed
11
LUAVER  := 5.2
François Perrad's avatar
François Perrad committed
12
13
14
15
16
PREFIX  := /usr/local
DPREFIX := $(DESTDIR)$(PREFIX)
LIBDIR  := $(DPREFIX)/share/lua/$(LUAVER)
INSTALL := install

François Perrad's avatar
François Perrad committed
17
18
ifeq ($(LUAVER),5.3)
SRC     := src5.3
François Perrad's avatar
François Perrad committed
19
20
else ifeq ($(LUAVER),5.4)
SRC     := src5.3
François Perrad's avatar
François Perrad committed
21
22
23
24
else
SRC     := src
endif

François Perrad's avatar
François Perrad committed
25
26
BED_OPTS:= --lua latest

François Perrad's avatar
François Perrad committed
27
28
29
30
all:
	@echo "Nothing to build here, you can just make install"

install:
François Perrad's avatar
François Perrad committed
31
	$(INSTALL) -m 644 -D $(SRC)/MessagePack.lua         $(LIBDIR)/MessagePack.lua
François Perrad's avatar
François Perrad committed
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

uninstall:
	rm -f $(LIBDIR)/MessagePack.lua

manifest_pl := \
use strict; \
use warnings; \
my @files = qw{MANIFEST}; \
while (<>) { \
    chomp; \
    next if m{^\.}; \
    next if m{^rockspec/}; \
    push @files, $$_; \
} \
print join qq{\n}, sort @files;

rockspec_pl := \
use strict; \
use warnings; \
use Digest::MD5; \
open my $$FH, q{<}, q{$(TARBALL)} \
    or die qq{Cannot open $(TARBALL) ($$!)}; \
binmode $$FH; \
my %config = ( \
    version => q{$(VERSION)}, \
    rev     => q{$(REV)}, \
    md5     => Digest::MD5->new->addfile($$FH)->hexdigest(), \
); \
close $$FH; \
while (<>) { \
    s{@(\w+)@}{$$config{$$1}}g; \
    print; \
}

version:
	@echo $(VERSION)

CHANGES:
	perl -i.bak -pe "s{^$(VERSION).*}{q{$(VERSION)  }.localtime()}e" CHANGES

tag:
	git tag -a -m 'tag release $(VERSION)' $(VERSION)

François Perrad's avatar
François Perrad committed
75
MANIFEST:
François Perrad's avatar
François Perrad committed
76
77
78
79
	git ls-files | perl -e '$(manifest_pl)' > MANIFEST

$(TARBALL): MANIFEST
	[ -d lua-MessagePack-$(VERSION) ] || ln -s . lua-MessagePack-$(VERSION)
François Perrad's avatar
typo    
François Perrad committed
80
	perl -ne 'print qq{lua-MessagePack-$(VERSION)/$$_};' MANIFEST | \
François Perrad's avatar
François Perrad committed
81
82
83
84
85
86
87
	    tar -zc -T - -f $(TARBALL)
	rm lua-MessagePack-$(VERSION)

dist: $(TARBALL)

rockspec: $(TARBALL)
	perl -e '$(rockspec_pl)' rockspec.in > rockspec/lua-messagepack-$(VERSION)-$(REV).rockspec
François Perrad's avatar
François Perrad committed
88
89
90
91
92
	perl -e '$(rockspec_pl)' rockspec.lua53.in > rockspec/lua-messagepack-lua53-$(VERSION)-$(REV).rockspec

rock:
	luarocks pack rockspec/lua-messagepack-$(VERSION)-$(REV).rockspec
	luarocks pack rockspec/lua-messagepack-lua53-$(VERSION)-$(REV).rockspec
François Perrad's avatar
François Perrad committed
93

François Perrad's avatar
François Perrad committed
94
95
96
97
98
99
100
101
102
bed:
	hererocks bed $(BED_OPTS) --no-readline --luarocks latest --verbose
	bed/bin/luarocks install lua-testmore
	bed/bin/luarocks install lua-coat
	bed/bin/luarocks install lbc
	bed/bin/luarocks install luacov
	hererocks bed --show
	bed/bin/luarocks list

François Perrad's avatar
François Perrad committed
103
104
105
check: test

test:
François Perrad's avatar
François Perrad committed
106
	LUA_PATH=";;$(CURDIR)/$(SRC)/?.lua" \
François Perrad's avatar
François Perrad committed
107
		prove --exec=$(LUA) test/*.lua
François Perrad's avatar
François Perrad committed
108

François Perrad's avatar
François Perrad committed
109
luacheck:
François Perrad's avatar
François Perrad committed
110
	luacheck --std=max --codes src --ignore 211/_ENV 212 213 311/j 631
Pierre Chapuis's avatar
Pierre Chapuis committed
111
	luacheck --std=max --codes src5.3 --ignore 211/_ENV 212 213 311/j
François Perrad's avatar
François Perrad committed
112
	luacheck --std=max --config .test.luacheckrc test
François Perrad's avatar
François Perrad committed
113

François Perrad's avatar
François Perrad committed
114
coverage:
François Perrad's avatar
François Perrad committed
115
116
	rm -f luacov.*
	-LUA_PATH=";;$(CURDIR)/$(SRC)/?.lua" \
François Perrad's avatar
François Perrad committed
117
		prove --exec="$(LUA) -lluacov" test/*.lua
François Perrad's avatar
François Perrad committed
118
119
	luacov-console $(CURDIR)/src
	luacov-console -s $(CURDIR)/src
François Perrad's avatar
François Perrad committed
120
121
	luacov-console test
	luacov-console -s test
François Perrad's avatar
François Perrad committed
122
123
124
125

README.html: README.md
	Markdown.pl README.md > README.html

François Perrad's avatar
François Perrad committed
126
127
pages:
	mkdocs build -d public
François Perrad's avatar
François Perrad committed
128

François Perrad's avatar
François Perrad committed
129
clean:
François Perrad's avatar
François Perrad committed
130
	rm -f MANIFEST *.bak luacov.* README.html
François Perrad's avatar
François Perrad committed
131
132

realclean: clean
François Perrad's avatar
François Perrad committed
133
	rm -rf bed
François Perrad's avatar
François Perrad committed
134
135
136

.PHONY: test rockspec CHANGES