1#!/usr/bin/env bash
2
3set -euf
4
5COMPILER=gcc
6
7if [ $# -gt 0 ]
8then
9	COMPILER="${1}"
10	shift
11fi
12
13echo "I: ${COMPILER} compiler"
14
15if [ "x${COMPILER}" = xclang ]
16then
17	CC=clang-5.0
18	CXX=clang++-5.0
19	LIBS='-liconv'
20
21	export CC CXX LIBS
22fi
23
24RETRY=0
25
26while [ $RETRY -lt 3 ];
27do
28	./autogen.sh "$@" && break
29
30	echo "W: failed to run autogen.sh, will retry..."
31	RETRY=$(($RETRY + 1))
32	sleep $((10 * $RETRY))
33done
34
35if [ $RETRY -ge 3 ];
36then
37	echo "F: All retries failed, aborting..."
38	exit 1
39fi
40
41make
42make check || { find test -name 'test-suite.log' -exec cat {} ';' && exit 1; }
43make clean
44
45exit 0
46