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" = "arm"; then
83 cflags="$cflags -DNEED_FAKE_INT128_T"
84 elif test "$host" = "ppc" -a `uname -s` = "Darwin"; then
85 cflags="$cflags -DNEED_FAKE_INT128_T"
94 HOSTARCH=`uname -m | sed -e s/i.86/x86/ -e s/i86pc/x86/ \
95 -e s/sun4u/sparc64/ -e s/sparc$/sparc32/ \
96 -e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \
97 -e "s/Power Macintosh/ppc/"`
102 TARGETS="${1}-unknown-linux-gnu- ${1}-linux-gnu- ${1}-linux- ${1}-elf- ${1}-eabi-"
104 if [ x"$CROSS_COMPILE" != "x" ]; then
105 TARGETS=$CROSS_COMPILE
108 for TARGET in $TARGETS
110 if type ${TARGET}gcc > /dev/null 2>&1
115 if [ "$ARCH" = "$HOSTARCH" ]; then
118 echo "ERROR: no ${1} cross-compiler found !" 1>&2
124 option=`echo $1 | tr a-z A-Z`
125 echo "<option name=\"$option\" type=\"boolean\" value=\"true\" />"
130 type "$1" >/dev/null 2>&1
134 SRCDIR=`dirname "$0"`/../..
137 # make source path absolute
138 SRCDIR=`cd "$SRCDIR"; pwd`
140 if test "x$HOSTARCH" = "x"; then
144 VERSION=`head $SRCDIR/VERSION`
146 echo "Configuring OpenBIOS on $HOSTARCH for $*"
151 echo "Unable to locate toke executable from the fcode-utils package - aborting"
158 unix-*|builtin-*|plain-*|mol-ppc|briq-ppc|pearpc-ppc|qemu-ppc|qemu-ppc64|xbox-x86)
159 target_list="$target_list $target"
162 echo "\"cross-\" prefix is no longer needed"
163 target=`echo $target | sed s/cross-//g`
164 target_list="$target_list builtin-$target"
167 #default: build builtin and if possible, unix target
168 target_list="$target_list builtin-$target unix-$target"
174 for target in $target_list; do
175 arch=`echo $target | sed s/.*-//g`
176 if ! test -f $SRCDIR/config/examples/${arch}_config.xml; then
177 echo "Cannot find $SRCDIR/config/examples/${arch}_config.xml" >&2
180 if ! echo $arch_list | grep -q "$arch"; then
181 arch_list="$arch_list $arch"
185 for ARCH in $arch_list; do
196 for target in $target_list; do
215 builtin-ppc|qemu-ppc|builtin-ppc64|qemu-ppc64)
230 if [ "$ARCH" != "$HOSTARCH" ]; then
231 # Can't cross compile Unix target
249 CFLAGS="-fno-builtin"
254 select_prefix powerpc
255 if [ "$unix" = "no" ]; then
256 CFLAGS="-m32 -msoft-float -fno-builtin-bcopy -fno-builtin-log2"
259 CFLAGS="-fno-builtin"
265 select_prefix powerpc64
266 CFLAGS="-Wa,-a64 -m64 -msoft-float -fno-builtin"
273 CFLAGS="-Wa,-xarch=v8 -Wa,-32 -m32 -mcpu=supersparc -fno-builtin"
274 AS_FLAGS="-Wa,-xarch=v8 -Wa,-32"
278 select_prefix sparc64
279 CFLAGS="-Wa,-xarch=v9b -Wa,-64 -m64 -mcpu=ultrasparc -mcmodel=medany -fno-builtin"
280 AS_FLAGS="-Wa,-xarch=v9b -Wa,-64"
285 CFLAGS="-fno-builtin -m32"
289 if [ "$ARCH" != "$HOSTARCH" -o `uname -s` = "Darwin" ]; then
292 crosscflags $HOSTARCH $ARCH
293 OBJDIR=$BUILDDIR/obj-$ARCH
294 ODIRS="$ODIRS $OBJDIR"
296 printf "Initializing build tree $OBJDIR..."
299 mkdir -p $OBJDIR/target
300 mkdir -p $OBJDIR/target/include
301 mkdir -p $OBJDIR/target/arch
302 mkdir -p $OBJDIR/target/arch/unix
303 mkdir -p $OBJDIR/target/arch/$ARCH
304 mkdir -p $OBJDIR/target/libgcc
305 mkdir -p $OBJDIR/target/kernel
306 mkdir -p $OBJDIR/target/libopenbios
307 mkdir -p $OBJDIR/target/packages
308 mkdir -p $OBJDIR/target/fs
309 mkdir -p $OBJDIR/target/fs/grubfs
310 mkdir -p $OBJDIR/target/fs/hfs
311 mkdir -p $OBJDIR/target/fs/hfsplus
312 mkdir -p $OBJDIR/target/fs/iso9660
313 mkdir -p $OBJDIR/target/fs/ext2
314 mkdir -p $OBJDIR/target/drivers
315 mkdir -p $OBJDIR/target/libc
316 mkdir -p $OBJDIR/host/include
317 mkdir -p $OBJDIR/host/kernel
318 mkdir -p $OBJDIR/forth
319 ln -s $SRCDIR/include/arch/$BASEARCH $OBJDIR/target/include/asm
320 #compile the host binary with target settings instead
321 #ln -s $SRCDIR/include/arch/$HOSTARCH $OBJDIR/host/include/asm
322 if [ "$mol" = "yes" ]; then
323 printf "\nUsing MOL path $MOLPATH...\n"
324 mkdir -p $OBJDIR/target/arch/ppc/mol
325 ln -s $MOLPATH/src/shared/osi_calls.h $OBJDIR/target/include/
326 ln -s $MOLPATH/src/shared/osi.h $OBJDIR/target/include/
327 ln -s $MOLPATH/src/shared/prom.h $OBJDIR/target/include/
328 ln -s $MOLPATH/src/include/boothelper_sh.h $OBJDIR/target/include/
329 ln -s $MOLPATH/src/include/video_sh.h $OBJDIR/target/include/
330 ln -s $MOLPATH/src/include/pseudofs_sh.h $OBJDIR/target/include/
331 ln -s $MOLPATH/src/include/kbd_sh.h $OBJDIR/target/include/
332 ln -s $MOLPATH/src/drivers/disk/include/scsi_sh.h $OBJDIR/target/include/
333 ln -s $MOLPATH/src/drivers/disk/include/ablk_sh.h $OBJDIR/target/include/
335 if [ "$briq" = "yes" ]; then
336 mkdir -p $OBJDIR/target/arch/ppc/briq
338 if [ "$pearpc" = "yes" ]; then
339 mkdir -p $OBJDIR/target/arch/ppc/pearpc
341 if [ "$qemu" = "yes" ]; then
342 mkdir -p $OBJDIR/target/arch/ppc/qemu
344 if [ "$xbox" = "yes" ]; then
345 mkdir -p $OBJDIR/target/arch/x86/xbox
351 printf "Creating target config.mak..."
352 echo "ARCH=$ARCH" > $ODIR/config.mak
353 if [ "$cross" = "yes" ]; then
354 echo "TARGET=$TARGET" >> $ODIR/config.mak
356 echo "CFLAGS=$CFLAGS" >> $ODIR/config.mak
357 echo "AS_FLAGS=$AS_FLAGS" >> $ODIR/config.mak
358 echo "HOSTARCH?=$HOSTARCH" >> $ODIR/config.mak
359 echo "CROSSCFLAGS=$CROSSCFLAGS" >> $ODIR/config.mak
360 echo "VERSION=\"$VERSION\"" >> $ODIR/config.mak
361 echo "SRCDIR=$SRCDIR" >> $ODIR/config.mak
364 printf "Creating target rules.mak..."
365 ln -s $SRCDIR/config/xml/rules.xml $ODIR/rules.xml
366 echo "<?xml version=\"1.0\"?><config>" > $ODIR/config.xml
368 config_set_boolean CONFIG_$ARCH >> $ODIR/config.xml
369 if [ "$BASEARCH" != "$ARCH" ]; then
370 config_set_boolean CONFIG_$BASEARCH >> $ODIR/config.xml
372 if [ "$mol" = "yes" ]; then
373 config_set_boolean CONFIG_MOL >> $ODIR/config.xml
375 if [ "$briq" = "yes" ]; then
376 config_set_boolean CONFIG_BRIQ >> $ODIR/config.xml
378 if [ "$pearpc" = "yes" ]; then
379 config_set_boolean CONFIG_PEARPC >> $ODIR/config.xml
381 if [ "$qemu" = "yes" ]; then
382 config_set_boolean CONFIG_QEMU >> $ODIR/config.xml
384 if [ "$xbox" = "yes" ]; then
385 config_set_boolean CONFIG_XBOX >> $ODIR/config.xml
387 if [ "$targetbigendian" = "yes" ]; then
388 config_set_boolean CONFIG_BIG_ENDIAN >> $ODIR/config.xml
390 config_set_boolean CONFIG_LITTLE_ENDIAN >> $ODIR/config.xml
393 if [ "$plain" = "yes" ]; then
394 config_set_boolean CONFIG_IMAGE_ELF >> $ODIR/config.xml
396 if [ "$builtin" = "yes" ]; then
397 config_set_boolean CONFIG_IMAGE_ELF_EMBEDDED >> $ODIR/config.xml
399 # Build hosted Unix binary?
400 if [ "$unix" = "yes" ]; then
401 config_set_boolean CONFIG_HOST_UNIX >> $ODIR/config.xml
402 #config_set_boolean CONFIG_UNIX_QT >> $ODIR/config.xml
403 #config_set_boolean CONFIG_PLUGINS >> $ODIR/config.xml
405 cat $SRCDIR/config/examples/${ARCH}_config.xml >> $ODIR/config.xml
408 echo "</config>" >> $ODIR/config.xml
409 ln -s $SRCDIR/Makefile.target $ODIR/Makefile
410 xsltproc $SRCDIR/config/xml/xinclude.xsl $SRCDIR/build.xml > $ODIR/build-full.xml
411 xsltproc $SRCDIR/config/xml/makefile.xsl $ODIR/build-full.xml > $ODIR/rules.mak
413 printf "Creating config files..."
414 xsltproc $SRCDIR/config/xml/config-c.xsl $ODIR/config.xml > $ODIR/host/include/autoconf.h
415 xsltproc $SRCDIR/config/xml/config-c.xsl $ODIR/config.xml > $ODIR/target/include/autoconf.h
416 xsltproc $SRCDIR/config/xml/config-forth.xsl $ODIR/config.xml > $ODIR/forth/config.fs
422 if [ "$SRCDIR" != "$BUILDDIR" ]; then
423 ln -s $SRCDIR/Makefile $BUILDDIR
426 echo "ODIRS=$ODIRS" >> $BUILDDIR/config-host.mak
427 echo "TARGETS=$arch_list" >> $BUILDDIR/config-host.mak