aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/build.sh
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2020-04-09 16:52:33 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-04-09 17:04:52 -0700
commitc6704f2aa699ea4d3643b2e84c30b06f446f43a5 (patch)
treeac674e618c0d0bb20322fe0542338bd681fdfe48 /scripts/build.sh
parent3a74f650637e5e8e1ae71933cbfb6373147c0456 (diff)
downloadsubsurface-c6704f2aa699ea4d3643b2e84c30b06f446f43a5.tar.gz
build-system: deal with libgit2 versions 1 and later
We assumed everywhere that libgit would always have a 0.xx version number. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'scripts/build.sh')
-rwxr-xr-xscripts/build.sh22
1 files changed, 15 insertions, 7 deletions
diff --git a/scripts/build.sh b/scripts/build.sh
index aeb3ecbed..83923744e 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -245,8 +245,8 @@ fi
if [ "$PLATFORM" = Darwin ] ; then
SH_LIB_EXT=dylib
if [ ! "$BUILD_DEPS" == "1" ] ; then
- pkg-config --exists libgit2 && LIBGIT=$(pkg-config --modversion libgit2 | cut -d. -f2)
- if [[ "$LIBGIT" -gt "23" ]] ; then
+ pkg-config --exists libgit2 && LIBGIT=$(pkg-config --modversion libgit2) && LIBGITMAJ=$(echo $LIBGIT | cut -d. -f1) && LIBGIT=$(echo $LIBGIT | cut -d. -f2)
+ if [[ "$LIBGITMAJ" -gt "0" || "$LIBGIT" -gt "25" ]] ; then
LIBGIT2_FROM_PKGCONFIG="-DLIBGIT2_FROM_PKGCONFIG=ON"
fi
fi
@@ -258,12 +258,20 @@ else
# first check pkgconfig (that will capture our own local build if
# this script has been run before)
if pkg-config --exists libgit2 ; then
- LIBGIT=$(pkg-config --modversion libgit2 | cut -d. -f2)
- LIBGIT2_FROM_PKGCONFIG="-DLIBGIT2_FROM_PKGCONFIG=ON"
+ LIBGIT=$(pkg-config --modversion libgit2)
+ LIBGITMAJ=$(echo $LIBGIT | cut -d. -f1)
+ LIBGIT=$(echo $LIBGIT | cut -d. -f2)
+ if [[ "$LIBGITMAJ" -gt "0" || "$LIBGIT" -gt "25" ]] ; then
+ LIBGIT2_FROM_PKGCONFIG="-DLIBGIT2_FROM_PKGCONFIG=ON"
+ fi
fi
- if [[ "$LIBGIT" -lt "26" ]] ; then
+ if [[ "$LIBGITMAJ" -lt "1" && "$LIBGIT" -lt "26" ]] ; then
# maybe there's a system version that's new enough?
- LIBGIT=$(ldconfig -p | grep libgit2\\.so\\. | awk -F. '{ print $NF }')
+ # Ugh that's uggly - read the ultimate filename, split at the last 'o' which gets us ".0.26.3" or ".1.0.0"
+ # since that starts with a dot, the field numbers in the cut need to be one higher
+ LIBGIT=$(realpath $(ldconfig -p | grep libgit2\\.so\\. | cut -d\ -f4) | awk -Fo '{ print $NF }')
+ LIBGITMAJ=$(echo $LIBGIT | cut -d. -f2)
+ LIBGIT=$(echo $LIBGIT | cut -d. -f3)
fi
fi
@@ -312,7 +320,7 @@ if [[ $PLATFORM = Darwin && "$BUILD_DEPS" == "1" ]] ; then
fi
fi
-if [[ "$LIBGIT" -lt "26" ]] ; then
+if [[ "$LIBGITMAJ" -lt "1" && "$LIBGIT" -lt "26" ]] ; then
LIBGIT_ARGS=" -DLIBGIT2_INCLUDE_DIR=$INSTALL_ROOT/include -DLIBGIT2_LIBRARIES=$INSTALL_ROOT/lib/libgit2.$SH_LIB_EXT "
cd "$SRC"