#!/usr/bin/env sh

if ! qmake -v; then
    printf '%s\n' 'ERROR: qmake not found, cannot build Qt GUI' > /dev/stderr
    exit 1
fi

rm -f .qmake.stash qt5check qt5check-makefile qt5check.o

# DARWIN_OPTS as in src/CoCoA-5/make-c5makefile.sh:
if [ "$SYS_TYPE" = "Darwin" ]; then
    DARWIN_OPTS="-spec macx-g++"
fi

qmake $DARWIN_OPTS qt5check.pro
make --file=qt5check-makefile

if ! ./qt5check; then
    printf '%s\n' 'ERROR: Insufficient Qt5 system' > /dev/stderr
    exit 1
fi

rm -f .qmake.stash qt5check qt5check-makefile qt5check.o

printf '%s\n' 'qt5check finished successfully'
