diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build.sh | 62 | ||||
-rwxr-xr-x | scripts/get-version | 2 | ||||
-rw-r--r-- | scripts/write-version | 49 |
3 files changed, 91 insertions, 22 deletions
diff --git a/scripts/build.sh b/scripts/build.sh index 9ea0f4f76..f4db5518d 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -8,32 +8,27 @@ # /libdivecomputer # # the script will build these three libraries from source, even if -# they are installed as part of the host OS since we have seen +# they are installed as part of the host OS since we have seen # numerous cases where building with random versions (especially older, # but sometimes also newer versions than recommended here) will lead # to all kinds of unnecessary pain +# +# it installs the libraries and subsurface in the install-root subdirectory +# of the current directory (except on Mac where the Subsurface.app ends up +# in subsurface/build SRC=$(pwd) +PLATFORM=$(uname) + if [[ ! -d "subsurface" ]] ; then echo "please start this script from the directory containing the Subsurface source directory" exit 1 fi -# qmake or qmake-qt5 ? -qmake -v | grep "version 5" > /dev/null 2>&1 -if [[ $? -eq 0 ]] ; then - QMAKE=qmake -else - qmake-qt5 -v | grep "version 5" > /dev/null 2>&1 - if [[ $? -eq 0 ]] ; then - QMAKE=qmake-qt5 - else - echo "can't find a working qmake for Qt5" - exit 1 - fi -fi +mkdir -p install-root +INSTALL_ROOT=$SRC/install-root -mkdir -p install +echo Building in $SRC, installing in $INSTALL_ROOT # build libgit2 @@ -45,12 +40,22 @@ if [ ! -d libgit2 ] ; then fi fi cd libgit2 -git checkout v0.21.5 +git checkout v0.22.0 mkdir -p build cd build -cmake -DCMAKE_INSTALL_PREFIX=$SRC/install -DCMAKE_BUILD_TYPE=Release -DBUILD_CLAR=OFF .. +cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT -DCMAKE_BUILD_TYPE=Release -DBUILD_CLAR=OFF .. cmake --build . --target 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 + cd $SRC # build libdivecomputer @@ -66,8 +71,8 @@ cd libdivecomputer git checkout Subsurface-4.4 if [ ! -f configure ] ; then autoreconf --install - ./configure --prefix=$SRC/install fi +./configure --prefix=$INSTALL_ROOT make -j4 make install @@ -87,7 +92,7 @@ git checkout Subsurface-4.4 mkdir -p build cd build cmake -DCMAKE_BUILD_TYPE=Release -DQTONLY=TRUE -DQT5BUILD=ON \ - -DCMAKE_INSTALL_PREFIX=$SRC/install \ + -DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT \ -DBUILD_MARBLE_TESTS=NO \ -DWITH_DESIGNER_PLUGIN=NO \ -DBUILD_MARBLE_APPS=NO \ @@ -96,7 +101,22 @@ cd src/lib/marble make -j4 make install +if [ $PLATFORM = Darwin ] ; then + SH_LIB_EXT=dylib +else + SH_LIB_EXT=so +fi + cd $SRC/subsurface -$QMAKE CONFIG+=setRpath LIBDCDEVEL=1 LIBMARBLEDEVEL=$SRC/install SPECIAL_MARBLE_PREFIX=1 LIBGIT2DEVEL=$SRC/libgit2 subsurface.pro -make -j4 +mkdir -p build +cd build +cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT .. \ + -DLIBGIT2_INCLUDE_DIR=$INSTALL_ROOT/include \ + -DLIBGIT2_LIBRARIES=$INSTALL_ROOT/lib/libgit2.$SH_LIB_EXT \ + -DLIBDIVECOMPUTER_INCLUDE_DIR=$INSTALL_ROOT/include \ + -DLIBDIVECOMPUTER_LIBRARIES=$INSTALL_ROOT/lib/libdivecomputer.a \ + -DMARBLE_INCLUDE_DIR=$INSTALL_ROOT/include \ + -DMARBLE_LIBRARIES=$INSTALL_ROOT/lib/libssrfmarblewidget.$SH_LIB_EXT +make -j4 +make install diff --git a/scripts/get-version b/scripts/get-version index eb93a3322..27f02f640 100755 --- a/scripts/get-version +++ b/scripts/get-version @@ -19,7 +19,7 @@ if [ $# -eq 2 ] && [ "$2" ]; then v0=$2 else cmd="git describe --tags --abbrev=12" - v0=$($cmd) || croak "odd; command '$cmd' failed" + v0=$($cmd) || v0=$(cat .gitversion) || croak "odd; command '$cmd' failed" fi # strip off the 'v' prefix, if any diff --git a/scripts/write-version b/scripts/write-version new file mode 100644 index 000000000..81562fbb8 --- /dev/null +++ b/scripts/write-version @@ -0,0 +1,49 @@ +#!/bin/sh + +# +# arguments: +# $1 - target H file +# $2 - fallback version string +# $3 - os name {linux|darwin|win} +# +# doesn't have much error checking! +# should be started from where .git is! +# + +if [ "$#" -lt 3 ]; then + echo "ERROR: missing arguments"; + exit 1; +fi + +# set OS and TARGET +TARGET=$1 +TARGET_TEMP=$TARGET.tmp +VERSION=$2 +OS=$3 + +# get the full version: git based or hardcoded from .gitversion or the fallback version string +if gitpwd=`git rev-parse --show-toplevel 2> /dev/null`; then + FULL_VER=`sh "$gitpwd/scripts/get-version" linux` +else + FULL_VER=`cat .gitversion 2> /dev/null || echo $VERSION` +fi + +# grab some strings from get-version +CANONICAL_VER=`sh ./scripts/get-version full $FULL_VER` +OS_USABLE_VER=`sh ./scripts/get-version $OS $FULL_VER` + +# write to a temp file +echo "#define VERSION_STRING \"$OS_USABLE_VER\"" > $TARGET_TEMP +echo "#define GIT_VERSION_STRING \"$FULL_VER\"" >> $TARGET_TEMP +echo "#define CANONICAL_VERSION_STRING \"$CANONICAL_VER\"" >> $TARGET_TEMP + +# if the target file is missing create it +if [ ! -f $TARGET ]; then + CMD=`touch $TARGET` +fi + +# if the temp file and the target file differ, replace the target file with the temp file +CMD=`diff -q $TARGET $TARGET_TEMP || cp $TARGET_TEMP $TARGET` + +# remove the temp file +CMD=`rm -f $TARGET_TEMP` |