1#!/bin/bash
2
3set -e
4
5if [ "$1" == "" ]; then
6    QMAKE=`which qmake`
7    if [ "$QMAKE" == "" ]; then
8	echo "Cannot find qmake"
9	exit 1
10    else
11	read -p "Is this correct qmake (y/N) $QMAKE : " yn
12	case $yn in
13	    [Yy]* ) ;;
14	    * ) echo "Please pass path to correct qmake as argument to this script."; exit;;
15	esac
16    fi
17else
18    QMAKE=$1
19fi
20
21cdir=`pwd`
22cpu_cores=`grep -c ^processor /proc/cpuinfo`
23absolute_path=`realpath $0`
24this_dir=`dirname $absolute_path`
25this_dir=`dirname $this_dir`
26parent_dir=`dirname $this_dir`
27
28if [ "$2" == "" ]; then
29    read -p "Number of CPU cores to use for compiling (hit enter to use $cpu_cores): " new_cpu_cores
30    case $new_cpu_cores in
31	"" ) ;;
32	* ) cpu_cores=$new_cpu_cores ;;
33    esac
34else
35    cpu_cores=$2
36fi
37
38if [ -d $parent_dir/output ]; then
39	read -p "Directory $parent_dir/output already exists. The script will delete and recreate it. Is that okay? (y/N) : " yn
40	case $yn in
41	    [Yy]* ) rm -rf $parent_dir/output ;;
42	    * ) echo "Aborted."; exit;;
43	esac
44fi
45
46cd $parent_dir
47mkdir output output/build output/build/Plugins
48
49cd output/build
50$QMAKE CONFIG+=portable ../../SQLiteStudio3
51make -j $cpu_cores
52
53cd Plugins
54$QMAKE CONFIG+=portable ../../../Plugins
55make -j $cpu_cores
56
57cd $cdir
58