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
87 # get a working payload for the board if we have one.
89 if [ -x $payloads/payload.sh ]; then
90 PAYLOAD=`$payloads/payload.sh $VENDOR $MAINBOARD`
91 echo "Using custom payload $PAYLOAD"
96 if [ -f $TARGCONFIG ]; then
97 cp $TARGCONFIG $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
98 echo -n "Using existing test target $TARGCONFIG"
99 xml " <config>$TARGCONFIG</config>"
102 echo -n " Creating config file..."
103 xml " <config>autogenerated</config>"
105 # This will make a target directory of ./VENDOR_MAINBOARD
107 target VENDOR_MAINBOARD
108 mainboard VENDOR/MAINBOARD
111 option CROSS_COMPILE="CROSS_PREFIX"
112 option HOSTCC="CROSS_HOSTCC"
115 if [ "$TARCH" == i386 ] ; then
118 option USE_FALLBACK_IMAGE=0
119 option ROM_IMAGE_SIZE=0x20000
120 option LINUXBIOS_EXTRA_VERSION=".0-normal"
125 option USE_FALLBACK_IMAGE=1
126 option ROM_IMAGE_SIZE=0x20000
127 option LINUXBIOS_EXTRA_VERSION=".0-fallback"
130 buildrom ./linuxbios.rom ROM_SIZE "normal" "fallback"
135 option LINUXBIOS_EXTRA_VERSION=".0"
138 buildrom ./linuxbios.rom ROM_SIZE "only"
141 ) > $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
144 sed -i.pre -e s,VENDOR,$VENDOR,g \
145 -e s,MAINBOARD,$MAINBOARD,g \
146 -e s,PAYLOAD,$PAYLOAD,g \
147 -e s,CROSSCC,"$CC",g \
148 -e s,CROSS_PREFIX,"$CROSS_COMPILE",g \
149 -e s,CROSS_HOSTCC,"$HOSTCC",g \
150 $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
155 function create_builddir
160 echo -n " Creating builddir..."
163 config_dir=$LBROOT/util/newconfig
164 yapps2_py=$config_dir/yapps2.py
165 config_g=$config_dir/config.g
166 config_lb=Config-${VENDOR}_${MAINBOARD}.lb
170 build_dir=${VENDOR}_${MAINBOARD}
171 config_py=$build_dir/config.py
173 if [ ! -d $build_dir ] ; then
176 if [ ! -f $config_py ]; then
177 $PYTHON $yapps2_py $config_g $config_py &> $build_dir/py.log
180 # make sure config.py is up-to-date
182 export PYTHONPATH=$config_dir
183 $PYTHON $config_py $config_lb $LBROOT &> $build_dir/config.log
184 if [ $? -eq 0 ]; then
186 xml " <builddir>ok</builddir>"
190 echo "FAILED! Log excerpt:"
191 xml " <builddir>failed</builddir>"
193 xmlfile $build_dir/config.log
196 tail -n $CONTEXT $build_dir/config.log
201 function create_buildenv
205 create_config $VENDOR $MAINBOARD
206 create_builddir $VENDOR $MAINBOARD
209 function compile_target
214 echo -n " Compiling image .."
216 cd $TARGET/${VENDOR}_${MAINBOARD}
218 eval $MAKE &> make.log
221 duration=$(( $etime - $stime ))
222 if [ $ret -eq 0 ]; then
223 xml " <compile>ok</compile>"
224 xml " <compiletime>${duration}s</compiletime>"
225 echo "ok" > compile.status
226 echo "ok. (took ${duration}s)"
230 xml " <compile>failed</compile>"
231 xml " <compiletime>${duration}s</compiletime>"
236 echo "FAILED after ${duration}s! Log excerpt:"
237 tail -n $CONTEXT make.log
243 function built_successfully
247 if [ -d "$TARGET/${VENDOR}_${MAINBOARD}" ]; then
248 cd $TARGET/${VENDOR}_${MAINBOARD}
249 if [ -r compile.status ] ; then
250 status=`cat compile.status`
254 [ "$buildall" != "true" -a "$status" == "ok" ]
257 function build_broken
261 [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/BROKEN" ] && status="no"
262 [ "$buildbroken" == "true" -o "$status" == "yes" ]
265 function build_target
269 TARCH=$( architecture $VENDOR $MAINBOARD )
272 CC='$(CROSS_COMPILE)gcc'
276 echo -n "Processing mainboard/$VENDOR/$MAINBOARD"
280 xml " <vendor>$VENDOR</vendor>"
281 xml " <device>$MAINBOARD</device>"
283 xml " <architecture>$TARCH</architecture>"
286 [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info" ] && \
287 source $LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info
289 if [ "$ARCH" == "$TARCH" ]; then
292 found_crosscompiler=false
293 if [ "$ARCH" == amd64 -a "$TARCH" == i386 ]; then
295 found_crosscompiler=true
297 if [ "$ARCH" == ppc64 -a "$TARCH" == ppc ]; then
299 found_crosscompiler=true
301 if [ "$found_crosscompiler" == "false" -a "$TARCH" == ppc ];then
302 for prefix in powerpc-eabi- powerpc-linux- ppc_74xx- \
303 powerpc-7450-linux-gnu-; do
304 if ${prefix}gcc --version > /dev/null 2> /dev/null ; then
305 found_crosscompiler=true
306 CROSS_COMPILE=$prefix
312 # TBD: look for suitable cross compiler suite
313 # cross-$TARCH-gcc and cross-$TARCH-ld
316 if [ $found_crosscompiler == "false" ]; then
317 echo " ($TARCH: skipped, we're $ARCH)"
319 xml " <status>notbuilt</status>"
325 echo " ($TARCH: ok, we're $ARCH)"
327 xml " <path>`which ${CROSS_COMPILE}gcc`</path>"
328 xml " <version>`${CROSS_COMPILE}gcc --version | head -1`</version>"
334 built_successfully $VENDOR $MAINBOARD && \
336 echo " ( mainboard/$VENDOR/$MAINBOARD previously ok )"
338 xml " <status>previouslyok</status>"
344 build_broken $VENDOR $MAINBOARD || \
346 echo " ( broken mainboard/$VENDOR/$MAINBOARD skipped )"
348 xml " <status>knownbroken</status>"
354 create_buildenv $VENDOR $MAINBOARD
355 if [ $? -eq 0 ]; then
356 compile_target $VENDOR $MAINBOARD &&
357 xml "<status>ok</status>" ||
358 xml "<status>broken</status>"
369 echo "Usage: $0 [-v] [-a] [-b] [-t <vendor/board>] [-p <dir>] [lbroot]"
370 echo " $0 [-V|--version]"
371 echo " $0 [-h|--help]"
374 echo " [-v|--verbose] print more messages"
375 echo " [-a|--all] build previously succeeded ports as well"
376 echo " [-b|--broken] attempt to build ports that are known broken"
377 echo " [-t|--target <vendor/board>] attempt to build target vendor/board only"
378 echo " [-p|--payloads <dir>] use payloads in <dir> to build images"
379 echo " [-V|--version] print version number and exit"
380 echo " [-h|--help] print this help and exit"
381 echo " [-x|--xml] write xml log file "
382 echo " (defaults to $XMLFILE)"
383 echo " [lbroot] absolute path to LinuxBIOS sources"
384 echo " (defaults to $LBROOT)"
392 LinuxBIOS autobuild: V0.3.
394 Copyright (C) 2004 by Stefan Reinauer <stepan@openbios.org>
395 Copyright (C) 2006 by coresystems GmbH <info@coresystems.de>
396 This program is free software; you may redistribute it under the terms
397 of the GNU General Public License. This program has absolutely no
407 LBROOT=$( cd ../..; pwd )
411 args=`getopt -l version,verbose,help,all,target:,broken,payloads: Vvhat:bp: -- "$@"`
421 -x|--xml) shift; mode=xml; rm -f $XMLFILE ;;
422 -t|--target) shift; target="$1"; shift;;
423 -a|--all) shift; buildall=true;;
424 -b|--broken) shift; buildbroken=true;;
425 -v|--verbose) shift; verbose=true;;
426 -V|--version) shift; myversion; exit 0;;
427 -h|--help) shift; myhelp; exit 0;;
428 -p|--payloads) shift; payloads="$1"; shift;;
430 -*) echo -e "Invalid option\n"; myhelp; exit 1;;
435 # /path/to/freebios2/
436 test -z "$1" || LBROOT=$1
438 debug "LBROOT=$LBROOT"
440 xml '<?xml version="1.0" encoding="utf-8"?>'
443 if [ "$target" != "" ]; then
444 # build a single board
445 VENDOR=`echo $target|cut -f1 -d/`
446 MAINBOARD=`echo $target|cut -f2 -d/`
447 build_target $VENDOR $MAINBOARD
449 # build all boards per default
450 for VENDOR in $( vendors ); do
451 for MAINBOARD in $( mainboards $VENDOR ); do
452 build_target $VENDOR $MAINBOARD