2017-10-27 01:03:11 +00:00
|
|
|
SHELL := /bin/bash
|
|
|
|
|
2019-06-26 01:10:57 +00:00
|
|
|
VERSION=$(shell grep -e 'Version =' pkg/branding/branding.go | head -n 1 | cut -d '"' -f 2)
|
2017-10-27 01:03:11 +00:00
|
|
|
BUILD=$(shell git describe --always)
|
2019-07-09 01:16:45 +00:00
|
|
|
BUILD_DATE=$(shell date +"%Y-%m-%dT%H:%M:%S%z")
|
2017-10-27 01:03:11 +00:00
|
|
|
CURDIR=$(shell curdir)
|
|
|
|
|
|
|
|
# Inject the build version (commit hash) into the executable.
|
2019-04-10 02:17:56 +00:00
|
|
|
LDFLAGS := -ldflags "-X main.Build=$(BUILD) -X main.BuildDate=$(BUILD_DATE)"
|
2019-07-09 01:16:45 +00:00
|
|
|
LDFLAGS_W := -ldflags "-X main.Build=$(BUILD) -X main.BuildDate=$(BUILD_DATE) -H windowsgui"
|
2017-10-27 01:03:11 +00:00
|
|
|
|
|
|
|
# `make setup` to set up a new environment, pull dependencies, etc.
|
|
|
|
.PHONY: setup
|
|
|
|
setup: clean
|
2019-06-28 03:24:13 +00:00
|
|
|
go get -u github.com/go-bindata/go-bindata/...
|
2019-03-01 02:32:44 +00:00
|
|
|
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
|
2018-10-16 16:20:25 +00:00
|
|
|
go build $(LDFLAGS) -i -o bin/doodad cmd/doodad/main.go
|
2017-10-27 01:03:11 +00:00
|
|
|
|
2019-06-28 03:24:13 +00:00
|
|
|
# `make buildall` to run all build steps including doodads and bindata.
|
|
|
|
.PHONY: buildall
|
|
|
|
buildall: doodads bindata build
|
|
|
|
|
2019-04-20 00:23:37 +00:00
|
|
|
# `make build-free` to build the binary in free mode.
|
|
|
|
.PHONY: build-free
|
|
|
|
build-free:
|
|
|
|
gofmt -w .
|
|
|
|
go build $(LDFLAGS) -tags="shareware" -i -o bin/doodle cmd/doodle/main.go
|
|
|
|
go build $(LDFLAGS) -tags="shareware" -i -o bin/doodad cmd/doodad/main.go
|
|
|
|
|
2019-05-05 21:03:20 +00:00
|
|
|
# `make build-debug` to build the binary in developer mode.
|
|
|
|
.PHONY: build-debug
|
|
|
|
build-debug:
|
|
|
|
gofmt -w .
|
|
|
|
go build $(LDFLAGS) -tags="developer" -i -o bin/doodle cmd/doodle/main.go
|
|
|
|
go build $(LDFLAGS) -tags="developer" -i -o bin/doodad cmd/doodad/main.go
|
|
|
|
|
2019-06-27 22:07:34 +00:00
|
|
|
# `make bindata` generates the embedded binary assets package.
|
|
|
|
.PHONY: bindata
|
|
|
|
bindata:
|
2019-06-28 05:54:46 +00:00
|
|
|
go-bindata -pkg bindata -o pkg/bindata/bindata.go assets/...
|
2019-06-27 22:07:34 +00:00
|
|
|
|
|
|
|
# `make bindata-dev` generates the debug version of bindata package.
|
|
|
|
.PHONY: bindata-dev
|
|
|
|
bindata-dev:
|
2019-06-28 05:54:46 +00:00
|
|
|
go-bindata -debug -pkg bindata -o pkg/bindata/bindata.go assets/...
|
2019-06-27 22:07:34 +00:00
|
|
|
|
2019-06-27 01:36:54 +00:00
|
|
|
# `make wasm` builds the WebAssembly port.
|
|
|
|
.PHONY: wasm
|
|
|
|
wasm:
|
|
|
|
cd wasm && make
|
|
|
|
|
|
|
|
# `make wasm-serve` builds and launches the WebAssembly server.
|
|
|
|
.PHONY: wasm-serve
|
|
|
|
wasm-serve: wasm
|
|
|
|
sh -c 'sleep 1; xdg-open http://localhost:8080/' &
|
|
|
|
cd wasm && go run server.go
|
|
|
|
|
2019-05-05 23:32:30 +00:00
|
|
|
# `make install` to install the Go binaries to your GOPATH.
|
|
|
|
.PHONY: install
|
|
|
|
install:
|
|
|
|
go install git.kirsle.net/apps/doodle/cmd/...
|
|
|
|
|
2019-05-02 01:27:20 +00:00
|
|
|
# `make doodads` to build the doodads from the dev-assets folder.
|
|
|
|
.PHONY: doodads
|
|
|
|
doodads:
|
|
|
|
cd dev-assets/doodads && ./build.sh
|
|
|
|
|
2019-04-07 02:30:25 +00:00
|
|
|
# `make mingw` to cross-compile a Windows binary with mingw.
|
|
|
|
.PHONY: mingw
|
2019-06-28 03:24:13 +00:00
|
|
|
mingw: doodads bindata
|
2019-04-07 02:30:25 +00:00
|
|
|
env CGO_ENABLED="1" CC="/usr/bin/x86_64-w64-mingw32-gcc" \
|
|
|
|
GOOS="windows" CGO_LDFLAGS="-lmingw32 -lSDL2" CGO_CFLAGS="-D_REENTRANT" \
|
2019-07-09 01:16:45 +00:00
|
|
|
go build $(LDFLAGS_W) -i -o bin/doodle.exe cmd/doodle/main.go
|
2019-04-07 02:30:25 +00:00
|
|
|
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
|
|
|
|
|
2019-07-09 02:12:25 +00:00
|
|
|
# `make mingw-free` for Windows binary in free mode.
|
|
|
|
.PHONY: mingw-free
|
|
|
|
mingw-free: doodads bindata
|
|
|
|
env CGO_ENABLED="1" CC="/usr/bin/x86_64-w64-mingw32-gcc" \
|
|
|
|
GOOS="windows" CGO_LDFLAGS="-lmingw32 -lSDL2" CGO_CFLAGS="-D_REENTRANT" \
|
2019-07-10 03:09:01 +00:00
|
|
|
go build $(LDFLAGS_W) -tags="shareware" -i -o bin/doodle.exe cmd/doodle/main.go
|
2019-07-09 02:12:25 +00:00
|
|
|
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) -tags="shareware" -i -o bin/doodad.exe cmd/doodad/main.go
|
|
|
|
|
2019-04-07 02:30:25 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2018-10-08 17:38:49 +00:00
|
|
|
# `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 ./...
|
|
|
|
|
2019-03-01 02:32:44 +00:00
|
|
|
# `make dist` builds and tars up a release.
|
|
|
|
.PHONY: dist
|
2019-07-09 02:12:25 +00:00
|
|
|
dist: doodads bindata build __dist-common
|
|
|
|
|
|
|
|
# `make dist-free` builds and tars up a release in shareware mode.
|
|
|
|
.PHONY: dist-free
|
|
|
|
dist-free: doodads bindata build-free __dist-common
|
|
|
|
|
|
|
|
# Common logic behind `make dist`
|
|
|
|
.PHONY: __dist-common
|
|
|
|
__dist-common:
|
2019-03-01 02:32:44 +00:00
|
|
|
mkdir -p dist/doodle-$(VERSION)
|
|
|
|
cp bin/* dist/doodle-$(VERSION)/
|
2019-07-09 02:12:25 +00:00
|
|
|
cp -r README.md "Open Source Licenses.md" dist/doodle-$(VERSION)/
|
2019-03-01 02:32:44 +00:00
|
|
|
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
|
2019-03-01 02:32:44 +00:00
|
|
|
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
|
2019-03-01 02:32:44 +00:00
|
|
|
__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
|