#!/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 4.8. It was 
# created by:
#
#  1) Installing the Qt 4.8 SDK as sudo into /opt/RStudio-QtSDK. Note that 
#     to minimize the size of the archive all components except Desktop Qt
#     4.8.0 are excluded (via custom setup)

#  2) Creating an archive using: 
#
#     tar czfP QtSDK-4.8.0-x86_64.tar.gz /opt/RStudio-QtSDK/ 
#

# install dir
INSTALL_DIR=`pwd`

# 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-4.8.0-${QT_ARCH}.tar.gz
QT_SDK_URL=https://s3.amazonaws.com/rstudio-buildtools/$QT_SDK_BINARY
QT_SDK_DIR=/opt/RStudio-QtSDK

if ! test -e $QT_SDK_DIR
then
   # download and install
   wget $QT_SDK_URL -O $QT_SDK_BINARY
   cd /
   sudo tar xfP $INSTALL_DIR/$QT_SDK_BINARY
   cd $INSTALL_DIR
   rm $QT_SDK_BINARY
else
   echo "Qt 4.8.0 SDK already installed"
fi

