5 # This script builds coreboot images for all available targets.
7 # (C) 2004 by Stefan Reinauer <stepan@openbios.org>
8 # (C) 2006-2008 by coresystems GmbH <info@coresystems.de>
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.
15 #set -x # Turn echo on....
17 ABUILD_DATE="May 27th, 2008"
20 # Where shall we place all the build trees?
21 TARGET=$( pwd )/coreboot-builds
22 XMLFILE=$( pwd )/abuild.xml
24 # path to payload. Should be more generic
27 # Lines of error context to be printed in FAILURE case
30 TESTSUBMISSION="http://qa.coreboot.org/deployment/send.php"
32 # Number of CPUs to compile on per default
35 # One might want to adjust these in case of cross compiling
39 # this can be changed to xml by -x
42 # silent mode.. no compiler calls, only warnings in the log files.
43 # this is disabled per default but can be enabled with -s
46 ARCH=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
47 -e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \
48 -e "s/Power Macintosh/ppc/"`
54 printf "\n$0: execution interrupted manually.\n"
55 if [ "$mode" == "xml" ]; then
56 printf "$0: deleting incomplete xml output file.\n"
63 test "$verbose" == "true" && printf "$*\n"
68 test "$mode" == "xml" && printf "$*\n" >> $XMLFILE
73 test "$mode" == "xml" && {
84 # make this a function so we can easily select
85 # without breaking readability
86 ls -1 "$LBROOT/src/mainboard" | grep -v CVS
91 # make this a function so we can easily select
92 # without breaking readability
96 ls -1 $LBROOT/src/mainboard/$VENDOR | grep -v CVS
103 cat $LBROOT/src/mainboard/$VENDOR/$MAINBOARD/Config.lb | \
104 grep ^arch | cut -f 2 -d\
107 function create_config
111 TARCH=$( architecture $VENDOR $MAINBOARD )
112 TARGCONFIG=$LBROOT/targets/$VENDOR/$MAINBOARD/Config-abuild.lb
114 # get a working payload for the board if we have one.
115 # the --payload option expects a directory containing
116 # an executable shell script payload.sh
117 # Usage: payload.sh [VENDOR] [DEVICE]
118 # the script returns an absolute path to the payload binary.
120 if [ -x $payloads/payload.sh ]; then
121 PAYLOAD=`$payloads/payload.sh $VENDOR $MAINBOARD`
122 printf "Using payload $PAYLOAD\n"
127 if [ -f $TARGCONFIG ]; then
128 cp $TARGCONFIG $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
129 printf "Using existing test target $TARGCONFIG"
130 xml " <config>$TARGCONFIG</config>"
133 printf " Creating config file..."
134 xml " <config>autogenerated</config>"
136 # This will make a target directory of ./VENDOR_MAINBOARD
138 target VENDOR_MAINBOARD
139 mainboard VENDOR/MAINBOARD
142 option CROSS_COMPILE="CROSS_PREFIX"
143 option HOSTCC="CROSS_HOSTCC"
148 if [ "$TARCH" == i386 ] ; then
151 option USE_FALLBACK_IMAGE=0
152 option ROM_IMAGE_SIZE=0x17000
153 option COREBOOT_EXTRA_VERSION=".0-normal"
158 option USE_FALLBACK_IMAGE=1
159 option ROM_IMAGE_SIZE=0x17000
160 option COREBOOT_EXTRA_VERSION=".0-fallback"
163 buildrom ./coreboot.rom ROM_SIZE "normal" "fallback"
168 option COREBOOT_EXTRA_VERSION=".0"
171 buildrom ./coreboot.rom ROM_SIZE "only"
174 ) > $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
177 if [ "`which lzma`" != "" -a "$PAYLOAD" != /dev/null ]; then
178 COMPRESSION="option CONFIG_COMPRESSED_PAYLOAD_LZMA=1"
180 COMPRESSION="# no compression"
183 sed -i.pre -e s:VENDOR:$VENDOR:g \
184 -e s:MAINBOARD:$MAINBOARD:g \
185 -e s:payload\ __PAYLOAD__:payload\ $PAYLOAD:g \
186 -e s:CROSSCC:"$CC":g \
187 -e s:CROSS_PREFIX:"$CROSS_COMPILE":g \
188 -e s:CROSS_HOSTCC:"$HOSTCC":g \
189 -e s:__COMPRESSION__:"$COMPRESSION":g \
190 $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
194 function create_builddir
199 printf " Creating builddir..."
202 config_dir=$LBROOT/util/newconfig
203 yapps2_py=$config_dir/yapps2.py
204 config_g=$config_dir/config.g
205 config_lb=Config-${VENDOR}_${MAINBOARD}.lb
209 build_dir=${VENDOR}_${MAINBOARD}
210 config_py=$build_dir/config.py
212 if [ ! -d $build_dir ] ; then
215 if [ ! -f $config_py ]; then
216 $PYTHON $yapps2_py $config_g $config_py &> $build_dir/py.log
219 # make sure config.py is up-to-date
221 export PYTHONPATH=$config_dir
222 $PYTHON $config_py $config_lb $LBROOT &> $build_dir/config.log
223 if [ $? -eq 0 ]; then
225 xml " <builddir>ok</builddir>"
229 printf "FAILED! Log excerpt:\n"
230 xml " <builddir>failed</builddir>"
232 xmlfile $build_dir/config.log
235 tail -n $CONTEXT $build_dir/config.log
240 function create_buildenv
244 create_config $VENDOR $MAINBOARD
245 create_builddir $VENDOR $MAINBOARD
248 function compile_target
253 printf " Compiling image "
254 test "$cpus" == "" && printf "in parallel .. "
255 test "$cpus" == "1" && printf "on 1 cpu .. "
256 test 0$cpus -gt 1 && printf "on %d cpus in parallel .. " $cpus
259 cd $TARGET/${VENDOR}_${MAINBOARD}
261 eval $MAKE $silent -j $cpus &> make.log
264 duration=$(( $etime - $stime ))
265 if [ $ret -eq 0 ]; then
266 xml " <compile>ok</compile>"
267 xml " <compiletime>${duration}s</compiletime>"
268 printf "ok\n" > compile.status
269 printf "ok. (took ${duration}s)\n"
273 xml " <compile>failed</compile>"
274 xml " <compiletime>${duration}s</compiletime>"
279 printf "FAILED after ${duration}s! Log excerpt:\n"
280 tail -n $CONTEXT make.log
286 function built_successfully
290 if [ -d "$TARGET/${VENDOR}_${MAINBOARD}" ]; then
291 cd $TARGET/${VENDOR}_${MAINBOARD}
292 if [ -r compile.status ] ; then
293 status=`cat compile.status`
297 [ "$buildall" != "true" -a "$status" == "ok" ]
300 function build_broken
304 [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/BROKEN" ] && status="no"
305 [ "$buildbroken" == "true" -o "$status" == "yes" ]
308 function build_target
312 TARCH=$( architecture $VENDOR $MAINBOARD )
316 if [ "`uname -s`" == Darwin ]; then
317 # Darwin requires i386-elf-[binuitils|gcc] from MacPorts
318 # and a link from i386-elf-gcc-<version> to i386-elf-gcc
319 CC="$TARCH-elf-gcc -Wa,--divide"
320 CROSS_COMPILE="$TARCH-elf-"
322 CC='$(CROSS_COMPILE)gcc'
327 printf "Processing mainboard/$VENDOR/$MAINBOARD"
331 xml " <vendor>$VENDOR</vendor>"
332 xml " <device>$MAINBOARD</device>"
334 xml " <architecture>$TARCH</architecture>"
337 [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info" ] && \
338 source $LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info
340 if [ "$ARCH" == "$TARCH" ]; then
341 printf " ($TARCH: ok)\n"
343 found_crosscompiler=false
344 if [ "$ARCH" == amd64 -a "$TARCH" == i386 ]; then
346 found_crosscompiler=true
348 if [ "$ARCH" == ppc64 -a "$TARCH" == ppc ]; then
350 found_crosscompiler=true
352 if [ "$found_crosscompiler" == "false" -a "$TARCH" == ppc ];then
353 for prefix in powerpc-eabi- powerpc-linux- ppc_74xx- \
354 powerpc-7450-linux-gnu-; do
355 if ${prefix}gcc --version > /dev/null 2> /dev/null ; then
356 found_crosscompiler=true
357 CROSS_COMPILE=$prefix
363 # TBD: look for suitable cross compiler suite
364 # cross-$TARCH-gcc and cross-$TARCH-ld
367 if [ $found_crosscompiler == "false" ]; then
368 printf " ($TARCH: skipped, we're $ARCH)\n\n"
369 xml " <status>notbuilt</status>"
375 printf " ($TARCH: ok, we're $ARCH)\n"
377 xml " <path>`which ${CROSS_COMPILE}gcc`</path>"
378 xml " <version>`${CROSS_COMPILE}gcc --version | head -1`</version>"
384 built_successfully $VENDOR $MAINBOARD && \
386 printf " ( mainboard/$VENDOR/$MAINBOARD previously ok )\n\n"
387 xml " <status>previouslyok</status>"
393 build_broken $VENDOR $MAINBOARD || \
395 printf " ( broken mainboard/$VENDOR/$MAINBOARD skipped )\n\n"
396 xml " <status>knownbroken</status>"
402 create_buildenv $VENDOR $MAINBOARD
403 if [ $? -eq 0 ]; then
404 compile_target $VENDOR $MAINBOARD &&
405 xml " <status>ok</status>" ||
406 xml "<status>broken</status>"
420 if [ "$hwtest" != "true" ]; then
424 # image does not exist. we silently skip the patch.
425 if [ ! -r "$TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom" ]; then
429 which curl &> /dev/null
431 printf "curl is not installed but required for test submission. skipping test.\n\n"
436 if [ -r "$TARGET/${VENDOR}_${MAINBOARD}/tested" ]; then
437 printf "Testing image for board $VENDOR $MAINBOARD skipped (previously submitted).\n\n"
440 # touch $TARGET/${VENDOR}_${MAINBOARD}/tested
442 printf "Submitting image for board $VENDOR $MAINBOARD to test system...\n"
444 curl -f -F "romfile=@$TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom" \
445 -F "mode=abuild" -F "mainboard=${VENDOR}_${MAINBOARD}" -F "submit=Upload" \
446 "http://qa.coreboot.org/deployment/send.php"
454 printf "Usage: $0 [-v] [-a] [-b] [-t <vendor/board>] [-p <dir>] [lbroot]\n"
455 printf " $0 [-V|--version]\n"
456 printf " $0 [-h|--help]\n\n"
459 printf " [-v|--verbose] print more messages\n"
460 printf " [-a|--all] build previously succeeded ports as well\n"
461 printf " [-b|--broken] attempt to build ports that are known broken\n"
462 printf " [-t|--target <vendor/board>] attempt to build target vendor/board only\n"
463 printf " [-p|--payloads <dir>] use payloads in <dir> to build images\n"
464 printf " [-V|--version] print version number and exit\n"
465 printf " [-h|--help] print this help and exit\n"
466 printf " [-x|--xml] write xml log file \n"
467 printf " (defaults to $XMLFILE)\n"
468 printf " [-T|--test] submit image(s) to automated test system\n"
469 printf " [-c|--cpus <numcpus>] build on <numcpus> at the same time\n"
470 printf " [-s|--silent] omit compiler calls in logs\n"
471 printf " [lbroot] absolute path to coreboot sources\n"
472 printf " (defaults to $LBROOT)\n\n"
479 coreboot autobuild v$ABUILD_VERSION ($ABUILD_DATE)
481 Copyright (C) 2004 by Stefan Reinauer <stepan@openbios.org>
482 Copyright (C) 2006-2008 by coresystems GmbH <info@coresystems.de>
484 This program is free software; you may redistribute it under the terms
485 of the GNU General Public License. This program has absolutely no
494 LBROOT=$( cd ../..; pwd )
497 # parse parameters.. try to find out whether we're running GNU getopt
498 if [ "`getopt -V`" == "getopt.*" ]; then
499 args=`getopt -l version,verbose,help,all,target:,broken,payloads:,test,cpus:,silent,xml Vvhat:bp:Tc:sx -- "$@"`
502 # Detected non-GNU getopt
503 args=`getopt Vvhat:bp:Tc:sx $*`
514 -x|--xml) shift; mode=xml; rm -f $XMLFILE ;;
515 -t|--target) shift; target="$1"; shift;;
516 -a|--all) shift; buildall=true;;
517 -b|--broken) shift; buildbroken=true;;
518 -v|--verbose) shift; verbose=true;;
519 -V|--version) shift; myversion; exit 0;;
520 -h|--help) shift; myversion; myhelp; exit 0;;
521 -p|--payloads) shift; payloads="$1"; shift;;
522 -T|--test) shift; hwtest=true;;
523 -c|--cpus) shift; cpus="$1"; test "$cpus" == "max" && cpus=""; shift;;
524 -s|--silent) shift; silent="-s";;
526 -*) printf "Invalid option\n\n"; myhelp; exit 1;;
531 # /path/to/freebios2/
532 test -z "$1" || LBROOT=$1
534 debug "LBROOT=$LBROOT"
536 xml '<?xml version="1.0" encoding="utf-8"?>'
539 if [ "$target" != "" ]; then
540 # build a single board
541 VENDOR=`printf $target|cut -f1 -d/`
542 MAINBOARD=`printf $target|cut -f2 -d/`
543 build_target $VENDOR $MAINBOARD
544 test_target $VENDOR $MAINBOARD
546 # build all boards per default
547 for VENDOR in $( vendors ); do
548 for MAINBOARD in $( mainboards $VENDOR ); do
549 build_target $VENDOR $MAINBOARD
550 test_target $VENDOR $MAINBOARD