How to get the invoking target of makefile?

和自甴很熟 提交于 2019-11-29 02:06:51

问题


How to get the invoking target of the GNU make Makefile?

for example, I invoke make with the following command line:

make a-target

How can I get the invoking target "a-target" in the Makefile and assign it to a variable?

Further more, if more than one target is specified on the command line:

make target1 target2 ...

How do I get all of them?


回答1:


The variable MAKECMDGOALS contains the list of targets that were specified on the command line, no matter how many (it's empty if there were none).




回答2:


Maybe you need $@?

See http://www.gnu.org/software/make/manual/make.html#Automatic-Variables for more details.



来源:https://stackoverflow.com/questions/3202384/how-to-get-the-invoking-target-of-makefile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!