forked from ipfs-force-community/sophon-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
47 lines (35 loc) · 1.2 KB
/
Copy pathMakefile
File metadata and controls
47 lines (35 loc) · 1.2 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
SHELL=/usr/bin/env bash
GOVERSION:=$(shell go version | cut -d' ' -f 3 | cut -d. -f 2)
ifeq ($(shell expr $(GOVERSION) \< 13), 1)
$(warning Your Golang version is go 1.$(GOVERSION))
$(error Update Golang to version $(shell grep '^go' go.mod))
endif
CLEAN:=
BINS:=./venus-gateway
git=$(subst -,.,$(shell git describe --always --match=NeVeRmAtCh --dirty 2>/dev/null || git rev-parse --short HEAD 2>/dev/null))
ldflags=-X=github.com/ipfs-force-community/venus-gateway/version.CurrentCommit='+git$(git)'
ifneq ($(strip $(LDFLAGS)),)
ldflags+=-extldflags=$(LDFLAGS)
endif
GOFLAGS+=-ldflags="$(ldflags)"
gateway: show-env $(BUILD_DEPS)
rm -f venus-gateway
go build $(GOFLAGS) -o venus-gateway
./venus-gateway --version
linux: show-env $(BUILD_DEPS)
rm -f venus-gateway
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-musl-gcc CGO_LDFLAGS="-static" go build $(GOFLAGS) -o venus-gateway
show-env:
@echo '_________________build_environment_______________'
@echo '| CC=$(CC)'
@echo '| CGO_CFLAGS=$(CGO_CFLAGS)'
@echo '| git commit=$(git)'
@echo '-------------------------------------------------'
lint:
gofmt -s -w ./
golangci-lint run
clean:
rm -rf $(CLEAN) $(BINS)
.PHONY: clean
print-%:
@echo $*=$($*)