mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
build.sh: if new enough libgit2 is installed, use it
Right now this is only designed for Linux where current distros all should have a new enough libgit2 (and our instructions tell people to install this with system tools, so we should also use it). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
c749498beb
commit
73641c4e73
3 changed files with 53 additions and 40 deletions
|
@ -22,6 +22,7 @@ option(LIBMARBLE_FROM_PKGCONFIG "use pkg-config to retrieve marble" OFF)
|
||||||
|
|
||||||
#Library Handling
|
#Library Handling
|
||||||
option(FORCE_LIBSSH "force linking with libssh to workaround libgit2 bug" ON)
|
option(FORCE_LIBSSH "force linking with libssh to workaround libgit2 bug" ON)
|
||||||
|
option(LIBGIT2_DYNAMIC "search for libgit2.so before libgit2.a" OFF)
|
||||||
|
|
||||||
#Options regarding disabling parts of subsurface.
|
#Options regarding disabling parts of subsurface.
|
||||||
option(NO_MARBLE "disable the marble widget" OFF)
|
option(NO_MARBLE "disable the marble widget" OFF)
|
||||||
|
|
|
@ -22,8 +22,13 @@ HINTS
|
||||||
/usr/include
|
/usr/include
|
||||||
)
|
)
|
||||||
|
|
||||||
|
IF ( LIBGIT2_DYNAMIC )
|
||||||
|
SET( LIBGIT2_SO libgit2.so )
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
FIND_LIBRARY( LIBGIT2_LIBRARIES
|
FIND_LIBRARY( LIBGIT2_LIBRARIES
|
||||||
NAMES
|
NAMES
|
||||||
|
${LIBGIT2_SO}
|
||||||
libgit2.a
|
libgit2.a
|
||||||
git2
|
git2
|
||||||
HINTS
|
HINTS
|
||||||
|
@ -36,4 +41,4 @@ SET(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARIES} -lssl -lcrypto)
|
||||||
|
|
||||||
INCLUDE( FindPackageHandleStandardArgs )
|
INCLUDE( FindPackageHandleStandardArgs )
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS( git2 DEFAULT_MSG LIBGIT2_INCLUDE_DIR LIBGIT2_LIBRARIES )
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS( git2 DEFAULT_MSG LIBGIT2_INCLUDE_DIR LIBGIT2_LIBRARIES )
|
||||||
include_directories(${LIBGIT2_INCLUDE_DIR}})
|
include_directories(${LIBGIT2_INCLUDE_DIR}})
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
# this should be run from the src directory, the layout is supposed to
|
# this should be run from the src directory, the layout is supposed to
|
||||||
# look like this:
|
# look like this:
|
||||||
#.../src/subsurface
|
#.../src/subsurface
|
||||||
# /libgit2
|
|
||||||
# /marble-source
|
# /marble-source
|
||||||
# /libdivecomputer
|
# /libdivecomputer
|
||||||
#
|
#
|
||||||
|
@ -73,37 +72,52 @@ export PKG_CONFIG_PATH=$INSTALL_ROOT/lib/pkgconfig:$PKG_CONFIG_PATH
|
||||||
|
|
||||||
echo Building in $SRC, installing in $INSTALL_ROOT
|
echo Building in $SRC, installing in $INSTALL_ROOT
|
||||||
|
|
||||||
# build libgit2
|
# set up the right file name extensions
|
||||||
|
|
||||||
cd $SRC
|
|
||||||
|
|
||||||
if [ ! -d libgit2 ] ; then
|
|
||||||
if [[ $1 = local ]] ; then
|
|
||||||
git clone $SRC/../libgit2 libgit2
|
|
||||||
else
|
|
||||||
git clone git://github.com/libgit2/libgit2
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
cd libgit2
|
|
||||||
# let's build with a recent enough version of master for the latest features
|
|
||||||
git fetch origin
|
|
||||||
if ! git checkout v0.24.5 ; then
|
|
||||||
echo "Can't find the right tag in libgit2 - giving up"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
mkdir -p build
|
|
||||||
cd build
|
|
||||||
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT -DCMAKE_BUILD_TYPE=Release -DBUILD_CLAR=OFF ..
|
|
||||||
make -j4
|
|
||||||
make install
|
|
||||||
|
|
||||||
if [ $PLATFORM = Darwin ] ; then
|
if [ $PLATFORM = Darwin ] ; then
|
||||||
# in order for macdeployqt to do its job correctly, we need the full path in the dylib ID
|
SH_LIB_EXT=dylib
|
||||||
cd $INSTALL_ROOT/lib
|
else
|
||||||
NAME=$(otool -L libgit2.dylib | grep -v : | head -1 | cut -f1 -d\ | tr -d '\t')
|
SH_LIB_EXT=so
|
||||||
echo $NAME | grep / > /dev/null 2>&1
|
|
||||||
if [ $? -eq 1 ] ; then
|
# check if we need to build libgit2 (and do so if necessary)
|
||||||
install_name_tool -id "$INSTALL_ROOT/lib/$NAME" "$INSTALL_ROOT/lib/$NAME"
|
|
||||||
|
LIBGIT_ARGS=" -DLIBGIT2_DYNAMIC=ON "
|
||||||
|
LIBGIT=$(ldconfig -p | grep libgit2\\.so\\. | awk -F. '{ print $NF }')
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $PLATFORM = Darwin || "$LIBGIT" < "24" ]] ; then
|
||||||
|
|
||||||
|
LIBGIT_ARGS=" -DLIBGIT2_INCLUDE_DIR=$INSTALL_ROOT/include -DLIBGIT2_LIBRARIES=$INSTALL_ROOT/lib/libgit2.$SH_LIB_EXT "
|
||||||
|
|
||||||
|
cd $SRC
|
||||||
|
|
||||||
|
if [ ! -d libgit2 ] ; then
|
||||||
|
if [[ $1 = local ]] ; then
|
||||||
|
git clone $SRC/../libgit2 libgit2
|
||||||
|
else
|
||||||
|
git clone git://github.com/libgit2/libgit2
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
cd libgit2
|
||||||
|
# let's build with a recent enough version of master for the latest features
|
||||||
|
git fetch origin
|
||||||
|
if ! git checkout v0.24.5 ; then
|
||||||
|
echo "Can't find the right tag in libgit2 - giving up"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
mkdir -p build
|
||||||
|
cd build
|
||||||
|
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT -DCMAKE_BUILD_TYPE=Release -DBUILD_CLAR=OFF ..
|
||||||
|
make -j4
|
||||||
|
make install
|
||||||
|
|
||||||
|
if [ $PLATFORM = Darwin ] ; then
|
||||||
|
# in order for macdeployqt to do its job correctly, we need the full path in the dylib ID
|
||||||
|
cd $INSTALL_ROOT/lib
|
||||||
|
NAME=$(otool -L libgit2.dylib | grep -v : | head -1 | cut -f1 -d\ | tr -d '\t')
|
||||||
|
echo $NAME | grep / > /dev/null 2>&1
|
||||||
|
if [ $? -eq 1 ] ; then
|
||||||
|
install_name_tool -id "$INSTALL_ROOT/lib/$NAME" "$INSTALL_ROOT/lib/$NAME"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -227,12 +241,6 @@ fi
|
||||||
|
|
||||||
# finally, build Subsurface
|
# finally, build Subsurface
|
||||||
|
|
||||||
if [ $PLATFORM = Darwin ] ; then
|
|
||||||
SH_LIB_EXT=dylib
|
|
||||||
else
|
|
||||||
SH_LIB_EXT=so
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd $SRC/subsurface
|
cd $SRC/subsurface
|
||||||
for (( i=0 ; i < ${#BUILDS[@]} ; i++ )) ; do
|
for (( i=0 ; i < ${#BUILDS[@]} ; i++ )) ; do
|
||||||
SUBSURFACE_EXECUTABLE=${BUILDS[$i]}
|
SUBSURFACE_EXECUTABLE=${BUILDS[$i]}
|
||||||
|
@ -250,8 +258,7 @@ for (( i=0 ; i < ${#BUILDS[@]} ; i++ )) ; do
|
||||||
export CMAKE_PREFIX_PATH="$INSTALL_ROOT/lib/cmake;${CMAKE_PREFIX_PATH}"
|
export CMAKE_PREFIX_PATH="$INSTALL_ROOT/lib/cmake;${CMAKE_PREFIX_PATH}"
|
||||||
cmake -DCMAKE_BUILD_TYPE=Debug .. \
|
cmake -DCMAKE_BUILD_TYPE=Debug .. \
|
||||||
-DSUBSURFACE_TARGET_EXECUTABLE=$SUBSURFACE_EXECUTABLE \
|
-DSUBSURFACE_TARGET_EXECUTABLE=$SUBSURFACE_EXECUTABLE \
|
||||||
-DLIBGIT2_INCLUDE_DIR=$INSTALL_ROOT/include \
|
${LIBGIT_ARGS} \
|
||||||
-DLIBGIT2_LIBRARIES=$INSTALL_ROOT/lib/libgit2.$SH_LIB_EXT \
|
|
||||||
-DLIBDIVECOMPUTER_INCLUDE_DIR=$INSTALL_ROOT/include \
|
-DLIBDIVECOMPUTER_INCLUDE_DIR=$INSTALL_ROOT/include \
|
||||||
-DLIBDIVECOMPUTER_LIBRARIES=$INSTALL_ROOT/lib/libdivecomputer.a \
|
-DLIBDIVECOMPUTER_LIBRARIES=$INSTALL_ROOT/lib/libdivecomputer.a \
|
||||||
-DMARBLE_INCLUDE_DIR=$INSTALL_ROOT/include \
|
-DMARBLE_INCLUDE_DIR=$INSTALL_ROOT/include \
|
||||||
|
|
Loading…
Reference in a new issue