Fwd: [RFC]Module problem

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

 



---------- Forwarded message ----------
From: harryxiyou <harryxiyou@xxxxxxxxx>
Date: Thu, Apr 5, 2012 at 4:20 PM
Subject: [RFC]Module problem
To: linux-kernel@xxxxxxxxxxxxxxx


Hi list,

When i write an easy module for testing, it happens to me a problem, which
is like this "Building modules, stage 2.  MODPOST 0 modules". I can not
find the *.ko file.

My Module file is like this:

hello.c

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>

static int __init hello_init(void) {
printk("<1> Hello World\n");
return 0;  }

static void __exit hello_exit(void) {
printk("<1> Goodbey\n");
return ;  }

MODULE_LICENSE("GPL");
module_init(hello_init);
module_exit(hello_exit);

Makefile is like this:

obj-m += hello.o

all:
               make -C /usr/src/linux-headers-3.0.0-12-generic
M=/home/sel/homeworl modules

clean:
              make -C /usr/src/linux-headers-3.0.0-12-generic
M=/home/sel/homeworl clean


  When i compile my modules as up Makefile, i cannot get my hello.ko
file. However, when
i change the Makefile like following it is ok for me.

obj-m :=hello.o
ifneq ($( KERNELRELEASE),)

else

KERNELDIR ?= /lib/modules/$(shell uname -r)/build

PWD :=$(shell pwd)
default:

            $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif

    I cannot understand this well Makefile clearly. Cloud anyone give
me a help ;-)

My kernel version is 2.6. Ubuntu 10.04. x86 32bits.

--
Thanks
Harry Wei


-- 
Thanks
Harry Wei

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[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