5 # This script builds LinuxBIOS images for all available targets.
7 # (C) 2004 by Stefan Reinauer <stepan@openbios.org>
8 # (C) 2006 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 # Where shall we place all the build trees?
18 TARGET=$( pwd )/linuxbios-builds
19 XMLFILE=$( pwd )/abuild.xml
21 # path to payload. Should be more generic
24 # Lines of error context to be printed in FAILURE case
27 # One might want to adjust these in case of cross compiling
31 # this can be changed to xml by -x
34 ARCH=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
35 -e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \
36 -e "s/Power Macintosh/ppc/"`
40 test "$verbose" == "true" && echo $*
45 test "$mode" == "xml" && echo "$*" >> $XMLFILE
50 test "$mode" == "xml" && { echo '<![CDATA['; cat $1; echo ']]>'; } >> $XMLFILE
57 # make this a function so we can easily select
58 # without breaking readability
59 ls -1 "$LBROOT/src/mainboard" | grep -v CVS
64 # make this a function so we can easily select
65 # without breaking readability
69 ls -1 $LBROOT/src/mainboard/$VENDOR | grep -v CVS
76 cat $LBROOT/src/mainboard/$VENDOR/$MAINBOARD/Config.lb | \
77 grep ^arch | cut -f 2 -d\
80 function create_config
84 TARCH=$( architecture $VENDOR $MAINBOARD )
85 TARGCONFIG=$LBROOT/targets/$VENDOR/$MAINBOARD/Config-abuild.lb
89 if [ -f $TARGCONFIG ]; then
90 cp $TARGCONFIG $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
91 echo "Used existing test target $TARGCONFIG"
92 xml " <config>$TARGCONFIG</config>"
96 echo -n " Creating config file..."
97 xml " <config>autogenerated</config>"
99 # This will make a target directory of ./VENDOR_MAINBOARD
101 target VENDOR_MAINBOARD
102 mainboard VENDOR/MAINBOARD
105 option CROSS_COMPILE="CROSS_PREFIX"
106 option HOSTCC="CROSS_HOSTCC"
109 if [ "$TARCH" == i386 ] ; then
112 option USE_FALLBACK_IMAGE=0
113 option ROM_IMAGE_SIZE=0x20000
114 option LINUXBIOS_EXTRA_VERSION=".0-normal"
119 option USE_FALLBACK_IMAGE=1
120 option ROM_IMAGE_SIZE=0x20000
121 option LINUXBIOS_EXTRA_VERSION=".0-fallback"
124 buildrom ./linuxbios.rom ROM_SIZE "normal" "fallback"
129 option LINUXBIOS_EXTRA_VERSION=".0"
132 buildrom ./linuxbios.rom ROM_SIZE "only"
135 ) | sed -e s,VENDOR,$VENDOR,g \
136 -e s,MAINBOARD,$MAINBOARD,g \
137 -e s,PAYLOAD,$PAYLOAD,g \
138 -e s,CROSSCC,"$CC",g \
139 -e s,CROSS_PREFIX,"$CROSS_COMPILE",g \
140 -e s,CROSS_HOSTCC,"$HOSTCC",g \
141 > $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
145 function create_builddir
150 echo -n " Creating builddir..."
153 config_dir=$LBROOT/util/newconfig
154 yapps2_py=$config_dir/yapps2.py
155 config_g=$config_dir/config.g
156 config_lb=Config-${VENDOR}_${MAINBOARD}.lb
160 build_dir=${VENDOR}_${MAINBOARD}
161 config_py=$build_dir/config.py
163 if [ ! -d $build_dir ] ; then
166 if [ ! -f $config_py ]; then
167 $PYTHON $yapps2_py $config_g $config_py &> $build_dir/py.log
170 # make sure config.py is up-to-date
172 export PYTHONPATH=$config_dir
173 $PYTHON $config_py $config_lb $LBROOT &> $build_dir/config.log
174 if [ $? -eq 0 ]; then
176 xml " <builddir>ok</builddir>"
180 echo "FAILED! Log excerpt:"
181 xml " <builddir>failed</builddir>"
183 xmlfile $build_dir/config.log
186 tail -n $CONTEXT $build_dir/config.log
191 function create_buildenv
195 create_config $VENDOR $MAINBOARD
196 create_builddir $VENDOR $MAINBOARD
199 function compile_target
204 echo -n " Compiling image .."
206 cd $TARGET/${VENDOR}_${MAINBOARD}
208 eval $MAKE &> make.log
211 duration=$(( $etime - $stime ))
212 if [ $ret -eq 0 ]; then
213 xml " <compile>ok</compile>"
214 xml " <compiletime>${duration}s</compiletime>"
215 echo "ok" > compile.status
216 echo "ok. (took ${duration}s)"
220 xml " <compile>failed</compile>"
221 xml " <compiletime>${duration}s</compiletime>"
226 echo "FAILED after ${duration}s! Log excerpt:"
227 tail -n $CONTEXT make.log
233 function built_successfully
237 if [ -d "$TARGET/${VENDOR}_${MAINBOARD}" ]; then
238 cd $TARGET/${VENDOR}_${MAINBOARD}
239 if [ -r compile.status ] ; then
240 status=`cat compile.status`
244 [ "$buildall" != "true" -a "$status" == "ok" ]
247 function build_broken
251 [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/BROKEN" ] && status="no"
252 [ "$buildbroken" == "true" -o "$status" == "yes" ]
255 function build_target
259 TARCH=$( architecture $VENDOR $MAINBOARD )
262 CC='$(CROSS_COMPILE)gcc'
266 echo -n "Processing mainboard/$VENDOR/$MAINBOARD"
270 xml " <vendor>$VENDOR</vendor>"
271 xml " <device>$MAINBOARD</device>"
273 xml " <architecture>$TARCH</architecture>"
276 [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info" ] && \
277 source $LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info
279 if [ "$ARCH" == "$TARCH" ]; then
282 found_crosscompiler=false
283 if [ "$ARCH" == amd64 -a "$TARCH" == i386 ]; then
285 found_crosscompiler=true
287 if [ "$ARCH" == ppc64 -a "$TARCH" == ppc ]; then
289 found_crosscompiler=true
291 if [ "$found_crosscompiler" == "false" -a "$TARCH" == ppc ];then
292 for prefix in powerpc-eabi- powerpc-linux- ppc_74xx- \
293 powerpc-7450-linux-gnu-; do
294 if ${prefix}gcc --version > /dev/null 2> /dev/null ; then
295 found_crosscompiler=true
296 CROSS_COMPILE=$prefix
302 xml " <path>`which ${CROSS_COMPILE}gcc`</path>"
303 xml " <version>`${CROSS_COMPILE}gcc --version | head -1`</version>"
307 # TBD: look for suitable cross compiler suite
308 # cross-$TARCH-gcc and cross-$TARCH-ld
311 if [ $found_crosscompiler == "false" ]; then
312 echo " ($TARCH: skipped, we're $ARCH)"
316 echo " ($TARCH: ok, we're $ARCH)"
320 built_successfully $VENDOR $MAINBOARD && \
322 echo " ( mainboard/$VENDOR/$MAINBOARD previously ok )"
324 xml " <status>previouslyok</status>"
330 build_broken $VENDOR $MAINBOARD || \
332 echo " ( broken mainboard/$VENDOR/$MAINBOARD skipped )"
334 xml " <status>knownbroken</status>"
340 create_buildenv $VENDOR $MAINBOARD
341 if [ $? -eq 0 ]; then
342 compile_target $VENDOR $MAINBOARD &&
343 xml "<status>ok</status>" ||
344 xml "<status>broken</status>"
355 echo "Usage: $0 [-v] [-a] [-b] [-t <vendor/board>] [lbroot]"
356 echo " $0 [-V|--version]"
357 echo " $0 [-h|--help]"
360 echo " [-v|--verbose] print more messages"
361 echo " [-a|--all] build previously succeeded ports as well"
362 echo " [-b|--broken] attempt to build ports that are known broken"
363 echo " [-t|--target <vendor/board>] attempt to build target vendor/board only"
364 echo " [-V|--version] print version number and exit"
365 echo " [-h|--help] print this help and exit"
366 echo " [-x|--xml] write xml log file $XMLFILE"
367 echo " [lbroot] absolute path to LinuxBIOS sources"
368 echo " (defaults to $LBROOT)"
376 LinuxBIOS autobuild: V0.2.
378 Copyright (C) 2004 by Stefan Reinauer <stepan@openbios.org>
379 Copyright (C) 2006 by coresystems GmbH <info@coresystems.de>
380 This program is free software; you may redistribute it under the terms
381 of the GNU General Public License. This program has absolutely no
391 LBROOT=$( cd ../..; pwd )
395 args=`getopt -l version,verbose,help,all,target:,broken Vvhat:b -- "$@"`
405 -x|--xml) shift; mode=xml; rm -f $XMLFILE ;;
406 -t|--target) shift; target="$1"; shift;;
407 -a|--all) shift; buildall=true;;
408 -b|--broken) shift; buildbroken=true;;
409 -v|--verbose) shift; verbose=true;;
410 -V|--version) shift; myversion; exit 0;;
411 -h|--help) shift; myhelp; exit 0;;
413 -*) echo -e "Invalid option\n"; myhelp; exit 1;;
418 # /path/to/freebios2/
419 test -z "$1" || LBROOT=$1
421 debug "LBROOT=$LBROOT"
423 xml '<?xml version="1.0" encoding="utf-8"?>'
426 if [ "$target" != "" ]; then
427 # build a single board
428 VENDOR=`echo $target|cut -f1 -d/`
429 MAINBOARD=`echo $target|cut -f2 -d/`
430 build_target $VENDOR $MAINBOARD
432 # build all boards per default
433 for VENDOR in $( vendors ); do
434 for MAINBOARD in $( mainboards $VENDOR ); do
435 build_target $VENDOR $MAINBOARD