Building multipart modules with subdirectories...

Steven J. Hill (sjhill@cotw.com)
Fri, 03 Aug 2001 13:40:14 -0500


This question has to do with the kernel build system as it relates to
building a driver both as static and as a module. I have a solution,
but I don't like it. Please read on...

I have driver that is rather complex and in order to maintain it, the
module is broke up into 17 different subdirectories. I am maintaining it
and I am trying to integrate it into the kernel build system. No, I am
not the original architect. Regardless, in the top level Makefile of
my driver directory I have the statement:

subdir-$(CONFIG_FOO_DRV) += $(17 directories' names)

When the module is built, the 'foodrv.o' object is placed in the top
level directory. The problem is that when a 'make modules_install' is
done, it uses the directories defined in 'subdir-$(CONFIG_FOO_DRV)' and
proceeds to fail installing in each of the subdirectories because there
is no target in their makefiles and nor should there be since their
objects are part of the top-level module object.

I could use the 'subdir-' directive above only when I am statically
linking in the driver, hence place it in an 'if' statement. Then when
I build the driver as a module, I manually enter each directory and
do a 'make -C <dir> modules'. However, since the 'subdir-' definition
would be missing if I am building as a module, no '.depend' files are
generated in my subdirectories when I do a 'make dep' which means if
I change a critical header file in my driver's common include
directory, the .c files using it will not be rebuilt! If I could
override the 'modules_install' target in each of my subdirectories
makefiles the problem would be solved. This is possible according to
a solution in the info pages for make, but it requires me to create a
GNUmakefile in each of my directories. Can someone perhaps give me
some ideas for this dilemna? Thanks.

-Steve

-- 
 Steven J. Hill - Embedded SW Engineer
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/