NetBSD src tree itself is fully cross-buildable, however you might want to set up a "generic" cross compilation environment that targets some particular NetBSD platform.
If you don't care about time and disc space, just do:
$ cross=/nbcross # root of the cross-build environment $ m=hpcsh # your target platform $ ./build.sh -m $m -u -U \ -T $cross/tools -R $cross/release \ -O $cross/obj/$m -D $cross/distrib/$m \ distribution
We start by building the cross toolchain:
$ cross=/nbcross # root of the cross-build environment $ m=hpcsh # your target platform $ ./build.sh -m $m -u -U \ -T $cross/tools -R $cross/release \ -O $cross/obj/$m -D $cross/distrib/$m \ tools
Now we create the hierarchy of objdirs:
$ $cross/tools/bin/nbmake-$m obj
Then we populate distdir with target's headers and libraries:
The list of targets is out of date, consult top-level Makefile for the up-to-date list.$ $cross/tools/bin/nbmake-$m do-tools do-distrib-dirs includes \ do-tools-compat do-lib-csu do-gnu-lib-libgcc3 do-lib-libc \ do-lib-libdes do-lib do-gnu-lib
I wonder if we should provide a top-level make target to do the above...
At this point $cross/tools and $cross/distrib/$m contain all the necessary bits. All we need is to connect them together. The NetBSD build doesn't need it as it specifies full paths, but for our generic cross environment we want to avoid that. Hence we do a little bit of symlinking. In the next command $gnu_target_name stands for the triplet that describes our target. For our hpcsh example it is shle--netbsdelf.
$ cd $cross/tools/$gnu_target_name
We create a symlink to target includes:
$ ln -s ../../distrib/$m/usr/include sys-include
And a bunch of symlinks to target libraries:
$ cd lib $ ln -s ../../../distrib/$m/usr/lib/* . $ ln -s -f ../../../distrib/$m/lib/* .
The order of the last two command is important, because /usr/lib in the distdir contains absolute symlinks to distdir's /lib that are not correct in the host environment, the second ln(1) will replace them with correct symlinks pointing to destdir's /lib
That's it. You can now use the toolchain from $cross/tools/bin to compile programs for your NetBSD target machine.