062b590798eaba0f1e9b62f868fd4f5e1ba10d16
[coreboot.git] / util / kbuildall / kbuildall
1 #!/bin/sh
2 #
3 #  coreboot autobuilder for kconfig
4 #
5 #  This script builds coreboot images for all available targets.
6 #
7 #  (C) 2009 coresystems GmbH 
8 #      written by Patrick Georgi <patrick.georgi@coresystems.de>
9 #
10 #  This file is subject to the terms and conditions of the GNU General
11 #  Public License, version 2. See the file COPYING in the main directory
12 #  of this archive for more details.
13
14 TARGETDIR=kbuildall.results
15 BOARD=$1
16
17 if [ ! -f util/kbuildall/kbuildall ]; then
18         echo "This application must be run from the"
19         echo "toplevel directory of a coreboot checkout."
20         exit 1
21 fi
22
23 for make in make gmake gnumake; do
24         if [ "`$make --version 2>/dev/null | grep -c GNU`" -gt 0 ]; then
25                 MAKE=$make
26                 break
27         fi
28 done
29
30 builddefconfig() {
31 # $1: mainboarddir
32         $MAKE distclean
33         grep "depends[\t ]on[\t ]*VENDOR" src/mainboard/$1/../Kconfig | sed "s,^.*\(VENDOR_.*\)[^A-Z0-9_]*,CONFIG_\1=y," > .config
34         grep "config[\t ]*BOARD" src/mainboard/$1/Kconfig | sed "s,^.*\(BOARD_.*\)[^A-Z0-9_]*,CONFIG_\1=y," >> .config
35         grep "select[\t ]*ARCH" src/mainboard/$1/Kconfig | sed "s,^.*\(ARCH_.*\)[^A-Z0-9_]*,CONFIG_\1=y," >> .config
36         echo "CONFIG_MAINBOARD_DIR=$1" >> .config
37         yes "" | $MAKE oldconfig
38 }
39
40 ALLTARGETS=`(cd src/mainboard; ls */*/Config.lb | sed s,/Config.lb,,)`
41 TARGETCOUNT=`echo $ALLTARGETS | wc -w`
42
43 if [ -n "$BOARD" ]; then
44         TARGETCOUNT=1
45         ALLTARGETS=$BOARD
46 else
47         rm -rf $TARGETDIR
48 fi
49 mkdir -p $TARGETDIR
50 i=0
51 for dir in $ALLTARGETS; do
52         i=`expr $i + 1`
53         if [ ! -f src/mainboard/$dir/Kconfig ]; then
54                 echo "[$i/$TARGETCOUNT] ($dir) no Kconfig"
55                 echo "$dir nokconfig" >> $TARGETDIR/_overview.txt
56                 continue
57         fi
58         name=`echo $dir | sed s,/,_,g`
59         printf "[$i/$TARGETCOUNT] $dir "
60         builddefconfig $dir > $TARGETDIR/$name.buildconfig.log 2>&1
61         result=`$MAKE > $TARGETDIR/$name.buildcoreboot.log 2>&1 && echo ok || echo fail`
62         echo "$result."
63         if [ "$result" = "ok" ]; then
64                 util/abuild/abuild -o -C -t $dir
65                 sh util/compareboard/compareboard $dir | tee $TARGETDIR/$name.variables.txt
66         fi
67         echo "$dir $result" >> $TARGETDIR/_overview.txt
68 done