2

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.

zzzhhh
  • 291
  • 3
  • 10

3 Answers3

6

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

$(info ============= $(TOOLPREFIX) =================)
zzzhhh
  • 291
  • 3
  • 10
1

Your directive can't be outside any rule.

You have to create one:

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

Mathieu
  • 8,840
  • 7
  • 32
  • 45
  • Then I got: ================= =================== TOOLPREFIX := make: TOOLPREFIX: Command not found make: *** [Makefile:39: mydebug] Error 127 The output is correct since TOOLPREFIX contains empty string. But what does the following lines mean? – zzzhhh Nov 15 '21 at 08:20
0

In my case $(info bla bla '$(FOO)') gives an error(missing operator) but $(warning bla bla '$(FOO)') works fine.

akor
  • 11
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 03 '22 at 18:51