Search code examples
cdriveropenbsd

How can I compile a single driver/file in OpenBSD without compiling the whole kernel?


I have started to write a driver (for the I2C device PCF8574 from NXP) for OpenBSD.

Currently I compile the kernel with the official instruction https://www.openbsd.org/faq/faq5.html from the OpenBSD page.

But when I change the code of the driver and I type make, the whole kernel will be compiled. Not only the changed file. How can I prevent this? How can I compile a single file from the kernel and then link it with the rest of the kernel?

Thanks in advance!


Solution

  • Some parts are always rebuilt but the full kernel is never rebuilt if you use the correct options.

    # cd /usr/src/sys/arch/amd64/conf
    # config GENERIC.MP
    # cd ../compile/GENERIC.MP
    # make clean
    # make -j4
    # make install
    

    Change any source file in /usr/src/sys and then:

    # cd /usr/src/sys/arch/amd64/compile/GENERIC.MP
    # make config
    # make -j4
    # make install
    

    The last make -j4 will only build the changed files + other necessary files.