2014-08-20 21:58:28 +00:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
|
|
|
# Build the syncthing library
|
|
|
|
ORIG=$(pwd)
|
|
|
|
mkdir -p bin
|
|
|
|
|
|
|
|
# Load submodules
|
|
|
|
if [ ! -f "ext/syncthing/src/github.com/syncthing/syncthing/.git" ]; then
|
2014-11-17 11:46:27 +00:00
|
|
|
git submodule update --init --recursive
|
2014-08-20 21:58:28 +00:00
|
|
|
fi
|
|
|
|
|
2014-11-17 11:46:27 +00:00
|
|
|
# Check for GOLANG installation
|
|
|
|
if [ -z $GOROOT ] || [[ $(go version) != go\ version\ go1.3.3* ]] ; then
|
|
|
|
mkdir -p "build"
|
|
|
|
tmpgo='build/go'
|
|
|
|
if [ ! -f "$tmpgo/bin/go" ]; then
|
|
|
|
# Download GOLANG v1.3.3
|
|
|
|
wget -O go.src.tar.gz https://golang.org/dl/go1.3.3.src.tar.gz
|
|
|
|
sha1=$(sha1sum go.src.tar.gz)
|
|
|
|
if [ "$sha1" != "b54b7deb7b7afe9f5d9a3f5dd830c7dede35393a go.src.tar.gz" ]; then
|
|
|
|
echo "go.src.tar.gz SHA1 checksum does not match!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
mkdir -p $tmpgo
|
|
|
|
tar -xzf go.src.tar.gz --strip=1 -C $tmpgo
|
|
|
|
rm go.src.tar.gz
|
|
|
|
# Build GO for host
|
|
|
|
pushd $tmpgo/src
|
|
|
|
./make.bash --no-clean
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
# Add GO to the environment
|
|
|
|
export GOROOT="$(pwd)/$tmpgo"
|
2014-08-20 21:58:28 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Add GO compiler to PATH
|
|
|
|
export PATH=$PATH:$GOROOT/bin
|
|
|
|
|
|
|
|
# Check whether GOLANG is compiled with cross-compilation for 386
|
|
|
|
if [ ! -f $GOROOT/bin/linux_386/go ]; then
|
2014-11-17 11:46:27 +00:00
|
|
|
pushd $GOROOT/src
|
|
|
|
# Build GO for cross-compilation
|
|
|
|
GOOS=linux GOARCH=386 ./make.bash --no-clean
|
|
|
|
popd
|
2014-08-20 21:58:28 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Check whether GOLANG is compiled with cross-compilation for arm
|
|
|
|
if [ ! -f $GOROOT/bin/linux_arm/go ]; then
|
2014-11-17 11:46:27 +00:00
|
|
|
pushd $GOROOT/src
|
|
|
|
# Build GO for cross-compilation
|
|
|
|
GOOS=linux GOARCH=arm ./make.bash --no-clean
|
|
|
|
popd
|
2014-08-20 21:58:28 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Setup GOPATH
|
|
|
|
cd "ext/syncthing/"
|
|
|
|
export GOPATH="$(pwd)"
|
|
|
|
|
|
|
|
# Install godep
|
|
|
|
$GOROOT/bin/go get github.com/tools/godep
|
2014-08-21 19:35:44 +00:00
|
|
|
export PATH="$(pwd)/bin":$PATH
|
2014-08-20 21:58:28 +00:00
|
|
|
|
2014-08-21 19:35:44 +00:00
|
|
|
# Setup syncthing and clean
|
2014-08-20 21:58:28 +00:00
|
|
|
export ENVIRONMENT=android
|
2014-08-21 19:35:44 +00:00
|
|
|
cd src/github.com/syncthing/syncthing
|
|
|
|
$GOROOT/bin/go run build.go clean
|
2014-08-20 21:58:28 +00:00
|
|
|
|
|
|
|
# X86
|
|
|
|
$GOROOT/bin/go run build.go -goos linux -goarch 386 -no-upgrade build
|
|
|
|
mv syncthing $ORIG/bin/syncthing-x86
|
|
|
|
$GOROOT/bin/go run build.go clean
|
|
|
|
|
|
|
|
# ARM-7
|
|
|
|
$GOROOT/bin/go run build.go -goos linux -goarch armv7 -no-upgrade build
|
|
|
|
mv syncthing $ORIG/bin/syncthing-armeabi-v7a
|
|
|
|
$GOROOT/bin/go run build.go clean
|
|
|
|
|
|
|
|
# ARM-5
|
|
|
|
$GOROOT/bin/go run build.go -goos linux -goarch armv5 -no-upgrade build
|
|
|
|
mv syncthing $ORIG/bin/syncthing-armeabi
|
|
|
|
$GOROOT/bin/go run build.go clean
|