diff --git a/Makefile b/Makefile index 80d6d6b1b..1c20c7be9 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +.PHONY: statusgo all test xgo clean +.PHONY: statusgo-android statusgo-ios + GOBIN = build/bin GO ?= latest @@ -6,9 +9,23 @@ statusgo: @echo "status go compilation done." @echo "Run \"build/bin/statusgo\" to view available commands" +statusgo-cross: statusgo-android statusgo-ios + @echo "Full cross compilation done:" + @ls -ld $(GOBIN)/statusgo-* + statusgo-android: xgo - build/env.sh $(GOBIN)/xgo --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=android-16/aar ./src + build/env.sh $(GOBIN)/xgo --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=android-16/aar -v $(shell build/flags.sh) ./src @echo "Android cross compilation done:" +statusgo-ios: xgo + build/env.sh $(GOBIN)/xgo --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=ios-7.0/framework -v $(shell build/flags.sh) ./src + @echo "iOS framework cross compilation done:" + xgo: build/env.sh go get github.com/karalabe/xgo + +test: + build/env.sh go test ./... + +clean: + rm -fr $(GOBIN)/* diff --git a/build/flags.sh b/build/flags.sh new file mode 100644 index 000000000..e021dbad4 --- /dev/null +++ b/build/flags.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -e + +if [ ! -f "build/env.sh" ]; then + echo "$0 must be run from the root of the repository." + exit 2 +fi + +# Since Go 1.5, the separator char for link time assignments +# is '=' and using ' ' prints a warning. However, Go < 1.5 does +# not support using '='. +sep=$(go version | awk '{ if ($3 >= "go1.5" || index($3, "devel")) print "="; else print " "; }' -) + +# set gitCommit when running from a Git checkout. +if [ -f ".git/HEAD" ]; then + echo "-ldflags '-X main.gitCommit$sep$(git rev-parse HEAD)'" +fi + +if [ ! -z "$GO_OPENCL" ]; then + echo "-tags opencl" +fi