@ -1,34 +1,13 @@
GOTOOLS : = \
GOTOOLS = \
github.com/mitchellh/gox \
github.com/mitchellh/gox \
github.com/Masterminds/glide \
github.com/Masterminds/glide \
github.com/tcnksm/ghr \
github.com/tcnksm/ghr \
gopkg.in/alecthomas/gometalinter.v2
gopkg.in/alecthomas/gometalinter.v2
GO_MIN_VERSION := 1.9.2
PACKAGES := $( shell go list ./... | grep -v '/vendor/' )
BUILD_TAGS ?= tendermint
TMHOME ?= $( HOME) /.tendermint
GOPATH ?= $( shell go env GOPATH)
GOROOT ?= $( shell go env GOROOT)
GOGCCFLAGS ?= $( shell go env GOGCCFLAGS)
#LDFLAGS_EXTRA ?= -w -s
XC_ARCH ?= 386 amd64 arm
XC_OS ?= solaris darwin freebsd linux windows
XC_OSARCH ?= !darwin/arm !solaris/amd64 !freebsd/amd64
BUILD_OUTPUT ?= ./build/{ { .OS} } _{ { .Arch} } /tendermint
GOX_FLAGS = -os= " $( XC_OS) " -arch= " $( XC_ARCH) " -osarch= " $( XC_OSARCH) " -output= " $( BUILD_OUTPUT) "
i f e q ( $( BUILD_FLAGS_RACE ) , Y E S )
RACEFLAG = -race
e l s e
RACEFLAG =
e n d i f
BUILD_FLAGS = -asmflags " -trimpath $( GOPATH) " -gcflags " -trimpath $( GOPATH) " -tags " $( BUILD_TAGS) " -ldflags " -X github.com/tendermint/tendermint/version.GitCommit= $( shell git rev-parse --short= 8 HEAD) $( LDFLAGS_EXTRA) " $( RACEFLAG)
GO_VERSION := $( shell go version | grep -o '[[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+' )
#Check that that minor version of GO meets the minimum required
GO_MINOR_VERSION := $( shell grep -o \. [ [ :digit:] ] [ [ :digit:] ] *\. <<< $( GO_VERSION) | grep -o [ [ :digit:] ] * )
GO_MIN_MINOR_VERSION := $( shell grep -o \. [ [ :digit:] ] [ [ :digit:] ] *\. <<< $( GO_MIN_VERSION) | grep -o [ [ :digit:] ] * )
GO_MINOR_VERSION_CHECK := $( shell test $( GO_MINOR_VERSION) -ge $( GO_MIN_MINOR_VERSION) && echo YES)
GOTOOLS_CHECK = gox glide ghr gometalinter.v2
PACKAGES = $( shell go list ./... | grep -v '/vendor/' )
BUILD_TAGS ?= tendermint
TMHOME = $$ { TMHOME:-$$ HOME/.tendermint}
BUILD_FLAGS = -ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short HEAD`"
all : check build test install metalinter
all : check build test install metalinter
@ -38,61 +17,27 @@ check: check_tools get_vendor_deps
########################################
########################################
### Build
### Build
build_xc : check_tools
$( shell which gox) $( BUILD_FLAGS) $( GOX_FLAGS) ./cmd/tendermint/
build :
build :
i f e q ( $( OS ) , W i n d o w s _ N T )
make build_xc XC_ARCH = amd64 XC_OS = windows BUILD_OUTPUT = $( GOPATH) /bin/tendermint
e l s e
make build_xc XC_ARCH = amd64 XC_OS = " $( shell uname -s) " BUILD_OUTPUT = $( GOPATH) /bin/tendermint
e n d i f
go build $( BUILD_FLAGS) -o build/tendermint ./cmd/tendermint/
build_race :
build_race :
#TODO: Wait for this to be merged: https://github.com/mitchellh/gox/pull/105 Then switch over to make build and remove the go build line.
# make build BUILD_FLAGS_RACE=YES
$( shell which go) build $( BUILD_FLAGS) -race -o " $( BUILD_OUTPUT) " ./cmd/tendermint/
go build -race $( BUILD_FLAGS) -o build/tendermint ./cmd/tendermint
# dist builds binaries for all platforms and packages them for distribution
# dist builds binaries for all platforms and packages them for distribution
dist :
dist :
@BUILD_TAGS= '$(BUILD_TAGS)' sh -c " ' $( CURDIR) /scripts/dist.sh' "
@BUILD_TAGS= '$(BUILD_TAGS)' sh -c " ' $( CURDIR) /scripts/dist.sh' "
install :
install :
make build
go install $( BUILD_FLAGS) ./cmd/tendermint
########################################
########################################
### Tools & dependencies
### Tools & dependencies
check_tools :
check_tools :
i f e q ( $( GO_VERSION ) , )
$( error go not found)
e n d i f
#Check minimum required go version
i f n e q ( $( GO_VERSION ) , $( GO_MIN_VERSION ) )
$( warning WARNING: build will not be deterministic. go version should be $( GO_MIN_VERSION) )
i f n e q ( $( GO_MINOR_VERSION_CHECK ) , Y E S )
$( error ERROR: The minor version of Go ( $( GO_VERSION) ) is lower than the minimum required ( $( GO_MIN_VERSION) ) )
e n d i f
e n d i f
#-fdebug-prefix-map switches the temporary, randomized workdir name in the binary to a static text
i f n e q ( $( findstring -fdebug -prefix -map ,$ ( GOGCCFLAGS ) ) , - f d e b u g - p r e f i x - m a p )
$( warning WARNING: build will not be deterministic. The compiler does not support the '-fdebug-prefix-map' flag.)
e n d i f
#GOROOT string is copied into the binary. For deterministic builds, we agree to keep it at /usr/local/go. (Default for golang:1.9.2 docker image, linux and osx.)
i f n e q ( $( GOROOT ) , / u s r / l o c a l / g o )
$( warning WARNING: build will not be deterministic. GOROOT should be set to /usr/local/go)
e n d i f
#GOPATH string is copied into the binary. Although the -trimpath flag tries to eliminate it, it doesn't do it everywhere in Go 1.9.2. For deterministic builds we agree to keep it at /go. (Default for golang:1.9.2 docker image.)
i f n e q ( $( GOPATH ) , / g o )
$( warning WARNING: build will not be deterministic. GOPATH should be set to /go)
e n d i f
#External dependencies defined in GOTOOLS are built with get_tools. If they are already available on the system (for exmaple using a package manager), then get_tools might not be necessary.
i f n e q ( $( findstring $ ( GOPATH ) /bin ,$ ( PATH ) ) , $( GOPATH ) / b i n )
$( warning WARNING: PATH does not contain GOPATH/bin. Some external dependencies might be unavailable.)
e n d i f
# https://stackoverflow.com/a/25668869
@echo " Found tools: $( foreach tool,$( notdir $( GOTOOLS) ) ,$( if $( shell which $( tool) ) ,$( tool) ,$( error " No $( tool) in PATH. Add GOPATH/bin to PATH and run 'make get_tools' " ) ) ) "
@# https://stackoverflow.com/a/25668869
@echo " Found tools: $( foreach tool,$( GOTOOLS_CHECK) ,\
$( if $( shell which $( tool) ) ,$( tool) ,$( error " No $( tool) in PATH " ) ) ) "
get_tools :
get_tools :
@echo "--> Installing tools"
@echo "--> Installing tools"