This repository has been archived by the owner on Jan 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathMakefile
69 lines (52 loc) · 1.66 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
appname := yago
BINARYNAME="YaGo"
VERSION=$(shell git describe)
TARGET=all
BUILD_TIME=$(shell date +%FT%T%z)
BUILD=$(shell git rev-parse HEAD)
LDFLAGS=-ldflags="\
-s \
-w \
-X main.Name=${BINARYNAME} \
-X main.Version=${VERSION} \
-X main.BuildID=${BUILD} \
-X main.BuildDate=${BUILD_TIME}"
sources := $(wildcard *.go)
cmd = GOOS=$(1) GOARCH=$(2) go build ${LDFLAGS} -o build/$(appname)$(3)
tar = cd build && tar -cvzf $(appname)_$(1)_$(2).tar.gz $(appname)$(3) && rm $(appname)$(3)
zip = cd build && zip $(appname)_$(1)_$(2).zip $(appname)$(3) && rm $(appname)$(3)
.PHONY: all windows darwin linux dev clean
all: windows darwin linux
clean:
rm -rf build/*
##### LINUX BUILDS #####
linux: build/linux_arm.tar.gz build/linux_arm64.tar.gz build/linux_386.tar.gz build/linux_amd64.tar.gz
build/linux_386.tar.gz: $(sources)
$(call cmd,linux,386,)
$(call tar,linux,386)
build/linux_amd64.tar.gz: $(sources)
$(call cmd,linux,amd64,)
$(call tar,linux,amd64)
build/linux_arm.tar.gz: $(sources)
$(call cmd,linux,arm,)
$(call tar,linux,arm)
build/linux_arm64.tar.gz: $(sources)
$(call cmd,linux,arm64,)
$(call tar,linux,arm64)
##### DARWIN (MAC) BUILDS #####
darwin: build/darwin_amd64.tar.gz
build/darwin_amd64.tar.gz: $(sources)
$(call cmd,darwin,amd64,)
$(call tar,darwin,amd64)
##### WINDOWS BUILDS #####
windows: build/windows_386.zip build/windows_amd64.zip
build/windows_386.zip: $(sources)
$(call cmd,windows,386,.exe)
$(call zip,windows,386,.exe)
build/windows_amd64.zip: $(sources)
$(call cmd,windows,amd64,.exe)
$(call zip,windows,amd64,.exe)
##### DEV BUILDS #####
dev: build-dev/darwin_amd64.tar.gz
build-dev/darwin_amd64.tar.gz:
$(call cmd,darwin,amd64,)