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