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
38 # One might want to adjust these in case of cross compiling
42 # this can be changed to xml by -x
45 # silent mode.. no compiler calls, only warnings in the log files.
46 # this is disabled per default but can be enabled with -s
49 # stackprotect mode enabled by -ns option.
52 ARCH=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
54 -e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \
55 -e "s/Power Macintosh/ppc/"`
61 printf "\n$0: execution interrupted manually.\n"
62 if [ "$mode" == "xml" ]; then
63 printf "$0: deleting incomplete xml output file.\n"
70 test "$verbose" == "true" && printf "$*\n"
75 test "$mode" == "xml" && printf "$*\n" >> $XMLFILE
80 test "$mode" == "xml" && {
91 # make this a function so we can easily select
92 # without breaking readability
93 ls -1 "$LBROOT/src/mainboard" | grep -v CVS
98 # make this a function so we can easily select
99 # without breaking readability
103 ls -1 $LBROOT/src/mainboard/$VENDOR | grep -v CVS
106 function architecture
110 cat $LBROOT/src/mainboard/$VENDOR/$MAINBOARD/Config.lb | \
111 grep ^arch | cut -f 2 -d\
114 function create_config
118 TARCH=$( architecture $VENDOR $MAINBOARD )
119 TARGCONFIG=$LBROOT/targets/$VENDOR/$MAINBOARD/Config-abuild.lb
121 # get a working payload for the board if we have one.
122 # the --payload option expects a directory containing
123 # an executable shell script payload.sh
124 # Usage: payload.sh [VENDOR] [DEVICE]
125 # the script returns an absolute path to the payload binary.
127 if [ -x $payloads/payload.sh ]; then
128 PAYLOAD=`$payloads/payload.sh $VENDOR $MAINBOARD`
129 printf "Using payload $PAYLOAD\n"
134 if [ -f $TARGCONFIG ]; then
135 cp $TARGCONFIG $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
136 printf "Using existing test target $TARGCONFIG"
137 xml " <config>$TARGCONFIG</config>"
140 printf " Creating config file..."
141 xml " <config>autogenerated</config>"
143 # This will make a target directory of ./VENDOR_MAINBOARD
145 target VENDOR_MAINBOARD
146 mainboard VENDOR/MAINBOARD
149 option CROSS_COMPILE="CROSS_PREFIX"
150 option HOSTCC="CROSS_HOSTCC"
155 if [ "$TARCH" == i386 ] ; then
158 option USE_FALLBACK_IMAGE=0
159 option ROM_IMAGE_SIZE=0x17000
160 option COREBOOT_EXTRA_VERSION=".0-normal"
165 option USE_FALLBACK_IMAGE=1
166 option ROM_IMAGE_SIZE=0x17000
167 option COREBOOT_EXTRA_VERSION=".0-fallback"
170 buildrom ./coreboot.rom ROM_SIZE "normal" "fallback"
175 option COREBOOT_EXTRA_VERSION=".0"
178 buildrom ./coreboot.rom ROM_SIZE "only"
181 ) > $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
184 if [ "`which lzma`" != "" -a "$PAYLOAD" != /dev/null ]; then
185 COMPRESSION="option CONFIG_COMPRESSED_PAYLOAD_LZMA=1"
187 COMPRESSION="# no compression"
190 cp $TARGET/Config-${VENDOR}_${MAINBOARD}.lb $TARGET/Config-${VENDOR}_${MAINBOARD}.lb.pre
191 sed -e s:VENDOR:$VENDOR:g \
192 -e s:MAINBOARD:$MAINBOARD:g \
193 -e s:payload\ __PAYLOAD__:payload\ $PAYLOAD:g \
194 -e s:CROSSCC:"$CC":g \
195 -e s:CROSS_PREFIX:"$CROSS_COMPILE":g \
196 -e s:CROSS_HOSTCC:"$HOSTCC":g \
197 -e s:__COMPRESSION__:"$COMPRESSION":g \
198 $TARGET/Config-${VENDOR}_${MAINBOARD}.lb.pre > $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
202 function create_builddir
207 printf " Creating builddir..."
210 config_dir=$LBROOT/util/newconfig
211 yapps2_py=$config_dir/yapps2.py
212 config_g=$config_dir/config.g
213 config_lb=Config-${VENDOR}_${MAINBOARD}.lb
217 build_dir=${VENDOR}_${MAINBOARD}
218 config_py=$build_dir/config.py
220 if [ ! -d $build_dir ] ; then
223 if [ ! -f $config_py ]; then
224 $PYTHON $yapps2_py $config_g $config_py &> $build_dir/py.log
227 # make sure config.py is up-to-date
229 export PYTHONPATH=$config_dir
230 $PYTHON $config_py $config_lb $LBROOT &> $build_dir/config.log
231 if [ $? -eq 0 ]; then
233 xml " <builddir>ok</builddir>"
237 printf "FAILED! Log excerpt:\n"
238 xml " <builddir>failed</builddir>"
240 xmlfile $build_dir/config.log
243 tail -n $CONTEXT $build_dir/config.log
248 function create_buildenv
252 create_config $VENDOR $MAINBOARD
253 create_builddir $VENDOR $MAINBOARD
256 function compile_target
261 printf " Compiling image "
262 test "$cpus" == "" && printf "in parallel .. "
263 test "$cpus" == "1" && printf "on 1 cpu .. "
264 test 0$cpus -gt 1 && printf "on %d cpus in parallel .. " $cpus
267 cd $TARGET/${VENDOR}_${MAINBOARD}
268 stime=`perl -e 'print time();'`
269 eval $MAKE $silent -j $cpus &> make.log
271 etime=`perl -e 'print time();'`
272 duration=$(( $etime - $stime ))
273 if [ $ret -eq 0 ]; then
274 xml " <compile>ok</compile>"
275 xml " <compiletime>${duration}s</compiletime>"
276 printf "ok\n" > compile.status
277 printf "ok. (took ${duration}s)\n"
281 xml " <compile>failed</compile>"
282 xml " <compiletime>${duration}s</compiletime>"
287 printf "FAILED after ${duration}s! Log excerpt:\n"
288 tail -n $CONTEXT make.log
294 function built_successfully
298 if [ -d "$TARGET/${VENDOR}_${MAINBOARD}" ]; then
299 cd $TARGET/${VENDOR}_${MAINBOARD}
300 if [ -r compile.status ] ; then
301 status=`cat compile.status`
305 [ "$buildall" != "true" -a "$status" == "ok" ]
308 function build_broken
312 [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/BROKEN" ] && status="no"
313 [ "$buildbroken" == "true" -o "$status" == "yes" ]
316 function build_target
320 TARCH=$( architecture $VENDOR $MAINBOARD )
324 CC="${CROSS_COMPILE}gcc"
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
330 if [ "$TARCH" = "i386" ]; then
331 CC="$CC -Wa,--divide"
334 CROSS_COMPILE="$TARCH-elf-"
335 found_crosscompiler=true
337 if [ "$stackprotect" = "true" ]; then
338 CC="$CC -fno-stack-protector"
342 printf "Processing mainboard/$VENDOR/$MAINBOARD"
346 xml " <vendor>$VENDOR</vendor>"
347 xml " <device>$MAINBOARD</device>"
349 xml " <architecture>$TARCH</architecture>"
352 [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info" ] && \
353 source $LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info
355 if [ "$ARCH" = "$TARCH" -o $found_crosscompiler = true ]; then
356 printf " ($TARCH: ok)\n"
358 found_crosscompiler=false
359 if [ "$ARCH" == amd64 -a "$TARCH" == i386 ]; then
361 found_crosscompiler=true
363 if [ "$ARCH" == ppc64 -a "$TARCH" == ppc ]; then
365 found_crosscompiler=true
367 if [ "$found_crosscompiler" == "false" -a "$TARCH" == ppc ];then
368 for prefix in powerpc-eabi- powerpc-linux- ppc_74xx- \
369 powerpc-7450-linux-gnu-; do
370 if ${prefix}gcc --version > /dev/null 2> /dev/null ; then
371 found_crosscompiler=true
372 CROSS_COMPILE=$prefix
378 # TBD: look for suitable cross compiler suite
379 # cross-$TARCH-gcc and cross-$TARCH-ld
382 if [ $found_crosscompiler == "false" ]; then
383 printf " ($TARCH: skipped, we're $ARCH)\n\n"
384 xml " <status>notbuilt</status>"
390 printf " ($TARCH: ok, we're $ARCH)\n"
392 xml " <path>`which ${CROSS_COMPILE}gcc`</path>"
393 xml " <version>`${CROSS_COMPILE}gcc --version | head -1`</version>"
399 built_successfully $VENDOR $MAINBOARD && \
401 printf " ( mainboard/$VENDOR/$MAINBOARD previously ok )\n\n"
402 xml " <status>previouslyok</status>"
408 build_broken $VENDOR $MAINBOARD || \
410 printf " ( broken mainboard/$VENDOR/$MAINBOARD skipped )\n\n"
411 xml " <status>knownbroken</status>"
417 create_buildenv $VENDOR $MAINBOARD
418 if [ $? -eq 0 -a $configureonly -eq 0 ]; then
419 compile_target $VENDOR $MAINBOARD &&
420 xml " <status>ok</status>" ||
421 xml "<status>broken</status>"
435 if [ "$hwtest" != "true" ]; then
439 # image does not exist. we silently skip the patch.
440 if [ ! -r "$TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom" ]; then
444 which curl &> /dev/null
446 printf "curl is not installed but required for test submission. skipping test.\n\n"
451 if [ -r "$TARGET/${VENDOR}_${MAINBOARD}/tested" ]; then
452 printf "Testing image for board $VENDOR $MAINBOARD skipped (previously submitted).\n\n"
455 # touch $TARGET/${VENDOR}_${MAINBOARD}/tested
457 printf "Submitting image for board $VENDOR $MAINBOARD to test system...\n"
459 curl -f -F "romfile=@$TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom" \
460 -F "mode=abuild" -F "mainboard=${VENDOR}_${MAINBOARD}" -F "submit=Upload" \
461 "http://qa.coreboot.org/deployment/send.php"
469 printf "Usage: $0 [-v] [-a] [-b] [-t <vendor/board>] [-p <dir>] [lbroot]\n"
470 printf " $0 [-V|--version]\n"
471 printf " $0 [-h|--help]\n\n"
474 printf " [-v|--verbose] print more messages\n"
475 printf " [-a|--all] build previously succeeded ports as well\n"
476 printf " [-b|--broken] attempt to build ports that are known broken\n"
477 printf " [-t|--target <vendor/board>] attempt to build target vendor/board only\n"
478 printf " [-p|--payloads <dir>] use payloads in <dir> to build images\n"
479 printf " [-V|--version] print version number and exit\n"
480 printf " [-h|--help] print this help and exit\n"
481 printf " [-x|--xml] write xml log file \n"
482 printf " (defaults to $XMLFILE)\n"
483 printf " [-T|--test] submit image(s) to automated test system\n"
484 printf " [-c|--cpus <numcpus>] build on <numcpus> at the same time\n"
485 printf " [-s|--silent] omit compiler calls in logs\n"
486 printf " [-ns|--nostackprotect] use gcc -fno-stack-protector option\n"
487 printf " [-C|--config] configure-only mode\n"
488 printf " [lbroot] absolute path to coreboot sources\n"
489 printf " (defaults to $LBROOT)\n\n"
496 coreboot autobuild v$ABUILD_VERSION ($ABUILD_DATE)
498 Copyright (C) 2004 by Stefan Reinauer <stepan@openbios.org>
499 Copyright (C) 2006-2008 by coresystems GmbH <info@coresystems.de>
501 This program is free software; you may redistribute it under the terms
502 of the GNU General Public License. This program has absolutely no
511 LBROOT=$( cd ../..; pwd )
514 # parse parameters.. try to find out whether we're running GNU getopt
515 getoptbrand="`getopt -V`"
516 if [ "${getoptbrand:0:6}" == "getopt" ]; then
517 # Detected GNU getopt that supports long options.
518 args=`getopt -l version,verbose,help,all,target:,broken,payloads:,test,cpus:,silent,xml,config Vvhat:bp:Tc:sxC -- "$@"`
521 # Detected non-GNU getopt
522 args=`getopt Vvhat:bp:Tc:sxC $*`
533 -x|--xml) shift; mode=xml; rm -f $XMLFILE ;;
534 -t|--target) shift; target="$1"; shift;;
535 -a|--all) shift; buildall=true;;
536 -b|--broken) shift; buildbroken=true;;
537 -v|--verbose) shift; verbose=true;;
538 -V|--version) shift; myversion; exit 0;;
539 -h|--help) shift; myversion; myhelp; exit 0;;
540 -p|--payloads) shift; payloads="$1"; shift;;
541 -T|--test) shift; hwtest=true;;
542 -c|--cpus) shift; cpus="$1"; test "$cpus" == "max" && cpus=""; shift;;
543 -s|--silent) shift; silent="-s";;
544 -ns|--nostackprotect) shift; stackprotect=true;;
545 -C|--config) shift; configureonly=1;;
547 -*) printf "Invalid option\n\n"; myhelp; exit 1;;
552 # /path/to/freebios2/
553 test -z "$1" || LBROOT=$1
555 debug "LBROOT=$LBROOT"
557 xml '<?xml version="1.0" encoding="utf-8"?>'
560 if [ "$target" != "" ]; then
561 # build a single board
562 VENDOR=`printf $target|cut -f1 -d/`
563 MAINBOARD=`printf $target|cut -f2 -d/`
564 build_target $VENDOR $MAINBOARD
565 test_target $VENDOR $MAINBOARD
567 # build all boards per default
568 for VENDOR in $( vendors ); do
569 for MAINBOARD in $( mainboards $VENDOR ); do
570 build_target $VENDOR $MAINBOARD
571 test_target $VENDOR $MAINBOARD