1

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.

HEKTO
  • 3,876
  • 2
  • 24
  • 45
AtomicPorkchop
  • 2,625
  • 5
  • 36
  • 55

1 Answers1

1

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.

Jesus Ramos
  • 22,940
  • 10
  • 58
  • 88
  • I don't really have a right way, I am just trying to get this thing to compile correctly. So you are saying that I should copy the contents of the "include" file into the directories that want them? – AtomicPorkchop Jan 08 '12 at 02:48
  • Yes because the headers used in drivers are generally driver specific and the standard convention is that if it's only used in the driver add it to the same directory. If it's used in the general kernel logic it goes in include/linux and if its architecture specific and used in multiple spots it goes in include/asm – Jesus Ramos Jan 08 '12 at 02:48
  • So if all of the modules SCST modules being built need these headers I should add them to include/linux right, since they are not arch specific? Even though they are only used by this project? – AtomicPorkchop Jan 08 '12 at 03:08
  • @Solignis Nope, all the files for the SCST modules should be within the SCST folder already so that's where. What I mean by general code is page fault handler, memory management, high level I/O elevator code, etc... – Jesus Ramos Jan 08 '12 at 03:11
  • The reason I ask is I will generate a patch for submition to the project repo once I get this pinned down. – AtomicPorkchop Jan 08 '12 at 03:12
  • Oh I see I had to read your comment again, so I think I have it right. I took the header files from the SCST include directory and added them to the SCST directory so they are at the root of the folder. – AtomicPorkchop Jan 08 '12 at 03:15
  • Awesome thanks for the help. Lets hope it compiles right for the 4 shot at this. – AtomicPorkchop Jan 08 '12 at 03:24
  • If you have any other issues just make a question and let me know :) – Jesus Ramos Jan 08 '12 at 03:28