当前位置: 技术问答>linux和unix
無法編譯外部的kernel module
来源: 互联网 发布时间:2016-03-15
本文导语: 用Makefile編一個hello.ko的module但卻不行 發生 make: Nothing to be done for `modules'. 該Makefile為 #ifeq ($(KERNELRELEASE),) # Assume the source tree is where the running kernel was built # You should set KERNELDIR in the environ...
用Makefile編一個hello.ko的module但卻不行
發生
make: Nothing to be done for `modules'.
該Makefile為
#ifeq ($(KERNELRELEASE),)
# Assume the source tree is where the running kernel was built
# You should set KERNELDIR in the environment if it's elsewhere
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
# The current directory is passed to sub-makes as argument
PWD := $(shell pwd)
modules:
$(MAKE) -C /lib/modules/2.6.23/build/ M=$(PWD) modules
#modules_install:
# $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
.PHONY: modules modules_install clean
#else
# called from kernel build system: just declare what our modules are
obj-m := hello.o
#endif
發生
make: Nothing to be done for `modules'.
該Makefile為
#ifeq ($(KERNELRELEASE),)
# Assume the source tree is where the running kernel was built
# You should set KERNELDIR in the environment if it's elsewhere
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
# The current directory is passed to sub-makes as argument
PWD := $(shell pwd)
modules:
$(MAKE) -C /lib/modules/2.6.23/build/ M=$(PWD) modules
#modules_install:
# $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
.PHONY: modules modules_install clean
#else
# called from kernel build system: just declare what our modules are
obj-m := hello.o
#endif
|
##Makefile ---
## Author: hefuhua@163.com
## Version: $Id: Makefile,v 0.0 2007/01/26 02:02:51 leno Exp $
## Keywords:
## X-URL:
ifneq ($(KERNELRELEASE),)
obj-m := -DEXPORT_SYMTAB
obj-m := hello.o
else
KERNELDIR ?= /home/leno/linux-2.6.24.2
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
###===============================
其实你也可以直接指到内核源码上,
## Author: hefuhua@163.com
## Version: $Id: Makefile,v 0.0 2007/01/26 02:02:51 leno Exp $
## Keywords:
## X-URL:
ifneq ($(KERNELRELEASE),)
obj-m := -DEXPORT_SYMTAB
obj-m := hello.o
else
KERNELDIR ?= /home/leno/linux-2.6.24.2
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
###===============================
其实你也可以直接指到内核源码上,