문제

How can I print a newline in a makefile?

For instance, if I have a target:

printIt:
        @echo "Compiling..."

How could I print out

Compiling...

I had read somewhere that you can define one. But I have tried what is mentioned here:

define \n

endef



printit:
        @echo "${\n}Compiling..."

But this doesn't print the newline. I have also tried a c++ style "\n". I'm using GNU Make 3.81.

도움이 되었습니까?

해결책

Use:

@echo ""; echo "Compiling..."

The first echo echoes a newline; the second echoes the message.

다른 팁

In some implementations of echo eg. Bash, you can use echo -e to interpret escape characters. Use

printIt:
        @echo -e "\nCompiling..."
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top