recompiling part of base and/or kernel

Hi all,

I was wondering: Is there a standard (deterministic) way which I can follow when I wish to recompile (and reinstall of course!!!!) only part of the world and/or the kernel? Moreover, what options should I use so as the "make" command won't have to recompile everything from scratch if interrupted during the make buildworld and make buildkernel procedures?

Thank you all for your time in advance!
 
It's Makefiles all the way down.

So if you want to rebuild just a single driver module, say fxp, you can change to that directory and just do make:
# cd /usr/src/sys/modules/fxp
# make; make install

That rebuilds and installs the module, but it won't help if you've got it built into the kernel.

If you want to restart a buildworld/buildkernel after an error, that might be trickier. In theory, you should be able to fix the problem and then just do make again, and it will start where it left off (sort of, due to Makefiles). In practice, it depends on the error. There might have some wrongly-built object code that needs to be cleared.

If you're just concerned about time, devel/ccache is another way to fix that. After a failed buildworld or kernel, remove /usr/obj/ as usual and just build it again. Everything that built in the previous step will come from cache instead of being compiled again.
 
Very nice directions. Let me ask a few more questions to clear things up. You said that by running make && make install in some kernel module's directory the module will be rebuilt, but not the kernel. This reminded me of one of my initial questions regarding the FreeBSD kernel that I haven't answered:

Where do I configure which parts of the kernel should be built as modules and which not?

Now, regarding your answer: When I [cmd=]make buildkernel[/cmd] it always cleans first, so it recompiles everything. It never starts from where I left it. Of course, your direction towards devel/ccache is very welcome and I will try it the soonest.

And another thing that hasn't been answered: ok about the kernel; what happens with the userland (the world)? When I need to patch some code due to a security advisory related with some program, I go to the program's directory and depending on the program I have to either

# make && make dep && make install
or just
# make && make install

or give other make options to achieve my goal. Isn't there a "generic, FreeBSD" way of doing this (as in ports I mean)?

Thanx again!
 
mamalos said:
Where do I configure which parts of the kernel should be built as modules and which not?

All the modules are built, but it's the kernel config file that controls which are included in the kernel. For example, /usr/src/sys/i386/conf/GENERIC.

Now, regarding your answer: When I "make buildkernel" it always cleans first, so it recompiles everything. It never starts from where I left it.

See /usr/src/Makefile.inc1 for a list of options including NO_CLEAN.

And another thing that hasn't been answered: ok about the kernel; what happens with the userland (the world)? When I need to patch some code due to a security advisory related with some program, I go to the program's directory and depending on the program I have to either

# make && make dep && make install
or just
# make && make install

or give other make options to achieve my goal. Isn't there a "generic, FreeBSD" way of doing this (as in ports I mean)?

I'd say that is the generic FreeBSD way, but patches vary. Security patches should always include instructions about the right way to install them.
 
wblock,

1) I know that all modules are compiled and installed. My question is if I am able to change this behavior and if so, how?
2) With regard to the partial compilation of the world. If I want to change the ./configure options given on a program because there is no other way to compile it (nor in /etc/src.conf), then do I have to know the specific program's way of compilation or is there a specific 'FreeBSD' way? From your answer I assume that there is no FreeBSD-specific way.

Thanx again for your replies.
 
mamalos said:
1) I know that all modules are compiled and installed. My question is if I am able to change this behavior and if so, how?

Modules can be disabled in /etc/src.conf (see src.conf(5)). The kernel config file controls which options and modules are built into the kernel.

2) With regard to the partial compilation of the world. If I want to change the ./configure options given on a program because there is no other way to compile it (nor in /etc/src.conf), then do I have to know the specific program's way of compilation or is there a specific 'FreeBSD' way? From your answer I assume that there is no FreeBSD-specific way.

A configure script is used in some of the /usr/src/contrib/ software, but AFAIK, running it manually should not be necessary, as that will be handled by the FreeBSD Makefiles or other parts of the build.
 
Back
Top