]> Creatis software - cpPlugins.git/blob - third_party_installers/cpPlugins_Install_QT4.sh
b8da6680a7287d458ae6933f95aea1e5fa8b4dd4
[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 2 ]; 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 elif [ "$#" -eq 3 ]; then
73     source_dir=`dirname $1`
74     build_dir=`dirname $2`
75     build_type=$3
76 else
77     echo "Usage: [qt4_package] or [qt4_source_dir qt4_build_dir] [build_type]" 
78 fi
79
80 # Apply patch
81 if [ "x$patch_file" != "x" ]; then
82     echo -n "Applying patch... "
83     cd $source_dir
84     patch -p0 < $patch_file
85     echo "done."
86 fi
87
88 echo "Given source dir : \"$source_dir\""
89 echo "Given build dir  : \"$build_dir\""
90
91 echo "Configuring sources... "
92 cd $build_dir
93 $source_dir/configure \
94     -prefix ${HOME}/local \
95     $build_type \
96     -opensource -shared -fast \
97     -no-phonon \
98     -no-phonon-backend \
99     -no-webkit \
100     -no-openvg \
101     -nomake demos -nomake examples \
102     -optimized-qmake \
103     $particular_options \
104     -confirm-license
105 echo "Configuring sources... done."
106
107 echo "Compiling sources..."
108 cd $build_dir
109 make $number_of_processes
110 echo "Compiling sources... done."
111
112 echo "Installing package..."
113 cd $build_dir
114 make -j install
115 echo "Installing package... done."
116
117 ## eof - $RCSfile$