Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add an include path for kernel module makefile

How do I add an include path for kernel module makefile? I want to include "test_kernel.h" in test_module.c. the "test_kernel.h" resides in other directory "inc" I tried in the following solution in my Makefile but it does not work:

obj-m += test_module.o

test_module:
    $(MAKE) -C "$(LINUX_DIR)" -Iinc $(MAKE_OPTS) modules
like image 485
MOHAMED Avatar asked Apr 16 '12 14:04

MOHAMED


2 Answers

You should make use of EXTRA_CFLAGS in your Makefile. Try something on these lines:

obj-m += test_module.o
EXTRA_CFLAGS=-I$(PWD)/inc

test_module:
    $(MAKE) -C "$(LINUX_DIR)" $(MAKE_OPTS) modules

See section 3.7 Compilation Flags section here.
Hope this helps!

like image 122
another.anon.coward Avatar answered Oct 19 '22 05:10

another.anon.coward


are you sure you correctly specified the include in your file?

e.g.:

#include "inc/something.h"

instead of

#include <inc/something.h>
like image 35
ticcky Avatar answered Oct 19 '22 05:10

ticcky