#!/bin/bash

#
# install-qt-sdk
#
# Copyright (C) 2009-12 by RStudio, Inc.
#
# Unless you have received this program directly from RStudio pursuant
# to the terms of a commercial license agreement with RStudio, then
# this program is licensed to you under the terms of version 3 of the
# GNU Affero General Public License. This program is distributed WITHOUT
# ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
# AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
#
#

# This archive includes the files required to build against Qt 5.4.0. It
# was created by installing Qt 5.4.0 via an interactive installer, and 
# manually removing components not needed by RStudio.

# define QT archive to download
SYSTEM_ARCH=`getconf LONG_BIT`
if [ "$SYSTEM_ARCH" == "64" ]
then
  QT_ARCH=x86_64
else
  QT_ARCH=x86
fi
QT_SDK_BINARY=QtSDK-5.4.0-${QT_ARCH}.tar.gz
QT_SDK_URL=https://s3.amazonaws.com/rstudio-buildtools/$QT_SDK_BINARY

# set Qt SDK dir if not already defined
if [ -z "$QT_SDK_DIR" ]; then
  QT_SDK_DIR=~/Qt5.4.0
fi

if ! test -e $QT_SDK_DIR
then
   # download and install
   wget $QT_SDK_URL -O /tmp/$QT_SDK_BINARY
   cd ~
   tar xzf /tmp/$QT_SDK_BINARY
   rm /tmp/$QT_SDK_BINARY
else
   echo "Qt 5.4.0 SDK already installed"
fi

