Search code examples
visual-studiomakefilewdk

what does $< and $@ mean in make file


I found these pseudo variable name in my makefile in WDK build environment. What is referenced by these variables? It is a little hard for me to get the answer by search engine because they are special, I believe.


Solution

  • These are automatic variables:

    $@ The file name of the target of the rule. If the target is an archive member, then ‘$@’ is the name of the archive file. In a pattern rule that has multiple targets (see Introduction to Pattern Rules), ‘$@’ is the name of whichever target caused the rule's recipe to be run.

    $< The name of the first prerequisite. If the target got its recipe from an implicit rule, this will be the first prerequisite added by the implicit rule (see Implicit Rules).

    They are used to build rules that can be applied to different targets so that one does not need to repeat the same rule for each and every file that must be worked on...

    PS: To find the answer, I first looked for the 'all documentation on a single page' for GNU make, then used my browser's search function...