2023-01-22 06:06:35 +00:00
|
|
|
ALL: build
|
|
|
|
|
|
|
|
SHELL := /bin/bash
|
|
|
|
|
|
|
|
VERSION=$(shell egrep -e 'Version\s+=' version.go | head -n 1 | cut -d '"' -f 2)
|
|
|
|
BUILD=$(shell git describe --always)
|
|
|
|
BUILD_DATE=$(shell date +"%Y-%m-%dT%H:%M:%S%z")
|
|
|
|
CURDIR=$(shell curdir)
|
|
|
|
|
|
|
|
# Inject the build version (commit hash) into the executable.
|
|
|
|
LDFLAGS := -ldflags "-X main.Build=$(BUILD) -X main.BuildDate=$(BUILD_DATE)"
|
|
|
|
LDFLAGS_W := -ldflags "-X main.Build=$(BUILD) -X main.BuildDate=$(BUILD_DATE) -H windowsgui"
|
|
|
|
|
|
|
|
# `make setup` to set up a new environment, pull dependencies, etc.
|
|
|
|
.PHONY: setup
|
|
|
|
setup: clean
|
|
|
|
go get ./...
|
|
|
|
|
|
|
|
# `make build` to build the binary.
|
|
|
|
.PHONY: build
|
|
|
|
build:
|
|
|
|
go build $(LDFLAGS) -o errorgen .
|
|
|
|
|
|
|
|
# `make install` to install the Go binaries to your GOPATH.
|
|
|
|
.PHONY: install
|
|
|
|
install:
|
|
|
|
go install git.kirsle.net/apps/errorgen
|
|
|
|
|
|
|
|
# `make mingw` to cross-compile a Windows binary with mingw.
|
|
|
|
.PHONY: mingw
|
|
|
|
mingw:
|
|
|
|
env CGO_ENABLED="1" CC="/usr/bin/x86_64-w64-mingw32-gcc" \
|
|
|
|
GOOS="windows" CGO_LDFLAGS="-lmingw32 -lSDL2" CGO_CFLAGS="-D_REENTRANT" \
|
|
|
|
go build $(LDFLAGS_W) -i -o bin/sketchymaze.exe cmd/doodle/main.go
|
|
|
|
env CGO_ENABLED="1" CC="/usr/bin/x86_64-w64-mingw32-gcc" \
|
|
|
|
GOOS="windows" CGO_LDFLAGS="-lmingw32 -lSDL2" CGO_CFLAGS="-D_REENTRANT" \
|
|
|
|
go build $(LDFLAGS) -i -o bin/doodad.exe cmd/doodad/main.go
|
|
|
|
|
|
|
|
# `make mingw32` to cross-compile a Windows binary with mingw (32-bit).
|
|
|
|
.PHONY: mingw32
|
|
|
|
mingw32:
|
|
|
|
env CGO_ENABLED="1" CC="/usr/bin/i686-w64-mingw32-gcc" \
|
|
|
|
GOOS="windows" CGO_LDFLAGS="-lmingw32 -lSDL2" CGO_CFLAGS="-D_REENTRANT" \
|
|
|
|
go build $(LDFLAGS_W) -i -o bin/sketchymaze.exe cmd/doodle/main.go
|
|
|
|
env CGO_ENABLED="1" CC="/usr/bin/i686-w64-mingw32-gcc" \
|
|
|
|
GOOS="windows" CGO_LDFLAGS="-lmingw32 -lSDL2" CGO_CFLAGS="-D_REENTRANT" \
|
|
|
|
go build $(LDFLAGS) -i -o bin/doodad.exe cmd/doodad/main.go
|
|
|
|
|
|
|
|
# `make run` to run it from source.
|
|
|
|
.PHONY: run
|
|
|
|
run:
|
|
|
|
go run .
|
|
|
|
|
|
|
|
# `make clean` to cleanup the repo.
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2023-01-22 20:02:21 +00:00
|
|
|
rm -rf errorgen fyne-cross
|
|
|
|
|
|
|
|
# `make release` uses fyne-cross to produce builds for Linux and Windows.
|
|
|
|
.PHONY: release
|
|
|
|
release: clean
|
|
|
|
fyne-cross windows -arch=*
|
|
|
|
fyne-cross linux -arch=*
|
|
|
|
|
|
|
|
# `make release-sudo` uses sudo commands for release in case of permission errors.
|
|
|
|
.PHONY: release-sudo
|
|
|
|
release-sudo: clean
|
|
|
|
sudo $(shell which fyne-cross) windows -arch=\*
|
|
|
|
sudo $(shell which fyne-cross) linux -arch=\*
|
|
|
|
sudo chown -R $(shell whoami) fyne-cross
|
|
|
|
|
|
|
|
# `make package` creates nice ZIP files for release after `make release`
|
|
|
|
.PHONY: package
|
|
|
|
package:
|
|
|
|
cp -r README.md README.html *.png icons fyne-cross/bin/windows-386/
|
|
|
|
cp -r README.md README.html *.png icons fyne-cross/bin/windows-amd64/
|
|
|
|
cp -r README.md README.html *.png icons fyne-cross/bin/linux-386/
|
|
|
|
cp -r README.md README.html *.png icons fyne-cross/bin/linux-amd64/
|
|
|
|
|
|
|
|
# `make pandoc` converts README.md into HTML for distribution.
|
|
|
|
.PHONY: pandoc
|
|
|
|
pandoc:
|
|
|
|
pandoc -o README.html README.md
|