Fwd: An OS X 10.5 -> *-linux-gnu HOWTO, and a help req.

David Smoot davidsmoot@gmail.com
Mon Jan 21 17:04:00 GMT 2008


Whoopsie... wrong address...


---------- Forwarded message ----------
From: David Smoot <davidsmoot@gmail.com>
Date: Jan 16, 2008 9:02 PM
Subject: Re: An OS X 10.5 -> *-linux-gnu HOWTO, and a help req.
To: crossgcc-digest-help@sourceware.org, jfannin@gmail.com


Judging from your comments you sound like you know more about this
topic than I but I've had some luck with what you are trying to do so
maybe my experience can be of help.  I've built a working toolchain
for a embedded powerpc-604 processor using cross test.  I built it
under 10.4 but I believe 10.5 won't be a problem.

Here's the trick:
The mac versions of awk, sed, and make are not gnu compatible.  The
easiest thing to do is use the macports system to set up gnu compliant
versions of awk, sed, and make and then be sure that crosstest uses
them instead of the built in OS X versions.

I plagiarized the script  of another guy but I do not remember where I
got it from nor do I guarantee if it will get you where you need to
go.  But it worked for me eventually.  I think I manually installed
the gnu versions of certain tools using macports (used to be called
darwinports) and fink and then used the script below.  Hopefully it
will help you.

David
#!/bin/sh
#
# This script builds a Xtoolchain crosscompiler package
#
# useage: build.sh processor languages gcc-version libc-version [
headers-version ]
#
# To use it you must install Darwinports-1.1 (or later)
#
# Copyright by H. N. Schaller, Jan 2006
#
# modified by dsmoot to suit my needs for cross tool development for the UEIPAC

$PROCESSOR="powerpc-604"
$LANGUAGES="c,c++"
$GCCVERSION="4.02"
$LIBCVERSION="2.3.5"
$HEADERSVERSION=""
export HERE=$PWD

if [ "$HEADERVERSION" = "" ]
  then HDRS=""
  else HDRS="-hdrs-$HEADERVERSION"
fi
export BUILD_VERSION="$PROCESSOR-gcc-$GCCVERSION-glibc-$LIBCVERSION$HDRS"
export XBUILD_NAME="Xtoolchain-$BUILD_VERSION"

[ -r "$HERE/GNUTOOLS" ] && echo "*** Warning: This file system is not
distinguishing upper and lower case filenames. This may cause trouble!
***"

echo Building $XBUILD_NAME.
date

set -ex

export PATH=$HERE/gnutools:/opt/local/bin:/Developer/Xtoolchain/tools:$PATH
    #
make us find wget etc.

# allow to fetch files from the online-repositories

[ -r /opt/local/bin/wget ] || /opt/local/bin/port install wget || exit 1

# install GNU tools and override through $PATH

mkdir -p gnutools

#[ -r gnutools/awk ] || ( /opt/local/bin/port install gawk && ln -s
/opt/local/bin/gawk gnutools/awk )
#[ -r gnutools/sed ] || ( /opt/local/bin/port install gsed && ln -s
/opt/local/bin/gnused gnutools/sed )
#[ -r gnutools/make ] || ( /opt/local/bin/port install gmake && ln -s
/opt/local/bin/gmake gnutools/make ) # /usr/bin/make has builtin-rule
for .m.c: which conflicts with the sources of gprof
#[ -r /opt/local/bin/msgfmt ] || /opt/local/bin/port install gettext
[ -r gnutools/make ] || (ln -s /opt/local/bin/gmake gnutools/make)

echo awk is: $(which awk)
echo sed is: $(which sed)
echo make is: $(which make)

# wrap Xcode as & ld so that they pretend to be the minimum required binutils

echo '[ "$1" = -v ] && echo GNU assembler 2.13 || /usr/bin/as $*' >gnutools/as
echo '[ "$1" = --version ] && echo GNU ld 2.13 || /usr/bin/ld $*' >gnutools/ld
chmod a+x gnutools/as
chmod a+x gnutools/ld

