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 # stackprotect mode enabled by -ns option.
49 ARCH=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
50 -e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \
51 -e "s/Power Macintosh/ppc/"`
57 printf "\n$0: execution interrupted manually.\n"
58 if [ "$mode" == "xml" ]; then
59 printf "$0: deleting incomplete xml output file.\n"
66 test "$verbose" == "true" && printf "$*\n"
71 test "$mode" == "xml" && printf "$*\n" >> $XMLFILE
76 test "$mode" == "xml" && {
87 # make this a function so we can easily select
88 # without breaking readability
89 ls -1 "$LBROOT/src/mainboard" | grep -v CVS
94 # make this a function so we can easily select
95 # without breaking readability
99 ls -1 $LBROOT/src/mainboard/$VENDOR | grep -v CVS
102 function architecture
106 cat $LBROOT/src/mainboard/$VENDOR/$MAINBOARD/Config.lb | \
107 grep ^arch | cut -f 2 -d\
110 function create_config
114 TARCH=$( architecture $VENDOR $MAINBOARD )
115 TARGCONFIG=$LBROOT/targets/$VENDOR/$MAINBOARD/Config-abuild.lb
117 # get a working payload for the board if we have one.
118 # the --payload option expects a directory containing
119 # an executable shell script payload.sh
120 # Usage: payload.sh [VENDOR] [DEVICE]
121 # the script returns an absolute path to the payload binary.
123 if [ -x $payloads/payload.sh ]; then
124 PAYLOAD=`$payloads/payload.sh $VENDOR $MAINBOARD`
125 printf "Using payload $PAYLOAD\n"
130 if [ -f $TARGCONFIG ]; then
131 cp $TARGCONFIG $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
132 printf "Using existing test target $TARGCONFIG"
133 xml " <config>$TARGCONFIG</config>"
136 printf " Creating config file..."
137 xml " <config>autogenerated</config>"
139 # This will make a target directory of ./VENDOR_MAINBOARD
141 target VENDOR_MAINBOARD
142 mainboard VENDOR/MAINBOARD
145 option CROSS_COMPILE="CROSS_PREFIX"
146 option HOSTCC="CROSS_HOSTCC"
151 if [ "$TARCH" == i386 ] ; then
154 option USE_FALLBACK_IMAGE=0
155 option ROM_IMAGE_SIZE=0x17000
156 option COREBOOT_EXTRA_VERSION=".0-normal"
161 option USE_FALLBACK_IMAGE=1
162 option ROM_IMAGE_SIZE=0x17000
163 option COREBOOT_EXTRA_VERSION=".0-fallback"
166 buildrom ./coreboot.rom ROM_SIZE "normal" "fallback"
171 option COREBOOT_EXTRA_VERSION=".0"
174 buildrom ./coreboot.rom ROM_SIZE "only"
177 ) > $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
180 if [ "`which lzma`" != "" -a "$PAYLOAD" != /dev/null ]; then
181 COMPRESSION="option CONFIG_COMPRESSED_PAYLOAD_LZMA=1"
183 COMPRESSION="# no compression"
186 sed -i.pre -e s:VENDOR:$VENDOR:g \
187 -e s:MAINBOARD:$MAINBOARD:g \
188 -e s:payload\ __PAYLOAD__:payload\ $PAYLOAD:g \
189 -e s:CROSSCC:"$CC":g \
190 -e s:CROSS_PREFIX:"$CROSS_COMPILE":g \
191 -e s:CROSS_HOSTCC:"$HOSTCC":g \
192 -e s:__COMPRESSION__:"$COMPRESSION":g \
193 $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
197 function create_builddir
202 printf " Creating builddir..."
205 config_dir=$LBROOT/util/newconfig
206 yapps2_py=$config_dir/yapps2.py
207 config_g=$config_dir/config.g
208 config_lb=Config-${VENDOR}_${MAINBOARD}.lb
212 build_dir=${VENDOR}_${MAINBOARD}
213 config_py=$build_dir/config.py
215 if [ ! -d $build_dir ] ; then
218 if [ ! -f $config_py ]; then
219 $PYTHON $yapps2_py $config_g $config_py &> $build_dir/py.log
222 # make sure config.py is up-to-date
224 export PYTHONPATH=$config_dir
225 $PYTHON $config_py $config_lb $LBROOT &> $build_dir/config.log
226 if [ $? -eq 0 ]; then
228 xml " <builddir>ok</builddir>"
232 printf "FAILED! Log excerpt:\n"
233 xml " <builddir>failed</builddir>"
235 xmlfile $build_dir/config.log
238 tail -n $CONTEXT $build_dir/config.log
243 function create_buildenv
247 create_config $VENDOR $MAINBOARD
248 create_builddir $VENDOR $MAINBOARD
251 function compile_target
256 printf " Compiling image "
257 test "$cpus" == "" && printf "in parallel .. "
258 test "$cpus" == "1" && printf "on 1 cpu .. "
259 test 0$cpus -gt 1 && printf "on %d cpus in parallel .. " $cpus
262 cd $TARGET/${VENDOR}_${MAINBOARD}
264 eval $MAKE $silent -j $cpus &> make.log
267 duration=$(( $etime - $stime ))
268 if [ $ret -eq 0 ]; then
269 xml " <compile>ok</compile>"
270 xml " <compiletime>${duration}s</compiletime>"
271 printf "ok\n" > compile.status
272 printf "ok. (took ${duration}s)\n"
276 xml " <compile>failed</compile>"
277 xml " <compiletime>${duration}s</compiletime>"
282 printf "FAILED after ${duration}s! Log excerpt:\n"
283 tail -n $CONTEXT make.log
289 function built_successfully
293 if [ -d "$TARGET/${VENDOR}_${MAINBOARD}" ]; then
294 cd $TARGET/${VENDOR}_${MAINBOARD}
295 if [ -r compile.status ] ; then
296 status=`cat compile.status`
300 [ "$buildall" != "true" -a "$status" == "ok" ]
303 function build_broken
307 [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/BROKEN" ] && status="no"
308 [ "$buildbroken" == "true" -o "$status" == "yes" ]
311 function build_target
315 TARCH=$( architecture $VENDOR $MAINBOARD )
319 if [ "`uname -s`" == Darwin ]; then
320 # Darwin requires i386-elf-[binuitils|gcc] from MacPorts
321 # and a link from i386-elf-gcc-<version> to i386-elf-gcc
322 CC="$TARCH-elf-gcc -Wa,--divide"
323 CROSS_COMPILE="$TARCH-elf-"
325 CC='$(CROSS_COMPILE)gcc'
329 if [ "$stackprotect" = "true" ]; then
330 CC="$CC -fno-stack-protector"
335 printf "Processing mainboard/$VENDOR/$MAINBOARD"
339 xml " <vendor>$VENDOR</vendor>"
340 xml " <device>$MAINBOARD</device>"
342 xml " <architecture>$TARCH</architecture>"
345 [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info" ] && \
346 source $LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info
348 if [ "$ARCH" == "$TARCH" ]; then
349 printf " ($TARCH: ok)\n"
351 found_crosscompiler=false
352 if [ "$ARCH" == amd64 -a "$TARCH" == i386 ]; then
354 found_crosscompiler=true
356 if [ "$ARCH" == ppc64 -a "$TARCH" == ppc ]; then
358 found_crosscompiler=true
360 if [ "$found_crosscompiler" == "false" -a "$TARCH" == ppc ];then
361 for prefix in powerpc-eabi- powerpc-linux- ppc_74xx- \
362 powerpc-7450-linux-gnu-; do
363 if ${prefix}gcc --version > /dev/null 2> /dev/null ; then
364 found_crosscompiler=true
365 CROSS_COMPILE=$prefix
371 # TBD: look for suitable cross compiler suite
372 # cross-$TARCH-gcc and cross-$TARCH-ld
375 if [ $found_crosscompiler == "false" ]; then
376 printf " ($TARCH: skipped, we're $ARCH)\n\n"
377 xml " <status>notbuilt</status>"
383 printf " ($TARCH: ok, we're $ARCH)\n"
385 xml " <path>`which ${CROSS_COMPILE}gcc`</path>"
386 xml " <version>`${CROSS_COMPILE}gcc --version | head -1`</version>"
392 built_successfully $VENDOR $MAINBOARD && \
394 printf " ( mainboard/$VENDOR/$MAINBOARD previously ok )\n\n"
395 xml " <status>previouslyok</status>"
401 build_broken $VENDOR $MAINBOARD || \
403 printf " ( broken mainboard/$VENDOR/$MAINBOARD skipped )\n\n"
404 xml " <status>knownbroken</status>"
410 create_buildenv $VENDOR $MAINBOARD
411 if [ $? -eq 0 ]; then
412 compile_target $VENDOR $MAINBOARD &&
413 xml " <status>ok</status>" ||
414 xml "<status>broken</status>"
428 if [ "$hwtest" != "true" ]; then
432 # image does not exist. we silently skip the patch.
433 if [ ! -r "$TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom" ]; then
437 which curl &> /dev/null
439 printf "curl is not installed but required for test submission. skipping test.\n\n"
444 if [ -r "$TARGET/${VENDOR}_${MAINBOARD}/tested" ]; then
445 printf "Testing image for board $VENDOR $MAINBOARD skipped (previously submitted).\n\n"
448 # touch $TARGET/${VENDOR}_${MAINBOARD}/tested
450 printf "Submitting image for board $VENDOR $MAINBOARD to test system...\n"
452 curl -f -F "romfile=@$TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom" \
453 -F "mode=abuild" -F "mainboard=${VENDOR}_${MAINBOARD}" -F "submit=Upload" \
454 "http://qa.coreboot.org/deployment/send.php"
462 printf "Usage: $0 [-v] [-a] [-b] [-t <vendor/board>] [-p <dir>] [lbroot]\n"
463 printf " $0 [-V|--version]\n"
464 printf " $0 [-h|--help]\n\n"
467 printf " [-v|--verbose] print more messages\n"
468 printf " [-a|--all] build previously succeeded ports as well\n"
469 printf " [-b|--broken] attempt to build ports that are known broken\n"
470 printf " [-t|--target <vendor/board>] attempt to build target vendor/board only\n"
471 printf " [-p|--payloads <dir>] use payloads in <dir> to build images\n"
472 printf " [-V|--version] print version number and exit\n"
473 printf " [-h|--help] print this help and exit\n"
474 printf " [-x|--xml] write xml log file \n"
475 printf " (defaults to $XMLFILE)\n"
476 printf " [-T|--test] submit image(s) to automated test system\n"
477 printf " [-c|--cpus <numcpus>] build on <numcpus> at the same time\n"
478 printf " [-s|--silent] omit compiler calls in logs\n"
479 printf " [-ns|--nostackprotect] use gcc -fno-stack-protector option\n"
480 printf " [lbroot] absolute path to coreboot sources\n"
481 printf " (defaults to $LBROOT)\n\n"
488 coreboot autobuild v$ABUILD_VERSION ($ABUILD_DATE)
490 Copyright (C) 2004 by Stefan Reinauer <stepan@openbios.org>
491 Copyright (C) 2006-2008 by coresystems GmbH <info@coresystems.de>
493 This program is free software; you may redistribute it under the terms
494 of the GNU General Public License. This program has absolutely no
503 LBROOT=$( cd ../..; pwd )
506 # parse parameters.. try to find out whether we're running GNU getopt
507 getoptbrand="`getopt -V`"
508 if [ "${getoptbrand:0:6}" == "getopt" ]; then
509 # Detected GNU getopt that supports long options.
510 args=`getopt -l version,verbose,help,all,target:,broken,payloads:,test,cpus:,silent,xml Vvhat:bp:Tc:sx -- "$@"`
513 # Detected non-GNU getopt
514 args=`getopt Vvhat:bp:Tc:sx $*`
525 -x|--xml) shift; mode=xml; rm -f $XMLFILE ;;
526 -t|--target) shift; target="$1"; shift;;
527 -a|--all) shift; buildall=true;;
528 -b|--broken) shift; buildbroken=true;;
529 -v|--verbose) shift; verbose=true;;
530 -V|--version) shift; myversion; exit 0;;
531 -h|--help) shift; myversion; myhelp; exit 0;;
532 -p|--payloads) shift; payloads="$1"; shift;;
533 -T|--test) shift; hwtest=true;;
534 -c|--cpus) shift; cpus="$1"; test "$cpus" == "max" && cpus=""; shift;;
535 -s|--silent) shift; silent="-s";;
536 -ns|--nostackprotect) shift; stackprotect=true;;
538 -*) printf "Invalid option\n\n"; myhelp; exit 1;;
543 # /path/to/freebios2/
544 test -z "$1" || LBROOT=$1
546 debug "LBROOT=$LBROOT"
548 xml '<?xml version="1.0" encoding="utf-8"?>'
551 if [ "$target" != "" ]; then
552 # build a single board
553 VENDOR=`printf $target|cut -f1 -d/`
554 MAINBOARD=`printf $target|cut -f2 -d/`
555 build_target $VENDOR $MAINBOARD
556 test_target $VENDOR $MAINBOARD
558 # build all boards per default
559 for VENDOR in $( vendors ); do
560 for MAINBOARD in $( mainboards $VENDOR ); do
561 build_target $VENDOR $MAINBOARD
562 test_target $VENDOR $MAINBOARD