Skip to contentSkip to conversation

Question on compiling a kernel Module

DISCUSSION Madhav Bhamidipati 4 participants 4 messages Sep 15, 2006 – Sep 17, 2006

lore
Share & tools
lore
#0 lore raw

Hello,

I have the following source tree, objective is to get a single kernel module.ko object.

module/
module/sub-module1
module/sub-module2
module/include
module/objs/

module folder has a Makefile, it may or may not have *.c files, it invokes sub-* Makefiles
which build respective objects, these objects need to go into objs folder, finally makefile in 'objs'
builds the module.ko linking all sub-module *.o.

I could not find much information for my requirement in the file linux/Documentation/kbuild/makefiles.txt

any information with an example for my requirement is greatly appreciated. Also let me know
how do I expose module/include in sub-module/ c files, looks like -I../include is not working

-Madhav

#1 lore raw
Quoted 6 lines

module/
module/sub-module1
module/sub-module2
module/include
module/objs/

obj-m += my.o
my-objs := sub1/foo.o sub1/bar.o sub2/abc.o sub2/xyz.o EXTRA_CFLAGS += -I$(src)/include

Should be straightforward.

Quoted 6 lines

module folder has a Makefile, it may or may not have *.c files, it invokes sub-* Makefiles
which build respective objects, these objects need to go into objs folder, finally makefile in 'objs'
builds the module.ko linking all sub-module *.o.

Quoted 7 lines

I could not find much information for my requirement in the file linux/Documentation/kbuild/makefiles.txt

any information with an example for my requirement is greatly appreciated. Also let me know
how do I expose module/include in sub-module/ c files, looks like -I../include is not working

Jan Engelhardt

#2 lore raw
Quoted 8 lines · Jan Engelhardt
Quoted 6 lines

module/
module/sub-module1
module/sub-module2
module/include
module/objs/

Quoted 6 lines

obj-m += my.o
my-objs := sub1/foo.o sub1/bar.o sub2/abc.o sub2/xyz.o EXTRA_CFLAGS += -I$(src)/include

Should be straightforward.

XFS does this and makes

	make fs/xfs/linux-2.6/xfs_stats.i

impossible.

Quoted 14 lines
Quoted 14 lines

module folder has a Makefile, it may or may not have *.c files, it invokes sub-* Makefiles
which build respective objects, these objects need to go into objs folder, finally makefile in 'objs'
builds the module.ko linking all sub-module *.o.

I could not find much information for my requirement in the file linux/Documentation/kbuild/makefiles.txt

any information with an example for my requirement is greatly appreciated. Also let me know
how do I expose module/include in sub-module/ c files, looks like -I../include is not working

#3 lore raw
In reply to Madhav Bhamidipati
Quoted 14 lines · Madhav Bhamidipati

Hello,

I have the following source tree, objective is to get a single kernel module.ko object.

module/
module/sub-module1
module/sub-module2
module/include
module/objs/

Quoted 8 lines

module folder has a Makefile, it may or may not have *.c files, it invokes sub-* Makefiles
which build respective objects, these objects need to go into objs folder, finally makefile in 'objs'
builds the module.ko linking all sub-module *.o.

I could not find much information for my requirement in the file linux/Documentation/kbuild/makefiles.txt

Please read modules.txt in same dir.

Let me know if you miss info (patchewelcome!).

Sam