forked from 3ofcoins/jetpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
108 lines (91 loc) · 3.05 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
.ifdef PREFIX
bindir ?= $(PREFIX)/bin
libexecdir ?= $(PREFIX)/libexec/jetpack
sharedir ?= $(PREFIX)/share/jetpack
examplesdir ?= $(PREFIX)/share/examples/jetpack
sysconfdir ?= $(PREFIX)/etc
.else
bindir ?= ${.CURDIR}/bin
libexecdir ?= ${bindir}
sharedir ?= ${.CURDIR}/share
examplesdir ?= ${.CURDIR}/images
sysconfdir ?= ${.CURDIR}
.endif
version := ${cat VERSION:L:sh}
.if exists(.git)
revision := ${git describe --always --long --dirty='*':L:sh}
.else
revision := (unknown)
.endif
const.jetpack = \
LibexecPath="${libexecdir}" \
DefaultConfigPath="${sysconfdir}/jetpack.conf" \
SharedPath="${sharedir}" \
Version="${version}" \
IsDevelopment=${PREFIX:Dfalse:Utrue} \
BuildTimestamp="${%FT%TZ:L:gmtime}" \
Revision="${revision}"
const.integration = \
BinPath="${bindir}" \
ImagesPath="${examplesdir}"
all: bin/jetpack bin/stage2 bin/test.integration .prefix
.prefix: .PHONY
echo "${PREFIX:Udevelopment}" > $@
.if exists(.prefix)
.prefix := ${cat .prefix:L:sh}
.else
.prefix := (no prefix saved)
.endif
CC=clang
GOPATH=$(.CURDIR)/vendor
.export CC GOPATH
bin/jetpack: .PHONY jetpack/const.go integration/const.go
go build -o $@
bin/stage2: stage2/*.go
cd stage2 && go build -o ../bin/stage2
bin/test.integration: .PHONY jetpack/const.go
cd integration && go test -c -o ../bin/test.integration
jetpack/const.go: .PHONY
echo 'package jetpack ${const.jetpack:@.CONST.@; const ${.CONST.}@}' | gofmt > $@
integration/const.go: .PHONY
echo 'package jetpack_integration ${const.integration:@.CONST.@; const ${.CONST.}@}' | gofmt > $@
vendor.refetch: .PHONY
rm -rf vendor
go get -d
set -e ; \
cd vendor/src ; \
for d in code.google.com/p/* ; do \
echo "$$d $$(cd $$d ; hg log -l 1 --template '{node|short} {desc|firstline}')" >> $(.CURDIR)/vendor/manifest.txt ; \
rm -rf $$d/.hg ; \
done ; \
for d in github.com/*/* ; do \
if test -L $$d ; then \
continue ; \
fi ; \
echo "$$d $$(cd $$d; git log -n 1 --oneline)" >> $(.CURDIR)/vendor/manifest.txt ; \
rm -rf $$d/.git ; \
done
.ifdef PREFIX
install: .PHONY
.if "${.prefix}" != "${PREFIX}"
@echo 'Cannot install to ${PREFIX}, source was built for ${.prefix}' ; false
.else
install -m 0755 -d $(DESTDIR)$(bindir) $(DESTDIR)$(libexecdir) $(DESTDIR)$(sharedir) $(DESTDIR)$(examplesdir)
install -m 0755 -s bin/jetpack $(DESTDIR)$(bindir)/jetpack
install -m 0755 -s bin/stage2 bin/test.integration $(DESTDIR)$(libexecdir)
install -m 0644 share/* $(DESTDIR)$(sharedir)
install -m 0644 jetpack.conf.sample $(DESTDIR)$(sysconfdir)/jetpack.conf.sample
cp -R images/ $(DESTDIR)$(examplesdir)
sed -i '' -e 's!^\.MAKEFLAGS: *-I.*!.MAKEFLAGS: -I$(sharedir)!' $(DESTDIR)$(examplesdir)/*/Makefile
.endif
uninstall: .PHONY
rm -rf \
$(DESTDIR)$(bindir)/jetpack \
$(DESTDIR)$(libexecdir) \
$(DESTDIR)$(sharedir) \
$(DESTDIR)$(examplesdir) \
$(DESTDIR)$(sysconfdir)/jetpack.conf.sample
reinstall: .PHONY uninstall .WAIT install
.endif
clean: .PHONY
rm -rf bin tmp .prefix jetpack/const.go integration/const.go