Building multiple .ko files from a single module
Hi, I have some source files: a.c b.c c.c etc. Now I need to generate a few .ko files such as, 1.ko, 2.ko, 3.ko etc. I know the correspondence between the source files and the .ko file. Is there a way I could achieve this with a single Makefile ? All the tutorials and the help pages seem to focus on creating a single .ko file from a Makefile, as that is the usual case. However, I need to have different modules generated from my sources. For some shareability reasons, I cannot move the sources to different folders either. Can someone please show me how it should be done ? For example, consider the following association between source files and the .ko files. a.c a.h common.c common.h => 1.ko b.c b.h common.c common.h => 2.ko Thank you. -- Sankar P http://psankar.blogspot.com
Hi Sankar, On Tue, Apr 9, 2013 at 4:33 AM, Sankar P <sankar.curiosity@gmail.com> wrote:
For example, consider the following association between source files and the .ko files.
a.c a.h common.c common.h => 1.ko b.c b.h common.c common.h => 2.ko
I'm not entirely sure if I got your question correct but you might want to have a look at the file Linux/drivers/net/wireless/iwlwifi/Makefile for reference. Happy hacking, Moritz
On 2013-04-09 17:03:14 (+0530), Sankar P <sankar.curiosity@gmail.com> wrote:
I have some source files: a.c b.c c.c etc. Now I need to generate a few .ko files such as, 1.ko, 2.ko, 3.ko etc. <SNIP> For example, consider the following association between source files and the .ko files.
a.c a.h common.c common.h => 1.ko b.c b.h common.c common.h => 2.ko
The following (untested!) should do the trick: obj-$(CONFIG_MYMOD) += mymod_a.o mymod_b.o mymod_a-objs += a.o common.o mymod_b-objs += b.o common.o I'd probably recommend creating three modules though: a, b and common. Regards, Kristof
On Tue, Apr 9, 2013 at 6:34 PM, Kristof Provost <kristof@sigsegv.be> wrote:
On 2013-04-09 17:03:14 (+0530), Sankar P <sankar.curiosity@gmail.com> wrote:
I have some source files: a.c b.c c.c etc. Now I need to generate a few .ko files such as, 1.ko, 2.ko, 3.ko etc. <SNIP> For example, consider the following association between source files and the .ko files.
a.c a.h common.c common.h => 1.ko b.c b.h common.c common.h => 2.ko
The following (untested!) should do the trick: obj-$(CONFIG_MYMOD) += mymod_a.o mymod_b.o mymod_a-objs += a.o common.o mymod_b-objs += b.o common.o
I'd probably recommend creating three modules though: a, b and common.
Yes, this does work :-) I found more information at https://www.kernel.org/doc/Documentation/kbuild/modules.txt too Thanks. -- Sankar P http://psankar.blogspot.com
participants (3)
-
Kristof Provost -
Moritz Fischer -
Sankar P