2006-04-26 23:08:19 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
2009-08-03 00:59:05 +08:00
|
|
|
#
|
|
|
|
# MOLPATH is needed if you want to build openbios-mol.elf
|
|
|
|
#
|
|
|
|
MOLPATH=$HOME/mol-0.9.71
|
|
|
|
|
2006-04-26 23:08:19 +08:00
|
|
|
if [ x"$1" = x ]; then
|
2009-01-24 04:09:26 +08:00
|
|
|
printf "Usage:\n $0 [arch-config]...\n"
|
2009-01-18 18:14:58 +08:00
|
|
|
printf "arch-config values supported for native builds:\n"
|
|
|
|
printf " amd64, ppc, sparc32, sparc64, x86\n"
|
|
|
|
printf "arch-config values supported for cross compiled builds:\n"
|
|
|
|
printf " cross-ppc, cross-sparc32, cross-sparc64, cross-x86\n"
|
2006-04-26 23:08:19 +08:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2009-08-03 00:59:05 +08:00
|
|
|
crosscflags()
|
|
|
|
{
|
|
|
|
local host=$1
|
|
|
|
local target=$2
|
|
|
|
|
|
|
|
if test "$host" = "powerpc" -o "$host" = "ppc" \
|
|
|
|
-o "$host" = "mips" -o "$host" = "s390" \
|
|
|
|
-o "$host" = "sparc32" -o "$host" = "sparc64" \
|
|
|
|
-o "$host" = "m68k" -o "$host" = "armv4b"; then
|
|
|
|
hostbigendian="yes"
|
|
|
|
else
|
|
|
|
hostbigendian="no"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# host long bits test
|
|
|
|
if test "$host" = "sparc64" -o "$host" = "ia64" \
|
|
|
|
-o "$host" = "amd64" -o "$host" = "x86_64" \
|
|
|
|
-o "$host" = "alpha"; then
|
|
|
|
hostlongbits="64"
|
|
|
|
else
|
|
|
|
hostlongbits="32"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "$target" = "powerpc" -o "$target" = "ppc" \
|
|
|
|
-o "$target" = "mips" -o "$target" = "s390" \
|
|
|
|
-o "$target" = "sparc32" -o "$target" = "sparc64" \
|
|
|
|
-o "$target" = "m68k" -o "$target" = "armv4b"; then
|
|
|
|
targetbigendian="yes"
|
|
|
|
else
|
|
|
|
targetbigendian="no"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# target long bits test
|
|
|
|
if test "$target" = "sparc64" -o "$target" = "ia64" \
|
|
|
|
-o "$target" = "amd64" -o "target" = "x86_64" \
|
|
|
|
-o "$target" = "alpha"; then
|
|
|
|
targetlongbits="64"
|
|
|
|
else
|
|
|
|
targetlongbits="32"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "$targetbigendian" = "$hostbigendian"; then
|
|
|
|
cflags="-USWAP_ENDIANNESS"
|
|
|
|
else
|
|
|
|
cflags="-DSWAP_ENDIANNESS"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "$targetlongbits" = "$hostlongbits"; then
|
|
|
|
cflags="$cflags -DNATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH"
|
|
|
|
elif test "$targetlongbits" -lt "$hostlongbits"; then
|
|
|
|
cflags="$cflags -DNATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH"
|
|
|
|
else
|
|
|
|
cflags="$cflags -DNATIVE_BITWIDTH_LARGER_THAN_HOST_BITWIDTH"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "$host" = "x86" -a "$targetlongbits" = "64"; then
|
|
|
|
cflags="$cflags -DNEED_FAKE_INT128_T"
|
|
|
|
fi
|
|
|
|
|
|
|
|
CROSSCFLAGS=$cflags
|
|
|
|
}
|
|
|
|
|
|
|
|
archname()
|
|
|
|
{
|
|
|
|
HOSTARCH=`uname -m | sed -e s/i.86/x86/ -e s/i86pc/x86/ \
|
|
|
|
-e s/sun4u/sparc64/ -e s/sparc$/sparc32/ \
|
|
|
|
-e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \
|
|
|
|
-e "s/Power Macintosh/ppc/"`
|
|
|
|
}
|
|
|
|
|
2009-12-10 08:23:02 +08:00
|
|
|
select_prefix()
|
|
|
|
{
|
|
|
|
for TARGET in ${1}-linux-gnu- ${1}-elf- ${1}-eabi-
|
|
|
|
do
|
|
|
|
if type -p ${TARGET}gcc > /dev/null
|
|
|
|
then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
2009-12-19 04:41:51 +08:00
|
|
|
if [ "$ARCH" = "$HOSTARCH" ]; then
|
|
|
|
return
|
|
|
|
fi
|
2009-12-28 18:24:32 +08:00
|
|
|
echo "ERROR: no ${1} cross-compiler found !" 1>&2
|
2009-12-10 08:23:02 +08:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2009-08-12 04:27:17 +08:00
|
|
|
if ! test -f utils/dist/debian/rules; then
|
|
|
|
echo "switch-arch must be run from the top-level source directory" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2009-01-24 04:09:26 +08:00
|
|
|
# This is needed because viewvc messes with the permissions of executables:
|
|
|
|
chmod 755 utils/dist/debian/rules
|
|
|
|
chmod 755 config/scripts/switch-arch
|
|
|
|
chmod 755 config/scripts/reldir
|
2009-08-03 00:59:05 +08:00
|
|
|
|
2009-01-31 17:07:29 +08:00
|
|
|
if test "x$HOSTARCH" = "x"; then
|
2009-08-03 00:59:05 +08:00
|
|
|
archname
|
2009-01-31 17:07:29 +08:00
|
|
|
fi
|
2006-04-26 23:08:19 +08:00
|
|
|
|
2009-08-03 02:20:53 +08:00
|
|
|
VERSION=`head VERSION`
|
|
|
|
|
2009-01-24 04:09:26 +08:00
|
|
|
echo "Configuring OpenBIOS on $HOSTARCH for $*"
|
|
|
|
for RULES_ARCH in $*; do
|
2009-08-12 04:27:17 +08:00
|
|
|
if ! test -f config/examples/${RULES_ARCH}_config.xml; then
|
|
|
|
echo "Cannot find config/examples/${RULES_ARCH}_config.xml" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2009-08-03 00:59:05 +08:00
|
|
|
ARCH=`echo $RULES_ARCH | sed s/cross-//g`
|
|
|
|
case $ARCH in
|
|
|
|
amd64)
|
2009-12-10 08:23:02 +08:00
|
|
|
select_prefix x86_64
|
2009-08-03 00:59:05 +08:00
|
|
|
CFLAGS="-fno-builtin"
|
2009-08-08 22:40:36 +08:00
|
|
|
AS_FLAGS=
|
2009-08-03 00:59:05 +08:00
|
|
|
;;
|
|
|
|
|
|
|
|
ppc)
|
2009-12-10 08:23:02 +08:00
|
|
|
select_prefix powerpc
|
2009-08-03 00:59:05 +08:00
|
|
|
CFLAGS="-msoft-float -fno-builtin-bcopy -fno-builtin-log2"
|
2009-08-08 22:40:36 +08:00
|
|
|
AS_FLAGS=
|
2009-08-03 00:59:05 +08:00
|
|
|
;;
|
|
|
|
|
|
|
|
sparc32)
|
2009-12-10 08:23:02 +08:00
|
|
|
select_prefix sparc
|
2009-08-03 00:59:05 +08:00
|
|
|
CFLAGS="-Wa,-xarch=v8 -Wa,-32 -m32 -mcpu=supersparc -fno-builtin"
|
|
|
|
AS_FLAGS="-Wa,-xarch=v8 -Wa,-32"
|
|
|
|
;;
|
|
|
|
|
|
|
|
sparc64)
|
2009-12-10 08:23:02 +08:00
|
|
|
select_prefix sparc64
|
2009-08-03 00:59:05 +08:00
|
|
|
CFLAGS="-Wa,-xarch=v9b -Wa,-64 -m64 -mcpu=ultrasparc -mcmodel=medany -fno-builtin"
|
|
|
|
AS_FLAGS="-Wa,-xarch=v9b -Wa,-64"
|
|
|
|
;;
|
|
|
|
|
|
|
|
x86)
|
2009-12-10 08:23:02 +08:00
|
|
|
select_prefix i486
|
2009-08-03 00:59:05 +08:00
|
|
|
CFLAGS="-fno-builtin -m32"
|
|
|
|
AS_FLAGS="-Wa,-32"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
if test "$ARCH" = "$RULES_ARCH"; then
|
|
|
|
TARGET=""
|
|
|
|
fi
|
|
|
|
crosscflags $HOSTARCH $ARCH
|
2009-01-24 04:09:26 +08:00
|
|
|
OBJDIR=obj-$ARCH
|
|
|
|
printf "Initializing build tree $OBJDIR..."
|
|
|
|
rm -rf "$OBJDIR"
|
|
|
|
mkdir "$OBJDIR"
|
|
|
|
mkdir -p $OBJDIR/target
|
|
|
|
mkdir -p $OBJDIR/target/include
|
|
|
|
mkdir -p $OBJDIR/target/arch
|
|
|
|
mkdir -p $OBJDIR/target/arch/unix
|
|
|
|
mkdir -p $OBJDIR/target/arch/$ARCH
|
|
|
|
mkdir -p $OBJDIR/target/arch/ppc
|
|
|
|
mkdir -p $OBJDIR/target/arch/ppc/briq # no autodetection of those..
|
|
|
|
mkdir -p $OBJDIR/target/arch/ppc/pearpc
|
|
|
|
mkdir -p $OBJDIR/target/arch/ppc/qemu
|
|
|
|
mkdir -p $OBJDIR/target/arch/ppc/mol
|
|
|
|
mkdir -p $OBJDIR/target/arch/x86
|
|
|
|
mkdir -p $OBJDIR/target/arch/x86/xbox
|
|
|
|
mkdir -p $OBJDIR/target/libgcc
|
|
|
|
mkdir -p $OBJDIR/target/kernel
|
|
|
|
mkdir -p $OBJDIR/target/modules
|
|
|
|
mkdir -p $OBJDIR/target/fs
|
|
|
|
mkdir -p $OBJDIR/target/fs/grubfs
|
|
|
|
mkdir -p $OBJDIR/target/fs/hfs
|
|
|
|
mkdir -p $OBJDIR/target/fs/hfsplus
|
2009-11-22 17:26:50 +08:00
|
|
|
mkdir -p $OBJDIR/target/fs/iso9660
|
2009-11-22 17:47:08 +08:00
|
|
|
mkdir -p $OBJDIR/target/fs/ext2
|
2009-01-24 04:09:26 +08:00
|
|
|
mkdir -p $OBJDIR/target/drivers
|
|
|
|
mkdir -p $OBJDIR/target/libc
|
|
|
|
mkdir -p $OBJDIR/host/include
|
|
|
|
mkdir -p $OBJDIR/host/kernel
|
|
|
|
mkdir -p $OBJDIR/forth
|
|
|
|
ln -s ../../../include/$ARCH $OBJDIR/target/include/asm
|
|
|
|
#compile the host binary with target settings instead
|
|
|
|
#ln -s ../../../include/$HOSTARCH $OBJDIR/host/include/asm
|
|
|
|
echo "ok."
|
|
|
|
|
|
|
|
cd $OBJDIR
|
|
|
|
SRCDIR=..
|
|
|
|
ODIR=.
|
|
|
|
|
|
|
|
printf "Creating target Makefile..."
|
2009-08-03 00:59:05 +08:00
|
|
|
echo "ARCH=$ARCH" > $ODIR/config.mak
|
|
|
|
echo "TARGET=$TARGET" >> $ODIR/config.mak
|
|
|
|
echo "CFLAGS=$CFLAGS" >> $ODIR/config.mak
|
|
|
|
echo "AS_FLAGS=$AS_FLAGS" >> $ODIR/config.mak
|
|
|
|
echo "HOSTARCH?=$HOSTARCH" >> $ODIR/config.mak
|
|
|
|
echo "CROSSCFLAGS=$CROSSCFLAGS" >> $ODIR/config.mak
|
2009-08-03 02:20:53 +08:00
|
|
|
echo "VERSION=\"$VERSION\"" >> $ODIR/config.mak
|
2009-08-03 00:59:05 +08:00
|
|
|
ln -s $SRCDIR/config/xml/rules.xml $ODIR/rules.xml
|
2009-01-24 04:09:26 +08:00
|
|
|
ln -s $SRCDIR/config/examples/${RULES_ARCH}_config.xml $ODIR/config.xml
|
2009-08-03 00:59:05 +08:00
|
|
|
ln -s ../Makefile.target $ODIR/Makefile
|
2009-01-24 04:09:26 +08:00
|
|
|
xsltproc $SRCDIR/config/xml/xinclude.xsl $SRCDIR/build.xml > $ODIR/build-full.xml
|
2009-08-03 00:59:05 +08:00
|
|
|
xsltproc $SRCDIR/config/xml/makefile.xsl $ODIR/build-full.xml > $ODIR/rules.mak
|
2009-01-24 04:09:26 +08:00
|
|
|
echo "ok."
|
|
|
|
printf "Creating config files..."
|
|
|
|
xsltproc $SRCDIR/config/xml/config-c.xsl $SRCDIR/config/examples/${RULES_ARCH}_config.xml > $ODIR/host/include/autoconf.h
|
|
|
|
xsltproc $SRCDIR/config/xml/config-c.xsl $SRCDIR/config/examples/${RULES_ARCH}_config.xml > $ODIR/target/include/autoconf.h
|
|
|
|
xsltproc $SRCDIR/config/xml/config-forth.xsl $SRCDIR/config/examples/${RULES_ARCH}_config.xml > $ODIR/forth/config.fs
|
|
|
|
echo "ok."
|
2009-08-03 00:59:05 +08:00
|
|
|
|
|
|
|
grep CONFIG_MOL $ODIR/forth/config.fs >/dev/null && ( \
|
|
|
|
echo "Using MOL path $MOLPATH..."; \
|
|
|
|
ln -s $MOLPATH/src/shared/osi_calls.h $ODIR/target/include/; \
|
|
|
|
ln -s $MOLPATH/src/shared/osi.h $ODIR/target/include/; \
|
|
|
|
ln -s $MOLPATH/src/shared/prom.h $ODIR/target/include/; \
|
|
|
|
ln -s $MOLPATH/src/include/boothelper_sh.h $ODIR/target/include/; \
|
|
|
|
ln -s $MOLPATH/src/include/video_sh.h $ODIR/target/include/; \
|
|
|
|
ln -s $MOLPATH/src/include/pseudofs_sh.h $ODIR/target/include/; \
|
|
|
|
ln -s $MOLPATH/src/include/kbd_sh.h $ODIR/target/include/; \
|
|
|
|
ln -s $MOLPATH/src/drivers/disk/include/scsi_sh.h $ODIR/target/include/; \
|
|
|
|
ln -s $MOLPATH/src/drivers/disk/include/ablk_sh.h $ODIR/target/include/ ) || true
|
|
|
|
|
2009-01-24 04:09:26 +08:00
|
|
|
cd $SRCDIR
|
|
|
|
done
|