-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
83 lines (62 loc) · 1.83 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
72
73
74
75
76
77
78
79
80
81
82
83
TARGET ?= bin/mpp
CRYSTAL ?= crystal
DIST ?= dist/$(notdir $(TARGET))
export VERSION = $(shell sed -ne '/.*version: *\(.*\)$$/s//\1/p' <shard.yml)
DEPS = src/mpp.cr $(shell find src -iname '*.cr' -not -name 'mpp.cr') src/version.cr
# The architectures we want to build packages for
DIST_TARGETS = $(shell find pkg -type d -depth 1 -not -name _support)
PACKAGES = $(addprefix pkg/mpp-$(VERSION)_,$(addsuffix .tar.gz,$(notdir $(DIST_TARGETS))))
-include config.mk
prefix ?= /usr/local
.PHONY: all
all: $(TARGET) man/mpp.1
.PHONY: test
test: $(DEPS)
crystal spec
.PHONY: clean
clean:
rm -f $(TARGET) $(DIST) src/version.cr pkg/*/mpp
cd man && $(MAKE) clean
cd example && $(MAKE) clean
rm -f pkg/_support/{configure,mpp.1} pkg/*.tar.gz
for arch in $(DIST_TARGETS); do (cd $$arch; $(MAKE) clean); done
.PHONY: dist
dist: $(DIST)
.PHONY: man
man: man/mpp.1
.PHONY: install
install: $(DIST) man/mpp.1
install -d $(prefix)/bin $(prefix)/share/man/man1
install -m 0755 $(DIST) $(prefix)/bin
install man/mpp.1 $(prefix)/share/man/man1
.PHONY: uninstall
uninstall:
rm -f $(prefix)/bin/mpp
rm -f $(prefix)/share/man/man1/mpp.1
.PHONY: example
example: $(TARGET)
cd example; $(MAKE)
.PHONY: pkg
pkg: $(PACKAGES)
.PHONY: release
release: $(PACKAGES)
git push origin master
script/release foca/mpp v$(VERSION) -- $(PACKAGES)
src/version.cr: shard.yml
echo 'MPP_VERSION = "$(VERSION)"' > $@
man/mpp.1:
cd $(@D); $(MAKE) $(@F)
$(TARGET): $(DEPS) src/version.cr | $(dir $(TARGET))
$(CRYSTAL) build -o $@ $<
$(DIST): $(DEPS) | $(dir $(DIST))
$(CRYSTAL) compile --release -o $@ $<
mpp-$(VERSION)_%.tar.gz: pkg/_support/mpp.1 pkg/_support/configure
cd $*; $(MAKE) mpp
tar -czf $*/$(@F) -C $* mpp -C ../_support .
mv $*/$(@F) $@
pkg/_support/configure: configure
cp $< $@
pkg/_support/mpp.1: man/mpp.1
cp $< $@
bin dist pkg/_support:
mkdir -p $@