#!/bin/bash

set -e
set -x

set -o pipefail

case $(uname -s) in
	Darwin)
		cd $(dirname $0)/..
		./scripts/mac/make-mac.sh | xcpretty
		xcodebuild -project beidmw.xcodeproj -target testsuite -configuration Release  CODE_SIGN_IDENTITY='' CODE_SIGNING_REQUIRED=NO | xcpretty
		./scripts/mac/make-viewer.sh | xcpretty
		cd Release
		DYLD_LIBRARY_PATH=$(pwd) ./testsuite
		;;
	Linux)
		cd $(dirname $0)/..
		autoreconf -f -i
		if ! ./configure; then
			cat config.log
			exit 1
		fi
		make
		make check
		;;
esac
