What does “all” stand for in a makefile?

前端 未结 4 1531
迷失自我
迷失自我 2020-12-22 17:20

I read some tutorials concerning Makefiles but for me it is still unclear for what the target \"all\" stands for and what it does.

Any ideas?

4条回答
  •  悲&欢浪女
    2020-12-22 18:03

    The manual for GNU Make gives a clear definition for all in its list of standard targets.

    If the author of the Makefile is following that convention then the target all should:

    1. Compile the entire program, but not build documentation.
    2. Be the the default target. As in running just make should do the same as make all.

    To achieve 1 all is typically defined as a .PHONY target that depends on the executable(s) that form the entire program:

    .PHONY : all
    all : executable
    

    To achieve 2 all should either be the first target defined in the make file or be assigned as the default goal:

    .DEFAULT_GOAL := all
    

提交回复
热议问题