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.
14 #set -x # Turn echo on....
16 # Where shall we place all the build trees?
17 TARGET=$( pwd )/linuxbios-builds
19 # path to payload. Should be more generic
22 # Lines of error context to be printed in FAILURE case
25 # One might want to adjust these in case of cross compiling
29 ARCH=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
30 -e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \
31 -e "s/Power Macintosh/ppc/"`
35 test "$verbose" == "true" && echo $*
40 # make this a function so we can easily select
41 # without breaking readability
42 ls -1 "$LBROOT/src/mainboard" | grep -v CVS
47 # make this a function so we can easily select
48 # without breaking readability
52 ls -1 $LBROOT/src/mainboard/$VENDOR | grep -v CVS
59 cat $LBROOT/src/mainboard/$VENDOR/$MAINBOARD/Config.lb | \
60 grep ^arch | cut -f 2 -d\
63 function create_config
67 TARCH=$( architecture $VENDOR $MAINBOARD )
68 echo -n " Creating config file..."
71 # This will make a target directory of ./VENDOR_MAINBOARD
73 target VENDOR_MAINBOARD
74 mainboard VENDOR/MAINBOARD
77 option CROSS_COMPILE="CROSS_PREFIX"
78 option HOSTCC="CROSS_HOSTCC"
81 if [ $TARCH == i386 ] ; then
84 option USE_FALLBACK_IMAGE=0
85 option ROM_IMAGE_SIZE=0x18000
86 option LINUXBIOS_EXTRA_VERSION=".0-normal"
91 option USE_FALLBACK_IMAGE=1
92 option ROM_IMAGE_SIZE=0x18000
93 option LINUXBIOS_EXTRA_VERSION=".0-fallback"
96 buildrom ./linuxbios.rom ROM_SIZE "normal" "fallback"
101 option LINUXBIOS_EXTRA_VERSION=".0"
104 buildrom ./linuxbios.rom ROM_SIZE "only"
107 ) | sed -e s,VENDOR,$VENDOR,g \
108 -e s,MAINBOARD,$MAINBOARD,g \
109 -e s,PAYLOAD,$PAYLOAD,g \
110 -e s,CROSSCC,"$CC",g \
111 -e s,CROSS_PREFIX,"$CROSS_COMPILE",g \
112 -e s,CROSS_HOSTCC,"$HOSTCC",g \
113 > $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
117 function create_builddir
122 echo -n " Creating builddir..."
125 config_dir=$LBROOT/util/newconfig
126 yapps2_py=$config_dir/yapps2.py
127 config_g=$config_dir/config.g
128 config_lb=Config-${VENDOR}_${MAINBOARD}.lb
132 build_dir=${VENDOR}_${MAINBOARD}
133 config_py=$build_dir/config.py
135 if [ ! -d $build_dir ] ; then
138 if [ ! -f $config_py ]; then
139 $PYTHON $yapps2_py $config_g $config_py &> $build_dir/py.log
142 # make sure config.py is up-to-date
144 export PYTHONPATH=$config_dir
145 $PYTHON $config_py $config_lb $LBROOT &> $build_dir/config.log
146 if [ $? -eq 0 ]; then
149 echo "FAILED! Log excerpt:"
150 tail -n $CONTEXT $build_dir/config.log
155 function create_buildenv
159 create_config $VENDOR $MAINBOARD
160 create_builddir $VENDOR $MAINBOARD
163 function compile_target
168 echo -n " Compiling image .."
170 cd $TARGET/${VENDOR}_${MAINBOARD}
171 eval $MAKE &> make.log
172 if [ $? -eq 0 ]; then
173 echo "ok" > compile.status
178 echo "FAILED! Log excerpt:"
179 tail -n $CONTEXT make.log
185 function built_successfully
189 if [ -d "$TARGET/${VENDOR}_${MAINBOARD}" ]; then
190 cd $TARGET/${VENDOR}_${MAINBOARD}
191 if [ -r compile.status ] ; then
192 status=`cat compile.status`
196 [ "$buildall" != "true" -a "$status" == "ok" ]
199 function build_broken
203 [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/BROKEN" ] && status="no"
204 [ "$buildbroken" == "true" -o "$status" == "yes" ]
207 function build_target
211 TARCH=$( architecture $VENDOR $MAINBOARD )
214 CC='$(CROSS_COMPILE)gcc'
218 echo -n "Processing mainboard/$VENDOR/$MAINBOARD"
220 if [ "$ARCH" == "$TARCH" ]; then
223 found_crosscompiler=false
224 if [ "$ARCH" == amd64 -a "$TARCH" == i386 ]; then
226 found_crosscompiler=true
228 if [ "$ARCH" == ppc64 -a "$TARCH" == ppc ]; then
230 found_crosscompiler=true
232 if [ "$found_crosscompiler" == "false" -a "$TARCH" == ppc ];then
233 for prefix in powerpc-eabi- powerpc-linux- ppc_74xx- \
234 powerpc-7450-linux-gnu-; do
235 if ${prefix}gcc --version > /dev/null 2> /dev/null ; then
236 found_crosscompiler=true
237 CROSS_COMPILE=$prefix
242 # TBD: look for suitable cross compiler suite
243 # cross-$TARCH-gcc and cross-$TARCH-ld
246 if [ $found_crosscompiler == "false" ]; then
247 echo " ($TARCH: skipped, we're $ARCH)"
251 echo " ($TARCH: ok, we're $ARCH)"
255 built_successfully $VENDOR $MAINBOARD && \
257 echo " ( mainboard/$VENDOR/$MAINBOARD previously ok )"
262 build_broken $VENDOR $MAINBOARD || \
264 echo " ( broken mainboard/$VENDOR/$MAINBOARD skipped )"
269 create_buildenv $VENDOR $MAINBOARD
270 if [ $? -eq 0 ]; then
271 compile_target $VENDOR $MAINBOARD
279 echo "Usage: $0 [-v] [-a] [-b] [-t <vendor/board>] [lbroot]"
280 echo " $0 [-V|--version]"
281 echo " $0 [-h|--help]"
284 echo " [-v|--verbose] print more messages"
285 echo " [-a|--all] build previously succeeded ports as well"
286 echo " [-b|--broken] attempt to build ports that are known broken"
287 echo " [-t|--target <vendor/board>] attempt to build target vendor/board only"
288 echo " [-V|--version] print version number and exit"
289 echo " [-h|--help] print this help and exit"
290 echo " [lbroot] absolute path to LinuxBIOS sources"
291 echo " (defaults to $LBROOT)"
299 LinuxBIOS autobuild: V0.1.
301 Copyright (C) 2004 by Stefan Reinauer, <stepan@openbios.org>
302 This program is free software; you may redistribute it under the terms
303 of the GNU General Public License. This program has absolutely no
313 LBROOT=$( cd ../..; pwd )
317 args=`getopt -l version,verbose,help,all,target:,broken Vvhat:b -- "$@"`
327 -t|--target) shift; target="$1"; shift;;
328 -a|--all) shift; buildall=true;;
329 -b|--broken) shift; buildbroken=true;;
330 -v|--verbose) shift; verbose=true;;
331 -V|--version) shift; myversion; exit 0;;
332 -h|--help) shift; myhelp; exit 0;;
334 -*) echo -e "Invalid option\n"; myhelp; exit 1;;
339 # /path/to/freebios2/
340 test -z "$1" || LBROOT=$1
342 debug "LBROOT=$LBROOT"
344 if [ "$target" != "" ]; then
345 # build a single board
346 VENDOR=`echo $target|cut -f1 -d/`
347 MAINBOARD=`echo $target|cut -f2 -d/`
348 build_target $VENDOR $MAINBOARD
350 # build all boards per default
351 for VENDOR in $( vendors ); do
352 for MAINBOARD in $( mainboards $VENDOR ); do
353 build_target $VENDOR $MAINBOARD