]> Creatis software - cpPlugins.git/blob - third_party_installers/cpPlugins_Install_ITK.sh
...
[cpPlugins.git] / third_party_installers / cpPlugins_Install_ITK.sh
1 #!/bin/bash
2
3 ## Some configuration variables
4 number_of_processes="-j4"
5 comp_type=Debug
6
7 ## Locate cmake executable
8 cmake_locations=("/usr/bin" "/usr/local/bin" "${HOME}/local/bin")
9 cmake_exec=""
10 cmake_ver=""
11 for loc in ${cmake_locations[@]}; do
12     cmake_file="$loc/cmake"
13     if [ -x $cmake_file ]; then
14         str=`$cmake_file --version | grep version`
15         version=${str:14}
16         if [ "$cmake_ver" \< "$version" ]; then
17             cmake_ver=$version
18             cmake_exec=$cmake_file
19         fi
20     fi
21 done
22 if [ ! -x $cmake_exec ]; then
23     echo "$0: modify this script to put the correct location of cmake."
24     exit 1
25 fi
26
27 ## Check input parameters and process inputs (if needed)
28 if [ "$#" -eq 1 ]; then
29     valid_extensions=("zip" "tar" "tar.gz" "tar.bz2")
30     actual_ext=""
31     for ext in ${valid_extensions[@]}; do
32         if [ `basename $1 $ext` != $1 ]; then
33             actual_ext=$ext
34         fi
35     done
36     if [ "x$actual_ext" == "x" ]; then
37         echo "$0: Invalid file type."
38         exit 1
39     fi
40     canonical_path=`readlink -e $1`
41     source_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`
42     build_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`-build
43     echo -n "Cleaning directories... "
44     rm -rf $source_dir
45     rm -rf $build_dir
46     echo "done."
47     echo -n "Creating directories... "
48     mkdir -p $source_dir
49     mkdir -p $build_dir
50     echo "done."
51     echo -n "Extracting sources... "
52     if [ "$actual_ext" == "zip" ]; then
53         echo unzip $canonical_path
54     elif [ "$actual_ext" == "tar" ]; then
55         tar xf $canonical_path -C $source_dir --strip-components=1
56     elif [ "$actual_ext" == "tar.gz" ]; then
57         tar xzf $canonical_path -C $source_dir --strip-components=1
58     elif [ "$actual_ext" == "tar.bz2" ]; then
59         tar xjf $canonical_path -C $source_dir --strip-components=1
60     else
61         echo "$0: Invalid file type."
62         exit 1
63     fi
64     echo "done!"
65 elif [ "$#" -eq 2 ]; then
66     source_dir=`dirname $1`
67     build_dir=`dirname $2`
68 else
69     echo "Usage: [itk_package] or [itk_source_dir itk_build_dir]" 
70 fi
71
72 echo "Given source dir : \"$source_dir\""
73 echo "Given build dir  : \"$build_dir\""
74
75 echo "Configuring sources... "
76 cd $build_dir
77 $cmake_exec \
78     -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
79     -DBUILD_DOCUMENTATION:BOOL=OFF \
80     -DBUILD_EXAMPLES:BOOL=OFF \
81     -DBUILD_SHARED_LIBS:BOOL=ON \
82     -DBUILD_TESTING:BOOL=OFF \
83     -DCMAKE_BUILD_TYPE:STRING=$comp_type \
84     -DModule_ITKReview:BOOL=ON \
85     -DModule_ITKVtkGlue:BOOL=OFF \
86     -DCMAKE_INSTALL_PREFIX:PATH=${HOME}/local \
87     ${source_dir}
88 echo "Configuring sources... done."
89
90 echo "Compiling sources..."
91 cd $build_dir
92 make $number_of_processes
93 echo "Compiling sources... done."
94
95 echo "Installing package..."
96 cd $build_dir
97 make -j install
98 echo "Installing package... done."
99
100 ## eof - $RCSfile$