-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
59 lines (42 loc) · 1.95 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
VERSION=1.0.3
OSES=linux darwin windows
ARCHS=arm64 amd64
SRCS=$(shell find . -iname '*.go')
ALLSRCS=$(SRCS) version/version.go
UNAME_S := $(shell uname -s)
default: $(ALLSRCS)
go build ./cmd/goignore
_build:
mkdir $@
version/version.go: version/version.go.m4 Makefile
m4 -D__VERSION__=$(VERSION) < $< > $@
define make-target
ifneq ($1, windows)
_build/$(VERSION)/$1_$2/goignore: $(ALLSRCS) | _build
GOOS=$1 GOARCH=$2 go build -o _build/$(VERSION)/$1_$2/goignore ./cmd/goignore
all:: _build/$(VERSION)/$1_$2/goignore
_build/$(VERSION)/goignore_$(VERSION)_$1_$2.tar.gz: _build/$(VERSION)/$1_$2/goignore | _build
tar -zcf _build/$(VERSION)/goignore_$(VERSION)_$1_$2.tar.gz -C _build/$(VERSION)/$1_$2 goignore
archive:: _build/$(VERSION)/goignore_$(VERSION)_$1_$2.tar.gz
else
_build/$(VERSION)/$1_$2/goignore.exe: $(ALLSRCS) | _build
GOOS=$1 GOARCH=$2 go build -o _build/$(VERSION)/$1_$2/goignore.exe ./cmd/goignore
all:: _build/$(VERSION)/$1_$2/goignore.exe
_build/$(VERSION)/goignore_$(VERSION)_$1_$2.zip: _build/$(VERSION)/$1_$2/goignore.exe | _build
zip _build/$(VERSION)/goignore_$(VERSION)_$1_$2.zip -j _build/$(VERSION)/$1_$2/goignore.exe
archive:: _build/$(VERSION)/goignore_$(VERSION)_$1_$2.zip
endif
endef
$(foreach os,$(OSES), $(foreach arch, $(ARCHS), $(eval $(call make-target,$(os),$(arch)))))
ifeq ($(UNAME_S),Darwin)
_build/$(VERSION)/darwin_universal/goignore: _build/$(VERSION)/darwin_amd64/goignore _build/$(VERSION)/darwin_arm64/goignore | _build
-mkdir _build/$(VERSION)/darwin_universal
lipo -create -output $@ $+
all:: _build/$(VERSION)/darwin_universal/goignore
_build/$(VERSION)/goignore_$(VERSION)_darwin_universal.tar.gz: _build/$(VERSION)/darwin_universal/goignore | _build
tar -zcf _build/$(VERSION)/goignore_$(VERSION)_darwin_universal.tar.gz -C _build/$(VERSION)/darwin_universal goignore
archive:: _build/$(VERSION)/goignore_$(VERSION)_darwin_universal.tar.gz
endif
clean:
-rm -rf _build version/version.go
.PHONY: all clean default archive