forked from crystal-lang/shards
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (45 loc) · 1.68 KB
/
Makefile
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
.POSIX:
release ?= ## Compile in release mode
debug ?= ## Add symbolic debug info
static ?= ## Enable static linking
CRYSTAL ?= crystal
SHARDS ?= shards
override FLAGS += $(if $(release),--release )$(if $(debug),-d )$(if $(static),--static )
SHARDS_SOURCES = $(shell find src -name '*.cr')
MOLINILLO_SOURCES = $(shell find lib/molinillo -name '*.cr' 2> /dev/null)
SOURCES = $(SHARDS_SOURCES) $(MOLINILLO_SOURCES)
TEMPLATES = src/templates/*.ecr
DESTDIR ?=
PREFIX ?= /usr/local
BINDIR ?= $(DESTDIR)$(PREFIX)/bin
MANDIR ?= $(DESTDIR)$(PREFIX)/share/man
INSTALL ?= /usr/bin/install
MOLINILLO_VERSION = $(shell $(CRYSTAL) eval 'require "yaml"; puts YAML.parse(File.read("shard.lock"))["shards"]["molinillo"]["version"]')
MOLINILLO_URL = "https://github.com/crystal-lang/crystal-molinillo/archive/v$(MOLINILLO_VERSION).tar.gz"
all: bin/shards
clean: phony
rm -f bin/shards
bin/shards: $(SOURCES) $(TEMPLATES) lib
@mkdir -p bin
$(CRYSTAL) build $(FLAGS) src/shards.cr -o bin/shards
install: bin/shards phony
$(INSTALL) -m 0755 -d "$(BINDIR)" "$(MANDIR)/man1" "$(MANDIR)/man5"
$(INSTALL) -m 0755 bin/shards "$(BINDIR)"
$(INSTALL) -m 0644 man/shards.1 "$(MANDIR)/man1"
$(INSTALL) -m 0644 man/shard.yml.5 "$(MANDIR)/man5"
uninstall: phony
rm -f "$(BINDIR)/shards"
rm -f "$(MANDIR)/man1/shards.1"
rm -f "$(MANDIR)/man5/shard.yml.5"
test: test_unit test_integration
test_unit: phony lib
$(CRYSTAL) spec ./spec/unit/
test_integration: bin/shards phony
$(CRYSTAL) spec ./spec/integration/
lib: shard.lock
mkdir -p lib/molinillo
$(SHARDS) install || (curl -L $(MOLINILLO_URL) | tar -xzf - -C lib/molinillo --strip-components=1)
touch lib
shard.lock: shard.yml
$(SHARDS) update
phony: