github.com/cosmos/cosmos-sdk@v0.50.10/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  RUNSIM         = $(TOOLS_DESTDIR)/runsim
    51  
    52  tools: tools-stamp
    53  tools-stamp: runsim
    54  	# Create dummy file to satisfy dependency and avoid
    55  	# rebuilding when this Makefile target is hit twice
    56  	# in a row.
    57  	touch $@
    58  
    59  # Install the runsim binary
    60  runsim: $(RUNSIM)
    61  $(RUNSIM):
    62  	@echo "Installing runsim..."
    63  	@go install github.com/cosmos/tools/cmd/runsim@v1.0.0
    64  
    65  tools-clean:
    66  	rm -f $(GOLANGCI_LINT) $(RUNSIM)
    67  	rm -f tools-stamp
    68  
    69  .PHONY: tools-clean runsim