-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
executable file
·49 lines (39 loc) · 1.21 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
SOURCE = $(wildcard *.go)
TAG = $(shell git describe --tags)
GOBUILD = go build -ldflags '-w'
# $(tag) here will contain either `-1.0-` or just `-`
ALL = \
$(foreach arch,32 64,\
$(foreach tag,-$(TAG)- -,\
$(foreach suffix,win.exe linux osx,\
build/gopherway$(tag)$(arch)-$(suffix))))
run:
go run *.go
install:
go get
all: $(ALL)
clean:
rm -f $(ALL)
fmt:
gofmt -w=true *.go
# os is determined as thus: if variable of suffix exists, it's taken, if not, then
# suffix itself is taken
win.exe = windows
osx = darwin
build/gopherway-$(TAG)-64-%: $(SOURCE)
# cd $(GOROOT)/src/; sudo CGO_ENABLED=0 GOOS=$(firstword $($*) $*) GOARCH=amd64 ./make.bash --no-clean
@mkdir -p $(@D)
CGO_ENABLED=0 GOOS=$(firstword $($*) $*) GOARCH=amd64 $(GOBUILD) -o $@
build/gopherway-$(TAG)-32-%: $(SOURCE)
# cd $(GOROOT)/src/; sudo CGO_ENABLED=0 GOOS=$(firstword $($*) $*) GOARCH=386 ./make.bash --no-clean
@mkdir -p $(@D)
CGO_ENABLED=0 GOOS=$(firstword $($*) $*) GOARCH=386 $(GOBUILD) -o $@
build/gopherway-%: build/gopherway-$(TAG)-%
@mkdir -p $(@D)
cd $(@D) && ln -sf $(<F) $(@F)
upload: $(ALL)
ifndef UPLOAD_PATH
@echo "Define UPLOAD_PATH to determine where files should be uploaded"
else
rsync -l -P $(ALL) $(UPLOAD_PATH)
endif