Code: Select all
cd builddir
make -C /usr/src/linux O=$PWD <target>I can't find any documentation as to when said source symlink is created, nor indeed overwritten. Tests show that "make clean" doesn't create it (which was a surprise). "make defconfig" does, so I suspect it's anything that creates something. Which is actually rather annoying.
The trouble is, having created the symlink, it's then permissible to just use "make <target>" without the "-C" parameter; make follows the symlink to the kernel source - note, the versioned /usr/src/linux-5.12.1-gentoo or whatever /usr/src/linux pointed at when the symlink was created. Which may be the right thing to do; it means you can download a new kernel and update the symlink, but make will still address the old version until you do something to update the source symlink.
I can see a couple of use cases:
a) normal kernel building: update gentoo-sources with USE="symlink", and issue "make -C /usr/src/linux -O=builddir clean oldconfig" to start building a new kernel with the latest sources.
b) external kernel building: in this case I'm thinking of cross-compiling a kernel for a Raspberry Pi or some other host. For whatever reason, I may not wish to update to the latest sources, so I'd want to simply "cd builddir; make <target>"
I'm trying to write a single shell script to simplify this, as it's far too easy to make a mess instead of a kernel. Perhaps a new Makefile target "newsource" that takes an optional directory defaulting to /usr/src/linux (or more likely a fake target handled in the script rather than dare to touch a Makefile). Which brings me to the title of this post: when/how should the script cause the "source" symlink to be set? I thought it might be enough to "make -C ... kernelversion", but that reports the version from the "-C" source, while leaving the source symlink pointing where it was, which is useless!
MY gut feel is that this is just a shambles, rather than a documented and well-considered API
(For anyone interested, my documentation thus far is in my user page in the wiki.)


