Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@echo in Makefile always causes error " *** missing separator. Stop."

I put

@echo "============= $(TOOLPREFIX) ================="

in line 34 of Makefile of xv6 used by many OS courses, in hope of printing out the value of variable TOOLPREFIX. But I always got error

Makefile:37: *** missing separator.  Stop.

This line is before any target. I tried everything I could, like adding Tab at the beginning of the command, moving the command to everywhere in Makefile, or deleting the symbol @ before echo, but I always got an error no matter what. But if I comment out this command, there is no error. So, how should I correctly print out a variable in this Makefile?

As a side note, if I add Tab at the beginning of the command, the error I got is "Makefile:37: *** recipe commences before first target. Stop." But if I move the @echo command to the bottom of Makefile, "Makefile:287: *** missing separator. Stop." comes out again.

The environment is Window Subsystem for Linux with ubuntu 20.04 installed.

like image 476
zzzhhh Avatar asked Oct 15 '25 11:10

zzzhhh


2 Answers

Should not use echo command there. Should use this to print out message:

$(info ============= $(TOOLPREFIX) =================)
like image 184
zzzhhh Avatar answered Oct 18 '25 05:10

zzzhhh


Your directive can't be outside any rule.

You have to create one:

mydebug:
        @echo "============= $(TOOLPREFIX) ================="

like image 30
Mathieu Avatar answered Oct 18 '25 06:10

Mathieu