]> Creatis software - cpPlugins.git/blob - third_party_installers/cpPlugins_Install_QT4.sh
...
[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 patch_file=""
26 if [ "$platform" == "Darwin" ]; then
27     particular_options=-no-framework
28     bash_path=`abspath $0`
29     bash_dir=`dirname $bash_path`
30     patch_file=$bash_dir/qt-4.8.6.patch
31 fi
32
33 ## Check input parameters and process inputs (if needed)
34 if [ "$#" -eq 3 ]; then
35     valid_extensions=("zip" "tar" "tar.gz" "tar.bz2")
36     actual_ext=""
37     for ext in ${valid_extensions[@]}; do
38         if [ `basename $1 $ext` != $1 ]; then
39             actual_ext=$ext
40         fi
41     done
42     if [ "x$actual_ext" == "x" ]; then
43         echo "$0: Invalid file type."
44         exit 1
45     fi
46     canonical_path=`abspath $1`
47     source_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`
48     build_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`-build
49     echo -n "Cleaning directories... "
50     rm -rf $source_dir
51     rm -rf $build_dir
52     echo "done."
53     echo -n "Creating directories... "
54     mkdir -p $source_dir
55     mkdir -p $build_dir
56     echo "done."
57     echo -n "Extracting sources... "
58     if [ "$actual_ext" == "zip" ]; then
59         echo unzip $canonical_path
60     elif [ "$actual_ext" == "tar" ]; then
61         tar xf $canonical_path -C $source_dir --strip-components=1
62     elif [ "$actual_ext" == "tar.gz" ]; then
63         tar xzf $canonical_path -C $source_dir --strip-components=1
64     elif [ "$actual_ext" == "tar.bz2" ]; then
65         tar xjf $canonical_path -C $source_dir --strip-components=1
66     else
67         echo "$0: Invalid file type."
68         exit 1
69     fi
70     echo "done!"
71     build_type=$2
72     full_compil=$3
73 elif [ "$#" -eq 4 ]; then
74     source_dir=`dirname $1`
75     build_dir=`dirname $2`
76     build_type=$3
77     full_compil=$4
78 else
79     echo "Usage: [qt4_package] or [qt4_source_dir qt4_build_dir] [build_type] [min/full]"
80 fi
81
82 # Apply patch
83 if [ "x$patch_file" != "x" ]; then
84     echo -n "Applying patch... "
85     cd $source_dir
86     patch -p0 < $patch_file
87     echo "done."
88 fi
89
90 echo "Given source dir : \"$source_dir\""
91 echo "Given build dir  : \"$build_dir\""
92
93 echo "Configuring sources... "
94 cd $build_dir
95 if [ "x$full_compil" == "xfull" ]; then
96     $source_dir/configure \
97         -prefix ${HOME}/local \
98         $build_type \
99         -opensource -shared -fast \
100         -no-webkit \
101         -optimized-qmake \
102         $particular_options \
103         -confirm-license
104 else
105     $source_dir/configure \
106         -prefix ${HOME}/local \
107         $build_type \
108         -opensource -shared -fast \
109         -no-phonon \
110         -no-phonon-backend \
111         -no-webkit \
112         -no-openvg \
113         -nomake demos -nomake examples \
114         -optimized-qmake \
115         $particular_options \
116         -confirm-license
117 fi
118 echo "Configuring sources... done."
119
120 echo "Compiling sources..."
121 cd $build_dir
122 make $number_of_processes
123 echo "Compiling sources... done."
124
125 echo "Installing package..."
126 cd $build_dir
127 make -j install
128 echo "Installing package... done."
129
130 ## eof - $RCSfile$