how to create a driver makefile which uses header files outside current dir?
Hi
I want to build a driver for the linux kernel which uses header files not in the current directory. == Dir tree looks like this /foo/inc/myheader.h /foo/driver/mydriver.c /foo/driver/Makefile == /driver/Makefile looks like this: KERNELDIR=/usr/src/linux TOPDIR=/foo obj-m := mydriver.o mydriver.o: mydriver.c ../inc/myheader.h $(MAKE) -I $(TOPDIR)/inc -C $(KERNELDIR) M=`pwd` modules == This will work until I add the following line in mydriver.c #include <myheader.h> At that point, it will complain that it can not find myheader.h During compile, I see this: make - I /foo/inc -C /usr/src/linux M=`pwd` modules make [3] Entering Directory `/usr/src/linux' CC [M] /foo/driver/mydriver.o /foo/driver/mydriver.c:20:10: error: myheader.h: No such filer or directory |
#include "inc/myheader.h"
Using <myheader.h> tells the compiler to look for the include in the standard include path. Putting it in quotes instead specifies a search relative to the directory you are compiling in. |
outside current dir?
#include "foo.h" does not work.
#include "inc/foo.h" also does not work. |
Suggest : Move or copy 'myheader.h' to foo/driver/ ,
then it will sit in the same directory as 'mydriver.c' and can be included with : #include "myheader.h" " " is for a local file, < > is for a system file, e.g. in /usr/include/ . ..... |
i can't exactly provide you with a solution, because i'm looking in to these matters myself this time, still i think that if you haven't already looked there, there's some documentation at /usr/src/linux-`uname -r`/Documentation/kbuild/modules.txt
specially chapter 6 on include directories |
#include "../inc/foo.h" -> it will work
|
All times are GMT -5. The time now is 02:02 PM. |