.EXPORT_ALL_VARIABLES works only when made 'phony'

前端 未结 1 1346
逝去的感伤
逝去的感伤 2021-01-22 10:53

The docs provides:

\'.EXPORT_ALL_VARIABLES\'

Simply by being mentioned as a target, this tells \'make\' to export all variables to child

1条回答
  •  天涯浪人
    2021-01-22 11:58

    Simply by being mentioned as a target,

    Why is the 'phoniness' needed in order to work?

    It's not. You didn't declare .EXPORT_ALL_VARIABLES as a target, you declared it as a prerequisite:

    all: .EXPORT_ALL_VARIABLES
    

    That's a prerequisite, not a target. If you declare it as a target:

    .EXPORT_ALL_VARIABLES:
    

    then it will work and you won't have to declare it phony.

    A more accurate question would be, why does declaring .EXPORT_ALL_VARIABLES as phony work even though it's not declared as a target? It happens because things that are marked phony are assumed to be targets even if they're not explicitly mentioned as such. That may or may not be a bug, depending on how you interpret the intent of .PHONY.

    Your questions recently seem to follow a pattern: read the documentation, then write a makefile that does something similar to but not the same as what the documentation says, observe it doesn't work as described, then ask why not.

    0 讨论(0)
提交回复
热议问题