diff --git a/README.md b/README.md index c157877..3ba9c0c 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,8 @@ and the Boost libraries (1.44 or above) to build Multovl. Run the `quickbuild.sh` script in the top-level Multovl directory. This will compile the package using static linkage, assuming a Linux platform, Boost libraries installed in the usual system location. -The Multovl installation goes under `/usr/local`. You can pass the -installation prefix by providing a path as a command line argument. -E.g. `quickbuild.sh $HOME/foo/bar` will install Multovl executables into +You have to specify the installation prefix by providing a path as a command line argument. +E.g. `quickbuild.sh $HOME/foo/bar` will install the Multovl executables into `$HOME/foo/bar/multovl-1.3/bin`. ### For the moderately impatient diff --git a/quickbuild.sh b/quickbuild.sh index 95c8c4d..16c4abd 100755 --- a/quickbuild.sh +++ b/quickbuild.sh @@ -1,26 +1,76 @@ -#!/bin/bash +#!/usr/bin/env bash # Quick build script # Release build, static linkage. # Works on Linux platforms. # 2022-05-11 Andras Aszodi +# -- Functions -- + +# Checks whether the arguments (program names) are in the user's $PATH, +# exits if not found. +exitif_notinpath() { + local missing=0 + + # iterate over all arguments + until [ -z "$1" ]; do + which $1 &> /dev/null + if [ $? -ne 0 ]; then + echo "No $1 in your PATH" + let "missing += 1" + fi + shift + done + if [ $missing -gt 0 ]; then + echo "Please install and then try again." + exit 991 + fi +} + +print_help() { + cat < +where is the installation directory path. +MULTOVL will be installed in /multovl-1.3. +HELP +} + +# == MAIN == + +# Check pre-requisites +exitif_notinpath make cmake + +# Installation directory +if [ $# -lt 1 ]; then + print_help + exit 1 +fi +INSTDIR=$(realpath $1) +if [ ! -d $INSTDIR ]; then + echo "Installation directory $INSTDIR does not exist" + exit 992 +fi +if [ ! -w $INSTDIR ]; then + echo "Installation directory $INSTDIR is not writable by you" + exit 993 +fi + # Top-level MULTOVL directory (where this script is located) MULTOVLDIR=$( cd $(dirname $0) ; pwd -P ) # Build in this subdirectory BUILDDIR=release -# Install in this directory -INSTALLDIR=${1:-"/usr/local"} # Build and install mkdir -p $BUILDDIR cd $BUILDDIR -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${INSTALLDIR} .. +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${INSTDIR} .. make -j2 install # Test the installation -cd ${INSTALLDIR}/multovl-1.3/bin +cd ${INSTDIR}/multovl-1.3/bin ./multovltest.sh ./multovl ./multovl --version