Makefile - Linux

This is a discussion on Makefile - Linux ; hai i am new to this Device Drivers i am having one basic doubt... How to write a makefile for for two files like file1.c ,file2.c for single file i have written like this and it is worked out ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Makefile

  1. Makefile

    hai
    i am new to this Device Drivers i am having one basic doubt...
    How to write a makefile for for two files like file1.c ,file2.c
    for single file i have written like this and it is worked out
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
    obj-m := file1.o
    all :
    make -C /lib/modules/`uname -r`/build M=`pwd` modules
    clean :
    make -C /lib/modules/`uname -r`/build M=`pwd` clean
    `````````````````````````````````````````````````` `````````````````````````````````````````````````` ````````````````````````````
    for 2 files how i have to write .could any one help me for this
    i am using kernel : 2.6 version
    thankyou


  2. Re: Makefile

    In article <1165903688.349723.106700@16g2000cwy.googlegroups.c om>,
    RAKHE wrote:
    >hai
    > i am new to this Device Drivers i am having one basic doubt...
    > How to write a makefile for for two files like file1.c ,file2.c
    >for single file i have written like this and it is worked out
    >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
    >obj-m := file1.o
    > all :
    > make -C /lib/modules/`uname -r`/build M=`pwd` modules
    >clean :
    > make -C /lib/modules/`uname -r`/build M=`pwd` clean
    >`````````````````````````````````````````````````` `````````````````````````````````````````````````` ````````````````````````````
    >for 2 files how i have to write .could any one help me for this
    > i am using kernel : 2.6 version


    --- 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
    $(-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.

    --
    http://www.spinics.net/lists/kernel/

+ Reply to Thread