doodle/Makefile

77 lines
2.1 KiB
Makefile
Raw Normal View History

2017-10-27 01:03:11 +00:00
SHELL := /bin/bash
VERSION=$(shell grep -e 'Version =' doodle.go | head -n 1 | cut -d '"' -f 2)
2017-10-27 01:03:11 +00:00
BUILD=$(shell git describe --always)
CURDIR=$(shell curdir)
# Inject the build version (commit hash) into the executable.
LDFLAGS := -ldflags "-X main.Build=$(BUILD)"
# `make setup` to set up a new environment, pull dependencies, etc.
.PHONY: setup
setup: clean
go get ./...
2017-10-27 01:03:11 +00:00
# `make build` to build the binary.
.PHONY: build
build:
gofmt -w .
go build $(LDFLAGS) -i -o bin/doodle cmd/doodle/main.go
go build $(LDFLAGS) -i -o bin/doodad cmd/doodad/main.go
2017-10-27 01:03:11 +00:00
# `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) -i -o bin/doodle.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
2017-10-27 01:03:11 +00:00
# `make run` to run it in debug mode.
.PHONY: run
run:
go run cmd/doodle/main.go -debug
# `make guitest` to run it in guitest mode.
.PHONY: guitest
guitest:
go run cmd/doodle/main.go -debug -guitest
2017-10-27 01:03:11 +00:00
# `make test` to run unit tests.
.PHONY: test
test:
go test ./...
# `make dist` builds and tars up a release.
.PHONY: dist
dist: build
mkdir -p dist/doodle-$(VERSION)
cp bin/* dist/doodle-$(VERSION)/
cp -r assets fonts README.md Changes.md dist/doodle-$(VERSION)/
cd dist && tar -czvf doodle-$(VERSION).tar.gz doodle-$(VERSION)
cd dist && zip -r doodle-$(VERSION).zip doodle-$(VERSION)
# `make docker` to run the Docker builds
2019-04-05 20:16:33 +00:00
.PHONY: docker docker.ubuntu docker.debian docker.fedora __docker.dist
docker.ubuntu:
mkdir -p docker/ubuntu
./docker/dist-ubuntu.sh
docker.debian:
mkdir -p docker/debian
./docker/dist-debian.sh
2019-04-05 20:16:33 +00:00
docker.fedora:
mkdir -p docker/fedora
./docker/dist-fedora.sh
docker: docker.ubuntu docker.debian docker.fedora
__docker.dist: dist
cp dist/*.tar.gz dist/*.zip /mnt/export/
2017-10-27 01:03:11 +00:00
# `make clean` cleans everything up.
.PHONY: clean
clean:
2019-04-05 20:16:33 +00:00
rm -rf bin dist docker/ubuntu docker/debian docker/fedora