makefilelinux-kernelcompiler-constructionlinux-scst

How can I add an include directory to a makefile for kernel source?


I am trying to build some kernel modules I added to my Ubuntu source code. After many failed attempts to compile I found out that the same error keep happening in different places. The compiler is not able to find a set of headers which sit in an include directory in the folder.

E.X.

Main folder: drivers/scst/

Sub folder: drivers/scst/iscsi-scst/

Include folder: drivers/scst/include

How can I add that include folder to the makefile?

Here is the makefile;

ccflags-y += -Wno-unused-parameter

scst-y        += scst_main.o
scst-y        += scst_pres.o
scst-y        += scst_targ.o
scst-y        += scst_lib.o
scst-y        += scst_sysfs.o
scst-y        += scst_mem.o
scst-y        += scst_tg.o
scst-y        += scst_debug.o

obj-$(CONFIG_SCST)   += scst.o dev_handlers/ iscsi-scst/

I am about 50% sure of how to do it with a "normal" makefile as in one that not work with the kernel source but how can I do it with one like above?

Thanks in advance.


Solution

  • Convention for driver code is to insert the include file for specific drivers into the same directory as the driver and include as #include "header.h". But if you want to do it your way use the -I option for gcc, so it might look like -Idrivers/scst/include or something along those lines and it should be added to the ccflags. Note: This path may change depending on where the Makefile you are editing is located.