#!/usr/bin/env bash

if [ "$SAGE_LOCAL" = "" ]; then
   echo "SAGE_LOCAL undefined ... exiting";
   echo "Maybe run 'sage -sh'?"
   exit 1
fi


QMAKE=`which qmake 2> /dev/null` || QMAKE=`which qmake-qt4` 
if [ $? -ne 0 ]; then
    echo "Cannot find qmake (the Qt make tool)"
    echo 
    echo "If you have a private installation somewhere, put a symlink to"
    echo "qmake into $SAGE_ROOT/local/bin and rerun the PyQt installation."
    exit 1
fi
echo "Using qmake located at $QMAKE"



cd src

python configure.py --no-qsci-api --no-designer-plugin --confirm-license -q "$QMAKE"
if [ $? -ne 0 ]; then
    echo "Error configuring PyQt4."
    exit 1
fi

make -j1
if [ $? -ne 0 ]; then
    echo "Error making PyQt4."
    exit 1
fi

make install
if [ $? -ne 0 ]; then
    echo "Error installing PyQt4."
    exit 1
fi

