@@ -15,14 +15,16 @@ INSTALL_LIBDIR ?= $(INSTALL_PREFIX)/lib/$(shell xx-info triple)
1515endif
1616BUILD_TYPE ?= "RelWithDebInfo"
1717FLAGS ?=
18- USE_HTTPS ?= OpenSSL
19- USE_SSH ?= ON
18+ USE_HTTPS ?= OFF
19+ USE_SSH ?= OFF
20+ USE_BUNDLED_ZLIB ?= OFF
21+ BUILD_SHARED_LIBS ?= ON
2022
2123# Cmake version to be installed.
2224CMAKE_VERSION ?= 3.21.3
2325
2426# Libgit2 version to be compiled and installed.
25- LIBGIT2_VERSION ?= 1.1.1
27+ LIBGIT2_VERSION ?= 1.3.0
2628# In some scenarios libgit2 needs to be checked out to a specific commit.
2729# This takes presidence over LIBGIT_VERSION if defined.
2830# Ref: https://github.com/libgit2/git2go/issues/834
@@ -65,19 +67,32 @@ ifeq (debian,$(XX_VENDOR))
6567# certain key formats).
6668# Ref: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=668271
6769# Ref: https://github.com/ARMmbed/mbedtls/issues/2452#issuecomment-802683144
70+ DEPENDENCIES =
71+ ifneq ("OFF",$(USE_BUNDLED_ZLIB ) )
72+ DEPENDENCIES += zlib1g-dev
73+ endif
74+ ifneq ("OFF",$(USE_HTTPS ) )
75+ DEPENDENCIES += libssl-dev
76+ endif
77+ ifneq ("OFF",$(USE_SSH ) )
78+ DEPENDENCIES += libssh2-1-dev
79+ endif
6880dependencies :
81+ ifneq ("",$(DEPENDENCIES ) )
6982 set -e; \
7083 echo "deb http://deb.debian.org/debian sid main" > /etc/apt/sources.list.d/sid.list \
7184 && echo "deb-src http://deb.debian.org/debian sid main" /etc/apt/sources.list.d/sid.list \
7285 && xx-apt update \
73- && xx-apt -t sid install --no-install-recommends -y zlib1g-dev libssl-dev libssh2-1-dev
86+ && xx-apt -t sid install --no-install-recommends -y $(DEPENDENCIES)
87+ endif
7488endif
7589.PHONY : dependencies
7690
7791libgit2 : $(LIBGIT2 )
7892.PHONY : libgit2
7993
8094ifdef HAS_BREW
95+ ifneq ("OFF",$(USE_HTTPS ) )
8196HAS_OPENSSL := $(shell brew --prefix openssl@1.1)
8297# NB: the OPENSSL_LDFLAGS ensures the path is included in the libgit2.pc
8398# file. As a standard brew installation doesn't appear to be system wide
@@ -87,11 +102,14 @@ ifdef HAS_OPENSSL
87102 PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):$(HAS_OPENSSL)/lib/pkgconfig
88103 FLAGS += -DOPENSSL_LDFLAGS:STRING='-L $(HAS_OPENSSL)/lib'
89104endif
105+ endif
106+ ifneq ("OFF",$(USE_SSH ) )
90107HAS_LIBSSH2 := $(shell brew --prefix libssh2)
91108ifdef HAS_LIBSSH2
92109 PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):$(HAS_LIBSSH2)/lib/pkgconfig
93110endif
94111endif
112+ endif
95113
96114$(LIBGIT2 ) :
97115 set -e; \
@@ -108,7 +126,7 @@ $(LIBGIT2):
108126 -DCMAKE_INSTALL_LIBDIR:PATH=$(INSTALL_LIBDIR ) \
109127 -DBUILD_CLAR:BOOL:BOOL=OFF \
110128 -DTHREADSAFE:BOOL=ON \
111- -DBUILD_SHARED_LIBS=ON \
129+ -DBUILD_SHARED_LIBS:BOOL= $( BUILD_SHARED_LIBS ) \
112130 -DUSE_BUNDLED_ZLIB:BOOL=OFF \
113131 -DUSE_HTTP_PARSER:STRING=builtin \
114132 -DREGEX_BACKEND:STRING=builtin \
0 commit comments