#!/bin/sh

cd wxPython-src-2.8.7.1
# build and install the wx widgets

mkdir bld
cd bld
../configure --prefix=$SAGE_ROOT/local \
             --with-gtk \
             --enable-unicode \
             --with-opengl \
             --enable-optimize \
             --enable-debug_flag \
             --enable-geometry \
             --enable-graphics_ctx \
             --enable-mediactrl \
             --enable-display \
             --enable-monolithic \
             --with-libjpeg=builtin \
             --with-libpng=builtin \
             --with-libtiff=builtin \
             --with-zlib=builtin \

if [ $? -ne 0 ]; then
    echo "Error configure wx widgets."
    exit 1
fi


make

if [ $? -ne 0 ]; then
    echo "Error building wx widgets."
    exit 1
fi

make -C contrib/src/gizmos
if [ $? -ne 0 ]; then
    echo "Error building wx widgets gizmos."
    exit 1
fi

make -C contrib/src/stc
if [ $? -ne 0 ]; then
    echo "Error building wx widgets stc."
    exit 1
fi

make install

if [ $? -ne 0 ]; then
    echo "Error installing wx widgets."
    exit 1
fi

make -C contrib/src/gizmos install

if [ $? -ne 0 ]; then
    echo "Error installing wx widgets gizmo."
    exit 1
fi

make -C contrib/src/stc install

if [ $? -ne 0 ]; then
    echo "Error installing wx widgets stc."
    exit 1
fi


# building and installing wxPython
cd ../wxPython

python setup.py build_ext --inplace

if [ $? -ne 0 ]; then
    echo "Error building wxPython."
    exit 1
fi


python setup.py install

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

cp -pr ../wxPython $SAGE_ROOT/local/share

echo "To test cd to local/share/wxPython/demo"
echo "./sage -sh"
echo "Than try python demo.py"


