0

I'm trying to compile my program thread.c with the following Makefile:

ifneq ($(KERNELRELEASE),)
obj-m := thread.o
else

KERNELDIR ?= /lib/modules/$(shell uname -r)/build

PWD := $(shell pwd)

default:
       $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif

When I run make I've got the error

Makefile:10: *** missing separator. Stop.

I'm not found the cause of this issue, someone can help me with this one ?

Ido Segal
  • 430
  • 2
  • 7
  • 20
  • It usually has to do with the whitespace. Try adding some before `obj-m := thread.o` and `$(MAKE) -C $(KERNELDIR) M=$(PWD) modules` – cleblanc Dec 05 '18 at 13:51
  • Does this answer your question? [Make error: missing separator](https://stackoverflow.com/questions/920413/make-error-missing-separator) – SuperStormer Feb 18 '23 at 04:31

2 Answers2

2

The commands in a rule's recipe must each start with a tab character. More or other whitespace may follow, but the leading tab is essential.

Your file contains a rule for target default, but the single command in its recipe does not begin with a tab (or any whitespace, for that matter). It turns out that that's line 10 (supposing that you have presented the whole file), which is indeed the line number implicated by make's diagnostic. Just insert the tab. Personally, I would also add a blank line before the endif, but that's a style recommendation, not a requirement. To wit:

ifneq ($(KERNELRELEASE),)

obj-m := thread.o

else

KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) modules

endif
John Bollinger
  • 160,171
  • 8
  • 81
  • 157
0

I believe I've had this issue before, especially when using windriver. Typically I just nano the specific file its complaining about, delete the first space in the line then add it back. It's a weird fix but usually works for me.

Noble
  • 104
  • 10