DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(make) Defining

Info Catalog (make) Override Directive (make) Using Variables (make) Environment
 
 Defining Variables Verbatim
 ===========================
 
 Another way to set the value of a variable is to use the `define'
 directive.  This directive has an unusual syntax which allows newline
 characters to be included in the value, which is convenient for defining
 canned sequences of commands ( Defining Canned Command Sequences
 Sequences.).
 
    The `define' directive is followed on the same line by the name of
 the variable and nothing more.  The value to give the variable appears
 on the following lines.  The end of the value is marked by a line
 containing just the word `endef'.  Aside from this difference in
 syntax, `define' works just like `=': it creates a recursively-expanded
 variable ( The Two Flavors of Variables Flavors.).  The variable
 name may contain function and variable references, which are expanded
 when the directive is read to find the actual variable name to use.
 
      define two-lines
      echo foo
      echo $(bar)
      endef
 
    The value in an ordinary assignment cannot contain a newline; but the
 newlines that separate the lines of the value in a `define' become part
 of the variable's value (except for the final newline which precedes
 the `endef' and is not considered part of the value).
 
    The previous example is functionally equivalent to this:
 
      two-lines = echo foo; echo $(bar)
 
 since two commands separated by semicolon behave much like two separate
 shell commands.  However, note that using two separate lines means
 `make' will invoke the shell twice, running an independent subshell for
 each line.   Command Execution Execution.
 
    If you want variable definitions made with `define' to take
 precedence over command-line variable definitions, you can use the
 `override' directive together with `define':
 
      override define two-lines
      foo
      $(bar)
      endef
 
  The `override' Directive Override Directive.
 
Info Catalog (make) Override Directive (make) Using Variables (make) Environment
automatically generated byinfo2html