make: Makefile Contents

1 
1 3.1 What Makefiles Contain
1 ==========================
1 
1 Makefiles contain five kinds of things: "explicit rules", "implicit
1 rules", "variable definitions", "directives", and "comments".  Rules,
1 variables, and directives are described at length in later chapters.
1 
1    * An "explicit rule" says when and how to remake one or more files,
1      called the rule's "targets".  It lists the other files that the
1      targets depend on, called the "prerequisites" of the target, and
1      may also give a recipe to use to create or update the targets.
1      ⇒Writing Rules Rules.
1 
1    * An "implicit rule" says when and how to remake a class of files
1      based on their names.  It describes how a target may depend on a
1      file with a name similar to the target and gives a recipe to create
11      or update such a target.  ⇒Using Implicit Rules Implicit
      Rules.
1 
1    * A "variable definition" is a line that specifies a text string
1      value for a variable that can be substituted into the text later.
1      The simple makefile example shows a variable definition for
11      'objects' as a list of all object files (⇒Variables Make
      Makefiles Simpler Variables Simplify.).
1 
1    * A "directive" is an instruction for 'make' to do something special
1      while reading the makefile.  These include:
1 
11         * Reading another makefile (⇒Including Other Makefiles
           Include.).
1 
1         * Deciding (based on the values of variables) whether to use or
11           ignore a part of the makefile (⇒Conditional Parts of
           Makefiles Conditionals.).
1 
1         * Defining a variable from a verbatim string containing multiple
1           lines (⇒Defining Multi-Line Variables Multi-Line.).
1 
1    * '#' in a line of a makefile starts a "comment".  It and the rest of
1      the line are ignored, except that a trailing backslash not escaped
1      by another backslash will continue the comment across multiple
1      lines.  A line containing just a comment (with perhaps spaces
1      before it) is effectively blank, and is ignored.  If you want a
1      literal '#', escape it with a backslash (e.g., '\#').  Comments may
1      appear on any line in the makefile, although they are treated
1      specially in certain situations.
1 
1      You cannot use comments within variable references or function
1      calls: any instance of '#' will be treated literally (rather than
1      as the start of a comment) inside a variable reference or function
1      call.
1 
1      Comments within a recipe are passed to the shell, just as with any
1      other recipe text.  The shell decides how to interpret it: whether
1      or not this is a comment is up to the shell.
1 
1      Within a 'define' directive, comments are not ignored during the
1      definition of the variable, but rather kept intact in the value of
1      the variable.  When the variable is expanded they will either be
1      treated as 'make' comments or as recipe text, depending on the
1      context in which the variable is evaluated.
1 

Menu