-which gmqcc >> /dev/null || (echo "error gmqcc not installed" && exit 1)
-pushd ~/.gmqcc/testsuite/projects >> /dev/null
+gmqcc_bin="gmqcc"
+env -i type gmqcc 1>/dev/null 2>&1 || {
+ if [ -f ../gmqcc ]; then
+ echo "previous build of gmqcc exists, using it"
+ gmqcc_bin="$(pwd)/../gmqcc"
+ elif [ -f ./gmqcc ]; then
+ echo "previous build of gmqcc exists, using it"
+ gmqcc_bin="$(pwd)/gmqcc"
+ else
+ echo "gmqcc not installed and previous build doesn't exist"
+ echo "please run make, or make install"
+ exit 1
+ fi
+}
+
+pushd ~/.gmqcc/testsuite/projects > /dev/null