[ -r crosstool-0.43.tar.gz ] || wget
http://kegel.com/crosstool/crosstool-0.43.tar.gz
[ -r crosstool-0.43 ] || tar -xzvf crosstool-0.43.tar.gz

[ -r /Developer/Xtoolchain/gcc-$GCCVERSION-glibc-$LIBCVERSION ] || (
cd crosstool-0.43

export GCC_LANGUAGES="$LANGUAGES"

export TARBALLS_DIR="$PWD/downloads"
export RESULT_TOP="/Developer/Xtoolchain"

# Really, you should do the mkdir before running this,
# and chown /opt/crosstool to yourself so you don't need to run as root.

mkdir -p $RESULT_TOP

# Build the toolchain.  Takes a couple hours and a couple gigabytes -
no not really that long and large.

# gcc-3.3 doesn't support this, need gcc-3.4
#eval `cat arm-xscale.dat gcc-3.4.0-glibc-2.3.2.dat` sh all.sh --notest
#eval `cat arm-xscale.dat gcc-3.4.1-glibc-2.3.3.dat` sh all.sh --notest
#eval `cat arm-xscale.dat gcc-3.4.1-glibc-20040827.dat` sh all.sh --notest
#eval `cat arm-xscale.dat gcc-3.4.2-glibc-20040827.dat` sh all.sh --notest

eval `cat $PROCESSOR.dat gcc-$GCCVERSION-glibc-$LIBCVERSION$HDRS.dat`
sh all.sh --notest

file /Developer/Xtoolchain/gcc-$GCCVERSION-glibc-$LIBCVERSION/$TARGET/tmp/*

printf '#include <stdio.h>\nint main() { printf("Hello World! %lf",
3.0*5.0); }\n' >test.c
/Developer/Xtoolchain/gcc-$GCCVERSION-glibc-$LIBCVERSION/$TARGET/$TARGET/bin/gcc
test.c
ls -l a.out
file a.out

printf '#include <iostream>\nusing namespace std; int main() { cout <<
"Hello World!\\n"; return 0; }\n' >test.cpp
/Developer/Xtoolchain/gcc-$GCCVERSION-glibc-$LIBCVERSION/$TARGET/$TARGET/bin/gcc
test.cpp -lstdc++
ls -l a.out
file a.out

rm -f "$HERE/packages/$XBUILD_NAME.pkg"

)

[ -r "packages/$XBUILD_NAME.pkg" ] || (
cd packages
setplist Description.plist IFPkgDescriptionVersion "$BUILD_VERSION"
setplist Info.plist CFBundleShortVersionString
"gcc-$GCCVERSION-glibc-$LIBCVERSION"
mkpkg "Xtoolchain" "$BUILD_VERSION"
"/Developer/Xtoolchain/gcc-$GCCVERSION-glibc-$LIBCVERSION" Info.plist
Description.plist installer-resources
rm -f "$HERE/$XBUILD_NAME.dmg"
) || exit 1

[ -r "$XBUILD_NAME.dmg" ] || (
mkdir /tmp/dmg$$
cp -R README.rtf build.sh Makefile tools "packages/$XBUILD_NAME.pkg" /tmp/dmg$$
echo >"/tmp/dmg$$/target=$PROCESSOR"
echo >"/tmp/dmg$$/languages=$LANGUAGES"
echo >"/tmp/dmg$$/gcc=$GCCVERSION"
echo >"/tmp/dmg$$/glibc=$LIBCVERSION"
echo >"/tmp/dmg$$/headers=$HEADERVERSION"
mkdmg Xtoolchain "$BUILD_VERSION" /tmp/dmg$$
rm -rf /tmp/dmg$$
) || exit 1

echo Done with $XBUILD_NAME.
date

--
For unsubscribe information see http://sourceware.org/lists.html#faq



More information about the crossgcc mailing list