Skip to content

Commit

Permalink
Makefile for cross compilation added
Browse files Browse the repository at this point in the history
Added a Makefile for cross compilation during releases and to
democratize compilation for users themselves.

Updates #662.
  • Loading branch information
odeke-em committed Jun 11, 2016
1 parent cd7845e commit bd7e3f5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin/
md5Sums.txt
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Makefile for cross-compilation
#
OS := $(shell uname)
BINDIR := ./bin
MD5_TEXTFILE := $(BINDIR)/md5Sums.txt

MAIN_FILE_DIR := ./cmd/drive

ifeq ($(OS), Darwin)
MD5_UTIL = md5
else
MD5_UTIL = md5sum
endif

all: compileThemAll md5SumThemAll

compileThemAll: armv5 armv6 armv7 armv8 darwin linux

md5SumThemAll:
rm -f $(MD5_TEXTFILE)
find $(BINDIR) -type f -name "drive_*" -exec $(MD5_UTIL) {} >> $(MD5_TEXTFILE) \;
cat $(MD5_TEXTFILE)

armv5:
CGO_ENABLED=0 GOOS=linux GOARM=5 GOARCH=arm go build -o $(BINDIR)/drive_armv5 $(MAIN_FILE_DIR)
armv6:
CGO_ENABLED=0 GOOS=linux GOARM=6 GOARCH=arm go build -o $(BINDIR)/drive_armv6 $(MAIN_FILE_DIR)
armv7:
CGO_ENABLED=0 GOOS=linux GOARM=7 GOARCH=arm go build -o $(BINDIR)/drive_armv7 $(MAIN_FILE_DIR)
armv8:
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(BINDIR)/drive_armv8 $(MAIN_FILE_DIR)
darwin:
CGO_ENABLED=0 GOOS=darwin go build -o $(BINDIR)/drive_darwin $(MAIN_FILE_DIR)
linux:
CGO_ENABLED=0 GOOS=linux go build -o $(BINDIR)/drive_linux $(MAIN_FILE_DIR)
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- [Installation](#installation)
- [Platform Packages](#platform-packages)
- [Godep](#godep)
- [Cross Compilation](#cross-compilation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Initializing](#initializing)
Expand Down Expand Up @@ -132,6 +133,21 @@ For curated packages on your favorite platform, please see file [Platform Packag
Is your platform missing a package? Feel free to prepare / contribute an installation package and then submit a PR to add it in.
### Cross Compilation
See file `Makefile` which currently supports cross compilation. Just run `make` and then inspect the binaries in directory `bin`.
* Supported platforms to cross compile to:
- ARMv5.
- ARMv6.
- ARMv7.
- ARMv8.
- Darwin (OS X).
- Linux.
Also inspect file `bin/md5Sums.txt` after the cross compilation.
## Configuration
Optionally set the `GOOGLE_API_CLIENT_ID` and `GOOGLE_API_CLIENT_SECRET` environment variables to use your own API keys.
Expand Down

0 comments on commit bd7e3f5

Please sign in to comment.