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