Skip to content

Commit

Permalink
Merge pull request #8 from SKAhack/cross-compile
Browse files Browse the repository at this point in the history
cross compilation
  • Loading branch information
skahack authored May 23, 2017
2 parents e7aa77f + 36d7889 commit 8c30f91
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ NAME := shipctl
VERSION := v0.3.0
REVISION := $(shell git rev-parse --short HEAD)

SRCS := $(shell find . -type f -name '*.go')
LDFLAGS := -ldflags="-s -w -X \"main.Version=$(VERSION)\" -X \"main.Revision=$(REVISION)\" -extldflags \"-static\""
SRCS := $(shell find . -type f -name '*.go')
LDFLAGS := -ldflags="-s -w -X \"main.Version=$(VERSION)\" -X \"main.Revision=$(REVISION)\" -extldflags \"-static\""
DIST_DIRS := find * -type d -exec

bin/$(NAME): $(SRCS)
@go build -a -tags netgo -installsuffix netgo $(LDFLAGS) -o bin/$(NAME)
Expand All @@ -22,19 +23,25 @@ clean:
rm -rf vendor/*
rm -rf dist

DIST_DIRS := find ./ -type d -exec
.PHONY: build-all
build-all:
gox -verbose \
$(LDFLAGS) \
-os="linux darwin" \
-arch="amd64 386 armv5 armv6 armv7 arm64" \
-osarch="!darwin/arm64" \
-output="dist/{{.OS}}-{{.Arch}}/{{.Dir}}" .

.PHONY: dist
dist: bin/${NAME}
dist: build-all
mkdir -p dist
cd bin && \
$(DIST_DIRS) tar -zcf ../dist/$(NAME)-$(VERSION).tar.gz {} \; && \
$(DIST_DIRS) zip -r ../dist/$(NAME)-$(VERSION).zip {} \; && \
cd dist && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.md {} \; && \
$(DIST_DIRS) tar -zcf $(NAME)-$(VERSION)-{}.tar.gz {} \; && \
$(DIST_DIRS) zip -r $(NAME)-$(VERSION)-{}.zip {} \; && \
cd ..

.PHONY: test
test:
@go test $$(go list ./... | grep -v '/vendor/') -cover

.PHONY: linux-bin
linux-bin:
docker run -it --rm -v$(CURDIR)/bin:/data $(NAME) cp /go/src/github.com/SKAhack/$(NAME)/bin/$(NAME) /data

0 comments on commit 8c30f91

Please sign in to comment.