make 报错 *** recipe commences before first target. Stop.

背景 学习linux设备驱动,写第一个hello world程序,make报错: eden@ubuntu:~/Documents/Project/scull/

背景

学习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.oobj-m := hello.oelseKERNELDIR ?= /lib/modules/$(shell uname -r)/buildPWD := $(shell pwd)modules:$(MAKE) -C $(KERNELDIR) M=$(PWD) modulesendif

  改为:

ifneq ($(KERNELRELEASE),)hello-objs := hello.oobj-m := hello.oelseKERNELDIR ?= /lib/modules/$(shell uname -r)/buildPWD := $(shell pwd)modules:$(MAKE) -C $(KERNELDIR) M=$(PWD) modulesendif

问题解决