5 # This script builds LinuxBIOS images for all available targets.
7 # (C) 2004 by Stefan Reinauer <stepan@openbios.org>
9 # This file is subject to the terms and conditions of the GNU General
10 # Public License. See the file COPYING in the main directory of this
11 # archive for more details.
15 # Where shall we place all the build trees?
16 TARGET=$( pwd )/linuxbios-builds
18 # path to payload. Should be more generic
21 # Lines of error context to be printed in FAILURE case
24 # One might want to adjust these in case of cross compiling
28 ARCH=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
29 -e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \
30 -e "s/Power Macintosh/ppc/"`
34 # make this a function so we can easily select
35 # without breaking readability
36 ls -1 $LBROOT/src/mainboard | grep -v CVS
41 # make this a function so we can easily select
42 # without breaking readability
46 ls -1 $LBROOT/src/mainboard/$VENDOR | grep -v CVS
53 cat $LBROOT/src/mainboard/$VENDOR/$MAINBOARD/Config.lb | \
54 grep ^arch | cut -f 2 -d\
57 function create_config
61 echo -n " Creating config file..."
64 # This will make a target directory of ./VENDOR_MAINBOARD
66 target VENDOR_MAINBOARD
67 mainboard VENDOR/MAINBOARD
74 option USE_FALLBACK_IMAGE=0
75 option ROM_IMAGE_SIZE=0x12000
76 option LINUXBIOS_EXTRA_VERSION=".0-normal"
81 option USE_FALLBACK_IMAGE=1
82 option ROM_IMAGE_SIZE=0x12000
83 option LINUXBIOS_EXTRA_VERSION=".0-fallback"
87 buildrom ./VENDOR_MAINBOARD.rom ROM_SIZE "normal" "fallback"
89 ) | sed -e s,VENDOR,$VENDOR,g \
90 -e s,MAINBOARD,$MAINBOARD,g \
91 -e s,PAYLOAD,$PAYLOAD,g \
92 -e s,CROSSCC,"$CC",g \
93 -e s,CROSSLD,"$LD",g \
94 > $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
98 function create_builddir
103 echo -n " Creating builddir..."
106 config_dir=$LBROOT/util/newconfig
107 yapps2_py=$config_dir/yapps2.py
108 config_g=$config_dir/config.g
109 config_lb=Config-${VENDOR}_${MAINBOARD}.lb
113 build_dir=${VENDOR}_${MAINBOARD}
114 config_py=$build_dir/config.py
116 if [ ! -d $build_dir ] ; then
119 if [ ! -f $config_py ]; then
120 $PYTHON $yapps2_py $config_g $config_py &> $build_dir/py.log
123 # make sure config.py is up-to-date
125 export PYTHONPATH=$config_dir
126 $PYTHON $config_py $config_lb $LBROOT &> $build_dir/config.log
127 if [ $? -eq 0 ]; then
130 echo "FAILED! Log excerpt:"
131 tail -n $CONTEXT $build_dir/config.log
136 function create_buildenv
140 create_config $VENDOR $MAINBOARD
141 create_builddir $VENDOR $MAINBOARD
144 function compile_target
149 echo -n " Compiling image .."
151 cd $TARGET/${VENDOR}_${MAINBOARD}
152 eval $MAKE &> make.log
153 if [ $? -eq 0 ]; then
154 echo "ok" > compile.status
159 echo "FAILED! Log excerpt:"
160 tail -n $CONTEXT make.log
166 function built_successfully
170 if [ -d "$TARGET/${VENDOR}_${MAINBOARD}" ]; then
171 cd $TARGET/${VENDOR}_${MAINBOARD}
172 if [ -r compile.status ] ; then
173 status=`cat compile.status`
177 [ "$buildall" != "true" -a "$status" == "ok" ]
179 function build_target
183 TARCH=$( architecture $VENDOR $MAINBOARD )
189 echo -n "Processing mainboard/$VENDOR/$MAINBOARD"
191 if [ "$ARCH" == "$TARCH" ]; then
194 found_crosscompiler=false
195 if [ "$ARCH" == amd64 -a "$TARCH" == i386 ]; then
197 found_crosscompiler=true
198 echo " ($TARCH: subset of $ARCH)"
200 if [ "$ARCH" == ppc64 -a "$TARCH" == ppc ]; then
202 found_crosscompiler=true
203 echo " ($TARCH: subset of $ARCH)"
206 # TBD: look for suitable cross compiler suite
207 # cross-$TARCH-gcc and cross-$TARCH-ld
210 if [ $found_crosscompiler == "false" ]; then
211 echo " ($TARCH: skipped, we're $ARCH)"
216 if ! built_successfully $VENDOR $MAINBOARD ; then
217 create_buildenv $VENDOR $MAINBOARD
218 if [ $? -eq 0 ]; then
219 compile_target $VENDOR $MAINBOARD
222 echo " ( mainboard/$VENDOR/$MAINBOARD previously ok )"
229 echo "Usage: $0 [-v|--verbose] [-a|--all] [-t|--target vendor/board] [lbroot]"
230 echo " $0 [-V|--version]"
231 echo " $0 [-h|--help]"
239 LinuxBIOS autobuild: V0.1.
241 Copyright (C) 2004 by Stefan Reinauer, <stepan@openbios.org>
242 This program is free software; you may redistribute it under the terms
243 of the GNU General Public License. This program has absolutely no
256 args=`getopt -l version,verbose,help,all,target: Vvhat: $*`
267 -t|--target) shift;target=$1;shift;;
268 -a|--all) shift;buildall=true;;
269 -v|--verbose) shift;verbose=true;;
270 -V|--version) shift;myversion;;
271 -h|--help) shift;myhelp;;
278 # /path/to/freebios2/
279 if [ -z "$LBROOT" ] ; then
280 LBROOT=$( cd ../..; pwd )
283 if [ "$target" != "" ]; then
284 # build a single board
285 VENDOR=`echo $target|tr -d \'|cut -f1 -d/`
286 MAINBOARD=`echo $target|tr -d \'|cut -f2 -d/`
287 build_target $VENDOR $MAINBOARD
289 # build all boards per default
290 for VENDOR in $( vendors ); do
291 for MAINBOARD in $( mainboards $VENDOR ); do
292 build_target $VENDOR $MAINBOARD