Subject: cross-compiler building notes (Was: Is 1.4.1 fpe busted?)
To: None <port-mac68k@netbsd.org>
From: Chris Baird <cbaird@turing.une.edu.au>
List: port-mac68k
Date: 09/07/1999 07:23:14
The cross-binutils should be installed before gcc, so the later's configure
will find and use them. I found it easiest to download binutils and untar
it-- binutils-2.9.1 was the closest at hand, but NetBSD-1.4.1 was released
with 2.9.

binutils-2.9.1 has a sys_errlist problem in libiberty/strerror.c at line
461. Replace
    static const char **sys_errlist;
with
    static __const char *__const *sys_errlist;

    binutils-2.9.1$ ./configure --host=i386-pc-netbsd1.4 \
	--target m68k-apple-netbsd1.4 --prefix=/usr/local
    binutils-2.9.1$ make
    binutils-2.9.1# umask 022; make install

There might be complaints if makeinfo isn't available. Building binutils
will require about 32M of disk space.


Installing mac68k header files and libraries: I downloaded
ftp://ftp.xx.netbsd.org/pub/NetBSD/NetBSD-1.4.1/mac68k/binary/sets/comp.tgz
and took what was needed:

    $ cd path_to_untarred_comp_tgz/usr/
    $ rm -rf include/dev/microcode lib/*_p.a lib/*_pic.a
    # tar cf - include|tar -C /usr/local/m68k-apple-netbsd1.4 -xf -
    # tar cf - lib|tar -C /usr/local/m68k-apple-netbsd1.4 -xf -


Now for gcc. I used the NetBSD-supplied gnu sources (egcs-2.91.60):

    tmp# umask 022; tar -C /usr/src/gnu/dist -cf - gcc | tar -xf -
    tmp# cp /usr/src/gnu/dist/install.sh gcc/

Configure exactly as binutils:

    gcc$ ./configure --host=i386-pc-netbsd1.4 --target=m68k-apple-netbsd1.4 \
	--prefix=/usr/local

    gcc$ make LANGUAGES="c"

All going to plan, the make will crash when it reaches libgcc.

    gcc# make -k LANGUAGES="c" install

Again, this will crash (don't forget the "-k"). Building gcc will require
about 58M of disk space.


Post-install cleanup:

    # find /usr/local/m68k-apple-netbsd1.4 -type d|xargs chmod a+rx $1
    # find /usr/local/m68k-apple-netbsd1.4 -type f|xargs chmod a+r $1
    # cd /usr/local/m68k-apple-netbsd1.4/bin
    # ln -s ../../bin/m68k-apple-netbsd1.4-gcc cc
    # ln -s ../../bin/m68k-apple-netbsd1.4-size size
    # ln -s ../../bin/m68k-apple-netbsd1.4-addr2line addr2line
    # ln -s ../../bin/m68k-apple-netbsd1.4-c++filt c++filt
    # ln -s ../../bin/m68k-apple-netbsd1.4-gasp gasp
    # ln -s ../../bin/m68k-apple-netbsd1.4-objcopy objcopy
    # ln -s ../../bin/m68k-apple-netbsd1.4-objdump objdump
    # ln -s ../../bin/m68k-apple-netbsd1.4-strings strings
    # ln -s ../../bin/m68k-apple-netbsd1.4-protoize protoize
    # ln -s ../../bin/m68k-apple-netbsd1.4-unprotoize unprotoize
    # strip *; chmod 755 *


Using the cross-compiler to build a kernel:

    # config FOO; cd ../compile/FOO
    # declare/setenv/whatever MACHINE_ARCH=m68k
    # declare/setenv/whatever PATH=/usr/local/m68k-apple-netbsd1.4/bin:$PATH
    # make depend netbsd

For binutils-2.9.1, I found it necessary to edit /sys/arch/m68k/fpsp/asm2gas,
line 149 from:
    s/#:/#:0x/g
to
    s/#:/#0x/g


For those trusting types who would like the cross-compiler without going
through the above, I've put up a tarfile with all the necessary executables
and files for installation under /usr/local/ (package? what's that?), at
http://mcs.une.edu.au/~cbaird/gcc-i386m68k.tar.gz (5060kB compressed,
16M untarred).

--
Chris Baird,, <cjb@brushtail.apana.org.au>