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

LUA     := lua
3
VERSION := $(shell cd src && $(LUA) -e "m = require [[Coat.Persistent]]; print(m._VERSION)")
François Perrad's avatar
François Perrad committed
4
TARBALL := lua-coatpersistent-$(VERSION).tar.gz
5
REV     := 1
François Perrad's avatar
François Perrad committed
6

François Perrad's avatar
François Perrad committed
7 8 9 10
LUAVER  := 5.1
PREFIX  := /usr/local
DPREFIX := $(DESTDIR)$(PREFIX)
LIBDIR  := $(DPREFIX)/share/lua/$(LUAVER)
11
INSTALL := install
François Perrad's avatar
François Perrad committed
12

13
all:
François Perrad's avatar
François Perrad committed
14 15
	@echo "Nothing to build here, you can just make install"

François Perrad's avatar
François Perrad committed
16 17 18
install: install.luasql

install.luasql:
19
	$(INSTALL) -m 644 -D src/Coat/Persistent.lua            $(LIBDIR)/Coat/Persistent.lua
François Perrad's avatar
François Perrad committed
20 21

install.lsqlite3:
22
	$(INSTALL) -m 644 -D src.lsqlite3/Coat/Persistent.lua   $(LIBDIR)/Coat/Persistent.lua
François Perrad's avatar
François Perrad committed
23 24 25 26 27 28 29 30 31 32 33

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

manifest_pl := \
use strict; \
use warnings; \
my @files = qw{MANIFEST}; \
while (<>) { \
    chomp; \
    next if m{^\.}; \
François Perrad's avatar
François Perrad committed
34
    next if m{^doc/\.}; \
François Perrad's avatar
François Perrad committed
35
    next if m{^doc/google}; \
François Perrad's avatar
François Perrad committed
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
    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)

62
CHANGES: dist.info
François Perrad's avatar
François Perrad committed
63 64
	perl -i.bak -pe "s{^$(VERSION).*}{q{$(VERSION)  }.localtime()}e" CHANGES

65 66 67
dist.info:
	perl -i.bak -pe "s{^version.*}{version = \"$(VERSION)\"}" dist.info

François Perrad's avatar
François Perrad committed
68 69 70
tag:
	git tag -a -m 'tag release $(VERSION)' $(VERSION)

François Perrad's avatar
François Perrad committed
71
doc:
François Perrad's avatar
François Perrad committed
72
	git read-tree --prefix=doc/ -u remotes/origin/gh-pages
François Perrad's avatar
François Perrad committed
73

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

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

dist: $(TARBALL)

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

François Perrad's avatar
François Perrad committed
91 92 93
rock:
	luarocks pack rockspec/lua-coatpersistent-luasql-$(VERSION)-$(REV).rockspec
	luarocks pack rockspec/lua-coatpersistent-lsqlite3-$(VERSION)-$(REV).rockspec
François Perrad's avatar
François Perrad committed
94 95 96 97 98 99 100 101 102 103

ifdef LUA_PATH
  export LUA_PATH:=$(LUA_PATH);../test/?.lua
else
  export LUA_PATH=;;../test/?.lua
endif
#export GEN_PNG=1

check: test

104 105 106
test: test.luasql test.lsqlite3

test.luasql:
François Perrad's avatar
François Perrad committed
107
	cd src && prove --exec=$(LUA) ../test/*.t
108 109 110

test.lsqlite3:
	cd src.lsqlite3 && prove --exec=$(LUA) ../test/*.t
François Perrad's avatar
François Perrad committed
111

François Perrad's avatar
François Perrad committed
112
luacheck:
François Perrad's avatar
François Perrad committed
113 114
	luacheck --std=max --codes src --ignore 212/t --ignore 421/cond
	luacheck --std=max --codes src.lsqlite3 --ignore 212/t --ignore 231/err
François Perrad's avatar
François Perrad committed
115
	luacheck --std=min --config .test.luacheckrc test/*.t
François Perrad's avatar
François Perrad committed
116

François Perrad's avatar
François Perrad committed
117 118 119 120 121
coverage:
	rm -f src/luacov.stats.out src/luacov.report.out
	cd src && prove --exec="$(LUA) -lluacov" ../test/*.t
	cd src && luacov

François Perrad's avatar
François Perrad committed
122 123 124
coveralls:
	rm -f src/luacov.stats.out src/luacov.report.out
	cd src && prove --exec="$(LUA) -lluacov" ../test/*.t
125
	cd src && luacov-coveralls -e ^/usr -e %.t$
François Perrad's avatar
François Perrad committed
126

François Perrad's avatar
François Perrad committed
127 128 129
README.html: README.md
	Markdown.pl README.md > README.html

François Perrad's avatar
François Perrad committed
130
clean:
François Perrad's avatar
François Perrad committed
131
	rm -rf doc
François Perrad's avatar
François Perrad committed
132
	rm -f MANIFEST *.bak *.db src/luacov.*.out src/*.db src/*.png test/*.png *.rockspec README.html
François Perrad's avatar
François Perrad committed
133

134 135 136
realclean: clean

.PHONY: test rockspec CHANGES dist.info
François Perrad's avatar
François Perrad committed
137