Re: multiple kernels with the same world

From: Warner Losh <imp_at_bsdimp.com>
Date: Thu, 16 Oct 2025 15:45:02 UTC
On Thu, Oct 16, 2025 at 9:39 AM Michael Grimm <trashcan@ellael.org> wrote:

> Lexi Winter <ivy@FreeBSD.org> wrote:
> > Anthony Pankov wrote in <575313120.20251014120303@yahoo.com>:
>
> >> I wander can I build multiple kernel from the same sources while using
> >> once builded world?
> >>
> >> My aim is to have basepkgs containing different kernels. It would be
> >> nice to have FreeBSD-kernel-general-*.pkg,
> >> FreeBSD-kernel-virtualmachine-*.pkg etc. in the same base package
> >> repository.
> >
> > % make KERNCONF='GENERIC FOO BAR BAZ' buildworld buildkernel
> update-packages
> >
> > the first kernel listed in KERNCONF will be installed in /boot/kernel,
> > the rest will be installed in /boot/kernel.NAME.  for consistency, i
> > prefer to always build GENERIC as the first kernel, but there's no
> > actual requirement to do that.
>
> Cool.
>
> Please excuse my ignorance but is there a way to get /boot/kernel.NAME
> installed without going via packages?
>
> I am used to build and install by source. Thus I tried:
>
> MWN> make KERNCONF='GENERIC CUSTOM' DESTDIR=/tmp/NEW installkernel | & tee
> LOG
>
> MWN> grep '^>>>' LOG
> >>> Install check kernel started on Thu Oct 16 17:27:31 CEST 2025
> >>> Installing kernel GENERIC on Thu Oct 16 17:27:31 CEST 2025
> >>> Installing kernel GENERIC completed on Thu Oct 16 17:27:44 CEST 2025
> >>> Install kernel(s) GENERIC completed in 13 seconds, ncpu: 16
>
> MWN> ls -al /tmp/NEW/boot | grep kernel
> drwxr-xr-x  2 root wheel 717 Oct 16 17:29 kernel
>
> Only the first kernel found in KERNCONF will be installed, though.
>
> Is there a way to end up in something like the following?
>
> tmp/NEW/boot/kernel
> tmp/NEW/boot/kernel.GENERIC
>
> P.S. I tried make KERNCONF='GENERIC CUSTOM' KERNEL='GENERIC CUSTOM'
> DESTDIR=/tmp/NEW installkernel
>      same results as mentioned above
>

The only way I know is to do them one at a time. The code in Makefile.inc1
treats the first one specially. You'd have to hack it so it doesn't.

Warner