summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2014-06-07 15:38:32 +0200
committerCarlos Martín Nieto <[email protected]>2014-06-07 15:43:05 +0200
commitaabeb7f585da1cf966191886eab732db0020a41a (patch)
treed414cc7e46aece422e47f9ec43ada6b4ba59dcab
parent6862c2c82d89d30b0283d8a7e77851a802534daa (diff)
Really build statically
-rw-r--r--Makefile5
-rw-r--r--git.go1
-rwxr-xr-xscript/build-libgit2-static.sh1
-rwxr-xr-xscript/with-less-static.sh13
-rwxr-xr-xscript/with-static.sh6
-rw-r--r--settings/settings.go1
6 files changed, 22 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index b306577..66f3d92 100644
--- a/Makefile
+++ b/Makefile
@@ -5,8 +5,9 @@ build-libgit2:
cat ./vendor/libgit2/libgit2.pc
cat ./vendor/install/lib/pkgconfig/libgit2.pc
-test: build-libgit2
- ./script/with-static.sh go test ./...
+test: install build-libgit2
+ ./script/with-static.sh go test
+ ./script/with-less-static.sh go test ./settings
install: build-libgit2
./script/with-static.sh go install ./...
diff --git a/git.go b/git.go
index 5e43dff..8154278 100644
--- a/git.go
+++ b/git.go
@@ -1,7 +1,6 @@
package git
/*
-#cgo pkg-config: --static libgit2
#include <git2.h>
#include <git2/errors.h>
*/
diff --git a/script/build-libgit2-static.sh b/script/build-libgit2-static.sh
index e486d1d..ca5390d 100755
--- a/script/build-libgit2-static.sh
+++ b/script/build-libgit2-static.sh
@@ -9,6 +9,7 @@ cd $VENDORED_PATH
cmake -DTHREADSAFE=ON \
-DBUILD_CLAR=OFF \
-DBUILD_SHARED_LIBS=OFF \
+ -DCMAKE_C_FLAGS=-fPIC \
-DCMAKE_INSTALL_PREFIX=../install \
.
diff --git a/script/with-less-static.sh b/script/with-less-static.sh
new file mode 100755
index 0000000..faaeb01
--- /dev/null
+++ b/script/with-less-static.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -ex
+
+export INSTALL_LOCATION=$PWD/vendor/install
+export PKG_CONFIG_PATH=$INSTALL_LOCATION/lib/pkgconfig
+
+export PCFILE="$PWD/vendor/libgit2/libgit2.pc"
+
+export CGO_LDFLAGS="$(pkg-config --static --libs $PCFILE)"
+export CGO_CFLAGS="$(pkg-config --static --cflags $PCFILE)"
+
+$@
diff --git a/script/with-static.sh b/script/with-static.sh
index 914d8b2..643dcff 100755
--- a/script/with-static.sh
+++ b/script/with-static.sh
@@ -4,6 +4,10 @@ set -ex
export INSTALL_LOCATION=$PWD/vendor/install
export PKG_CONFIG_PATH=$INSTALL_LOCATION/lib/pkgconfig
-export CGO_LDFLAGS='-lrt'
+
+export PCFILE="$PWD/vendor/libgit2/libgit2.pc"
+
+export CGO_LDFLAGS="$PWD/vendor/libgit2/libgit2.a $(pkg-config --static --libs $PCFILE)"
+export CGO_CFLAGS="$(pkg-config --static --cflags $PCFILE)"
$@
diff --git a/settings/settings.go b/settings/settings.go
index f18c7a1..a7f96c7 100644
--- a/settings/settings.go
+++ b/settings/settings.go
@@ -1,7 +1,6 @@
package settings
/*
-#cgo pkg-config: --static libgit2
#include <git2.h>
int _go_git_opts_get_search_path(int level, git_buf *buf)