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"
24 if test "$cpu" = "powerpc" -o "$cpu" = "ppc" \
25 -o "$cpu" = "powerpc64" -o "$cpu" = "ppc64" \
26 -o "$cpu" = "mips" -o "$cpu" = "s390" \
27 -o "$cpu" = "sparc32" -o "$cpu" = "sparc64" \
28 -o "$cpu" = "m68k" -o "$cpu" = "armv4b"; then
38 if test "$cpu" = "sparc64" -o "$cpu" = "ia64" \
39 -o "$cpu" = "amd64" -o "$cpu" = "x86_64" \
40 -o "$cpu" = "powerpc64" -o "$cpu" = "ppc64" \
41 -o "$cpu" = "alpha"; then
52 powerpc|ppc64|powerpc64)
66 hostbigendian=$(is_bigendian $host)
67 hostlongbits=$(longbits $host)
69 targetbigendian=$(is_bigendian $target)
70 targetlongbits=$(longbits $target)
72 if test "$targetbigendian" = "$hostbigendian"; then
73 cflags="-USWAP_ENDIANNESS"
75 cflags="-DSWAP_ENDIANNESS"
78 if test "$targetlongbits" = "$hostlongbits"; then
79 cflags="$cflags -DNATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH"
80 elif test "$targetlongbits" -lt "$hostlongbits"; then
81 cflags="$cflags -DNATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH"
83 cflags="$cflags -DNATIVE_BITWIDTH_LARGER_THAN_HOST_BITWIDTH"
86 if test "$target" = "sparc64" -o "$target" = "ia64" \
87 -o "$target" = "amd64" -o "$target" = "x86_64" \
88 -o "$target" = "alpha"; then
89 if test "$host" = "x86"; then
90 cflags="$cflags -DNEED_FAKE_INT128_T"
91 elif test "$host" = "arm"; then
92 cflags="$cflags -DNEED_FAKE_INT128_T"
93 elif test "$host" = "ppc" -a `uname -s` = "Darwin"; then
94 cflags="$cflags -DNEED_FAKE_INT128_T"
103 HOSTARCH=`uname -m | sed -e s/i.86/x86/ -e s/i86pc/x86/ \
104 -e s/sun4u/sparc64/ -e s/sparc$/sparc32/ \
105 -e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \
106 -e "s/Power Macintosh/ppc/"`
111 BASEARCH=$(basearch $ARCH)
113 TARGETS="${target_arch}-unknown-linux-gnu- ${target_arch}-linux-gnu- ${target_arch}-linux- ${target_arch}-elf- ${target_arch}-eabi-"
115 if [ x"$CROSS_COMPILE" != "x" ]; then
116 TARGETS=$CROSS_COMPILE
119 for TARGET in $TARGETS
121 if type ${TARGET}gcc > /dev/null 2>&1
126 if [ "$BASEARCH" = "$(basearch $HOSTARCH)" ]; then
131 echo "ERROR: no $* cross-compiler found !" 1>&2
137 option=`echo $1 | tr a-z A-Z`
138 echo "<option name=\"$option\" type=\"boolean\" value=\"true\" />"
143 type "$1" >/dev/null 2>&1
147 SRCDIR=`dirname "$0"`/../..
150 # make source path absolute
151 SRCDIR=`cd "$SRCDIR"; pwd`
153 if test "x$HOSTARCH" = "x"; then
157 VERSION=`head $SRCDIR/VERSION`
159 echo "Configuring OpenBIOS on $HOSTARCH for $*"
164 echo "Unable to locate toke executable from the fcode-utils package - aborting"
171 unix-*|builtin-*|plain-*|mol-ppc|briq-ppc|pearpc-ppc|qemu-ppc|qemu-ppc64|xbox-x86)
172 target_list="$target_list $target"
175 echo "\"cross-\" prefix is no longer needed"
176 target=`echo $target | sed s/cross-//g`
177 target_list="$target_list builtin-$target"
180 #default: build builtin and if possible, unix target
181 target_list="$target_list builtin-$target unix-$target"
187 for target in $target_list; do
188 arch=`echo $target | sed s/.*-//g`
189 if ! test -f $SRCDIR/config/examples/${arch}_config.xml; then
190 echo "Cannot find $SRCDIR/config/examples/${arch}_config.xml" >&2
193 if ! echo $arch_list | grep -q "$arch"; then
194 arch_list="$arch_list $arch"
198 for ARCH in $arch_list; do
209 for target in $target_list; do
228 builtin-ppc|qemu-ppc|builtin-ppc64|qemu-ppc64)
243 if [ "$ARCH" != "$HOSTARCH" ]; then
244 # Can't cross compile Unix target
261 CFLAGS="-fno-builtin"
266 select_prefix powerpc powerpc64
267 if [ "$unix" = "no" ]; then
268 # 604 cpu includes support for PReP as well as Mac
269 CFLAGS="-m32 -mcpu=604 -msoft-float -fno-builtin-bcopy -fno-builtin-log2"
272 CFLAGS="-fno-builtin"
278 select_prefix powerpc64
280 # 970 cpu is used in all 64-bit Macs but disable altivec
281 CFLAGS="-mcpu=970 -mno-altivec -Wa,-a64 -m64 -msoft-float -fno-builtin"
286 select_prefix sparc sparc64
287 CFLAGS="-Wa,-xarch=v8 -Wa,-32 -m32 -mcpu=supersparc -fno-builtin"
288 AS_FLAGS="-Wa,-xarch=v8 -Wa,-32"
292 select_prefix sparc64
293 CFLAGS="-Wa,-xarch=v9b -Wa,-64 -m64 -mcpu=ultrasparc -mcmodel=medany -fno-builtin"
294 AS_FLAGS="-Wa,-xarch=v9b -Wa,-64"
299 CFLAGS="-fno-builtin -m32"
303 if [ "$ARCH" != "$HOSTARCH" -o `uname -s` = "Darwin" ]; then
306 crosscflags $HOSTARCH $ARCH
307 OBJDIR=$BUILDDIR/obj-$ARCH
308 ODIRS="$ODIRS $OBJDIR"
310 printf "Initializing build tree $OBJDIR..."
313 mkdir -p $OBJDIR/target
314 mkdir -p $OBJDIR/target/include
315 mkdir -p $OBJDIR/target/arch
316 mkdir -p $OBJDIR/target/arch/unix
317 mkdir -p $OBJDIR/target/arch/$ARCH
318 mkdir -p $OBJDIR/target/libgcc
319 mkdir -p $OBJDIR/target/kernel
320 mkdir -p $OBJDIR/target/libopenbios
321 mkdir -p $OBJDIR/target/packages
322 mkdir -p $OBJDIR/target/fs
323 mkdir -p $OBJDIR/target/fs/grubfs
324 mkdir -p $OBJDIR/target/fs/hfs
325 mkdir -p $OBJDIR/target/fs/hfsplus
326 mkdir -p $OBJDIR/target/fs/iso9660
327 mkdir -p $OBJDIR/target/fs/ext2
328 mkdir -p $OBJDIR/target/drivers
329 mkdir -p $OBJDIR/target/libc
330 mkdir -p $OBJDIR/host/include
331 mkdir -p $OBJDIR/host/kernel
332 mkdir -p $OBJDIR/forth
333 ln -s $SRCDIR/include/arch/$BASEARCH $OBJDIR/target/include/asm
334 #compile the host binary with target settings instead
335 #ln -s $SRCDIR/include/arch/$HOSTARCH $OBJDIR/host/include/asm
336 if [ "$mol" = "yes" ]; then
337 printf "\nUsing MOL path $MOLPATH...\n"
338 mkdir -p $OBJDIR/target/arch/ppc/mol
339 ln -s $MOLPATH/src/shared/osi_calls.h $OBJDIR/target/include/
340 ln -s $MOLPATH/src/shared/osi.h $OBJDIR/target/include/
341 ln -s $MOLPATH/src/shared/prom.h $OBJDIR/target/include/
342 ln -s $MOLPATH/src/include/boothelper_sh.h $OBJDIR/target/include/
343 ln -s $MOLPATH/src/include/video_sh.h $OBJDIR/target/include/
344 ln -s $MOLPATH/src/include/pseudofs_sh.h $OBJDIR/target/include/
345 ln -s $MOLPATH/src/include/kbd_sh.h $OBJDIR/target/include/
346 ln -s $MOLPATH/src/drivers/disk/include/scsi_sh.h $OBJDIR/target/include/
347 ln -s $MOLPATH/src/drivers/disk/include/ablk_sh.h $OBJDIR/target/include/
349 if [ "$briq" = "yes" ]; then
350 mkdir -p $OBJDIR/target/arch/ppc/briq
352 if [ "$pearpc" = "yes" ]; then
353 mkdir -p $OBJDIR/target/arch/ppc/pearpc
355 if [ "$qemu" = "yes" ]; then
356 mkdir -p $OBJDIR/target/arch/ppc/qemu
358 if [ "$xbox" = "yes" ]; then
359 mkdir -p $OBJDIR/target/arch/x86/xbox
365 printf "Creating target config.mak..."
366 echo "ARCH=$ARCH" > $ODIR/config.mak
367 if [ "$cross" = "yes" ]; then
368 echo "TARGET=$TARGET" >> $ODIR/config.mak
370 echo "CFLAGS=$CFLAGS" >> $ODIR/config.mak
371 echo "AS_FLAGS=$AS_FLAGS" >> $ODIR/config.mak
372 echo "HOSTARCH?=$HOSTARCH" >> $ODIR/config.mak
373 echo "CROSSCFLAGS=$CROSSCFLAGS" >> $ODIR/config.mak
374 echo "VERSION=\"$VERSION\"" >> $ODIR/config.mak
375 echo "SRCDIR=$SRCDIR" >> $ODIR/config.mak
378 printf "Creating target rules.mak..."
379 ln -s $SRCDIR/config/xml/rules.xml $ODIR/rules.xml
380 echo "<?xml version=\"1.0\"?><config>" > $ODIR/config.xml
382 config_set_boolean CONFIG_$ARCH >> $ODIR/config.xml
383 if [ "$BASEARCH" != "$ARCH" ]; then
384 config_set_boolean CONFIG_$BASEARCH >> $ODIR/config.xml
386 if [ "$mol" = "yes" ]; then
387 config_set_boolean CONFIG_MOL >> $ODIR/config.xml
389 if [ "$briq" = "yes" ]; then
390 config_set_boolean CONFIG_BRIQ >> $ODIR/config.xml
392 if [ "$pearpc" = "yes" ]; then
393 config_set_boolean CONFIG_PEARPC >> $ODIR/config.xml
395 if [ "$qemu" = "yes" ]; then
396 config_set_boolean CONFIG_QEMU >> $ODIR/config.xml
398 if [ "$xbox" = "yes" ]; then
399 config_set_boolean CONFIG_XBOX >> $ODIR/config.xml
401 if [ "$targetbigendian" = "yes" ]; then
402 config_set_boolean CONFIG_BIG_ENDIAN >> $ODIR/config.xml
404 config_set_boolean CONFIG_LITTLE_ENDIAN >> $ODIR/config.xml
407 if [ "$plain" = "yes" ]; then
408 config_set_boolean CONFIG_IMAGE_ELF >> $ODIR/config.xml
410 if [ "$builtin" = "yes" ]; then
411 config_set_boolean CONFIG_IMAGE_ELF_EMBEDDED >> $ODIR/config.xml
413 # Build hosted Unix binary?
414 if [ "$unix" = "yes" ]; then
415 config_set_boolean CONFIG_HOST_UNIX >> $ODIR/config.xml
416 #config_set_boolean CONFIG_UNIX_QT >> $ODIR/config.xml
417 #config_set_boolean CONFIG_PLUGINS >> $ODIR/config.xml
419 cat $SRCDIR/config/examples/${ARCH}_config.xml >> $ODIR/config.xml
422 echo "</config>" >> $ODIR/config.xml
423 ln -s $SRCDIR/Makefile.target $ODIR/Makefile
424 xsltproc $SRCDIR/config/xml/xinclude.xsl $SRCDIR/build.xml > $ODIR/build-full.xml
425 xsltproc $SRCDIR/config/xml/makefile.xsl $ODIR/build-full.xml > $ODIR/rules.mak
427 printf "Creating config files..."
428 xsltproc $SRCDIR/config/xml/config-c.xsl $ODIR/config.xml > $ODIR/host/include/autoconf.h
429 xsltproc $SRCDIR/config/xml/config-c.xsl $ODIR/config.xml > $ODIR/target/include/autoconf.h
430 xsltproc $SRCDIR/config/xml/config-forth.xsl $ODIR/config.xml > $ODIR/forth/config.fs
436 if [ "$SRCDIR" != "$BUILDDIR" ]; then
437 ln -s $SRCDIR/Makefile $BUILDDIR
440 echo "ODIRS=$ODIRS" >> $BUILDDIR/config-host.mak
441 echo "TARGETS=$arch_list" >> $BUILDDIR/config-host.mak