Chinaunix

标题: 多文件内核模块Makefile问题 [打印本页]

作者: krocp    时间: 2012-11-23 17:14
标题: 多文件内核模块Makefile问题
文件目录
[root@fedora hello_multi]# tree
.
├── come.c
├── configs
│   ├── come.h
│   └── on.h
├── Makefile
└── on.c

[root@fedora hello_multi]#
[root@fedora hello_multi]# vim Makefile
  1 ################################
  2
  3 # sample from www.latelee.org
  4 #
  5 ################################
  6
  7 # debug or not
  8
  9 #### change your module name here
10 MODULE =GotoHell
11
12 #### change your objs here
13 $(MODULE)-objs := come.o on.o
14
15 ifneq ($(KERNELRELEASE), )
16 obj-m := $(MODULE).o
17 else
18 KERNELDIR ?= /usr/src/linux-3.4.7
19 PWD := $(shell pwd)
20
21 all:
22         $(MAKE) -C $(KERNELDIR) M=$(PWD) INCDIR=$(PWD)/configs modules
23 endif
24 clean:
25         rm -rf *.o *.ko *.mod.o *.mod.c *.symvers modul* *~
26 .PHONY: all clean install modules modules_install
27
~

错误信息
[root@fedora hello_multi]# make
make -C /usr/src/linux-3.4.7 M=/just_for_test/module/hello_multi INCDIR=/just_for_test/module/hello_multi/configs modules
make[1]: Entering directory `/usr/src/linux-3.4.7'
scripts/Makefile.build:312: target `/just_for_test/module/hello_multi/GotoHell' doesn't match the target pattern
  CC [M]  /just_for_test/module/hello_multi/GotoHell
gcc: fatal error: no input files
compilation terminated.
make[2]: *** [/just_for_test/module/hello_multi/GotoHell] Error 4
make[1]: *** [_module_/just_for_test/module/hello_multi] Error 2
make[1]: Leaving directory `/usr/src/linux-3.4.7'
make: *** [all] Error 2
[root@fedora hello_multi]#





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2