Skip to content

Commit

Permalink
The quickbuild.sh script now checks the availability of the installat…
Browse files Browse the repository at this point in the history
…ion directory, specification is mandatory. Also checks prerequisite tools: make, cmake. Updated README.md accordingly.
  • Loading branch information
Andras Aszodi committed May 12, 2022
1 parent a759e2f commit 6409a56
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 8 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
60 changes: 55 additions & 5 deletions quickbuild.sh
Original file line number Diff line number Diff line change
@@ -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 <<HELP
MULTOVL quick build/install script. Works on Linux platforms only.
Builds a Release version with static linkage.
Usage: quickbuild.sh <INSTDIR>
where <INSTDIR> is the installation directory path.
MULTOVL will be installed in <INSTDIR>/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

Expand Down

0 comments on commit 6409a56

Please sign in to comment.