1#!/bin/sh
2
3# This script builds all tests, including the one which
4# tests for configure.  I'm sure it would be possible to do it
5# with just "make", but a script seems vastly simpler now.
6
7# we know, we knooooooow
8export RUMPRUN_WARNING_STFU=please
9
10set -e
11
12TESTMODE=apptools
13TESTCONFIGURE=true
14TESTCMAKE=$(which cmake || echo "")
15
16while getopts 'kqh' opt; do
17	case "$opt" in
18	'k')
19		TESTMODE=kernonly
20		;;
21	'q')
22		TESTCONFIGURE=false
23		;;
24	'h'|'?')
25		echo "$0 [-k|-q]"
26		exit 1
27	esac
28done
29shift $((${OPTIND} - 1))
30
31# XXX: sourcing the file while aiming to use app-tools is plain wrong
32[ -n "${RUMPRUN_SHCONF}" ] || { echo '>> need RUMPRUN_SHCONF'; exit 1; }
33. "${RUMPRUN_SHCONF}"
34unset CC
35unset CXX
36
37cd "$(dirname $0)"
38
39test_apptools()
40{
41
42	case ${PLATFORM} in
43	hw)
44		RUMPBAKE_PLATFORM='hw_generic'
45		;;
46	xen)
47		RUMPBAKE_PLATFORM='xen_pv'
48		;;
49	*)
50		echo ">> unknown platform \"$PLATFORM\""
51		exit 1
52	esac
53
54	export PATH="${RRDEST}/bin:${PATH}"
55	export RUMPBAKE_PLATFORM
56
57	make
58
59	if ${TESTCONFIGURE}; then
60		(
61			cd configure
62			./configure --host=${TOOLTUPLE}
63			make
64		)
65	fi
66
67	if [ -n "${TESTCMAKE}" ]; then
68		(
69			mkdir -p cmake/build
70			cd cmake/build
71			cmake -DCMAKE_TOOLCHAIN_FILE=${RRDEST}/rumprun-${MACHINE_GNU_ARCH}/share/${TOOLTUPLE}-toolchain.cmake ..
72			make
73		)
74	fi
75}
76
77test_kernonly()
78{
79	if [ -z "${MAKE}" ]; then
80		MAKE=make
81		! type gmake >/dev/null 2>&1 || MAKE=gmake
82	fi
83
84	${MAKE} PLATFORM=${PLATFORM} kernonly-tests
85}
86
87test_${TESTMODE}
88
89exit 0
90