Build script for linux

This commit is contained in:
Nicolas Dextraze 2018-03-17 09:55:21 -07:00
parent 84e8e469ad
commit 8f2acc0605

35
build.sh Executable file
View File

@ -0,0 +1,35 @@
# clean
rm -rf bin
# create folders
mkdir .go
mkdir .deps
# get and build libzmq
cd .deps
git clone https://github.com/zeromq/libzmq
cd libzmq
git checkout v4.2.3
./autogen.sh && ./configure && make
cd ../..
# get and build go zmq4
GOPATH=`pwd`/.go
go get
# use built libzmq
ESC_PWD=`pwd | sed 's/\//\\\\\//g'`
cflags="\#cgo \!windows CFLAGS\: \-I${ESC_PWD}\/\.deps\/libzmq\/include"
ldflags="\#cgo \!windows LDFLAGS\: ${ESC_PWD}\/\.deps\/libzmq\/src\/\.libs\/libzmq\.a \-lstdc\+\+ \-lm"
sed -i "4s/.*/${cflags}/" .go/src/github.com/pebbe/zmq4/zmq4.go
sed -i "5s/.*/${ldflags}/" .go/src/github.com/pebbe/zmq4/zmq4.go
# build goes
go build -a -ldflags '-s' -o bin/goes goes.go
# copy licenses
cp .deps/libzmq/COPYING bin/libzmq.COPYING
cp .deps/libzmq/COPYING.LESSER bin/libzmq.COPYING.LESSER
cp LICENSE bin/LICENSE
tar -czvf goes.tar.gz bin/