]> Creatis software - cpPlugins.git/blob - third_party_installers/cpPlugins_Install_CMAKE.sh
61f058003924c5e026ec9c8265a47b47775fffe4
[cpPlugins.git] / third_party_installers / cpPlugins_Install_CMAKE.sh
1 #!/bin/bash
2
3 ## Some configuration variables
4 number_of_processes="-j4"
5
6 ## Check input parameters and process inputs (if needed)
7 if [ "$#" -eq 1 ]; then
8     valid_extensions=("zip" "tar" "tar.gz" "tar.bz2")
9     actual_ext=""
10     for ext in ${valid_extensions[@]}; do
11         if [ `basename $1 $ext` != $1 ]; then
12             actual_ext=$ext
13         fi
14     done
15     if [ "x$actual_ext" == "x" ]; then
16         echo "$0: Invalid file type."
17         exit 1
18     fi
19     canonical_path=`readlink -e $1`
20     source_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`
21     build_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`-build
22     echo -n "Cleaning directories... "
23     rm -rf $source_dir
24     rm -rf $build_dir
25     echo "done."
26     echo -n "Creating directories... "
27     mkdir -p $source_dir
28     mkdir -p $build_dir
29     echo "done."
30     echo -n "Extracting sources... "
31     if [ "$actual_ext" == "zip" ]; then
32         echo unzip $canonical_path
33     elif [ "$actual_ext" == "tar" ]; then
34         tar xf $canonical_path -C $source_dir --strip-components=1
35     elif [ "$actual_ext" == "tar.gz" ]; then
36         tar xzf $canonical_path -C $source_dir --strip-components=1
37     elif [ "$actual_ext" == "tar.bz2" ]; then
38         tar xjf $canonical_path -C $source_dir --strip-components=1
39     else
40         echo "$0: Invalid file type."
41         exit 1
42     fi
43     echo "done!"
44 elif [ "$#" -eq 2 ]; then
45     source_dir=`dirname $1`
46     build_dir=`dirname $2`
47 else
48     echo "Usage: [cmake_package] or [cmake_source_dir cmake_build_dir]" 
49 fi
50
51 echo "Given source dir : \"$source_dir\""
52 echo "Given build dir  : \"$build_dir\""
53
54 echo "Configuring sources... "
55 cd $build_dir
56 $source_dir/bootstrap --prefix=${HOME}/local
57 echo "Configuring sources... done."
58
59 echo "Compiling sources..."
60 cd $build_dir
61 make $number_of_processes
62 echo "Compiling sources... done."
63
64 echo "Installing package..."
65 cd $build_dir
66 make -j install
67 echo "Installing package... done."
68
69 ## eof - $RCSfile$