]> Creatis software - FrontAlgorithms.git/blob - config/install.sh
...
[FrontAlgorithms.git] / config / install.sh
1 #!/bin/bash
2
3 ## -- Command line options
4 while [[ "$#" -gt 1 ]]; do
5     key="$1"
6     case $key in
7         -prefix)
8         prefix="$2"
9         shift
10         ;;
11         -cores)
12         cores="$2"
13         shift
14         ;;
15         -build_type)
16         build_type="$2"
17         shift
18         ;;
19         -install_type)
20         install_type="$2"
21         shift
22         ;;
23         -eigen_version)
24         eigen_version="$2"
25         shift
26         ;;
27         *)
28         # Do nothing
29         ;;
30     esac
31     shift
32 done
33
34 ## -- Check command line options
35 if \
36     [ -z "$prefix" ] || \
37     [ -z "$build_type" ] ; then
38     (>&2 echo "Usage: $0 -prefix [dir] [-build_type [Release/Debug]] [-cores [n]] [-install_type [compile/install]] [-eigen_version [x.y.z]]}")
39     exit 1
40 fi
41
42 if [ -z "$cores" ] ; then
43     cores="1"
44 fi
45 if [ -z "$build_type" ] ; then
46     build_type="Release"
47 fi
48 if [ -z "$install_type" ] ; then
49     install_type="install"
50 fi
51
52 cmake=`find $prefix -type f -name "cmake" | grep bin`
53 cpPluginsConfig=`find $prefix -type f -name "cpPluginsConfig.cmake"`
54
55 ## -- Current dir
56 curr_dir=`pwd`
57
58 ## -- Compile eigen
59 if [ -n "$eigen_version" ] ; then
60     url="http://bitbucket.org/eigen/eigen/get/$eigen_version.tar.bz2"
61     dir="$HOME/.tmp"
62     mkdir -p $dir
63     mkdir -p $dir/eigen/src
64     mkdir -p $dir/eigen/bin
65     cd $dir/eigen
66     curl -L -o eigen.tar.bz2 $url
67     tar xf eigen.tar.bz2 -C $dir/eigen/src --strip-components=1
68     cd $dir/eigen/bin
69     $cmake $dir/eigen/src
70 fi
71
72 ## -- Current dir
73 cd $curr_dir/..
74
75 ## -- Configure, build and install
76 mkdir -p build
77 cd build
78 $cmake \
79     -DCMAKE_BUILD_TYPE:STRING=$build_type \
80     -DCMAKE_INSTALL_PREFIX:PATH=$prefix \
81     -Dfpa_BUILD_CTArteries:BOOL=ON \
82     -Dfpa_BUILD_CTBronchi:BOOL=ON \
83     -DcpPlugins_DIR:PATH=`dirname $cpPluginsConfig` \
84     $curr_dir/..
85 make -j$cores -k
86 if [[ "$install_type" == 'install' ]] ; then
87     make -j -k install
88 fi
89
90 ## -- End
91 cd $curr_dir
92
93 ## eof - $RCSfile$