Allow building statically via the "static" build tag
diff --git a/Makefile b/Makefile
index 9c42283..5b1e319 100644
--- a/Makefile
+++ b/Makefile
@@ -6,3 +6,13 @@
 
 install:
 	go install ./...
+
+build-libgit2:
+	./script/build-libgit2-static.sh
+
+static: build-libgit2
+	go run script/check-MakeGitError-thread-lock.go
+	go test --tags "static" ./...
+
+install-staic: build-libgit2
+	go install --tags "static" ./...
diff --git a/git.go b/git.go
index ed891e6..2b2a909 100644
--- a/git.go
+++ b/git.go
@@ -3,12 +3,6 @@
 /*
 #include <git2.h>
 #include <git2/sys/openssl.h>
-#cgo pkg-config: libgit2
-
-#if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 24
-# error "Invalid libgit2 version; this git2go supports libgit2 v0.24"
-#endif
-
 */
 import "C"
 import (
diff --git a/git_dynamic.go b/git_dynamic.go
new file mode 100644
index 0000000..6cd476d
--- /dev/null
+++ b/git_dynamic.go
@@ -0,0 +1,14 @@
+// +build !static
+
+package git
+
+/*
+#include <git2.h>
+#cgo pkg-config: libgit2
+
+#if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 24
+# error "Invalid libgit2 version; this git2go supports libgit2 v0.24"
+#endif
+
+*/
+import "C"
diff --git a/git_static.go b/git_static.go
new file mode 100644
index 0000000..9e7f03a
--- /dev/null
+++ b/git_static.go
@@ -0,0 +1,17 @@
+// +build static
+
+package git
+
+/*
+#cgo CFLAGS: -I${SRCDIR}/vendor/libgit2/include
+#cgo LDFLAGS: -L${SRCDIR}/vendor/libgit2/build/ -lgit2
+#cgo windows LDFLAGS: -lwinhttp
+#cgo !windows pkg-config: --static ${SRCDIR}/vendor/libgit2/build/libgit2.pc
+#include <git2.h>
+
+#if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 24
+# error "Invalid libgit2 version; this git2go supports libgit2 v0.24"
+#endif
+
+*/
+import "C"
diff --git a/vendor/libgit2 b/vendor/libgit2
new file mode 160000
index 0000000..4cf1ec7
--- /dev/null
+++ b/vendor/libgit2
@@ -0,0 +1 @@
+Subproject commit 4cf1ec7cff28da8838a2f0a9fb330e312ea3f963