背景
学习linux设备驱动,写第一个hello world程序,make报错:
eden@ubuntu:~/Documents/Project/scull/hello_world$ make Makefile:17: *** recipe commences before first target. ?Stop.
原因
最后查明原因是我的target多了tab
Makefile的rule基本是这样的
targets: prerequisites
????????command
????????command
????????command
targets前不能有tab键
command要使用tab键开始
我错误的写法是:
????? ifneq ($(KERNELRELEASE),)
? ? ????????hello-objs := hello.o
? ? ????????obj-m := hello.o
????????else
? ????????? KERNELDIR ?= /lib/modules/$(shell uname -r)/build
? ? ????????PWD := $(shell pwd)
????????modules:
? ? ????????$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
????????endif
? 改为:
ifneq ($(KERNELRELEASE),)
hello-objs := hello.o
obj-m := hello.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
问题解决
|