make有什么问题?

时间:2011-07-20 00:21:46

标签: c linux module header makefile

C

#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
    printk(KERN_INFO "Hello world 1.\n");
    return 0;
}
void cleanup_module(void)
{
    printk(KERN_INFO "Goodbye world 1.\n");
}

/* makefile */
/* uname -r = 2.6.32-5-686 */
obj-m += hello.o
all :
    make -C /lib/modules/2.6.32-5-686/build /home/mgh/Documents modules
clean : 
    make -C /lib/modules/2.6.32-5-686/build /home/mgh/Documents clean

root@localhost:/home/mgh/Documents# make
make -C /lib/modules/2.6.32-5-686/build /home/mgh/Documents modules
make[1]: Entering directory /usr/src/linux-headers-2.6.32-5-686'
/usr/src/linux-headers-2.6.32-5-common/scripts/Makefile.build:44: /usr/src/linux-headers-``2.6.32-5-common/scripts/basic/Makefile: No such file or directory
make[5]: *** No rule to make target `/usr/src/linux-headers-2.6.32-5-common/scripts/basic``/Makefile'.  Stop.
make[4]: *** [scripts_basic] Error 2
make[3]: Nothing to be done for `/home/mgh/Documents'.
make[3]: *** No rule to make target `include/config/auto.conf', needed by `include/config``/kernel.release'.  Stop.
make[2]: *** [sub-make] Error 2
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-5-686'
make: *** [all] Error 2

2 个答案:

答案 0 :(得分:5)

猜测:您没有在自定义Makefile中设置M环境变量。见http://tldp.org/LDP/lkmpg/2.6/html/x181.html

下一次,请确实提出一个比“错误?”更具体的问题。

答案 1 :(得分:4)

我对make的任何问题都提出异议。不过,我很确定你的Makefile有问题。根据一些随机的网络搜索,尝试这样的事情:

make -C /lib/modules/2.6.32-5-686/build SUBDIRS=/home/mgh/Documents modules

这假设您的Makefile位于/home/mgh/Documents