Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to manually include .config when compiling external kernel module?

I'm afraid my question is a bit complex. Appreciate anyone who can help.

Some background:

I have a 3rd party SW package that compile both kernel modules and user space applications. Unfortunately, this 3rd party is very complex, and doesn't use Kbuild for building kernel modules (I tried without success)

When compiling the kernel modules, I add -I{path to kernel headers}, but I see the .config file is not being parsed in the compilation, which, of course, causes many errors. I tried to manually add all flags from .config to gcc in command line (using a script to generate the command line) but that was a very very long line and gcc couldn't handle it.

So my question would be: Is there a way to force all these flags to gcc somehow?

Appreciate your ideas :)

Clarification:
The 3rd party SW can compile on older kernels (2.6, 2.4) I'm trying to compile it for 3.2 Maybe if someone can explain how the original kernel Makefile manages the .config file, I can mimic that behavior.

like image 746
shayst Avatar asked Apr 26 '26 04:04

shayst


1 Answers

After digging in the kernel sources, I found the answer. Here it is in case someone needs it. There's an automatically generated h file called autoconf.h which contains all the relevant definitions in C pre processor format. Just need to include it manually when compiling the module.

Also in theory, I could use my script to create such a file and include it from the sources.

Hope this helps someone. Now on to the next problem :)

like image 162
shayst Avatar answered Apr 29 '26 23:04

shayst



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!