Thanks Ted. I hope that will help me.
--- In "Theodore A. Roth" <> wrote:
>
> On Sun, Mar 15, 2009 at 4:09 PM, K <> wrote:
> > Hi All,
> > For the kernel module if you have just a single .c file for your module
> > then your makefile would just contain
> >
> > "obj-$(CONFIG_YOUR-DIRECTORY-FOR-THE-MODULE) += name_of_your_driver.o"
> >
> > but lets say if I want to split my module into several .c files then in that
> >case how would be my makefile? Finally my objective is to get a single .ko
> > file for my driver using all these c files. I am not really good at
> > makefiles for the kernel modules so please help.
>
> Have a look at the Documentation/kbuild/makefiles.txt file in the
> linux source tree. Section 3.3 is the particular section you want to
> read and understand:
>
> +++++++++++++++++++++++++
> --- 3.3 Loadable module goals - obj-m
>
> $(obj-m) specify object files which are built as loadable
> kernel modules.
>
> A module may be built from one source file or several source
> files. In the case of one source file, the kbuild makefile
> simply adds the file to $(obj-m).
>
> Example:
> #drivers/isdn/i4l/Makefile
> obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.o
>
> Note: In this example $(CONFIG_ISDN_PPP_BSDCOMP) evaluates to 'm'
>
> If a kernel module is built from several source files, you specify
> that you want to build a module in the same way as above.
>
> Kbuild needs to know which the parts that you want to build your
> module from, so you have to tell it by setting an
> $(<module_name>-objs) variable.
>
> Example:
> #drivers/isdn/i4l/Makefile
> obj-$(CONFIG_ISDN) += isdn.o
> isdn-objs := isdn_net_lib.o isdn_v110.o isdn_common.o
>
> In this example, the module name will be isdn.o. Kbuild will
> compile the objects listed in $(isdn-objs) and then run
> "$(LD) -r" on the list of these files to generate isdn.o.
>
> Kbuild recognises objects used for composite objects by the suffix
> -objs, and the suffix -y. This allows the Makefiles to use
> the value of a CONFIG_ symbol to determine if an object is part
> of a composite object.
>
> Example:
> #fs/ext2/Makefile
> obj-$(CONFIG_EXT2_FS) += ext2.o
> ext2-y := balloc.o bitmap.o
> ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o
>
> In this example, xattr.o is only part of the composite object
> ext2.o if $(CONFIG_EXT2_FS_XATTR) evaluates to 'y'.
>
> Note: Of course, when you are building objects into the kernel,
> the syntax above will also work. So, if you have CONFIG_EXT2_FS=y,
> kbuild will build an ext2.o file for you out of the individual
> parts and then link this into built-in.o, as you would expect.
> ++++++++++++++++++++
>
> Hope that helps.
>
> Ted Roth
>
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|