Subject: kernel cross-compile
To: None <port-hp300@NetBSD.ORG>
From: Werner Griessl <werner@btp1da.phy.uni-bayreuth.de>
List: port-hp300
Date: 01/24/1997 19:57:50
Hi hp-netbsd community,

Asuming we have a (older) hp300 and a (much faster) FreeBSD system,
we can speed up the kernel compilation with the famous gcc-cross-compiler.
(I believe it's very similar using a i386-based netbsd.)

I did the folowing steps to install the cross-compiler and compile the kernel:

 F means FreeBSD (3.0-current Pentium 100MHz 32Mb scsi)
 N means NetBSD  (1.2-Release hp370    33MHz  8Mb hpib)

first create the cross-compiler hpgcc on F

1) binutils

tar xvzf binutils-2.7.tar.gz
cd binutils-2.7
./configure --target=m68k-hp-netbsd
make CC="cc"
make CC="cc" install
(make distclean)


2) the cross-compiler

install the whole tree
/usr/include from N to /usr/local/m68k-hp-netbsd/include on F

copy from N /usr/lib/crt0.o gcrt0.o scrt0.o libc.a libm.a
to /usr/local/m68k-hp-netbsd/lib on F

tar xvzf gcc-2.7.2.1.tar.gz
cd gcc-2.7.2.1
./configure --target=m68k-hp-netbsd
make CC="cc" CFLAGS="-O -s"
make CC="cc" CFLAGS="-O -s" install
(make distclean)

3) make the (executable !) script "hpgcc" in /usr/local/bin/ on F

#!/bin/sh
# this is hpgcc
/usr/local/bin/m68k-hp-netbsd-gcc $*

That's all, now we have a cross-compiler for the hp300 running on FreeBSD


I did  the following steps to compile a kernel for the hp300 on FreeBSD:

mount(nfs) A_FreeBSD_directory to /N
mkdir /N/sys
cd /usr/src
mv sys sys.loc                          this saves the old tree
ln -s /N/sys sys                        link the new sys
cd sys.loc
tar cpf - . | (cd /N/sys; tar xvpf -)   populate the new sys
configure your kernel as usual
cd /sys/arch/hp300/compile/YOUR_KERNEL

(N: make clean)
F: make genassym CC=hpgcc       create ./genassym
N: make assym.h                 because ./genassym don't run on F
F: make CC=hpgcc       until error on begin of kernlib       ( ~ 10 min)
N: make                to compile the rest and link kernel   ( ~ 15 min)

The time for this is half an hour and saves me
more than 3 hours for a complete kernel built from scratch.

I know it's not perfect, but i can live with it.

Werner