make buildkernel

Hi Guys,

I am trying to see what's happening when I go through the various stages of configuring, building and installing a kernel.

What happens when I do:

Code:
make buildkernel

I know it compiles my custom kernel, using KERNCONFIG=SOMEKERNEL.
The handbook just goes over this and straight to the make installkernel command.

But where is the kernel saved to when it's done building?

*EDIT -> Sorry, I forget to ask, what are the symbols files for, can I do without them?

TIA,
Niels
 
niellusNL said:
But where is the kernel saved to when it's done building?
All that stuff ends up in /usr/obj/usr/src/.

*EDIT -> Sorry, I forget to ask, what are the symbols files for, can I do without them?
They're used for debugging. If you don't debug you can remove them.

Remove this line if you're building a custom kernel:
Code:
makeoptions     DEBUG=-g                # Build kernel with gdb(1) debug symbols
 
Hi SirDice,

Thanks for the quick reply! I'm just done building a kernel, configured without sound. This is just for testers and the kernel name is TEST (I did KERNCONF=TEST, after configuring).

In my /etc/make.conf I also added NO_MODULES=yes, because I want to only keep the *.ko files I need (and copy over the ones I need, from /boot/kernel/).
So ultimately I would like to keep my kernel file and just the appropiate *.ko files.

I followed the path you pointed me to and found /usr/obj/usr/src/sys/TEST. When I enter:
Code:
file kernel
From this directory I get:
Code:
kernel: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked (uses shared libs), not stripped
. So I think I found the kernel file I just created! \o/

The directory also contains loads of *.h and *.o files, what are these? Some of them are empty and some of them contain ASCII. I assumed I only built a kernel (because of NO_MODULES=yes)?
 
The .h files are include files, they usually define how a function or variable should be used. The .o files are object files. It's those that get linked into an exectable. A kernel is a bit of an exception as it's not really an "executable" in the traditional sense (like for example /sbin/ping). So it needs to be linked differently.

Wikipedia: Object file
Wikipedia: Linker (computing)
 
More tips for people reading this thread.
You can put
Code:
KERNCONF=MYKERNEL
into /etc/make.conf, then you do not need to add it to your command line.
It's recommended you keep MYKERNEL in a safe place, I keep mine in /root and create a symlink to it in kernel sources. This way your precious config will survive in case you flush sources.
 
Back
Top