@ -1,31 +1,15 @@
DIST := dist
DIST := dist
IMPORT := code.gitea.io/tea
export GO111MODULE = on
export GO111MODULE = on
export CGO_ENABLED = 0
GO ?= go
GO ?= go
SED_INPLACE := sed -i
SHASUM ?= shasum -a 256
SHASUM ?= shasum -a 256
export PATH := $( $( GO) env GOPATH) /bin:$( PATH)
export PATH := $( $( GO) env GOPATH) /bin:$( PATH)
i f e q ( $( OS ) , W i n d o w s _ N T )
EXECUTABLE := tea.exe
e l s e
EXECUTABLE := tea
UNAME_S := $( shell uname -s)
ifeq ( $( UNAME_S) ,Darwin)
SED_INPLACE := sed -i ''
endif
e n d i f
GOFILES := $( shell find . -name "*.go" -type f ! -path "./vendor/*" ! -path "*/bindata.go" )
GOFILES := $( shell find . -name "*.go" -type f ! -path "./vendor/*" ! -path "*/bindata.go" )
GOFMT ?= gofmt -s
GOFMT ?= gofmt -s
GOFLAGS := -i -v
EXTRA_GOFLAGS ?=
MAKE_VERSION := $( shell make -v | head -n 1)
i f n e q ( $( DRONE_TAG ) , )
i f n e q ( $( DRONE_TAG ) , )
VERSION ?= $( subst v,,$( DRONE_TAG) )
VERSION ?= $( subst v,,$( DRONE_TAG) )
TEA_VERSION ?= $( VERSION)
TEA_VERSION ?= $( VERSION)
@ -37,25 +21,31 @@ else
endif
endif
TEA_VERSION ?= $( shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//' )
TEA_VERSION ?= $( shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//' )
e n d i f
e n d i f
TEA_VERSION_TAG ?= $( shell sed 's/+/_/' <<< $( TEA_VERSION) )
TEA_VERSION_TAG ?= $( shell sed 's/+/_/' <<< $( TEA_VERSION) )
LDFLAGS := -X " main.Version= $( TEA_VERSION) " -X " main.Tags= $( TAGS) "
TAGS ?=
LDFLAGS := -X " main.Version= $( TEA_VERSION) " -X " main.Tags= $( TAGS) " -s -w
i f e q ( $( STATIC ) , t r u e )
# NOTE: clean up this mess, when https://github.com/golang/go/issues/26492 is resolved
# static_build is a defacto standard tag used in go packages
TAGS := osusergo,netgo,static_build,$( TAGS)
LDFLAGS := $( LDFLAGS) -linkmode= external -extldflags "-static-pie" -X " main.Tags= $( TAGS) "
export CGO_ENABLED = 1 # needed for linkmode=external
e n d i f
# override to allow passing additional goflags via make CLI
override GOFLAGS : = $( GOFLAGS ) -mod =vendor -tags '$( TAGS ) ' -ldflags '$( LDFLAGS ) '
PACKAGES ?= $( shell $( GO) list ./... | grep -v /vendor/)
PACKAGES ?= $( shell $( GO) list ./... | grep -v /vendor/)
SOURCES ?= $( shell find . -name "*.go" -type f)
SOURCES ?= $( shell find . -name "*.go" -type f)
TAGS ?=
i f e q ( $( OS ) , W i n d o w s _ N T )
i f e q ( $( OS ) , W i n d o w s _ N T )
EXECUTABLE := tea.exe
EXECUTABLE := tea.exe
e l s e
e l s e
EXECUTABLE := tea
EXECUTABLE := tea
e n d i f
e n d i f
# $(call strip-suffix,filename)
strip-suffix = $( firstword $( subst ., ,$( 1) ) )
.PHONY : all
.PHONY : all
all : build
all : build
@ -132,14 +122,18 @@ test-vendor: vendor
check : test
check : test
.PHONY : install
.PHONY : install
install : $( wildcard *.go )
install : $( SOURCES )
$( GO) install -mod= vendor -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
@echo " installing to $( GOPATH) /bin/ $( EXECUTABLE) "
$( GO) install -v -buildmode= pie $( GOFLAGS)
.PHONY : build
.PHONY : build
build : $( EXECUTABLE )
build : $( EXECUTABLE )
$(EXECUTABLE) : $( SOURCES )
$(EXECUTABLE) : $( SOURCES )
$( GO) build -mod= vendor $( GOFLAGS) $( EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
i f e q ( $( STATIC ) , t r u e )
@echo "enabling static build, make sure you have glibc-static (or equivalent) installed"
e n d i f
$( GO) build -buildmode= pie $( GOFLAGS) -o $@
.PHONY : build -image
.PHONY : build -image
build-image :
build-image :
@ -157,7 +151,7 @@ release-os:
@hash gox > /dev/null 2>& 1; if [ $$ ? -ne 0 ] ; then \
@hash gox > /dev/null 2>& 1; if [ $$ ? -ne 0 ] ; then \
cd /tmp && $( GO) get -u github.com/mitchellh/gox; \
cd /tmp && $( GO) get -u github.com/mitchellh/gox; \
fi
fi
CGO_ENABLED = 0 gox -verbose -cgo= false -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -osarch= '!darwin/386 !darwin/arm' -os= "windows linux darwin" -arch= "386 amd64 arm arm64" -output= " $( DIST) /release/tea- $( VERSION) -{{.OS}}-{{.Arch}} "
CGO_ENABLED = 0 gox -verbose -cgo= false $( GOFLAGS) -osarch= '!darwin/386 !darwin/arm' -os= "windows linux darwin" -arch= "386 amd64 arm arm64" -output= " $( DIST) /release/tea- $( VERSION) -{{.OS}}-{{.Arch}} "
.PHONY : release -compress
.PHONY : release -compress
release-compress :
release-compress :