How to print out a variable in makefile

2019-01-20 21:35发布

In my makefile, I have a variable 'NDK_PROJECT_PATH', my question is how can I print it out when it compiles?

I read Make file echo displaying "$PATH" string and I tried:

@echo $(NDK_PROJECT_PATH)
@echo $(value NDK_PROJECT_PATH)

Both gives me

"build-local.mk:102: *** missing separator.  Stop."

Any one knows why it is not working for me?

14条回答
闹够了就滚
2楼-- · 2019-01-20 22:11

All versions of make require that command lines be indented with a TAB (not space) as the first character in the line. If you showed us the entire rule instead of just the two lines in question we could give a clearer answer, but it should be something like:

myTarget: myDependencies
        @echo hi

where the first character in the second line must be TAB.

查看更多
Ridiculous、
3楼-- · 2019-01-20 22:11

To print the value of a variable you can use:

rule:
<tab>@echo $(VAR_NAME)

When the rule runs the variable will get printed.

查看更多
登录 后发表回答