Tuesday, January 3, 2012

Whats with FreeBSD and cross compiling?

From the beginning me and FreeBSD didn't go along very well when I was working on RouterStation Pro. Maybe it was because of my approach to cross-compiling. In my head I want to do everything on the host computer and then "deploy" it on the target.

Now cross compiling the kernel and world did work out for me in the end, and boy do I love how it works:

make TARGET=mips TARGET_ARCH=mipseb buildworld
make TARGET=mips TARGET_ARCH=mipseb KERNCONF=AR71XX buildkernel

Ok, I still hate the fact that I need to tell FreeBSD explicitly to not clean-up before compiling again when I just did a small change in the kernel, added a printf for instance? So then I change the buildkernel command to:

make TARGET=mips TARGET_ARCH=mipseb KERNFAST=AR71XX buildkernel

KERNFAST will just recompile the modified folder and then link everything, so why don't FreeBSD have KERNFAST as default?

Well you will get used to that eventually, so now we have a compiled kernel and world (I am not going deep into this, how do the kernel boot? What about the boot loader? etc..). Ok, now if I want rsync on my target what is the next step?

rsync is a third-party program residing under the /usr/ports folder, and somehow its not so easy to cross-compile. Why? I don't know, there is surely good reasons and one need to study the ports framework. But hasn't that bother anyone?

One day I hope to find an easy way to cross-compile ports, something like:

cd /usr/ports/somewhere
make TARGET=mips TARGET_ARCH=mipseb install

Lets say that will install somewhere in /usr/obj/mips.mipseb/... if so then I will die a happy man =)

While we are wishful, it would be nice to have things like:

PORTS_OVERRIDE=...
WITHOUT_PORTS=...
make buildports
make installports

just things nice to have, why not add a ports configuration file? =D