Skip to content

Commit

Permalink
guile-git: fix libgit2 library path (0.5.2 rev 3)
Browse files Browse the repository at this point in the history
  • Loading branch information
aconchillo committed Feb 24, 2024
1 parent 3ddc017 commit 8beec51
Showing 1 changed file with 67 additions and 1 deletion.
68 changes: 67 additions & 1 deletion Formula/guile-git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@ class GuileGit < Formula
homepage "https://gitlab.com/guile-git/guile-git"
url "https://gitlab.com/guile-git/guile-git/uploads/6450f3991aa524484038cdcea3fb248d/guile-git-0.5.2.tar.gz"
sha256 "949755a211ad6e905ecdebe66ca35bfaab638d985b9fadc928ad2538d8f5cc95"
revision 2
revision 3

bottle do
root_url "https://github.com/aconchillo/homebrew-guile/releases/download/guile-git-0.5.2_2"
sha256 cellar: :any_skip_relocation, big_sur: "de100ac6aefed86383b415f6e7d5453851d733cc3832a69d0e36d1991037a8f3"
sha256 cellar: :any_skip_relocation, x86_64_linux: "263d075ede376a0f3438acac685979d67fcd0a2b02e30e213a2bc314ada26374"
end

depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "pkg-config" => :build
depends_on "texinfo" => :build
depends_on "guile"
depends_on "guile-bytestructures"
depends_on "libgit2"

patch :DATA

def install
ENV["GUILE_AUTO_COMPILE"] = "0"

Expand All @@ -25,6 +29,7 @@ def install
ENV["GUILE_LOAD_COMPILED_PATH"] = HOMEBREW_PREFIX/"lib/guile/3.0/site-ccache"
ENV["GUILE_SYSTEM_EXTENSIONS_PATH"] = HOMEBREW_PREFIX/"lib/guile/3.0/extensions"

system "autoreconf", "-vif"
system "./configure", "--prefix=#{prefix}"
system "make", "install"
end
Expand Down Expand Up @@ -52,3 +57,64 @@ def caveats
system "guile", git
end
end

__END__
diff --git a/configure.ac b/configure.ac
index a6e2bd4..ac75b36 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,12 +35,36 @@ GUILE_MODULE_REQUIRED([srfi srfi-64])

GUILE_MODULE_REQUIRED([bytestructures guile])

-PKG_CHECK_MODULES([LIBGIT2], [libgit2 >= 0.28.0])
-PKG_CHECK_VAR([LIBGIT2_LIBDIR], [libgit2], [libdir])
-AC_MSG_CHECKING([libgit2 library path])
-AS_IF([test "x$LIBGIT2_LIBDIR" = "x"], [
- AC_MSG_FAILURE([Unable to identify libgit2 lib path.])
+AC_DEFUN([GUILE_LIBGIT2_FILE_NAME], [
+ AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+ AC_CACHE_CHECK([libgit2's file name],
+ [guile_cv_libgit2_libdir],
+ [if test "$cross_compiling" = yes; then
+ # When cross-compiling, we cannot rely on 'ldd'. Instead, look
+ # the output of 'ld --verbose', assuming we're using GNU ld.
+ echo 'int main () { return git_libgit2_init(); }' > conftest.c
+ guile_cv_libgit2_libdir="\
+ `$CC conftest.c -o conftest$EXEEXT -llz -Wl,--verbose 2>/dev/null \
+ | grep -E '^/.*/libgit2\.(a|so)'`"
+ rm -f conftest.c conftest$EXEEXT
+ else
+ old_LIBS="$LIBS"
+ LIBS="-lgit2"
+ AC_LINK_IFELSE([AC_LANG_SOURCE([int main () { return git_libgit2_init(); }])],
+ [guile_cv_libgit2_libdir="`ldd conftest$EXEEXT | grep libgit2 | sed '-es/.*=> \(.*\) .*$/\1/g'`"])
+ LIBS="$old_LIBS"
+ fi])
+ $1="$guile_cv_libgit2_libdir"
])
+
+dnl Library name of libgit2 suitable for 'dynamic-link'.
+GUILE_LIBGIT2_FILE_NAME([LIBGIT2_LIBDIR])
+if test "x$LIBGIT2_LIBDIR" = "x"; then
+ LIBGIT2_LIBDIR="libgit2"
+else
+ # Strip the .so or .so.1 extension since that's what 'dynamic-link' expects.
+ LIBGIT2_LIBDIR="`echo $LIBGIT2_LIBDIR | sed -es'/\.so\(\.[[0-9.]]\+\)\?//g'`"
+fi
AC_SUBST([LIBGIT2_LIBDIR])

AC_PROG_CC
diff --git a/git/configuration.scm.in b/git/configuration.scm.in
index dc7b1a9..a1c2a72 100644
--- a/git/configuration.scm.in
+++ b/git/configuration.scm.in
@@ -24,7 +24,7 @@
%have-fetch-options-follow-redirects?))

(define %libgit2
- "@LIBGIT2_LIBDIR@/libgit2")
+ "@LIBGIT2_LIBDIR@")

(define %have-remote-callbacks-resolve-url?
;; True if the 'git_remote_callbacks' struct has a 'resolve_url' field.

0 comments on commit 8beec51

Please sign in to comment.