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 "====================================================================="
139 read -n1 -r -p "Continue? [Y/N]... " key
141 if [ "$key" != 'Y' -a "$key" != 'y' ] ; then
146 if [ "x$source_file" != "x" ]; then
147 echo -n "==> Cleaning directories... "
151 echo -n "==> Creating directories... "
157 ## Extract source code
158 if [ "x$source_file" != "x" ]; then
159 echo -n "==> Extracting sources... "
160 base_path=`abspath $source_file`
161 base_ext=`get_file_extension $base_path`
162 if [ "$base_ext" == "zip" ]; then
163 echo unzip $base_path
164 elif [ "$base_ext" == "tar" ]; then
165 tar xf $base_path -C $source_dir --strip-components=1
166 elif [ "$base_ext" == "tar.gz" ]; then
167 tar xzf $base_path -C $source_dir --strip-components=1
168 elif [ "$base_ext" == "tar.bz2" ]; then
169 tar xjf $base_path -C $source_dir --strip-components=1
175 if [ "x$patch_file" != "x" ]; then
176 echo -n "==> Applying patch... "
178 patch -p0 < $patch_file
182 echo "==> Configuring sources... "
184 if [ "x$full_compile" == "xfull" ]; then
185 $source_dir/configure \
188 -opensource -shared -fast \
191 $particular_options \
194 $source_dir/configure \
197 -opensource -shared -fast \
202 -nomake demos -nomake examples \
204 $particular_options \
207 echo "==> Configuring sources... done."
209 echo "==> Compiling sources..."
211 make -j$number_of_threads
212 echo "==> Compiling sources... done."
214 echo "==> Installing package..."
217 echo "==> Installing package... done."