24e5d638bdc2fee91075d4b3f60e49a913129f56
[coreboot.git] / util / abuild / abuild
1 #!/bin/bash
2 #
3 #  coreboot autobuild
4 #
5 #  This script builds coreboot images for all available targets.
6 #
7 #  (C) 2004 by Stefan Reinauer <stepan@openbios.org>
8 #  (C) 2006-2010 by coresystems GmbH <info@coresystems.de>
9 #
10 #  This file is subject to the terms and conditions of the GNU General
11 #  Public License. See the file COPYING in the main directory of this
12 #  archive for more details.
13 #
14
15 #set -x # Turn echo on....
16
17 ABUILD_DATE="December 10th, 2010"
18 ABUILD_VERSION="0.9.1"
19
20 # Where shall we place all the build trees?
21 TARGET=coreboot-builds
22 XMLFILE=$( pwd )/abuild.xml
23
24 # path to payload. Should be more generic
25 PAYLOAD=/dev/null
26
27 # Lines of error context to be printed in FAILURE case
28 CONTEXT=6
29
30 TESTSUBMISSION="http://qa.coreboot.org/deployment/send.php"
31
32 # Number of CPUs to compile on per default
33 cpus=1
34
35 # Configure-only mode
36 configureonly=0
37
38 # Did any board fail to build?
39 failed=0
40
41 # One might want to adjust these in case of cross compiling
42 for i in make gmake gnumake nonexistant_make; do
43         $i --version 2>/dev/null |grep "GNU Make" >/dev/null && break
44 done
45 if [ "$i" = "nonexistant_make" ]; then
46         echo No GNU Make found.
47         exit 1
48 fi
49 MAKE=$i
50
51 # this can be changed to xml by -x
52 mode=text
53
54 # silent mode.. no compiler calls, only warnings in the log files.
55 # this is disabled per default but can be enabled with -s
56 silent=
57
58 # clang mode enabled by -sb option.
59 scanbuild=false
60
61 # use ccache
62 ccache=false
63
64 # stackprotect mode enabled by -ns option.
65 stackprotect=false
66
67 # loglevel changed with -l / --loglevel option
68 loglevel=default
69
70 # update existing image
71 update=false
72
73 # CBFS prefix
74 cbfs_prefix=fallback
75
76 ARCH=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
77         -e s/i86pc/i386/ \
78         -e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \
79         -e "s/Power Macintosh/ppc/"`
80
81 trap interrupt INT
82
83 function interrupt
84 {
85         printf "\n$0: execution interrupted manually.\n"
86         if [ "$mode" == "xml" ]; then
87                 printf "$0: deleting incomplete xml output file.\n"
88         fi
89         exit 1
90 }
91
92 function debug
93 {
94         test "$verbose" == "true" && printf "$*\n"
95 }
96
97 function xml
98 {
99         test "$mode" == "xml" && printf "$*\n" >> $XMLFILE
100         return 0
101 }
102
103 function xmlfile
104 {
105         test "$mode" == "xml" && {
106                 printf '<![CDATA[\n'
107                 cat $1
108                 printf ']]>\n'
109         } >> $XMLFILE
110 }
111
112
113
114 function vendors
115 {
116         # make this a function so we can easily select
117         # without breaking readability
118         ls -1 "$ROOT/src/mainboard" | grep -v Kconfig | grep -v Makefile
119 }
120
121 function mainboards
122 {
123         # make this a function so we can easily select
124         # without breaking readability
125
126         VENDOR=$1
127
128         ls -1 $ROOT/src/mainboard/$VENDOR | grep -v Kconfig
129 }
130
131 function architecture
132 {
133         VENDOR=$1
134         MAINBOARD=$2
135         ARCH=`cat $ROOT/src/mainboard/$VENDOR/$MAINBOARD/Kconfig | \
136                 grep "select ARCH_"|cut -f2- -d_`
137         echo $ARCH | sed s/X86/i386/
138 }
139
140 function create_config
141 {
142         VENDOR=$1
143         MAINBOARD=$2
144         CONFIG=$3
145
146         build_dir=$TARGET/${VENDOR}_${MAINBOARD}
147
148         # get a working payload for the board if we have one.
149         # the --payload option expects a directory containing
150         # a shell script payload.sh
151         #   Usage: payload.sh [VENDOR] [DEVICE]
152         # the script returns an absolute path to the payload binary.
153
154         if [ -f $payloads/payload.sh ]; then
155                 PAYLOAD=`sh $payloads/payload.sh $VENDOR $MAINBOARD`
156                 printf "Using payload $PAYLOAD\n"
157         fi
158
159         [ "$update" = "true" ] && mv ${build_dir}/coreboot.rom coreboot.rom.tmp
160         mkdir -p ${build_dir}
161         mkdir -p $TARGET/sharedutils
162         [ "$update" = "true" ] && mv coreboot.rom.tmp ${build_dir}/coreboot.rom
163
164         if [ "$CONFIG" != "" ]; then
165                 printf "  Using existing configuration $CONFIG ... "
166                 xml "  <config>$CONFIG</config>"
167                 cp src/mainboard/$VENDOR/$MAINBOARD/$CONFIG ${build_dir}/config.build
168         else
169                 printf "  Creating config file... "
170                 xml "  <config>autogenerated</config>"
171                 grep "if[\t ]*VENDOR" src/mainboard/$VENDOR/$MAINBOARD/../Kconfig | \
172                         sed "s,^.*\(VENDOR_.*\)[^A-Z0-9_]*,CONFIG_\1=y," > ${build_dir}/config.build
173                 grep "if[\t ]*BOARD" src/mainboard/$VENDOR/$MAINBOARD/Kconfig | \
174                         sed "s,^.*\(BOARD_.*\)[^A-Z0-9_]*,CONFIG_\1=y," >> ${build_dir}/config.build
175                 grep "select[\t ]*ARCH" src/mainboard/$VENDOR/$MAINBOARD/Kconfig | \
176                         sed "s,^.*\(ARCH_.*\)[^A-Z0-9_]*,CONFIG_\1=y," >> ${build_dir}/config.build
177                 echo "CONFIG_MAINBOARD_DIR=\"$VENDOR/$MAINBOARD\"" >> ${build_dir}/config.build
178                 echo "CONFIG_CBFS_PREFIX=\"$cbfs_prefix\"" >> ${build_dir}/config.build
179                 if [ "$PAYLOAD" != "/dev/null" ]; then
180                         echo "# CONFIG_PAYLOAD_NONE is not set" >> ${build_dir}/config.build
181                         echo "# CONFIG_PAYLOAD_SEABIOS is not set" >> ${build_dir}/config.build
182                         echo "CONFIG_PAYLOAD_ELF=y" >> ${build_dir}/config.build
183                         echo "CONFIG_PAYLOAD_FILE=\"$PAYLOAD\"" >> ${build_dir}/config.build
184                 fi
185
186                 if [ "$loglevel" != "default" ]; then
187                         printf "(loglevel override) "
188                         echo "CONFIG_MAXIMUM_CONSOLE_LOGLEVEL_$loglevel=y" >> ${build_dir}/config.build
189                         echo "CONFIG_MAXIMUM_CONSOLE_LOGLEVEL=$loglevel" >> ${build_dir}/config.build
190                         echo "CONFIG_DEFAULT_CONSOLE_LOGLEVEL_$loglevel=y" >> ${build_dir}/config.build
191                         echo "CONFIG_DEFAULT_CONSOLE_LOGLEVEL=$loglevel" >> ${build_dir}/config.build
192                 fi
193
194                 if [ "$update" != "false" ]; then
195                         printf "(update) "
196                         echo "CONFIG_UPDATE_IMAGE=y" >> ${build_dir}/config.build
197                 fi
198
199                 if [ "$ccache" = "true" ]; then
200                         printf "(ccache enabled) "
201                         echo "CONFIG_CCACHE=y" >> ${build_dir}/config.build
202                 fi
203
204                 if [ "$scanbuild" = "true" ]; then
205                         printf "(scan-build enabled) "
206                         echo "CONFIG_SCANBUILD_ENABLE=y" >> ${build_dir}/config.build
207                         echo "CONFIG_SCANBUILD_REPORT_LOCATION=\"$TARGET/scan-build-results-tmp\"" >> ${build_dir}/config.build
208                 fi
209         fi
210
211         #yes "" | $MAKE oldconfig -j $cpus obj=${build_dir} objutil=$TARGET/sharedutils &> ${build_dir}/config.log
212         yes "" | $MAKE oldconfig DOTCONFIG=${build_dir}/config.build obj=${build_dir} objutil=$TARGET/sharedutils &> ${build_dir}/config.log
213         ret=$?
214         if [ $ret -eq 0 ]; then
215                 printf "ok; "
216                 xml "  <builddir>ok</builddir>"
217                 xml "  <log>"
218                 xmlfile $build_dir/config.log
219                 xml "  </log>"
220                 xml ""
221                 return 0
222         else
223                 # Does this ever happen?
224                 printf "FAILED!\nLog excerpt:\n"
225                 xml "  <builddir>failed</builddir>"
226                 xml "  <log>"
227                 xmlfile $build_dir/config.log
228                 xml "  </log>"
229                 xml ""
230                 tail -n $CONTEXT $build_dir/config.log 2> /dev/null || tail -$CONTEXT $build_dir/config.log
231                 return 1
232         fi
233 }
234
235 function create_buildenv
236 {
237         VENDOR=$1
238         MAINBOARD=$2
239         CONFIG=$3
240
241         create_config $VENDOR $MAINBOARD $CONFIG
242         ret=$?
243
244         # Allow simple "make" in the target directory
245         MAKEFILE=$TARGET/${VENDOR}_${MAINBOARD}/Makefile
246         echo "# autogenerated" > $MAKEFILE
247         echo "TOP=$ROOT" >> $MAKEFILE
248         echo "BUILD=$TARGET" >> $MAKEFILE
249         echo "OBJ=\$(BUILD)/${VENDOR}_${MAINBOARD}" >> $MAKEFILE
250         echo "OBJUTIL=\$(BUILD)/sharedutils" >> $MAKEFILE
251         echo "all:" >> $MAKEFILE
252         echo "  @cp -a config.h config.h.bak" >> $MAKEFILE
253         echo "  @cd \$(TOP); \$(MAKE) oldconfig DOTCONFIG=\$(OBJ)/config.build objutil=\$(OBJUTIL) obj=\$(OBJ)" >> $MAKEFILE
254         echo "  @tail -n+6 config.h > config.new; tail -n+6 config.h.bak > config.old" >> $MAKEFILE
255         echo "  @cmp -s config.new config.old && cp -a config.h.bak config.h || echo \"Config file changed\"" >> $MAKEFILE
256         echo "  @rm config.h.bak config.new config.old" >> $MAKEFILE
257         echo "  @cd \$(TOP); \$(MAKE) DOTCONFIG=\$(OBJ)/config.build objutil=\$(OBJUTIL) obj=\$(OBJ)" >> $MAKEFILE
258
259         return $ret
260 }
261
262 function compile_target
263 {
264         VENDOR=$1
265         MAINBOARD=$2
266
267         printf " Compiling image "
268         test "$cpus" == "" && printf "in parallel .. "
269         test "$cpus" == "1" && printf "on 1 cpu .. "
270         test 0$cpus -gt 1 && printf "on %d cpus in parallel .. " $cpus
271
272         CURR=$( pwd )
273         #stime=`perl -e 'print time();' 2>/dev/null || date +%s`
274         build_dir=$TARGET/${VENDOR}_${MAINBOARD}
275         eval $MAKE $silent -j $cpus DOTCONFIG=${build_dir}/config.build obj=${build_dir} objutil=$TARGET/sharedutils \
276                 &> ${build_dir}/make.log
277         ret=$?
278         mv .xcompile ${build_dir}/xcompile.build
279         cd $TARGET/${VENDOR}_${MAINBOARD}
280
281         etime=`perl -e 'print time();' 2>/dev/null || date +%s`
282         duration=$(( $etime - $stime ))
283         xml "  <buildtime>${duration}s</buildtime>"
284
285         xml "  <log>"
286         xmlfile make.log
287         xml "  </log>"
288
289         if [ $ret -eq 0 ]; then
290                 xml "  <compile>ok</compile>"
291                 printf "ok\n" > compile.status
292                 printf "ok. (took ${duration}s)\n"
293                 cd $CURR
294                 return 0
295         else
296                 xml "  <compile>failed</compile>"
297                 printf "FAILED after ${duration}s!\nLog excerpt:\n"
298                 tail -n $CONTEXT make.log 2> /dev/null || tail -$CONTEXT make.log
299                 cd $CURR
300                 failed=1
301                 return 1
302         fi
303 }
304
305 function build_broken
306 {
307         CURR=`pwd`
308         status="yes"
309         [ -r "$ROOT/src/mainboard/${VENDOR}/${MAINBOARD}/BROKEN" ] && status="no"
310         [ "$buildbroken" == "true" -o "$status" == "yes" ]
311 }
312
313 function build_target
314 {
315         VENDOR=$1
316         MAINBOARD=$2
317         CONFIG=$3
318         TARCH=$( architecture $VENDOR $MAINBOARD )
319
320         # Allow architecture override in an abuild.info file.
321         # This is used for the Motorola Sandpoint, which is not a real target
322         # but a skeleton target for the Sandpoint X3.
323         [ -r "$ROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info" ] && \
324                 source $ROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info
325
326         # default setting
327
328         CC="${CROSS_COMPILE}gcc"
329         CROSS_COMPILE=""
330         found_crosscompiler=false
331         if which $TARCH-elf-gcc 2>/dev/null >/dev/null; then
332                 # i386-elf target needs --divide, for i386-linux, that's the default
333                 if [ "$TARCH" = "i386" ]; then
334                         CC="$CC -Wa,--divide"
335                 fi
336                 CROSS_COMPILE="$TARCH-elf-"
337                 CC=gcc
338                 CROSS_TEXT=", using $CROSS_COMPILE$CC"
339                 found_crosscompiler=true
340         fi
341
342         HOSTCC='gcc'
343
344         printf "Building $VENDOR/$MAINBOARD; "
345
346         xml "<mainboard>"
347         xml ""
348         xml "  <vendor>$VENDOR</vendor>"
349         xml "  <device>$MAINBOARD</device>"
350         xml ""
351         xml "  <architecture>$TARCH</architecture>"
352         xml ""
353
354         if [ "$ARCH" = "$TARCH" -o $found_crosscompiler = true ]; then
355                 printf "$TARCH: ok$CROSS_TEXT\n"
356         else
357                 # FIXME this is basically the same as above.
358                 found_crosscompiler=false
359                 if [ "$ARCH" == amd64 -a "$TARCH" == i386 ]; then
360                         CC="gcc -m32"
361                         found_crosscompiler=true
362                 fi
363                 if [ "$ARCH" == ppc64 -a "$TARCH" == ppc ]; then
364                         CC="gcc -m32"
365                         found_crosscompiler=true
366                 fi
367                 if [ "$found_crosscompiler" == "false" -a "$TARCH" == ppc ];then
368                         for prefix in powerpc-eabi- powerpc-linux- ppc_74xx- \
369                             powerpc-7450-linux-gnu- powerpc-elf-; do
370                                 if ${prefix}gcc --version > /dev/null 2> /dev/null ; then
371                                         found_crosscompiler=true
372                                         CROSS_COMPILE=$prefix
373                                 fi
374                         done
375                 fi
376
377
378                 # TBD: look for suitable cross compiler suite
379                 # cross-$TARCH-gcc and cross-$TARCH-ld
380
381                 # Check result:
382                 if [ $found_crosscompiler == "false" ]; then
383                         printf "$TARCH: skipped, we're $ARCH\n\n"
384                         xml "  <status>notbuilt</status>"
385                         xml ""
386                         xml "</mainboard>"
387
388                         return 0
389                 else
390                         printf "$TARCH: ok, $ARCH using ${CROSS_COMPILE}gcc\n"
391                         xml "  <compiler>"
392                         xml "    <path>`which ${CROSS_COMPILE}gcc`</path>"
393                         xml "    <version>`${CROSS_COMPILE}gcc --version | head -1`</version>"
394                         xml "  </compiler>"
395                         xml ""
396                 fi
397         fi
398
399         CC=${CROSS_COMPILE}$CC
400
401         if  [ "$stackprotect" = "true" ]; then
402                 CC="$CC -fno-stack-protector"
403         fi
404
405         build_broken $VENDOR $MAINBOARD || \
406         {
407                 printf " ( broken mainboard/$VENDOR/$MAINBOARD skipped )\n\n"
408                 xml "  <status>knownbroken</status>"
409                 xml ""
410                 xml "</mainboard>"
411                 return 0
412         }
413
414         stime=`perl -e 'print time();' 2>/dev/null || date +%s`
415         create_buildenv $VENDOR $MAINBOARD $CONFIG
416         if [ $? -eq 0  -a  $configureonly -eq 0 ]; then
417                 if [ "$scanbuild" = "true" ]; then
418                         rm -rf $TARGET/scan-build-results-tmp
419                 fi
420                 compile_target $VENDOR $MAINBOARD &&
421                         xml "  <status>ok</status>" ||
422                         xml "<status>broken</status>"
423                 if [ "$scanbuild" = "true" ]; then
424                         rm -rf $TARGET/${VENDOR}_${MAINBOARD}-scanbuild
425                         mv `dirname $TARGET/scan-build-results-tmp/*/index.html` $TARGET/${VENDOR}_${MAINBOARD}-scanbuild
426                 fi
427         fi
428         # Not calculated here because we still print it in compile_target
429         #etime=`perl -e 'print time();' 2>/dev/null || date +%s`
430         #duration=$(( $etime - $stime ))
431         #xml "  <buildtime>${duration}s</buildtime>"
432
433         xml ""
434         xml "</mainboard>"
435
436         printf "\n"
437 }
438
439 function test_target
440 {
441         VENDOR=$1
442         MAINBOARD=$2
443
444         if [ "$hwtest" != "true" ]; then
445                 return 0
446         fi
447
448         # image does not exist. we silently skip the patch.
449         if [ ! -r "$TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom" ]; then
450                 return 0
451         fi
452
453         which curl &> /dev/null
454         if [ $? != 0 ]; then
455                 printf "curl is not installed but required for test submission.  skipping test.\n\n"
456                 return 0
457         fi
458
459         CURR=`pwd`
460         if [ -r "$TARGET/${VENDOR}_${MAINBOARD}/tested" ]; then
461                 printf "Testing image for board $VENDOR $MAINBOARD skipped (previously submitted).\n\n"
462                 return 0
463         fi
464         # touch $TARGET/${VENDOR}_${MAINBOARD}/tested
465
466         printf "Submitting image for board $VENDOR $MAINBOARD to test system...\n"
467
468         curl -f -F "romfile=@$TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom" \
469                 -F "mode=abuild" -F "mainboard=${VENDOR}_${MAINBOARD}" -F "submit=Upload" \
470                 "http://qa.coreboot.org/deployment/send.php"
471
472         printf "\n"
473         return 0
474 }
475
476 function remove_target
477 {
478         if [ "$remove" != "true" ]; then
479                 return 0
480         fi
481
482         VENDOR=$1
483         MAINBOARD=$2
484
485         # Save the generated coreboot.rom file of each board.
486         if [ -r "$TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom" ]; then
487                 cp $TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom \
488                    ${VENDOR}_${MAINBOARD}_coreboot.rom
489         fi
490
491         printf "Removing build dir for board $VENDOR $MAINBOARD...\n"
492         rm -rf $TARGET/${VENDOR}_${MAINBOARD}
493
494         return 0
495 }
496
497 function myhelp
498 {
499         printf "Usage: $0 [-v] [-a] [-b] [-r] [-t <vendor/board>] [-p <dir>] [lbroot]\n"
500         printf "       $0 [-V|--version]\n"
501         printf "       $0 [-h|--help]\n\n"
502
503         printf "Options:\n"
504         printf "    [-v|--verbose]                print more messages\n"
505         printf "    [-a|--all]                    build previously succeeded ports as well\n"
506         printf "    [-b|--broken]                 attempt to build ports that are known broken\n"
507         printf "    [-r|--remove]                 remove output dir after build\n"
508         printf "    [-t|--target <vendor/board>]  attempt to build target vendor/board only\n"
509         printf "    [-p|--payloads <dir>]         use payloads in <dir> to build images\n"
510         printf "    [-V|--version]                print version number and exit\n"
511         printf "    [-h|--help]                   print this help and exit\n"
512         printf "    [-x|--xml]                    write xml log file \n"
513         printf "                                  (defaults to $XMLFILE)\n"
514         printf "    [-T|--test]                   submit image(s) to automated test system\n"
515         printf "    [-c|--cpus <numcpus>]         build on <numcpus> at the same time\n"
516         printf "    [-s|--silent]                 omit compiler calls in logs\n"
517         printf "    [-ns|--nostackprotect]        use gcc -fno-stack-protector option\n"
518         printf "    [-sb|--scan-build]            use clang's static analyzer\n"
519         printf "    [-y|--ccache]                 use ccache\n"
520         printf "    [-C|--config]                 configure-only mode\n"
521         printf "    [-l|--loglevel <num>]         set loglevel\n"
522         printf "    [-u|--update]                 update existing image\n"
523         printf "    [-P|--prefix <name>]          file name prefix in CBFS\n"
524         printf "    [lbroot]                      absolute path to coreboot sources\n"
525         printf "                                  (defaults to $ROOT)\n\n"
526 }
527
528 function myversion
529 {
530         cat << EOF
531
532 coreboot autobuild v$ABUILD_VERSION ($ABUILD_DATE)
533
534 Copyright (C) 2004 by Stefan Reinauer <stepan@openbios.org>
535 Copyright (C) 2006-2010 by coresystems GmbH <info@coresystems.de>
536
537 This program is free software; you may redistribute it under the terms
538 of the GNU General Public License. This program has absolutely no
539 warranty.
540
541 EOF
542 }
543
544 # default options
545 target=""
546 buildall=false
547 verbose=false
548
549 test -f util/sconfig/sconfig.l && ROOT=$( pwd )
550 test -f ../util/sconfig/sconfig.l && ROOT=$( cd ..; pwd )
551 test "$ROOT" = "" && ROOT=$( cd ../..; pwd )
552
553 # parse parameters.. try to find out whether we're running GNU getopt
554 getoptbrand="`getopt -V`"
555 if [ "${getoptbrand:0:6}" == "getopt" ]; then
556         # Detected GNU getopt that supports long options.
557         args=`getopt -l version,verbose,help,all,target:,broken,payloads:,test,cpus:,silent,xml,config,loglevel:,remove,prefix:,update,nostackprotect,scan-build,ccache -o Vvhat:bp:Tc:sxCl:rP:uy -- "$@"`
558         eval set -- $args
559 else
560         # Detected non-GNU getopt
561         args=`getopt Vvhat:bp:Tc:sxCl:rP:uy $*`
562         set -- $args
563 fi
564
565 if [ $? != 0 ]; then
566         myhelp
567         exit 1
568 fi
569
570 while true ; do
571         case "$1" in
572                 -x|--xml)       shift; mode=xml; rm -f $XMLFILE ;;
573                 -t|--target)    shift; target="$1"; shift;;
574                 -a|--all)       shift; buildall=true;;
575                 -b|--broken)    shift; buildbroken=true;;
576                 -r|--remove)    shift; remove=true;;
577                 -v|--verbose)   shift; verbose=true; silent='V=1';;
578                 -V|--version)   shift; myversion; exit 0;;
579                 -h|--help)      shift; myversion; myhelp; exit 0;;
580                 -p|--payloads)  shift; payloads="$1"; shift;;
581                 -T|--test)      shift; hwtest=true;;
582                 -c|--cpus)      shift; cpus="$1"; test "$cpus" == "max" && cpus=""; shift;;
583                 -s|--silent)    shift; silent="-s";;
584                 -ns|--nostackprotect) shift; stackprotect=true;;
585                 -sb|--scan-build) shift; scanbuild=true;;
586                 -y|--ccache)    shift; ccache=true;;
587                 -C|--config)    shift; configureonly=1;;
588                 -l|--loglevel)  shift; loglevel="$1"; shift;;
589                 -u|--update)    shift; update="true";;
590                 -P|--prefix)    shift; cbfs_prefix="$1"; shift;;
591                 --)             shift; break;;
592                 -*)             printf "Invalid option\n\n"; myhelp; exit 1;;
593                 *)              break;;
594         esac
595 done
596
597 # /path/to/freebios2/
598 test -z "$1" || ROOT=$1
599
600 debug "ROOT=$ROOT"
601
602 xml '<?xml version="1.0" encoding="utf-8"?>'
603 xml '<abuild>'
604
605 if [ "$target" != "" ]; then
606         # build a single board
607         VENDOR=`printf $target|cut -f1 -d/`
608         MAINBOARD=`printf $target|cut -f2 -d/`
609         CONFIG=`printf $target|cut -f3 -d/`
610         if [ ! -r $ROOT/src/mainboard/$target ]; then
611                 printf "No such target: $target\n"
612                 xml '</abuild>'
613                 exit 1
614         fi
615         build_target $VENDOR $MAINBOARD $CONFIG
616         test_target $VENDOR $MAINBOARD
617 else
618         # build all boards per default
619         for VENDOR in $( vendors ); do
620                 for MAINBOARD in $( mainboards $VENDOR ); do
621                         build_target $VENDOR $MAINBOARD
622                         test_target $VENDOR $MAINBOARD
623                         remove_target $VENDOR $MAINBOARD
624                 done
625         done
626 fi
627 xml '</abuild>'
628
629 exit $failed