#!/usr/bin/env bash

. common

$DIALOG --title "Install?" --backtitle "Installing catlibs" --yesno "This script will ask you for superuser password to install xoverlay and glez." 9 78
if [ $? == 1 ]; then exit; fi

SU=gksu

if ! command -v gksu; then
    SU=sudo
    exit
fi

pushd ../libxoverlay
if ! make -e ARCH=32 >/tmp/buildxoverlay.log 2>&1; then
    $DIALOG --title "Build failed" --msgbox "Failed to build libxoverlay. See /tmp/buildxoverlay.log for more info." 9 78
    exit
fi
$SU make install
popd

pushd ../libglez
if ! make -e ARCH=32 >/tmp/buildglez.log 2>&1; then
    $DIALOG --title "Build failed" --msgbox "Failed to build libglez. See /tmp/buildglez.log for more info." 9 78
    exit
fi
$SU make install
popd