# Script to auto build all test configurations of the 
# Linux kernel.
# Configuration (".config") files should be renamed to
# "config_somename" and added to the linux-2.4.19/test/configs
# directory.  Then add a build_a_config line leaving off the
# "config_" part of the name.
#
# Output of build is in linux-2.4.19/autobuilt_test directory.
#
# updated June 19, 2003 adt 
#
# Copyright 2003 Cirrus Logic
#
# Warning: The first thing this script does is delete
# the last autobuild.
#
logf=autobuild_for_test.log

#
# Execute a command
#
dowork() {
	echo "# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" >>${logf}
	echo "# Work: `pwd`" >>${logf}
	echo "# Task: $@" >>${logf}
	/usr/bin/time -f "# Time: %U user  %S system  %E elapsed" $@ >>${logf} 2>&1 || fail
}

#
# Report failure
#
fail() {
	echo "----------------------------------------------------------------------"
	echo "FAILED"
	echo "----------------------------------------------------------------------"
	exit 1
}

#
# Build one of the test configurations.
#
build_a_config(){
	echo "----------------------------------------------------------------------"
	echo Building test/configs/config_"$1"
	echo "Removing old build"
	dowork rm -f vmlin*
	echo "make distclean"
	dowork make distclean
	echo "getting config"
	dowork cp test/configs/config_"$1" .config
	echo "make oldconfig"
	dowork make oldconfig
	echo "make dep"
	dowork make dep
	echo "make vmlinux"
	dowork make vmlinux

	if [ -f vmlinux.bin ]; then
	    echo Built Linux with config_"$1"
	else 
	    echo Failed to build with config_"$1"
	    fail
	fi
}

rm -f ${logf}

build_a_config kernel_ac97
build_a_config kernel_crt640x480x16bpp
build_a_config kernel_crt640x480x8bpp
build_a_config kernel_ide_pio
build_a_config kernel_lcd640x480x16bpp
build_a_config kernel_lcd640x480x8bpp
build_a_config kernel_serial_console
build_a_config kernel_sir_irda

build_a_config kernel_ep9301

echo "SUCCESS!"

exit 0
