Combining several subdirectories into a single loadable module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all!

Sorry if this question is stupid, I'm new to this whole kbuild thing.

I have a kernel module with source scattered over several directories,
with a separate set of specific compilation flags for each directory.
How do I write Makefiles for it, assuming in-tree compilation?

Here's the situation in detail. Suppose I have this directory structure:

mymodule
mymodule/subdir1
mymodule/subdir1/source11.c
mymodule/subdir1/source12.c
...
mymodule/subdir1/source1N.c
mymodule/subdir2
mymodule/subdir2/source21.c
mymodule/subdir2/source22.c
...
mymodule/subdir2/source2M.c
...
mymodule/subdirK/sourceKL.c

Each subdirI needs to have its own Makefile with its own EXTRA_CFLAGS,
and all .o files created in subdirectories need be combined into single
mymodule.ko. How do I do that? There are no examples in the
documentation, nor in the kernel source.

The question could be subdivided in two.

1. How do I tell the build system to compile sourceIJ.c and then leave
   sourceIJ.o alone (do not include in the kernel, do not build a .ko)?

2. Given a set of already built sourceIJ.o files, how do I tell the
   build system to combine them into a single .ko without trying to
   compile the corresponding sources first? If I say something like

      mymodule-objs := subdir1/source11.o (etc)

   in mymodule/Makefile, the build system will try to compile
   subdir1/source11.c *with mymodule/Makefile*, which is wrong (I need
   it to be done with mymodule/subdir1/Makefile).

I also tried to build libraries (.a archives) instead of using
sourceIJ.o directly, but without success.

I tried to understand scripts/Makefile.build but it only gave me a
headache...

Regards
-- 
Anatoli Tubman
Connectra performance and infrastructure
Check Point Software Technologies
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux