make file

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

 



hi all,
         i have wriiten a makefile which compliles two different modules and create one main object file.
1> if i do make i should get hello1.ko,hello2.ko and combine.ko
2> then i can insmod combine.ko instead of doing insmod hello1.ko and insmod hello2.ko................

hello1.c
----------------------------------------------------------------------------------------------
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>

static int __init hello_test1_init(void)
{
        printk(KERN_INFO "I am in init hello1 \n");
        return 0;
}

static void __exit hello_test1_exit(void)
{
        printk(KERN_INFO "I am in cleanup hello1 \n");
}

module_init(hello_test1_init);
module_exit(hello_test1_exit);
-----------------------------------------------------------------------------------------------------------------
hello2.c
-----------------------------------------------------------------------------------------------------------------
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>

static int __init hello_test2_init(void)
{
        printk(KERN_INFO "I am in init hello2 \n");
        return 0;
}

static void __exit hello_test2_exit(void)
{
        printk(KERN_INFO "I am in cleanup hello2 \n");
}

module_init(hello_test2_init);
module_exit(hello_test2_exit);
------------------------------------------------------------------------------------------------------------------
Makefile is
---------------------------------------------------------------------------------------------------------------
obj-m :=combine.o
module-objs :=hello1.o hello2.o

obj-m :=hello1.o hello2.o



all:
        make -C /lib/modules/$(shell uname -r)/build SUBDIRS=$(PWD) modules


clean:
        make -C /lib/modules/$(shell uname -r)/build SUBDIRS=$(PWD) clean
--------------------------------------------------------------------------------------------------------------
i dont get error,i will get output hello1.ko and hello.ko but not combine.ko


Send instant messages to your online friends http://uk.messenger.yahoo.com


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux