github.com/Finschia/finschia-sdk@v0.48.1/contrib/devtools/Makefile (about) 1 ### 2 # Find OS and Go environment 3 # GO contains the Go binary 4 # FS contains the OS file separator 5 ### 6 ifeq ($(OS),Windows_NT) 7 GO := $(shell where go.exe 2> NUL) 8 FS := "\\" 9 else 10 GO := $(shell command -v go 2> /dev/null) 11 FS := "/" 12 endif 13 14 ifeq ($(GO),) 15 $(error could not find go. Is it in PATH? $(GO)) 16 endif 17 18 ############################################################################### 19 ### Functions ### 20 ############################################################################### 21 22 go_get = $(if $(findstring Windows_NT,$(OS)),\ 23 IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS) ( mkdir $(GITHUBDIR)$(FS)$(1) ) else (cd .) &\ 24 IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS)$(2)$(FS) ( cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2) ) else (cd .) &\ 25 ,\ 26 mkdir -p $(GITHUBDIR)$(FS)$(1) &&\ 27 (test ! -d $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2)) || true &&\ 28 )\ 29 cd $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && git fetch origin && git checkout -q $(3) 30 31 mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) 32 mkfile_dir := $(shell cd $(shell dirname $(mkfile_path)); pwd) 33 34 35 ############################################################################### 36 ### Tools ### 37 ############################################################################### 38 39 PREFIX ?= /usr/local 40 BIN ?= $(PREFIX)/bin 41 UNAME_S ?= $(shell uname -s) 42 UNAME_M ?= $(shell uname -m) 43 44 GOPATH ?= $(shell $(GO) env GOPATH) 45 GITHUBDIR := $(GOPATH)$(FS)src$(FS)github.com 46 47 BUF_VERSION ?= 0.11.0 48 49 TOOLS_DESTDIR ?= $(GOPATH)/bin 50 STATIK = $(TOOLS_DESTDIR)/statik 51 RUNSIM = $(TOOLS_DESTDIR)/runsim 52 53 tools: tools-stamp 54 tools-stamp: statik runsim 55 # Create dummy file to satisfy dependency and avoid 56 # rebuilding when this Makefile target is hit twice 57 # in a row. 58 touch $@ 59 60 # Install the runsim binary 61 statik: $(STATIK) 62 $(STATIK): 63 @echo "Installing statik..." 64 @go install github.com/rakyll/statik@v0.1.6 65 66 # Install the runsim binary 67 runsim: $(RUNSIM) 68 $(RUNSIM): 69 @echo "Installing runsim..." 70 @go install github.com/cosmos/tools/cmd/runsim@v1.0.0 71 72 tools-clean: 73 rm -f $(STATIK) $(GOLANGCI_LINT) $(RUNSIM) 74 rm -f tools-stamp 75 76 .PHONY: tools-clean statik runsim