]> Creatis software - cpPlugins.git/blob - third_party_installers/cpPlugins_Install_QT4.sh
76fdddeccf9183ec4b71b77e14e13a3ec162d30d
[cpPlugins.git] / third_party_installers / cpPlugins_Install_QT4.sh
1 #!/bin/bash
2
3 function abspath()
4 {
5     pushd . > /dev/null
6     if [ -d "$1" ]; then
7         cd "$1"
8         dirs -l +0
9     else
10         cd "`dirname \"$1\"`"
11         cur_dir=`dirs -l +0`
12         if [ "$cur_dir" == "/" ]; then
13             echo "$cur_dir`basename \"$1\"`"
14         else
15             echo "$cur_dir/`basename \"$1\"`"
16         fi
17     fi
18     popd > /dev/null
19 }
20
21 ## Some configuration variables
22 number_of_processes="-j4"
23 platform=`uname`
24 particular_options=""
25 if [ "$platform" == "Darwin" ]; then
26     particular_options=-no-framework
27 fi
28
29 ## Check input parameters and process inputs (if needed)
30 if [ "$#" -eq 2 ]; then
31     valid_extensions=("zip" "tar" "tar.gz" "tar.bz2")
32     actual_ext=""
33     for ext in ${valid_extensions[@]}; do
34         if [ `basename $1 $ext` != $1 ]; then
35             actual_ext=$ext
36         fi
37     done
38     if [ "x$actual_ext" == "x" ]; then
39         echo "$0: Invalid file type."
40         exit 1
41     fi
42     canonical_path=`abspath $1`
43     source_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`
44     build_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`-build
45     echo -n "Cleaning directories... "
46     rm -rf $source_dir
47     rm -rf $build_dir
48     echo "done."
49     echo -n "Creating directories... "
50     mkdir -p $source_dir
51     mkdir -p $build_dir
52     echo "done."
53     echo -n "Extracting sources... "
54     if [ "$actual_ext" == "zip" ]; then
55         echo unzip $canonical_path
56     elif [ "$actual_ext" == "tar" ]; then
57         tar xf $canonical_path -C $source_dir --strip-components=1
58     elif [ "$actual_ext" == "tar.gz" ]; then
59         tar xzf $canonical_path -C $source_dir --strip-components=1
60     elif [ "$actual_ext" == "tar.bz2" ]; then
61         tar xjf $canonical_path -C $source_dir --strip-components=1
62     else
63         echo "$0: Invalid file type."
64         exit 1
65     fi
66     echo "done!"
67     build_type=$2
68 elif [ "$#" -eq 3 ]; then
69     source_dir=`dirname $1`
70     build_dir=`dirname $2`
71     build_type=$3
72 else
73     echo "Usage: [qt4_package] or [qt4_source_dir qt4_build_dir] [build_type]" 
74 fi
75
76 echo "Given source dir : \"$source_dir\""
77 echo "Given build dir  : \"$build_dir\""
78
79 echo "Configuring sources... "
80 cd $build_dir
81 $source_dir/configure \
82     -prefix ${HOME}/local \
83     $build_type \
84     -opensource -shared -fast \
85     -no-phonon \
86     -no-phonon-backend \
87     -no-webkit \
88     -no-openvg \
89     -nomake demos -nomake examples \
90     -optimized-qmake \
91     $particular_options \
92     -confirm-license
93 echo "Configuring sources... done."
94
95 echo "Compiling sources..."
96 cd $build_dir
97 make $number_of_processes
98 echo "Compiling sources... done."
99
100 echo "Installing package..."
101 cd $build_dir
102 make -j install
103 echo "Installing package... done."
104
105 ## eof - $RCSfile$