Makefile
841 Bytes
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
PACKAGE = gitlab.weird-web-workers.org/golang/test
SOURCES = version.go \
server.go \
signal.go
VERSION = 0.0.1
REVISION = $(shell git rev-parse HEAD)
BUILDTIME= "$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')"
GOOS = $(shell go env GOOS)
GOARCH = $(shell go env GOARCH)
LIBRARY = $(GOPATH)/pkg/$(GOOS)_$(GOARCH)/$(PACKAGE).a
.PHONY: all clean
all: $(LIBRARY)
$(LIBRARY): $(SOURCES)
go install $(PACKAGE)
.version.new:
-@printf "%s\n" "$(VERSION)" "$(REVISION)" >$@
.version: .version.new
-@diff $@ $< >/dev/null 2>&1 && rm $< || mv $< $@
version.go: version.go.m4 .version
-@m4 -Dm4_version=$(VERSION) \
-Dm4_revision=$(REVISION) \
-Dm4_build_time=$(BUILDTIME) \
-Dm4_package=$(PACKAGE) \
$< >$@
clean:
-@rm -f version.go 2>/dev/null
-@rm -f .version 2>/dev/null
-@rm -f $(LIBRARY) 2>/dev/null