# make buildkernel



## niellusNL (Nov 7, 2012)

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:


```
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


----------



## SirDice (Nov 7, 2012)

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:

```
makeoptions     DEBUG=-g                # Build kernel with gdb(1) debug symbols
```


----------



## niellusNL (Nov 7, 2012)

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:

```
file kernel
```
From this directory I get:

```
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)?


----------



## Speedy (Nov 7, 2012)

You should use MODULES_OVERRIDE to build the modules you need.


----------



## SirDice (Nov 7, 2012)

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)


----------



## Speedy (Nov 7, 2012)

More tips for people reading this thread. 
You can put 
	
	



```
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.


----------

