| 
									
										
										
										
											2016-09-25 21:54:39 +02:00
										 |  |  | #!/bin/bash
 | 
					
						
							| 
									
										
										
										
											2015-02-17 13:10:45 -08:00
										 |  |  | # | 
					
						
							|  |  |  | # this should be run from the src directory, the layout is supposed to | 
					
						
							|  |  |  | # look like this: | 
					
						
							|  |  |  | #.../src/subsurface | 
					
						
							|  |  |  | #       /marble-source | 
					
						
							|  |  |  | #       /libdivecomputer | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # the script will build these three libraries from source, even if | 
					
						
							| 
									
										
										
										
											2015-04-26 15:43:02 -03:00
										 |  |  | # they are installed as part of the host OS since we have seen | 
					
						
							| 
									
										
										
										
											2015-02-17 13:10:45 -08:00
										 |  |  | # 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 | 
					
						
							| 
									
										
										
										
											2015-04-15 11:33:14 -07:00
										 |  |  | # | 
					
						
							|  |  |  | # 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 | 
					
						
							| 
									
										
										
										
											2015-02-17 13:10:45 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-02 10:22:10 -07:00
										 |  |  | # create a log file of the build | 
					
						
							|  |  |  | exec 1> >(tee build.log) 2>&1 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-15 21:39:54 -07:00
										 |  |  | SRC=$(pwd) | 
					
						
							|  |  |  | PLATFORM=$(uname) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-04 01:45:05 +09:00
										 |  |  | # in order to build the dependencies on Mac for release builds (to deal with the macosx-version-min for those | 
					
						
							|  |  |  | # call this script with -build-deps | 
					
						
							|  |  |  | if [ "$1" == "-build-deps" ] ; then | 
					
						
							|  |  |  | 	shift | 
					
						
							|  |  |  | 	BUILD_DEPS="1" | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-15 21:39:54 -07:00
										 |  |  | # unless you build Qt from source (or at least webkit from source, you won't have webkit installed | 
					
						
							|  |  |  | # -build-with-webkit tells the script that in fact we can assume that webkit is present (it usually | 
					
						
							|  |  |  | # is still available on Linux distros) | 
					
						
							|  |  |  | if [ "$1" == "-build-with-webkit" ] ; then | 
					
						
							|  |  |  | 	shift | 
					
						
							|  |  |  | 	BUILD_WITH_WEBKIT="1" | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | if [ $PLATFORM = Linux ] ; then | 
					
						
							|  |  |  | 	BUILD_WITH_WEBKIT="1" | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2015-04-15 11:33:14 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-04 01:45:05 +09:00
										 |  |  | # most of these will only be needed with -build-deps on a Mac | 
					
						
							|  |  |  | CURRENT_LIBZIP="1.2.0" | 
					
						
							|  |  |  | CURRENT_HIDAPI="hidapi-0.7.0" | 
					
						
							|  |  |  | CURRENT_LIBCURL="curl-7_54_1" | 
					
						
							|  |  |  | CURRENT_LIBUSB="v1.0.21" | 
					
						
							|  |  |  | CURRENT_OPENSSL="OpenSSL_1_1_0f" | 
					
						
							|  |  |  | CURRENT_LIBSSH2="libssh2-1.8.0" | 
					
						
							|  |  |  | CURRENT_LIBGIT2="v0.26.0" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-16 09:02:03 +01:00
										 |  |  | # Verify that the Xcode Command Line Tools are installed | 
					
						
							|  |  |  | if [ $PLATFORM = Darwin ] ; then | 
					
						
							| 
									
										
										
										
											2017-07-15 10:37:50 -07:00
										 |  |  | 	if [ -d /Developer/SDKs ] ; then | 
					
						
							|  |  |  | 		SDKROOT=/Developer/SDKs | 
					
						
							|  |  |  | 	elif [ -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs ] ; then | 
					
						
							|  |  |  | 		SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		echo "Cannot find SDK sysroot (usually /Developer/SDKs or" | 
					
						
							|  |  |  | 		echo "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs)" | 
					
						
							|  |  |  | 		exit 1; | 
					
						
							|  |  |  | 	fi | 
					
						
							|  |  |  | 	BASESDK=$(ls $SDKROOT | grep "MacOSX10\.1.\.sdk" | head -1 | sed -e "s/MacOSX//;s/\.sdk//") | 
					
						
							|  |  |  | 	OLDER_MAC="-mmacosx-version-min=${BASESDK} -isysroot${SDKROOT}/MacOSX${BASESDK}.sdk" | 
					
						
							|  |  |  | 	OLDER_MAC_CMAKE="-DCMAKE_OSX_DEPLOYMENT_TARGET=${BASESDK} -DCMAKE_OSX_SYSROOT=${SDKROOT}/MacOSX${BASESDK}.sdk/" | 
					
						
							| 
									
										
										
										
											2016-03-16 09:02:03 +01:00
										 |  |  | 	if [ ! -d /usr/include ] ; then | 
					
						
							|  |  |  | 		echo "Error: Xcode Command Line Tools are not installed" | 
					
						
							|  |  |  | 		echo "" | 
					
						
							|  |  |  | 		echo "Please run:" | 
					
						
							|  |  |  | 		echo " xcode-select --install" | 
					
						
							|  |  |  | 		echo "to install them (you'll have to agree to Apple's licensing terms etc), then run build.sh again" | 
					
						
							|  |  |  | 		exit 1; | 
					
						
							|  |  |  | 	fi | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-17 10:44:00 -08:00
										 |  |  | # normally this script builds the desktop version in subsurface/build | 
					
						
							|  |  |  | # if the first argument is "-mobile" then build Subsurface-mobile in subsurface/build-mobile | 
					
						
							|  |  |  | # if the first argument is "-both" then build both in subsurface/build and subsurface/build-mobile | 
					
						
							| 
									
										
										
										
											2016-01-22 10:15:51 -08:00
										 |  |  | BUILDGRANTLEE=0 | 
					
						
							| 
									
										
										
										
											2016-08-17 21:37:03 +02:00
										 |  |  | BUILDMARBLE=0 | 
					
						
							| 
									
										
										
										
											2016-01-17 10:44:00 -08:00
										 |  |  | if [ "$1" = "-mobile" ] ; then | 
					
						
							|  |  |  | 	echo "building Subsurface-mobile in subsurface/build-mobile" | 
					
						
							|  |  |  | 	BUILDS=( "MobileExecutable" ) | 
					
						
							|  |  |  | 	BUILDDIRS=( "build-mobile" ) | 
					
						
							|  |  |  | 	shift | 
					
						
							|  |  |  | elif [ "$1" = "-both" ] ; then | 
					
						
							|  |  |  | 	echo "building both Subsurface and Subsurface-mobile in subsurface/build and subsurface/build-mobile, respectively" | 
					
						
							|  |  |  | 	BUILDS=( "DesktopExecutable" "MobileExecutable" ) | 
					
						
							|  |  |  | 	BUILDDIRS=( "build" "build-mobile" ) | 
					
						
							| 
									
										
										
										
											2017-07-15 21:39:54 -07:00
										 |  |  | 	if [ "$BUILD_WITH_WEBKIT" = "1" ] ; then | 
					
						
							|  |  |  | 		BUILDGRANTLEE=1 | 
					
						
							|  |  |  | 		BUILDMARBLE=1 | 
					
						
							|  |  |  | 	fi | 
					
						
							| 
									
										
										
										
											2016-01-17 10:44:00 -08:00
										 |  |  | 	shift | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  | 	echo "building Subsurface in subsurface/build" | 
					
						
							|  |  |  | 	BUILDS=( "DesktopExecutable" ) | 
					
						
							|  |  |  | 	BUILDDIRS=( "build" ) | 
					
						
							| 
									
										
										
										
											2017-07-15 21:39:54 -07:00
										 |  |  | 	if [ "$BUILD_WITH_WEBKIT" = "1" ] ; then | 
					
						
							|  |  |  | 		BUILDGRANTLEE=1 | 
					
						
							|  |  |  | 		BUILDMARBLE=1 | 
					
						
							|  |  |  | 	fi | 
					
						
							| 
									
										
										
										
											2016-01-17 10:44:00 -08:00
										 |  |  | fi | 
					
						
							| 
									
										
										
										
											2016-01-07 06:59:33 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-17 13:10:45 -08:00
										 |  |  | if [[ ! -d "subsurface" ]] ; then | 
					
						
							|  |  |  | 	echo "please start this script from the directory containing the Subsurface source directory" | 
					
						
							|  |  |  | 	exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2015-02-17 22:03:15 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-09 15:00:52 -07:00
										 |  |  | mkdir -p install-root | 
					
						
							|  |  |  | INSTALL_ROOT=$SRC/install-root | 
					
						
							| 
									
										
										
										
											2015-02-17 13:10:45 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-04 13:52:13 -07:00
										 |  |  | # make sure we find our own packages first (e.g., libgit2 only uses pkg_config to find libssh2) | 
					
						
							|  |  |  | export PKG_CONFIG_PATH=$INSTALL_ROOT/lib/pkgconfig:$PKG_CONFIG_PATH | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-15 11:33:14 -07:00
										 |  |  | echo Building in $SRC, installing in $INSTALL_ROOT | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-16 15:56:56 -08:00
										 |  |  | # set up the right file name extensions | 
					
						
							|  |  |  | if [ $PLATFORM = Darwin ] ; then | 
					
						
							|  |  |  | 	SH_LIB_EXT=dylib | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  | 	SH_LIB_EXT=so | 
					
						
							| 
									
										
										
										
											2015-02-17 13:10:45 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-16 15:56:56 -08:00
										 |  |  | 	# check if we need to build libgit2 (and do so if necessary) | 
					
						
							| 
									
										
										
										
											2015-06-04 13:52:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-16 15:56:56 -08:00
										 |  |  | 	LIBGIT_ARGS=" -DLIBGIT2_DYNAMIC=ON " | 
					
						
							|  |  |  | 	LIBGIT=$(ldconfig -p | grep libgit2\\.so\\. | awk -F. '{ print $NF }') | 
					
						
							| 
									
										
										
										
											2015-02-17 13:10:45 -08:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-16 15:56:56 -08:00
										 |  |  | if [[ $PLATFORM = Darwin || "$LIBGIT" < "24" ]] ; then | 
					
						
							| 
									
										
										
										
											2017-07-04 01:45:05 +09:00
										 |  |  | 	# when building distributable binaries on a Mac, we cannot rely on anything from Homebrew, | 
					
						
							|  |  |  | 	# because that always requires the latest OS (how stupid is that - and they consider it a | 
					
						
							|  |  |  | 	# feature). So we painfully need to build the dependencies ourselves. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if [ "$BUILD_DEPS" == "1" ] ; then | 
					
						
							|  |  |  | 		if [ ! -d libzip-${CURRENT_LIBZIP} ] ; then | 
					
						
							|  |  |  | 			curl -O https://nih.at/libzip/libzip-${CURRENT_LIBZIP}.tar.gz | 
					
						
							|  |  |  | 			tar xzf libzip-${CURRENT_LIBZIP}.tar.gz | 
					
						
							|  |  |  | 		fi | 
					
						
							|  |  |  | 		cd libzip-${CURRENT_LIBZIP} | 
					
						
							|  |  |  | 		mkdir -p build | 
					
						
							|  |  |  | 		cd build | 
					
						
							|  |  |  | 		../configure CFLAGS="$OLDER_MAC" --prefix=$INSTALL_ROOT | 
					
						
							|  |  |  | 		make -j4 | 
					
						
							|  |  |  | 		make install | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		cd $SRC | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if [ ! -d hidapi ] ; then | 
					
						
							|  |  |  | 			git clone https://github.com/signal11/hidapi | 
					
						
							|  |  |  | 		fi | 
					
						
							|  |  |  | 		cd hidapi | 
					
						
							|  |  |  | 		# there is no good tag, so just build master | 
					
						
							|  |  |  | 		bash ./bootstrap | 
					
						
							|  |  |  | 		mkdir -p build | 
					
						
							|  |  |  | 		cd build | 
					
						
							|  |  |  | 		CFLAGS="$OLDER_MAC" ../configure --prefix=$INSTALL_ROOT | 
					
						
							|  |  |  | 		make -j4 | 
					
						
							|  |  |  | 		make install | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		cd $SRC | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if [ ! -d libcurl ] ; then | 
					
						
							|  |  |  | 			git clone https://github.com/curl/curl libcurl | 
					
						
							|  |  |  | 		fi | 
					
						
							|  |  |  | 		cd libcurl | 
					
						
							|  |  |  | 		if ! git checkout $CURRENT_LIBCURL ; then | 
					
						
							|  |  |  | 			echo "Can't find the right tag in libcurl - giving up" | 
					
						
							|  |  |  | 			exit 1 | 
					
						
							|  |  |  | 		fi | 
					
						
							|  |  |  | 		bash ./buildconf | 
					
						
							|  |  |  | 		mkdir -p build | 
					
						
							|  |  |  | 		cd build | 
					
						
							|  |  |  | 		CFLAGS="$OLDER_MAC" ../configure --prefix=$INSTALL_ROOT --with-darwinssl \
 | 
					
						
							|  |  |  | 			--disable-tftp --disable-ftp --disable-ldap --disable-ldaps --disable-imap --disable-pop3 --disable-smtp --disable-gopher --disable-smb --disable-rtsp | 
					
						
							|  |  |  | 		make -j4 | 
					
						
							|  |  |  | 		make install | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		cd $SRC | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if [ ! -d libusb ] ; then | 
					
						
							|  |  |  | 			git clone https://github.com/libusb/libusb | 
					
						
							|  |  |  | 		fi | 
					
						
							|  |  |  | 		cd libusb | 
					
						
							|  |  |  | 		if ! git checkout $CURRENT_LIBUSB ; then | 
					
						
							|  |  |  | 			echo "Can't find the right tag in libusb - giving up" | 
					
						
							|  |  |  | 			exit 1 | 
					
						
							|  |  |  | 		fi | 
					
						
							|  |  |  | 		bash ./bootstrap.sh | 
					
						
							|  |  |  | 		mkdir -p build | 
					
						
							|  |  |  | 		cd build | 
					
						
							|  |  |  | 		CFLAGS="$OLDER_MAC" ../configure --prefix=$INSTALL_ROOT --disable-examples | 
					
						
							|  |  |  | 		make -j4 | 
					
						
							|  |  |  | 		make install | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		cd $SRC | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if [ ! -d openssl ] ; then | 
					
						
							|  |  |  | 			git clone https://github.com/openssl/openssl | 
					
						
							|  |  |  | 		fi | 
					
						
							|  |  |  | 		cd openssl | 
					
						
							|  |  |  | 		if ! git checkout $CURRENT_OPENSSL ; then | 
					
						
							|  |  |  | 			echo "Can't find the right tag in openssl - giving up" | 
					
						
							|  |  |  | 			exit 1 | 
					
						
							|  |  |  | 		fi | 
					
						
							|  |  |  | 		mkdir -p build | 
					
						
							|  |  |  | 		cd build | 
					
						
							|  |  |  | 		../Configure --prefix=$INSTALL_ROOT --openssldir=$INSTALL_ROOT $OLDER_MAC darwin64-x86_64-cc | 
					
						
							|  |  |  | 		make depend | 
					
						
							|  |  |  | 		# all the tests fail because the assume that openssl is already installed. Odd? Still thinks work | 
					
						
							|  |  |  | 		make -j4 -k | 
					
						
							|  |  |  | 		make -k install | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		cd $SRC | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if [ ! -d libssh2 ] ; then | 
					
						
							|  |  |  | 			git clone https://github.com/libssh2/libssh2 | 
					
						
							|  |  |  | 		fi | 
					
						
							|  |  |  | 		cd libssh2 | 
					
						
							|  |  |  | 		if ! git checkout $CURRENT_LIBSSH2 ; then | 
					
						
							|  |  |  | 			echo "Can't find the right tag in libssh2 - giving up" | 
					
						
							|  |  |  | 			exit 1 | 
					
						
							|  |  |  | 		fi | 
					
						
							|  |  |  | 		mkdir -p build | 
					
						
							|  |  |  | 		cd build | 
					
						
							|  |  |  | 		cmake $OLDER_MAC_CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF .. | 
					
						
							|  |  |  | 		make -j4 | 
					
						
							|  |  |  | 		make install | 
					
						
							| 
									
										
										
										
											2017-07-15 14:18:33 -07:00
										 |  |  | 	else | 
					
						
							|  |  |  | 		# we are getting libusb and hidapi from pkg-config and that goes wrong | 
					
						
							|  |  |  | 		# or more specifically, the way libdivecomputer references | 
					
						
							|  |  |  | 		# the include files goes wrong | 
					
						
							| 
									
										
										
										
											2017-07-15 21:59:31 -07:00
										 |  |  | 		pkg-config --exists libusb-1.0 && LIBDC_CFLAGS=-I$(dirname $(pkg-config --cflags libusb-1.0 | sed -e 's/^-I//')) | 
					
						
							|  |  |  | 		pkg-config --exists hidapi && LIBDC_CFLAGS="${LIBDC_CFLAGS} -I$(dirname $(pkg-config --cflags hidapi | sed -e 's/^-I//'))" | 
					
						
							| 
									
										
										
										
											2017-07-04 01:45:05 +09:00
										 |  |  | 	fi | 
					
						
							| 
									
										
										
										
											2017-01-16 15:56:56 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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 | 
					
						
							| 
									
										
										
										
											2017-04-15 12:33:38 +02:00
										 |  |  | 			git clone https://github.com/libgit2/libgit2.git | 
					
						
							| 
									
										
										
										
											2017-01-16 15:56:56 -08:00
										 |  |  | 		fi | 
					
						
							|  |  |  | 	fi | 
					
						
							|  |  |  | 	cd libgit2 | 
					
						
							|  |  |  | 	# let's build with a recent enough version of master for the latest features | 
					
						
							|  |  |  | 	git fetch origin | 
					
						
							| 
									
										
										
										
											2017-07-04 01:45:05 +09:00
										 |  |  | 	if ! git checkout $CURRENT_LIBGIT2 ; then | 
					
						
							| 
									
										
										
										
											2017-01-16 15:56:56 -08:00
										 |  |  | 		echo "Can't find the right tag in libgit2 - giving up" | 
					
						
							|  |  |  | 		exit 1 | 
					
						
							|  |  |  | 	fi | 
					
						
							|  |  |  | 	mkdir -p build | 
					
						
							|  |  |  | 	cd build | 
					
						
							| 
									
										
										
										
											2017-07-04 01:42:51 +09:00
										 |  |  | 	cmake $OLDER_MAC_CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT -DCMAKE_BUILD_TYPE=Release -DBUILD_CLAR=OFF .. | 
					
						
							| 
									
										
										
										
											2017-01-16 15:56:56 -08:00
										 |  |  | 	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 | 
					
						
							| 
									
										
										
										
											2015-04-15 11:33:14 -07:00
										 |  |  | 	fi | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-17 13:10:45 -08:00
										 |  |  | cd $SRC | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # build libdivecomputer | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [ ! -d libdivecomputer ] ; then | 
					
						
							|  |  |  | 	if [[ $1 = local ]] ; then | 
					
						
							|  |  |  | 		git clone $SRC/../libdivecomputer libdivecomputer | 
					
						
							|  |  |  | 	else | 
					
						
							| 
									
										
										
										
											2017-04-15 12:33:38 +02:00
										 |  |  | 		git clone -b Subsurface-branch https://github.com/Subsurface-divelog/libdc.git libdivecomputer | 
					
						
							| 
									
										
										
										
											2015-02-17 13:10:45 -08:00
										 |  |  | 	fi | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | cd libdivecomputer | 
					
						
							| 
									
										
										
										
											2015-07-12 14:42:18 +02:00
										 |  |  | git pull --rebase | 
					
						
							| 
									
										
										
										
											2015-08-26 11:44:56 -07:00
										 |  |  | if ! git checkout Subsurface-branch ; then | 
					
						
							|  |  |  | 	echo "can't check out the Subsurface-branch branch of libdivecomputer -- giving up" | 
					
						
							| 
									
										
										
										
											2015-06-04 10:47:57 -07:00
										 |  |  | 	exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2016-02-02 10:17:51 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | mkdir -p build | 
					
						
							|  |  |  | cd build | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [ ! -f ../configure ] ; then | 
					
						
							| 
									
										
										
										
											2017-01-16 10:12:17 -08:00
										 |  |  | 	# this is not a typo | 
					
						
							|  |  |  | 	# in some scenarios it appears that autoreconf doesn't copy the | 
					
						
							|  |  |  | 	# ltmain.sh file; running it twice, however, fixes that problem | 
					
						
							|  |  |  | 	autoreconf --install .. | 
					
						
							| 
									
										
										
										
											2016-02-02 10:17:51 +01:00
										 |  |  | 	autoreconf --install .. | 
					
						
							| 
									
										
										
										
											2015-02-17 13:10:45 -08:00
										 |  |  | fi | 
					
						
							| 
									
										
										
										
											2017-07-15 14:18:33 -07:00
										 |  |  | CFLAGS="$OLDER_MAC -I$INSTALL_ROOT/include $LIBDC_CFLAGS" ../configure --prefix=$INSTALL_ROOT --disable-examples | 
					
						
							| 
									
										
										
										
											2015-02-17 13:10:45 -08:00
										 |  |  | make -j4 | 
					
						
							|  |  |  | make install | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-15 21:41:47 -07:00
										 |  |  | if [ $PLATFORM = Darwin ] ; then | 
					
						
							|  |  |  | 	if [ -z "$CMAKE_PREFIX_PATH" ] ; then | 
					
						
							|  |  |  | 		# qmake in PATH? | 
					
						
							|  |  |  | 		libdir=`qmake -query QT_INSTALL_LIBS` | 
					
						
							|  |  |  | 		if [ $? -eq 0 ]; then | 
					
						
							|  |  |  | 			export CMAKE_PREFIX_PATH=$libdir/cmake | 
					
						
							|  |  |  | 		elif [ -d "$HOME/Qt/5.9.1" ] ; then | 
					
						
							|  |  |  | 			export CMAKE_PREFIX_PATH=~/Qt/5.9.1/clang_64/lib/cmake | 
					
						
							|  |  |  | 		elif [ -d "$HOME/Qt/5.9" ] ; then | 
					
						
							|  |  |  | 			export CMAKE_PREFIX_PATH=~/Qt/5.9/clang_64/lib/cmake | 
					
						
							|  |  |  | 		elif [ -d "$HOME/Qt/5.8" ] ; then | 
					
						
							|  |  |  | 			export CMAKE_PREFIX_PATH=~/Qt/5.8/clang_64/lib/cmake | 
					
						
							|  |  |  | 		elif [ -d "$HOME/Qt/5.7" ] ; then | 
					
						
							|  |  |  | 			export CMAKE_PREFIX_PATH=~/Qt/5.7/clang_64/lib/cmake | 
					
						
							|  |  |  | 		elif [ -d "$HOME/Qt/5.6" ] ; then | 
					
						
							|  |  |  | 			export CMAKE_PREFIX_PATH=~/Qt/5.6/clang_64/lib/cmake | 
					
						
							|  |  |  | 		elif [ -d "$HOME/Qt/5.5" ] ; then | 
					
						
							|  |  |  | 			export CMAKE_PREFIX_PATH=~/Qt/5.5/clang_64/lib/cmake | 
					
						
							|  |  |  | 		elif [ -d /usr/local/opt/qt5/lib ] ; then | 
					
						
							|  |  |  | 			# Homebrew location for qt5 package | 
					
						
							|  |  |  | 			export CMAKE_PREFIX_PATH=/usr/local/opt/qt5/lib/cmake | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			echo "cannot find Qt 5.5 or newer in ~/Qt" | 
					
						
							|  |  |  | 			exit 1 | 
					
						
							|  |  |  | 		fi | 
					
						
							|  |  |  | 	fi | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-17 13:10:45 -08:00
										 |  |  | cd $SRC | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # build libssrfmarblewidget | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-27 15:43:14 -08:00
										 |  |  | if [ $BUILDMARBLE = 1 ]; then | 
					
						
							| 
									
										
										
										
											2017-07-15 21:39:54 -07:00
										 |  |  | 	MARBLE_OPTS="-DMARBLE_INCLUDE_DIR=$INSTALL_ROOT/include \
 | 
					
						
							|  |  |  | 		-DMARBLE_LIBRARIES=$INSTALL_ROOT/lib/libssrfmarblewidget.$SH_LIB_EXT \
 | 
					
						
							|  |  |  | 		-DNO_MARBLE=OFF -DNO_USERMANUAL=OFF -DFBSUPPORT=ON"
 | 
					
						
							| 
									
										
										
										
											2016-12-27 01:43:53 -08:00
										 |  |  | 	if [ ! -d marble-source ] ; then | 
					
						
							|  |  |  | 		if [[ $1 = local ]] ; then | 
					
						
							|  |  |  | 			git clone $SRC/../marble-source marble-source | 
					
						
							|  |  |  | 		else | 
					
						
							| 
									
										
										
										
											2017-04-15 12:33:38 +02:00
										 |  |  | 			git clone -b Subsurface-branch https://github.com/Subsurface-divelog/marble.git marble-source | 
					
						
							| 
									
										
										
										
											2016-12-27 01:43:53 -08:00
										 |  |  | 		fi | 
					
						
							| 
									
										
										
										
											2015-02-17 13:10:45 -08:00
										 |  |  | 	fi | 
					
						
							| 
									
										
										
										
											2016-12-27 01:43:53 -08:00
										 |  |  | 	cd marble-source | 
					
						
							|  |  |  | 	git pull --rebase | 
					
						
							|  |  |  | 	if ! git checkout Subsurface-branch ; then | 
					
						
							|  |  |  | 		echo "can't check out the Subsurface-branch branch of marble -- giving up" | 
					
						
							| 
									
										
										
										
											2016-03-03 14:32:23 -08:00
										 |  |  | 		exit 1 | 
					
						
							|  |  |  | 	fi | 
					
						
							| 
									
										
										
										
											2016-12-27 01:43:53 -08:00
										 |  |  | 	mkdir -p build | 
					
						
							|  |  |  | 	cd build | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-04 01:42:51 +09:00
										 |  |  | 	cmake $OLDER_MAC_CMAKE -DCMAKE_BUILD_TYPE=Release -DQTONLY=TRUE -DQT5BUILD=ON \
 | 
					
						
							| 
									
										
										
										
											2016-08-17 21:37:03 +02:00
										 |  |  | 		-DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT \
 | 
					
						
							|  |  |  | 		-DBUILD_MARBLE_TESTS=NO \
 | 
					
						
							|  |  |  | 		-DWITH_DESIGNER_PLUGIN=NO \
 | 
					
						
							|  |  |  | 		-DBUILD_MARBLE_APPS=NO \
 | 
					
						
							|  |  |  | 		$SRC/marble-source | 
					
						
							|  |  |  | 	cd src/lib/marble | 
					
						
							|  |  |  | 	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 libssrfmarblewidget.dylib | grep -v : | head -1 | cut -f1 -d\  | tr -d '\t' | cut -f3 -d/ ) | 
					
						
							|  |  |  | 		echo $NAME | grep / > /dev/null 2>&1 | 
					
						
							|  |  |  | 		if [ $? -eq 1 ] ; then | 
					
						
							|  |  |  | 			install_name_tool -id "$INSTALL_ROOT/lib/$NAME" "$INSTALL_ROOT/lib/$NAME" | 
					
						
							|  |  |  | 		fi | 
					
						
							| 
									
										
										
										
											2015-08-16 16:57:24 -07:00
										 |  |  | 	fi | 
					
						
							| 
									
										
										
										
											2017-07-15 21:39:54 -07:00
										 |  |  | else | 
					
						
							|  |  |  | 	MARBLE_OPTS="-DNO_MARBLE=ON -DNO_USERMANUAL=ON -DFBSUPPORT=OFF" | 
					
						
							| 
									
										
										
										
											2015-08-16 16:57:24 -07:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-22 10:15:51 -08:00
										 |  |  | if [ "$BUILDGRANTLEE" = "1" ] ; then | 
					
						
							| 
									
										
										
										
											2016-01-07 21:30:51 -08:00
										 |  |  | 	# build grantlee | 
					
						
							| 
									
										
										
										
											2017-07-15 21:39:54 -07:00
										 |  |  | 	PRINTING="-DNO_PRINTING=OFF" | 
					
						
							| 
									
										
										
										
											2015-06-04 11:53:31 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-07 21:30:51 -08:00
										 |  |  | 	cd $SRC | 
					
						
							| 
									
										
										
										
											2015-06-04 11:53:31 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-07 21:30:51 -08:00
										 |  |  | 	if [ ! -d grantlee ] ; then | 
					
						
							|  |  |  | 		if [[ $1 = local ]] ; then | 
					
						
							|  |  |  | 			git clone $SRC/../grantlee grantlee | 
					
						
							|  |  |  | 		else | 
					
						
							| 
									
										
										
										
											2017-04-15 12:33:38 +02:00
										 |  |  | 			git clone https://github.com/steveire/grantlee.git | 
					
						
							| 
									
										
										
										
											2016-01-07 21:30:51 -08:00
										 |  |  | 		fi | 
					
						
							| 
									
										
										
										
											2015-06-04 11:53:31 -07:00
										 |  |  | 	fi | 
					
						
							| 
									
										
										
										
											2016-01-07 21:30:51 -08:00
										 |  |  | 	cd grantlee | 
					
						
							|  |  |  | 	if ! git checkout v5.0.0 ; then | 
					
						
							|  |  |  | 		echo "can't check out v5.0.0 of grantlee -- giving up" | 
					
						
							|  |  |  | 		exit 1 | 
					
						
							|  |  |  | 	fi | 
					
						
							|  |  |  | 	mkdir -p build | 
					
						
							|  |  |  | 	cd build | 
					
						
							| 
									
										
										
										
											2017-07-04 01:42:51 +09:00
										 |  |  | 	cmake $OLDER_MAC_CMAKE -DCMAKE_BUILD_TYPE=Release \
 | 
					
						
							| 
									
										
										
										
											2016-01-07 21:30:51 -08:00
										 |  |  | 		-DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT \
 | 
					
						
							|  |  |  | 		-DBUILD__TESTS=NO \
 | 
					
						
							|  |  |  | 		$SRC/grantlee | 
					
						
							|  |  |  | 	make -j4 | 
					
						
							|  |  |  | 	make install | 
					
						
							| 
									
										
										
										
											2017-07-15 21:51:42 -07:00
										 |  |  | else | 
					
						
							|  |  |  | 	PRINTING="-DNO_PRINTING=ON" | 
					
						
							| 
									
										
										
										
											2015-06-04 11:53:31 -07:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-22 18:17:25 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-04 11:53:31 -07:00
										 |  |  | # finally, build Subsurface | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-17 13:10:45 -08:00
										 |  |  | cd $SRC/subsurface | 
					
						
							| 
									
										
										
										
											2016-01-17 10:44:00 -08:00
										 |  |  | for (( i=0 ; i < ${#BUILDS[@]} ; i++ )) ; do | 
					
						
							|  |  |  | 	SUBSURFACE_EXECUTABLE=${BUILDS[$i]} | 
					
						
							|  |  |  | 	BUILDDIR=${BUILDDIRS[$i]} | 
					
						
							|  |  |  | 	echo "build $SUBSURFACE_EXECUTABLE in $BUILDDIR" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-18 11:20:05 -08:00
										 |  |  | 	# pull the plasma-mobile components from upstream if building Subsurface-mobile | 
					
						
							|  |  |  | 	if [ "$SUBSURFACE_EXECUTABLE" = "MobileExecutable" ] ; then | 
					
						
							|  |  |  | 		cd $SRC/subsurface | 
					
						
							|  |  |  | 		bash ./scripts/mobilecomponents.sh | 
					
						
							|  |  |  | 	fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-17 10:44:00 -08:00
										 |  |  | 	mkdir -p $SRC/subsurface/$BUILDDIR | 
					
						
							|  |  |  | 	cd $SRC/subsurface/$BUILDDIR | 
					
						
							| 
									
										
										
										
											2016-03-16 09:00:37 +01:00
										 |  |  | 	export CMAKE_PREFIX_PATH="$INSTALL_ROOT/lib/cmake;${CMAKE_PREFIX_PATH}" | 
					
						
							| 
									
										
										
										
											2016-01-17 10:44:00 -08:00
										 |  |  | 	cmake -DCMAKE_BUILD_TYPE=Debug .. \
 | 
					
						
							|  |  |  | 		-DSUBSURFACE_TARGET_EXECUTABLE=$SUBSURFACE_EXECUTABLE \
 | 
					
						
							| 
									
										
										
										
											2017-01-16 15:56:56 -08:00
										 |  |  | 		${LIBGIT_ARGS} \
 | 
					
						
							| 
									
										
										
										
											2016-01-17 10:44:00 -08:00
										 |  |  | 		-DLIBDIVECOMPUTER_INCLUDE_DIR=$INSTALL_ROOT/include \
 | 
					
						
							|  |  |  | 		-DLIBDIVECOMPUTER_LIBRARIES=$INSTALL_ROOT/lib/libdivecomputer.a \
 | 
					
						
							| 
									
										
										
										
											2016-03-16 09:00:37 +01:00
										 |  |  | 		-DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH \
 | 
					
						
							| 
									
										
										
										
											2017-07-15 21:39:54 -07:00
										 |  |  | 		$PRINTING $MARBLE_OPTS | 
					
						
							| 
									
										
										
										
											2016-01-17 10:44:00 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if [ $PLATFORM = Darwin ] ; then | 
					
						
							|  |  |  | 		rm -rf Subsurface.app | 
					
						
							|  |  |  | 		rm -rf Subsurface-mobile.app | 
					
						
							|  |  |  | 	fi | 
					
						
							| 
									
										
										
										
											2015-06-02 10:43:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-17 10:44:00 -08:00
										 |  |  | 	LIBRARY_PATH=$INSTALL_ROOT/lib make -j4 | 
					
						
							| 
									
										
										
										
											2015-09-02 18:35:40 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-17 10:44:00 -08:00
										 |  |  | 	if [ $PLATFORM = Darwin ] ; then | 
					
						
							|  |  |  | 		LIBRARY_PATH=$INSTALL_ROOT/lib make install | 
					
						
							|  |  |  | 	fi | 
					
						
							|  |  |  | done |