GITCOMMIT = $(shell git rev-list -1 HEAD)
GOVERSION = $(shell go version | cut -d' '  -f 3)
BUILDTIME = $(shell date -u --iso-8601=seconds)
VERSION = $(shell cat resources/VERSION)

GO111MODULE=on

# try go get github.com/ahmetb/govvv
# this will add branch info & build RFC3339 date also

run:

debug:
	go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT} -X main.GOVERSION='${GOVERSION}' -X main.BUILDTIME='${BUILDTIME}' -X main.VERSION=${VERSION}"

gaper:
	# 'gaper' is a simple and smart golang tool that just rebuilds every time you change a file
	# go get -u github.com/maxcnunes/gaper
	gaper

#### NEVER DO THIS. THIS APPEARS TO INDUCE INSTABILITY IN GTK
bad-run:
	#### NEVER DO THIS. THIS APPEARS TO INDUCE INSTABILITY IN GTK
	# go run *.go

tag-version:
	# git push --delete origin v0.6.15 # to delete a tag upstream
	git diff --quiet 
	go build # just an extra check to make sure the damn thing builds
	git tag v${VERSION}
	git push --tags
	cp .git/refs/tags/v${VERSION} resources/tags/
	scp resources/VERSION root@mirrors.wit.com:/data/mirrors/cloud/control-panel/
	scp resources/VERSION root@mirrors.wit.com:/data/mirrors/cloud/control-panel/linux/

# should update every go dependancy (?)
update:
	git pull
	go get -v -t -u .

diff:
	git diff

# https://www.digitalocean.com/community/tutorials/how-to-build-go-executables-for-multiple-platforms-on-ubuntu-16-04
build-darwin:
	env GOOS=darwin GOARCH=amd64 go build

build-windows:
	env GOOS=windows GOARCH=amd64 go build