12 if [ "$cur_dir" == "/" ]; then
13 echo "$cur_dir`basename \"$1\"`"
15 echo "$cur_dir/`basename \"$1\"`"
21 function get_file_extension
23 valid_extensions=("zip" "tar" "tar.gz" "tar.bz2")
24 actual_file=`abspath $1`
26 for ext in ${valid_extensions[@]}; do
27 test_str=`dirname $actual_file`/`basename $actual_file $ext`
28 if [ $test_str != $actual_file ]; then
37 echo "Usage: `basename $0` -f=compressed_code -c=source_dir -b=build_dir [-t=build_type[release/debug]] [-p=instalation_prefix] [--full]"
40 ## Analyze command-line arguments
46 prefix="${HOME}/local"
79 ## Check command line arguments
80 if [ "x$source_dir" == "x" ]; then
81 if [ "x$source_file" != "x" ]; then
82 base_path=`abspath $source_file`
83 base_ext=`get_file_extension $base_path`
84 base_dir=`dirname $base_path`
85 if [ "x$base_ext" != "x" ]; then
86 source_dir="$base_dir"/`basename $base_path .$base_ext`
88 echo "Error: Input compressed file extension not recognized."
96 if [ "x$build_dir" == "x" ]; then
97 if [ "x$source_dir" != "x" ]; then
99 if [ "${source_dir:$((${#str}-1)):1}" == "/" ]; then
100 base_dir=`echo $source_dir | rev | cut -c 2- | rev`
102 build_dir="$base_dir-build"
109 ## Other configuration variables
111 particular_options=""
113 if [ "$platform" == "Darwin" ]; then
114 particular_options=-no-framework
115 bash_path=`abspath $0`
116 bash_dir=`dirname $bash_path`
117 patch_file=$bash_dir/qt-4.8.6.patch
119 number_of_cores=`grep -c ^processor /proc/cpuinfo`
120 number_of_threads=`expr $number_of_cores / 2`
121 if [ "x$source_file" != "x" ]; then
122 source_file=`abspath $source_file`
124 source_dir=`abspath $source_dir`
125 build_dir=`abspath $build_dir`
127 echo "====================================================================="
128 echo "==> Source file : $source_file"
129 echo "==> Source dir : $source_dir"
130 echo "==> Build dir : $build_dir"
131 echo "==> Build type : $build_type"
132 echo "==> Prefix : $prefix"
133 echo "==> Full compile : $full_compile"
134 echo "==> Platform : $platform"
135 echo "==> Number of cores : $number_of_cores"
136 echo "==> Number of threads : $number_of_threads"
137 echo "==> Patch file : $patch_file"
138 echo "====================================================================="
141 if [ "x$source_file" != "x" ]; then
142 echo -n "==> Cleaning directories... "
146 echo -n "==> Creating directories... "
152 ## Extract source code
153 if [ "x$source_file" != "x" ]; then
154 echo -n "==> Extracting sources... "
155 base_path=`abspath $source_file`
156 base_ext=`get_file_extension $base_path`
157 if [ "$base_ext" == "zip" ]; then
158 echo unzip $base_path
159 elif [ "$base_ext" == "tar" ]; then
160 tar xf $base_path -C $source_dir --strip-components=1
161 elif [ "$base_ext" == "tar.gz" ]; then
162 tar xzf $base_path -C $source_dir --strip-components=1
163 elif [ "$base_ext" == "tar.bz2" ]; then
164 tar xjf $base_path -C $source_dir --strip-components=1
170 if [ "x$patch_file" != "x" ]; then
171 echo -n "==> Applying patch... "
173 patch -p0 < $patch_file
177 echo "==> Configuring sources... "
179 if [ "x$full_compile" == "xfull" ]; then
180 $source_dir/configure \
183 -opensource -shared -fast \
186 $particular_options \
189 $source_dir/configure \
192 -opensource -shared -fast \
197 -nomake demos -nomake examples \
199 $particular_options \
202 echo "==> Configuring sources... done."
204 echo "==> Compiling sources..."
206 make -j$number_of_threads
207 echo "==> Compiling sources... done."
209 echo "==> Installing package..."
212 echo "==> Installing package... done."