Compilation taking too long time

Polytropon freebsd at
Fri Apr 10 02:49:41 UTC 2015

On Fri, 10 Apr 2015 01:08:25 +0530, Pratik Singhal wrote:
> Whenever I make a small change in the kernel, say apply a patch which only
> affects 1 or 2 files and compile the kernel using the command :-
> make KERNCONF=config_file buildkernel
> It takes a lot of time (around 1 hour) and starts rebuilding the whole
> kernel instead of just building the relevant files.
> I have checked the freeBSD handbook and checked the targets in Makefile ,
> but none of them provide information about this situation.

Check the comment headers of /usr/src/Makefile and /usr/src/Makefile.inc1,
as well as "man src.conf".

> How, can I make sure that only the relevant files are built and not the
> whole kernel again and again ?

Building an operating system kernel is a complex task. It's
usually not as easy as "just compile this one file into
machine code, then magically splice it into the whole
process that creates the kernel". ;-)

In fact, running a _clean_ building process (when a source
file has changed) is something quite typical and intended.
The make utility, aided by several Makefiles across the
source tree, decides what to do. Interfering with this
logic can lead to a nonfunctional kernel, even if you
say that just "1 or 2 files" are affecte by a change.
The make utility is meant to deal with the decisions
that those changes imply.

Doing things like "resume an interrupted build process"
or "cope with a small change" are therefore hard to

However, it's possible to build parts of the kernel (and
especially kernel modules) by running "make" in their
respective subdirectories. Of course this does not lead
to a fully-functional kernel, but in case you just want
to rebuild a module, this approach might work.

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

More information about the freebsd-questions mailing list