forked from crystal-lang/shards
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (52 loc) · 2.18 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
62
63
64
65
66
67
68
69
70
71
.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
SHARDS_CONFIG_BUILD_COMMIT := $(shell git rev-parse --short HEAD 2> /dev/null)
SHARDS_VERSION := $(shell cat VERSION)
SOURCE_DATE_EPOCH := $(shell (git show -s --format=%ct HEAD || stat -c "%Y" Makefile || stat -f "%m" Makefile) 2> /dev/null)
EXPORTS := SHARDS_CONFIG_BUILD_COMMIT="$(SHARDS_CONFIG_BUILD_COMMIT)" SOURCE_DATE_EPOCH="$(SOURCE_DATE_EPOCH)"
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: build
include docs.mk
build: phony bin/shards
clean: phony clean_docs
rm -f bin/shards
bin/shards: $(SOURCES) $(TEMPLATES) lib
@mkdir -p bin
$(EXPORTS) $(CRYSTAL) build $(FLAGS) src/shards.cr -o bin/shards
install: bin/shards man/shards.1.gz man/shard.yml.5.gz phony
$(INSTALL) -m 0755 -d "$(BINDIR)" "$(MANDIR)/man1" "$(MANDIR)/man5"
$(INSTALL) -m 0755 bin/shards "$(BINDIR)"
$(INSTALL) -m 0644 man/shards.1.gz "$(MANDIR)/man1"
$(INSTALL) -m 0644 man/shard.yml.5.gz "$(MANDIR)/man5"
uninstall: phony
rm -f "$(BINDIR)/shards"
rm -f "$(MANDIR)/man1/shards.1.gz"
rm -f "$(MANDIR)/man5/shard.yml.5.gz"
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)
shard.lock: shard.yml
[ $(SHARDS) = false ] || $(SHARDS) update
man/%.gz: man/%
gzip -c -9 $< > $@
phony: