4 # MOLPATH is needed if you want to build openbios-mol.elf
6 MOLPATH
=$HOME/mol-0.9
.71
8 if [ x
"$1" = x
-o "$1" = "-help" ]; then
9 printf "Usage:\n $0 [arch-config]...\n"
10 printf "arch-config values supported for native or cross compiled builds:\n"
11 printf " amd64, ppc, sparc32, sparc64, x86\n\n"
12 printf "Add \"unix-\" prefix to compile openbios-unix executable (native only)\n"
13 printf "Add \"builtin-\" prefix to compile openbios-builtin executables\n\n"
14 printf "Without prefixes, builtin and unix targets are selected\n\n"
15 printf "Special targets: mol-ppc briq-ppc pearpc-ppc qemu-ppc qemu-ppc64 xbox-x86\n\n"
16 printf "Example: $0 builtin-sparc32 unix-amd64 builtin-amd64\n"
25 if test "$host" = "powerpc" -o "$host" = "ppc" \
26 -o "$host" = "mips" -o "$host" = "s390" \
27 -o "$host" = "sparc32" -o "$host" = "sparc64" \
28 -o "$host" = "m68k" -o "$host" = "armv4b"; then
35 if test "$host" = "sparc64" -o "$host" = "ia64" \
36 -o "$host" = "amd64" -o "$host" = "x86_64" \
37 -o "$host" = "alpha"; then
43 if test "$target" = "powerpc" -o "$target" = "ppc" \
44 -o "$target" = "powerpc64" -o "$target" = "ppc64" \
45 -o "$target" = "mips" -o "$target" = "s390" \
46 -o "$target" = "sparc32" -o "$target" = "sparc64" \
47 -o "$target" = "m68k" -o "$target" = "armv4b"; then
53 # target long bits test
54 if test "$target" = "sparc64" -o "$target" = "ia64" \
55 -o "$target" = "amd64" -o "$target" = "x86_64" \
56 -o "$target" = "powerpc64" -o "$target" = "ppc64" \
57 -o "$target" = "alpha"; then
63 if test "$targetbigendian" = "$hostbigendian"; then
64 cflags
="-USWAP_ENDIANNESS"
66 cflags
="-DSWAP_ENDIANNESS"
69 if test "$targetlongbits" = "$hostlongbits"; then
70 cflags
="$cflags -DNATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH"
71 elif test "$targetlongbits" -lt "$hostlongbits"; then
72 cflags
="$cflags -DNATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH"
74 cflags
="$cflags -DNATIVE_BITWIDTH_LARGER_THAN_HOST_BITWIDTH"
77 if test "$target" = "sparc64" -o "$target" = "ia64" \
78 -o "$target" = "amd64" -o "$target" = "x86_64" \
79 -o "$target" = "alpha"; then
80 if test "$host" = "x86"; then
81 cflags
="$cflags -DNEED_FAKE_INT128_T"
82 elif test "$host" = "ppc" -a `uname -s` = "Darwin"; then
83 cflags
="$cflags -DNEED_FAKE_INT128_T"
92 HOSTARCH
=`uname -m | sed -e s/i.86/x86/ -e s/i86pc/x86/ \
93 -e s/sun4u/sparc64/ -e s/sparc$/sparc32/ \
94 -e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \
95 -e "s/Power Macintosh/ppc/"`
100 for TARGET
in ${1}-linux-gnu- ${1}-linux- ${1}-elf- ${1}-eabi-
102 if type ${TARGET}gcc
> /dev
/null
2>&1
107 if [ "$ARCH" = "$HOSTARCH" ]; then
110 echo "ERROR: no ${1} cross-compiler found !" 1>&2
116 option
=`echo $1 | tr a-z A-Z`
117 echo "<option name=\"$option\" type=\"boolean\" value=\"true\" />"
120 if ! test -f utils
/dist
/debian
/rules
; then
121 echo "switch-arch must be run from the top-level source directory" >&2
125 # This is needed because viewvc messes with the permissions of executables:
126 chmod 755 utils
/dist
/debian
/rules
127 chmod 755 config
/scripts
/switch-arch
128 chmod 755 config
/scripts
/reldir
130 if test "x$HOSTARCH" = "x"; then
134 VERSION
=`head VERSION`
136 echo "Configuring OpenBIOS on $HOSTARCH for $*"
141 unix-
*|builtin-
*|plain-
*|mol-ppc|briq-ppc|pearpc-ppc|qemu-ppc|qemu-ppc64|xbox-x86
)
142 target_list
="$target_list $target"
145 echo "\"cross-\" prefix is no longer needed"
146 target
=`echo $target | sed s/cross-//g`
147 target_list
="$target_list builtin-$target"
150 #default: build builtin and if possible, unix target
151 target_list
="$target_list builtin-$target unix-$target"
157 for target
in $target_list; do
158 arch
=`echo $target | sed s/.*-//g`
159 if ! test -f config
/examples
/${arch}_config.xml
; then
160 echo "Cannot find config/examples/${arch}_config.xml" >&2
163 if ! echo $arch_list |
grep -q "$arch"; then
164 arch_list
="$arch_list $arch"
168 for ARCH
in $arch_list; do
179 for target
in $target_list; do
198 builtin-ppc|qemu-ppc|builtin-ppc64|qemu-ppc64
)
209 if [ "$ARCH" != "$HOSTARCH" ]; then
210 # Can't cross compile Unix target
228 CFLAGS
="-fno-builtin"
233 select_prefix powerpc
234 if [ "$unix" = "no" ]; then
235 CFLAGS
="-msoft-float -fno-builtin-bcopy -fno-builtin-log2"
237 CFLAGS
="-fno-builtin"
243 select_prefix powerpc64
244 CFLAGS
="-Wa,-a64 -m64 -msoft-float -fno-builtin"
251 CFLAGS
="-Wa,-xarch=v8 -Wa,-32 -m32 -mcpu=supersparc -fno-builtin"
252 AS_FLAGS
="-Wa,-xarch=v8 -Wa,-32"
256 select_prefix sparc64
257 CFLAGS
="-Wa,-xarch=v9b -Wa,-64 -m64 -mcpu=ultrasparc -mcmodel=medany -fno-builtin"
258 AS_FLAGS
="-Wa,-xarch=v9b -Wa,-64"
263 CFLAGS
="-fno-builtin -m32"
267 if [ "$ARCH" != "$HOSTARCH" -o `uname -s` = "Darwin" ]; then
270 crosscflags
$HOSTARCH $ARCH
273 printf "Initializing build tree $OBJDIR..."
276 mkdir
-p $OBJDIR/target
277 mkdir
-p $OBJDIR/target
/include
278 mkdir
-p $OBJDIR/target
/arch
279 mkdir
-p $OBJDIR/target
/arch
/unix
280 mkdir
-p $OBJDIR/target
/arch
/$ARCH
281 mkdir
-p $OBJDIR/target
/libgcc
282 mkdir
-p $OBJDIR/target
/kernel
283 mkdir
-p $OBJDIR/target
/libopenbios
284 mkdir
-p $OBJDIR/target
/packages
285 mkdir
-p $OBJDIR/target
/fs
286 mkdir
-p $OBJDIR/target
/fs
/grubfs
287 mkdir
-p $OBJDIR/target
/fs
/hfs
288 mkdir
-p $OBJDIR/target
/fs
/hfsplus
289 mkdir
-p $OBJDIR/target
/fs
/iso9660
290 mkdir
-p $OBJDIR/target
/fs
/ext2
291 mkdir
-p $OBJDIR/target
/drivers
292 mkdir
-p $OBJDIR/target
/libc
293 mkdir
-p $OBJDIR/host
/include
294 mkdir
-p $OBJDIR/host
/kernel
295 mkdir
-p $OBJDIR/forth
296 ln -s ..
/..
/..
/include
/arch
/$BASEARCH $OBJDIR/target
/include
/asm
297 #compile the host binary with target settings instead
298 #ln -s ../../../include/arch/$HOSTARCH $OBJDIR/host/include/asm
299 if [ "$mol" = "yes" ]; then
300 printf "\nUsing MOL path $MOLPATH...\n"
301 mkdir
-p $OBJDIR/target
/arch
/ppc
/mol
302 ln -s $MOLPATH/src
/shared
/osi_calls.h
$OBJDIR/target
/include
/
303 ln -s $MOLPATH/src
/shared
/osi.h
$OBJDIR/target
/include
/
304 ln -s $MOLPATH/src
/shared
/prom.h
$OBJDIR/target
/include
/
305 ln -s $MOLPATH/src
/include
/boothelper_sh.h
$OBJDIR/target
/include
/
306 ln -s $MOLPATH/src
/include
/video_sh.h
$OBJDIR/target
/include
/
307 ln -s $MOLPATH/src
/include
/pseudofs_sh.h
$OBJDIR/target
/include
/
308 ln -s $MOLPATH/src
/include
/kbd_sh.h
$OBJDIR/target
/include
/
309 ln -s $MOLPATH/src
/drivers
/disk
/include
/scsi_sh.h
$OBJDIR/target
/include
/
310 ln -s $MOLPATH/src
/drivers
/disk
/include
/ablk_sh.h
$OBJDIR/target
/include
/
312 if [ "$briq" = "yes" ]; then
313 mkdir
-p $OBJDIR/target
/arch
/ppc
/briq
315 if [ "$pearpc" = "yes" ]; then
316 mkdir
-p $OBJDIR/target
/arch
/ppc
/pearpc
318 if [ "$qemu" = "yes" ]; then
319 mkdir
-p $OBJDIR/target
/arch
/ppc
/qemu
321 if [ "$xbox" = "yes" ]; then
322 mkdir
-p $OBJDIR/target
/arch
/x86
/xbox
330 printf "Creating target Makefile..."
331 echo "ARCH=$ARCH" > $ODIR/config.mak
332 if [ "$cross" = "yes" ]; then
333 echo "TARGET=$TARGET" >> $ODIR/config.mak
335 echo "CFLAGS=$CFLAGS" >> $ODIR/config.mak
336 echo "AS_FLAGS=$AS_FLAGS" >> $ODIR/config.mak
337 echo "HOSTARCH?=$HOSTARCH" >> $ODIR/config.mak
338 echo "CROSSCFLAGS=$CROSSCFLAGS" >> $ODIR/config.mak
339 echo "VERSION=\"$VERSION\"" >> $ODIR/config.mak
341 ln -s $SRCDIR/config
/xml
/rules.xml
$ODIR/rules.xml
342 echo "<?xml version=\"1.0\"?><config>" > $ODIR/config.xml
344 config_set_boolean CONFIG_
$ARCH >> $ODIR/config.xml
345 if [ "$BASEARCH" != "$ARCH" ]; then
346 config_set_boolean CONFIG_
$BASEARCH >> $ODIR/config.xml
348 if [ "$mol" = "yes" ]; then
349 config_set_boolean CONFIG_MOL
>> $ODIR/config.xml
351 if [ "$briq" = "yes" ]; then
352 config_set_boolean CONFIG_BRIQ
>> $ODIR/config.xml
354 if [ "$pearpc" = "yes" ]; then
355 config_set_boolean CONFIG_PEARPC
>> $ODIR/config.xml
357 if [ "$qemu" = "yes" ]; then
358 config_set_boolean CONFIG_QEMU
>> $ODIR/config.xml
360 if [ "$xbox" = "yes" ]; then
361 config_set_boolean CONFIG_XBOX
>> $ODIR/config.xml
363 if [ "$targetbigendian" = "yes" ]; then
364 config_set_boolean CONFIG_BIG_ENDIAN
>> $ODIR/config.xml
366 config_set_boolean CONFIG_LITTLE_ENDIAN
>> $ODIR/config.xml
369 if [ "$plain" = "yes" ]; then
370 config_set_boolean CONFIG_IMAGE_ELF
>> $ODIR/config.xml
372 if [ "$builtin" = "yes" ]; then
373 config_set_boolean CONFIG_IMAGE_ELF_EMBEDDED
>> $ODIR/config.xml
375 # Build hosted Unix binary?
376 if [ "$unix" = "yes" ]; then
377 config_set_boolean CONFIG_HOST_UNIX
>> $ODIR/config.xml
378 #config_set_boolean CONFIG_UNIX_QT >> $ODIR/config.xml
379 #config_set_boolean CONFIG_PLUGINS >> $ODIR/config.xml
381 cat $SRCDIR/config
/examples
/${ARCH}_config.xml
>> $ODIR/config.xml
383 echo "</config>" >> $ODIR/config.xml
384 ln -s ..
/Makefile.target
$ODIR/Makefile
385 xsltproc
$SRCDIR/config
/xml
/xinclude.xsl
$SRCDIR/build.xml
> $ODIR/build-full.xml
386 xsltproc
$SRCDIR/config
/xml
/makefile.xsl
$ODIR/build-full.xml
> $ODIR/rules.mak
388 printf "Creating config files..."
389 xsltproc
$SRCDIR/config
/xml
/config-c.xsl
$ODIR/config.xml
> $ODIR/host
/include
/autoconf.h
390 xsltproc
$SRCDIR/config
/xml
/config-c.xsl
$ODIR/config.xml
> $ODIR/target
/include
/autoconf.h
391 xsltproc
$SRCDIR/config
/xml
/config-forth.xsl
$ODIR/config.xml
> $ODIR/forth
/config.fs