To conclude "the team begins before the first goal"

I am new to Linux driver.

I am writing a helloworld driver.

here is the code:

#define MODULE
#define __KERNEL__
#include <module.h>
int init_module() 
{
 return 0;
}

void cleanup_module()
{
 return;
}

and here is the makefile:

    CC=gcc
    MODFLAGS:= -O3 -Wall -DLINUX
    module.o: module.c
    $(CC) $(MODFLAGS) -c module.c

But when I run the make command, I have the following: makefile: 3: * Error "command before the first target"

what's wrong?

+5
source share
2 answers

Remove the leading tabs in the makefile from each line that is not a command:

CC=gcc
MODFLAGS:= -O3 -Wall -DLINUX
module.o: module.c
    $(CC) $(MODFLAGS) -c module.c
+9
source

Although this was not for you, I came across the same error message for a different reason. Therefore, I also answer so that he can help people in the future when they encounter an error message, but the reason is not as obvious as in your case.

, , , $(wildcard) (, =). , , $(FILES).

FILES := $(wildcard ./*=*)

.PHONY: all

define foo
all: something-$(1)
something-$(1): $(1)
    cat $$^ > $$@
endef

$(foreach goal,$(sort $(FILES)),$(eval $(call foo,$(goal))))

, - , - .

, , , make - - . , - . .

+1

All Articles