PDA

View Full Version : how to check if a file builds before firing the kernel build


bsd_newbie
March 24th, 2009, 14:54
During development it happens all the time that you have made a mistake somewhere in the code and your code does not even compile.
How to find this without firing the whole build. So basically how does one just build one file in kernel source tree.

thank.

SirDice
March 24th, 2009, 15:32
Just cd to the directory in question and do a make there.

lyuts
March 24th, 2009, 16:52
just do g++ -c <your file>

if you get an object file for that then it is ok.

rwatson@
May 16th, 2009, 17:05
'make buildkernel' by default cleans your source tree, re-configs, does a 'make depend', and then builds the kernel and modules. With some caution, you can do these steps individually, or force the kernel build to skip steps, saving a lot of time. src/Makefile.inc1 documents the following -D options:

# -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
# -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
# -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel

You can also look at the buildkernel target to see what it does to build the kernel -- historically, most developers did something like the following:

cd src/sys/i386/conf
config MYKERNEL
cd ../../i386/compile/MYKERNEL
make depend
make

In which case you can just do "make foo.o" in the kernel build directory to rebuild the one file. If you're cross-building, you need to use a cross-toolchain, which is something buildkernel does automatically.