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