[libgit2-glib] Make ssh support optional



commit 6605ada3d7fd22adcdc85ab4494bde1d999bf0dd
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Wed Jun 25 12:57:32 2014 +0200

    Make ssh support optional
    
    For now we set -DGIT_SSH=1 in our .pc file when we detected git2
    with ssh support. This should be removed when this issue is fixed
    in git2 itself.

 configure.ac             |   44 +++++++++++++++++++++++++++++++++++++++++++-
 libgit2-glib-1.0.pc.in   |    2 +-
 libgit2-glib/Makefile.am |   15 ++++++++++-----
 libgit2-glib/ggit.h      |    5 +++++
 4 files changed, 59 insertions(+), 7 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 519f620..f3b73b5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,9 +64,11 @@ PKG_CHECK_MODULES(LIBGIT2_GLIB, [
        gio-2.0 >= $GLIB_REQUIRED
        libgit2 >= $GIT2_REQUIRED
        gobject-introspection-1.0 >= $INTROSPECTION_REQUIRED
-       libssh2
 ])
 
+LIBGIT2_INCLUDE_DIR=$($PKG_CONFIG --variable=includedir libgit2)
+LIBGIT2_GLIB_CFLAGS="${LIBGIT2_GLIB_CFLAGS} -I$LIBGIT2_INCLUDE_DIR"
+
 GOBJECT_INTROSPECTION_REQUIRE($INTROSPECTION_REQUIRED)
 
 AC_SUBST(INTROSPECTION_REQUIRED)
@@ -74,6 +76,46 @@ AC_SUBST(GLIB_REQUIRED)
 AC_SUBST(GIT2_REQUIRED)
 
 dnl ===========================================================================
+dnl Check for libgit2 ssh support
+dnl ===========================================================================
+
+AC_MSG_CHECKING([for libgit2 ssh support])
+
+cflags_save="${CFLAGS}"
+libs_save="${LIBS}"
+
+CFLAGS="${LIBGIT2_GLIB_CFLAGS}"
+LIBS="${LIBGIT2_GLIB_LIBS}"
+
+AC_TRY_RUN([
+        #include <git2.h>
+        int
+        main(int argc, const char *argv[])
+        {
+                git_threads_init ();
+                return ((git_libgit2_features() & GIT_FEATURE_SSH) != 0) ? 0 : 1;
+        }
+],[
+    AC_MSG_RESULT([yes])
+    git_ssh=yes
+],[
+    AC_MSG_RESULT([no])
+    git_ssh=no
+])
+
+CFLAGS="${cflags_save}"
+LIBS="${libs_save}"
+
+if test "x$git_ssh" = "xyes"; then
+       LIBGIT2_GLIB_CFLAGS="${LIBGIT2_GLIB_CFLAGS} -DGIT_SSH=1"
+       LIBGIT2_GLIB_PCCFLAGS="-DGIT_SSH=1"
+fi
+
+AC_SUBST(LIBGIT2_GLIB_PCCFLAGS)
+
+AM_CONDITIONAL(GIT_SSH, test x"$git_ssh" = "xyes")
+
+dnl ===========================================================================
 dnl Check for python
 dnl ===========================================================================
 PYGOBJECT_REQUIRED=3.0.0
diff --git a/libgit2-glib-1.0.pc.in b/libgit2-glib-1.0.pc.in
index 2b3696e..cf8eb36 100644
--- a/libgit2-glib-1.0.pc.in
+++ b/libgit2-glib-1.0.pc.in
@@ -7,5 +7,5 @@ Name: libgit2-glib
 Description: libgit2-glib, a a glib wrapper library around the libgit2 git access library.
 Requires: libgit2 >= @GIT2_REQUIRED@, glib-2.0 >= @GLIB_REQUIRED@, gobject-2.0 >= @GLIB_REQUIRED@, gio-2.0 
= @GLIB_REQUIRED@, gobject-introspection-1.0 >= @INTROSPECTION_REQUIRED@
 Version: @VERSION@
-Cflags: -I${includedir}/libgit2-glib-1.0 -DGIT_SSH=1
+Cflags: -I${includedir}/libgit2-glib-1.0 @LIBGIT2_GLIB_PCCFLAGS@
 Libs: -L${libdir} -lgit2-glib-1.0
diff --git a/libgit2-glib/Makefile.am b/libgit2-glib/Makefile.am
index 977f77f..d2a7090 100644
--- a/libgit2-glib/Makefile.am
+++ b/libgit2-glib/Makefile.am
@@ -6,7 +6,6 @@ AM_CPPFLAGS =                                                           \
        $(LIBGIT2_GLIB_CFLAGS)                                          \
        $(WARN_CFLAGS)                                                  \
        $(DISABLE_DEPRECATED_CFLAGS)                                    \
-       -DGIT_SSH=1                                                     \
        -DDATADIR=\""$(datadir)"\"                                      \
        -DLIBDIR=\""$(libdir)"\"
 
@@ -31,9 +30,7 @@ INST_H_FILES =                                \
        ggit-config.h                   \
        ggit-config-entry.h             \
        ggit-cred.h                     \
-       ggit-cred-ssh-interactive.h     \
        ggit-cred-plaintext.h           \
-       ggit-cred-ssh-key-from-agent.h  \
        ggit-diff.h                     \
        ggit-diff-delta.h               \
        ggit-diff-file.h                \
@@ -95,8 +92,6 @@ C_FILES =                             \
        ggit-convert.c                  \
        ggit-cred.c                     \
        ggit-cred-plaintext.c           \
-       ggit-cred-ssh-interactive.c     \
-       ggit-cred-ssh-key-from-agent.c  \
        ggit-diff.c                     \
        ggit-diff-delta.c               \
        ggit-diff-file.c                \
@@ -139,6 +134,16 @@ C_FILES =                          \
        ggit-types.c                    \
        ggit-utils.c
 
+if GIT_SSH
+C_FILES +=                             \
+       ggit-cred-ssh-interactive.c     \
+       ggit-cred-ssh-key-from-agent.c
+
+INST_H_FILES +=                                \
+       ggit-cred-ssh-interactive.h     \
+       ggit-cred-ssh-key-from-agent.h
+endif
+
 ENUM_TYPES =                           \
        $(INST_H_FILES)
 
diff --git a/libgit2-glib/ggit.h b/libgit2-glib/ggit.h
index a7236c3..d880a7c 100644
--- a/libgit2-glib/ggit.h
+++ b/libgit2-glib/ggit.h
@@ -71,6 +71,11 @@
 #include <libgit2-glib/ggit-tree.h>
 #include <libgit2-glib/ggit-types.h>
 
+#ifdef GIT_SSH
+#include <libgit2-glib/ggit-cred-ssh-key-from-agent.h>
+#include <libgit2-glib/ggit-cred-ssh-interactive.h>
+#endif
+
 #endif
 
 /* ex:set ts=8 noet: */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]