]> Creatis software - FrontAlgorithms.git/blobdiff - config/install.sh
...
[FrontAlgorithms.git] / config / install.sh
diff --git a/config/install.sh b/config/install.sh
new file mode 100755 (executable)
index 0000000..8228b51
--- /dev/null
@@ -0,0 +1,93 @@
+#!/bin/bash
+
+## -- Command line options
+while [[ "$#" -gt 1 ]]; do
+    key="$1"
+    case $key in
+        -prefix)
+        prefix="$2"
+        shift
+        ;;
+        -cores)
+        cores="$2"
+        shift
+        ;;
+        -build_type)
+        build_type="$2"
+        shift
+        ;;
+        -install_type)
+        install_type="$2"
+        shift
+        ;;
+        -eigen_version)
+        eigen_version="$2"
+        shift
+        ;;
+        *)
+        # Do nothing
+        ;;
+    esac
+    shift
+done
+
+## -- Check command line options
+if \
+    [ -z "$prefix" ] || \
+    [ -z "$build_type" ] ; then
+    (>&2 echo "Usage: $0 -prefix [dir] [-build_type [Release/Debug]] [-cores [n]] [-install_type [compile/install]] [-eigen_version [x.y.z]]}")
+    exit 1
+fi
+
+if [ -z "$cores" ] ; then
+    cores="1"
+fi
+if [ -z "$build_type" ] ; then
+    build_type="Release"
+fi
+if [ -z "$install_type" ] ; then
+    install_type="install"
+fi
+
+cmake=`find $prefix -type f -name "cmake" | grep bin`
+cpPluginsConfig=`find $prefix -type f -name "cpPluginsConfig.cmake"`
+
+## -- Current dir
+curr_dir=`pwd`
+
+## -- Compile eigen
+if [ -n "$eigen_version" ] ; then
+    url="http://bitbucket.org/eigen/eigen/get/$eigen_version.tar.bz2"
+    dir="$HOME/.tmp"
+    mkdir -p $dir
+    mkdir -p $dir/eigen/src
+    mkdir -p $dir/eigen/bin
+    cd $dir/eigen
+    curl -L -o eigen.tar.bz2 $url
+    tar xf eigen.tar.bz2 -C $dir/eigen/src --strip-components=1
+    cd $dir/eigen/bin
+    $cmake $dir/eigen/src
+fi
+
+## -- Current dir
+cd $curr_dir/..
+
+## -- Configure, build and install
+mkdir -p build
+cd build
+$cmake \
+    -DCMAKE_BUILD_TYPE:STRING=$build_type \
+    -DCMAKE_INSTALL_PREFIX:PATH=$prefix \
+    -Dfpa_BUILD_CTArteries:BOOL=ON \
+    -Dfpa_BUILD_CTBronchi:BOOL=ON \
+    -DcpPlugins_DIR:PATH=`dirname $cpPluginsConfig` \
+    $curr_dir/..
+make -j$cores -k
+if [[ "$install_type" == 'install' ]] ; then
+    make -j -k install
+fi
+
+## -- End
+cd $curr_dir
+
+## eof - $RCSfile$