-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
108 lines (86 loc) · 3.71 KB
/
Makefile
File metadata and controls
108 lines (86 loc) · 3.71 KB
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
GITOPIA_ENV ?= prod
LEDGER_ENABLED ?= true
build_tags = netgo
ifeq ($(LEDGER_ENABLED),true)
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
ifeq ($(GCCEXE),)
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),OpenBSD)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
else
GCC = $(shell command -v gcc 2> /dev/null)
ifeq ($(GCC),)
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
endif
endif
endif
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))
BUILD_FLAGS := -tags "$(build_tags) $(GITOPIA_ENV)" -ldflags="-s -w"
appname := git-remote-gitopia
version := $(shell echo $(shell git describe --tags) | sed 's/^v//')
build = GOOS=$(1) GOARCH=$(2) go build $(BUILD_FLAGS) -o build/$(appname)$(3) ./cmd/git-remote-gitopia && \
GOOS=$(1) GOARCH=$(2) go build $(BUILD_FLAGS) -o build/git-gitopia$(3) ./cmd/git-gitopia && \
GOOS=$(1) GOARCH=$(2) go build $(BUILD_FLAGS) -o build/git-credential-gitopia$(3) ./cmd/git-credential-gitopia
tar = cd build && tar -cvzf $(appname)_$(version)_$(1)_$(2).tar.gz $(appname)$(3) git-gitopia$(3) git-credential-gitopia$(3) && \
rm $(appname)$(3) && rm git-gitopia$(3) && rm git-credential-gitopia$(3)
zip = cd build && zip $(appname)_$(version)_$(1)_$(2).zip $(appname)$(3) git-gitopia$(3) git-credential-gitopia$(3) && \
rm $(appname)$(3) && rm git-gitopia$(3) && rm git-credential-gitopia$(3)
.PHONY: build
all: darwin linux git_release_tar_gz git_release_zip
clean:
rm -rf build/
##### LINUX BUILDS #####
linux: build/$(appname)_$(version)_linux_arm.tar.gz build/$(appname)_$(version)_linux_arm64.tar.gz build/$(appname)_$(version)_linux_386.tar.gz build/$(appname)_$(version)_linux_amd64.tar.gz
build/$(appname)_$(version)_linux_386.tar.gz:
$(call build,linux,386,)
$(call tar,linux,386)
build/$(appname)_$(version)_linux_amd64.tar.gz:
$(call build,linux,amd64,)
$(call tar,linux,amd64)
build/$(appname)_$(version)_linux_arm.tar.gz:
$(call build,linux,arm,)
$(call tar,linux,arm)
build/$(appname)_$(version)_linux_arm64.tar.gz:
$(call build,linux,arm64,)
$(call tar,linux,arm64)
##### DARWIN (MAC) BUILDS #####
darwin: build/$(appname)_$(version)_darwin_amd64.tar.gz build/$(appname)_$(version)_darwin_arm64.tar.gz
build/$(appname)_$(version)_darwin_arm64.tar.gz:
$(call build,darwin,arm64,)
$(call tar,darwin,arm64)
build/$(appname)_$(version)_darwin_amd64.tar.gz:
$(call build,darwin,amd64,)
$(call tar,darwin,amd64)
##### WINDOWS BUILDS #####
windows: build/$(appname)_$(version)_windows_386.zip build/$(appname)_$(version)_windows_amd64.zip
build/$(appname)_$(version)_windows_386.zip:
$(call build,windows,386,.exe)
$(call zip,windows,386,.exe)
build/$(appname)_$(version)_windows_amd64.zip:
$(call build,windows,amd64,.exe)
$(call zip,windows,amd64,.exe)
git_release_tar_gz:
git archive --format=tar --prefix=$(appname)-$(version)/ v$(version) \
| gzip > build/$(appname)-$(version).tar.gz
git_release_zip:
git archive --format zip --output build/$(appname)-$(version).zip v$(version)
install: go.sum
@echo "--> Installing git-remote-gitopia"
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/git-remote-gitopia
@echo "--> Installing git-gitopia"
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/git-gitopia
@echo "--> Installing git-credential-gitopia"
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/git-credential-gitopia
go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
GO111MODULE=on go mod verify