I'm trying to follow a guide to compile a program for Debian in FreeBSD. I have the following makefile:

obj-m += kernelinfo.o
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

I'm confused as to how I would compile this on FreeBSD since I do not have a /lib/modules folder on the machine. I have installed all of the default headers on FreeBSD in the /usr/src/ directory but I can't find a modules folder. I'm guessing the Makefile needs to be translated for FreeBSD, though I am very new to Linux and so I have no idea. Any help is much appreciated.

1 Answer 1


This looks like it may be from a Linux kernel module. You will probably not be able to compile or use the code associated with the Linux kernel module on FreeBSD, as it's written specifically for Linux, and the Linux kernel is totally different from the FreeBSD kernel.

In short, it's not the Makefile that needs translating, but the kernel module source code that needs porting over to FreeBSD. This is not a trivial undertaking and requires knowledge of both the Linux and FreeBSD kernels.

See also Conceptual difference between Linux and (Free)BSD Kernel

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.