VirtualBox

Changeset 503 in kBuild for trunk/src/gmake/doc/make.texi


Ignore:
Timestamp:
Sep 15, 2006 5:09:38 AM (18 years ago)
Author:
bird
Message:

Untested merge with GNU Make v3.81 (vendor/gnumake/2005-05-16 -> vendor/gnumake/current).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gmake/doc/make.texi

    r281 r503  
    22@c %**start of header
    33@setfilename make.info
     4
     5@include version.texi
     6@set EDITION 0.70
     7@set RCSID $Id: make.texi,v 1.45 2006/04/01 06:36:40 psmith Exp $
     8
    49@settitle GNU @code{make}
    510@setchapternewpage odd
    6 @c %**end of header
    7 
    8 @c FSF publishers: format makebook.texi instead of using this file directly.
    9 
    10 @set RCSID $Id: make.texi,v 1.30 2005/05/13 12:45:31 psmith Exp $
    11 @set EDITION 0.70
    12 @set VERSION 3.81
    13 @set UPDATED 07 May 2005
    14 @set UPDATE-MONTH May 2005
    15 @c ISBN provided by Lisa M. Opus Goldstein <[email protected]>, 5 May 2004
    16 @set ISBN 1-882114-83-5
    17 
    18 @c finalout
    19 
    20 @c ISPELL CHECK: done, 10 June 1993 --roland
    21 @c ISPELL CHECK: done, 2000-06-25 --Martin Buchholz
    22 
    2311@c Combine the variable and function indices:
    2412@syncodeindex vr fn
    2513@c Combine the program and concept indices:
    2614@syncodeindex pg cp
     15@c FSF publishers: format makebook.texi instead of using this file directly.
     16@c ISBN provided by Lisa M. Opus Goldstein <[email protected]>, 5 May 2004
     17@set ISBN 1-882114-83-5
     18@c %**end of header
     19
     20@copying
     21This file documents the GNU @code{make} utility, which determines
     22automatically which pieces of a large program need to be recompiled,
     23and issues the commands to recompile them.
     24
     25This is Edition @value{EDITION}, last updated @value{UPDATED},
     26of @cite{The GNU Make Manual}, for GNU @code{make} version @value{VERSION}.
     27
     28Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
     291996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006
     30Free Software Foundation, Inc.
     31
     32@quotation
     33Permission is granted to copy, distribute and/or modify this document
     34under the terms of the GNU Free Documentation License, Version 1.2 or
     35any later version published by the Free Software Foundation; with no
     36Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
     37and with the Back-Cover Texts as in (a) below.  A copy of the
     38license is included in the section entitled ``GNU Free Documentation
     39License.''
     40
     41(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
     42this GNU Manual, like GNU software.  Copies published by the Free
     43Software Foundation raise funds for GNU development.''
     44@end quotation
     45@end copying
     46
     47@c finalout
     48
     49@c ISPELL CHECK: done, 10 June 1993 --roland
     50@c ISPELL CHECK: done, 2000-06-25 --Martin Buchholz
     51
    2752
    2853@dircategory GNU Packages
     
    3055* Make: (make).            Remake files automatically.
    3156@end direntry
    32 
    33 @ifnottex
    34 This file documents the GNU Make utility, which determines
    35 automatically which pieces of a large program need to be recompiled,
    36 and issues the commands to recompile them.
    37 
    38 This is Edition @value{EDITION}, last updated @value{UPDATED},
    39 of @cite{The GNU Make Manual}, for @code{make}, Version @value{VERSION}.
    40 
    41 Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    42 1998, 1999, 2000, 2002, 2003, 2004, 2005
    43 Free Software Foundation, Inc.
    44 
    45 Permission is granted to copy, distribute and/or modify this document
    46 under the terms of the GNU Free Documentation License, Version 1.1 or
    47 any later version published by the Free Software Foundation; with no
    48 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
    49 Texts.  A copy of the license is included in the section entitled
    50 ``GNU Free Documentation License''.
    51 @end ifnottex
    5257
    5358@iftex
     
    5863@subtitle A Program for Directing Recompilation
    5964@subtitle GNU @code{make} Version @value{VERSION}
    60 @subtitle @value{UPDATE-MONTH}
     65@subtitle @value{UPDATED-MONTH}
    6166@author Richard M. Stallman, Roland McGrath, Paul D. Smith
    6267@page
    6368@vskip 0pt plus 1filll
    64 Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
    65 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
     69@insertcopying
    6670@sp 2
    6771Published by the Free Software Foundation @*
    68 59 Temple Place -- Suite 330, @*
    69 Boston, MA 02111-1307 USA @*
     7251 Franklin St. -- Fifth Floor @*
     73Boston, MA 02110-1301 USA @*
    7074ISBN @value{ISBN} @*
    71 
    72 Permission is granted to copy, distribute and/or modify this document
    73 under the terms of the GNU Free Documentation License, Version 1.1 or
    74 any later version published by the Free Software Foundation; with the
    75 Invariant Sections being ``GNU General Public License'', the Front-Cover
    76 Texts being ``A GNU Manual'', and with the Back-Cover Texts being as in
    77 (a) below.  A copy of the license is included in the section entitled
    78 ``GNU Free Documentation License''.
    79 
    80 (a) The FSF's Back-Cover Text is:
    81 
    82 @quotation
    83       You have freedom to copy and modify this GNU Manual, like GNU
    84       software.  Copies published by the Free Software Foundation raise
    85       funds for GNU development.
    86 @end quotation
    8775@sp 2
    8876Cover art by Etienne Suvasa.
    8977@end titlepage
    90 @page
     78
     79@summarycontents
     80@contents
    9181
    9282@ifnottex
    9383@node Top, Overview, (dir), (dir)
    94 @top Make
    95 
    96 The GNU @code{make} utility automatically determines which pieces of a
    97 large program need to be recompiled, and issues the commands to
    98 recompile them.@refill
    99 
    100 This edition of the @cite{GNU Make Manual},
    101 last updated @value{UPDATED},
    102 documents GNU @code{make} Version @value{VERSION}.@refill
    103 
    104 This manual describes @code{make} and contains the following chapters:@refill
     84@top GNU @code{make}
     85
     86@insertcopying
    10587@end ifnottex
    10688
     
    174156* Phony Targets::               Using a target that is not a real file's name.
    175157* Force Targets::               You can use a target without commands
    176                                   or prerequisites to mark other
    177                                   targets as phony.
     158                                  or prerequisites to mark other targets
     159                                  as phony.
    178160* Empty Targets::               When only the date matters and the
    179161                                  files are empty.
     
    215197Writing the Commands in Rules
    216198
     199* Command Syntax::              Command syntax features and pitfalls.
    217200* Echoing::                     How to control when commands are echoed.
    218201* Execution::                   How commands are executed.
     
    223206* Sequences::                   Defining canned sequences of commands.
    224207* Empty Commands::              Defining useful, do-nothing commands.
     208
     209Command Syntax
     210
     211* Splitting Lines::             Breaking long command lines for readability.
     212* Variables in Commands::       Using @code{make} variables in commands.
     213
     214Command Execution
     215
     216* Choosing the Shell::          How @code{make} chooses the shell used
     217                                  to run commands.
    225218
    226219Recursive Use of @code{make}
     
    268261* Text Functions::              General-purpose text manipulation functions.
    269262* File Name Functions::         Functions for manipulating file names.
     263* Conditional Functions::       Functions that implement conditions.
    270264* Foreach Function::            Repeat some text with controlled variation.
    271 * If Function::                 Conditionally expand a value.
    272265* Call Function::               Expand a user-defined function.
    273266* Value Function::              Return the un-expanded value of a variable.
    274267* Eval Function::               Evaluate the arguments as makefile syntax.
    275268* Origin Function::             Find where a variable got its value.
     269* Flavor Function::             Find out the flavor of a variable.
    276270* Shell Function::              Substitute the output of a shell command.
    277271* Make Control Functions::      Functions that control how make runs.
     
    301295* Chained Rules::               How to use a chain of implicit rules.
    302296* Pattern Rules::               How to define new implicit rules.
    303 * Last Resort::                 How to defining commands for rules
    304                                   which cannot find any.
     297* Last Resort::                 How to define commands for rules which
     298                                  cannot find any.
    305299* Suffix Rules::                The old-fashioned style of implicit rule.
    306300* Implicit Rule Search::        The precise algorithm for applying
     
    330324
    331325* Archive Symbols::             How to update archive symbol directories.
    332 
    333 Makefile Conventions
    334 
    335 * Makefile Basics::             General Conventions for Makefiles
    336 * Utilities in Makefiles::      Utilities in Makefiles
    337 * Command Variables::           Variables for Specifying Commands
    338 * Directory Variables::         Variables for Installation Directories
    339 * Standard Targets::            Standard Targets for Users
    340 * Install Command Categories::  Three categories of commands in the `install'
    341326
    342327@end detailmenu
     
    11001085
    11011086@noindent
    1102 @var{filenames} can contain shell file name patterns.
     1087@var{filenames} can contain shell file name patterns.  If
     1088@var{filenames} is empty, nothing is included and no error is printed.
    11031089@cindex shell file name pattern (in @code{include})
    11041090@cindex shell wildcards (in @code{include})
     
    12891275@code{.DEFAULT_GOAL} variable allows you to discover the current
    12901276default goal, restart the default goal selection algorithm by clearing
    1291 its value, or to explicitly set the default goal. The following
     1277its value, or to explicitly set the default goal.  The following
    12921278example illustrates these cases:
    12931279
     
    13301316Note that assigning more than one target name to @code{.DEFAULT_GOAL} is
    13311317illegal and will result in an error.
     1318
     1319@vindex MAKE_RESTARTS @r{(number of times @code{make} has restarted)}
     1320@item MAKE_RESTARTS
     1321This variable is set only if this instance of @code{make} has
     1322restarted (@pxref{Remaking Makefiles, , How Makefiles Are Remade}): it
     1323will contain the number of times this instance has restarted.  Note
     1324this is not the same as recursion (counted by the @code{MAKELEVEL}
     1325variable).  You should not set, modify, or export this variable.
    13321326
    13331327@vindex .VARIABLES @r{(list of variables)}
     
    13571351
    13581352@table @samp
     1353
     1354@item archives
     1355Supports @code{ar} (archive) files using special filename syntax.
     1356@xref{Archives, ,Using @code{make} to Update Archive Files}.
     1357
     1358@item check-symlink
     1359Supports the @code{-L} (@code{--check-symlink-times}) flag.
     1360@xref{Options Summary, ,Summary of Options}.
     1361
     1362@item else-if
     1363Supports ``else if'' non-nested conditionals.  @xref{Conditional
     1364Syntax, ,Syntax of Conditionals}.
     1365
     1366@item jobserver
     1367Supports ``job server'' enhanced parallel builds.  @xref{Parallel,
     1368,Parallel Execution}.
     1369
     1370@item second-expansion
     1371Supports secondary expansion of prerequisite lists.
     1372
     1373@item order-only
     1374Supports order-only prerequisites.  @xref{Prerequisite Types, ,Types
     1375of Prerequisites}.
     1376
    13591377@item target-specific
    13601378Supports target-specific and pattern-specific variable assignments.
    13611379@xref{Target-specific, ,Target-specific Variable Values}.
    13621380
    1363 @item order-only
    1364 Supports order-only prerequisites.  @xref{Prerequisite Types, ,Types
    1365 of Prerequisites}.
    1366 
    1367 @item second-expansion
    1368 Supports secondary expansion of prerequisite lists.
    1369 
    1370 @item jobserver
    1371 Supports ``job server'' enhanced parallel builds.  @xref{Parallel,
    1372 ,Parallel Execution}.
    1373 
    1374 @item check-symlink
    1375 Supports the @code{-L} (@code{--check-symlink-times}) flag.
    1376 @xref{Options Summary, ,Summary of Options}.
    1377 
    13781381@end table
     1382
     1383@vindex .INCLUDE_DIRS @r{(list of include directories)}
     1384@item .INCLUDE_DIRS
     1385Expands to a list of directories that @code{make} searches for
     1386included makefiles (@pxref{Include, , Including Other Makefiles}).
    13791387
    13801388@end table
     
    16001608@cindex expansion, secondary
    16011609
     1610@findex .SECONDEXPANSION
    16021611In the previous section we learned that GNU @code{make} works in two
    16031612distinct phases: a read-in phase and a target-update phase
    1604 (@pxref{Reading Makefiles, , How @code{make} Reads a Makefile}).
    1605 There is an extra wrinkle that comes in between those two phases,
    1606 right at the end of the read-in phase: at that time, all the
    1607 prerequisites of all of the targets are expanded a @emph{second time}.
    1608 In most circumstances this secondary expansion will have no effect,
    1609 since all variable and function references will have been expanded
    1610 during the initial parsing of the makefiles.  In order to take
    1611 advantage of the secondary expansion phase of the parser, then, it's
    1612 necessary to @emph{escape} the variable or function reference in the
    1613 makefile.  In this case the first expansion merely un-escapes the
    1614 reference but doesn't expand it, and expansion is left to the
    1615 secondary expansion phase.  For example, consider this makefile:
    1616 
    1617 @example
     1613(@pxref{Reading Makefiles, , How @code{make} Reads a Makefile}).  GNU
     1614make also has the ability to enable a @emph{second expansion} of the
     1615prerequisites (only) for some or all targets defined in the makefile.
     1616In order for this second expansion to occur, the special target
     1617@code{.SECONDEXPANSION} must be defined before the first prerequisite
     1618list that makes use of this feature.
     1619
     1620If that special target is defined then in between the two phases
     1621mentioned above, right at the end of the read-in phase, all the
     1622prerequisites of the targets defined after the special target are
     1623expanded a @emph{second time}.  In most circumstances this secondary
     1624expansion will have no effect, since all variable and function
     1625references will have been expanded during the initial parsing of the
     1626makefiles.  In order to take advantage of the secondary expansion
     1627phase of the parser, then, it's necessary to @emph{escape} the
     1628variable or function reference in the makefile.  In this case the
     1629first expansion merely un-escapes the reference but doesn't expand it,
     1630and expansion is left to the secondary expansion phase.  For example,
     1631consider this makefile:
     1632
     1633@example
     1634.SECONDEXPANSION:
    16181635ONEVAR = onefile
    16191636TWOVAR = twofile
     
    16391656
    16401657@example
     1658.SECONDEXPANSION:
    16411659AVAR = top
    16421660onefile: $(AVAR)
     
    16581676defer the expansion by escaping the @code{$}.  Also, secondary
    16591677expansion occurs for both explicit and implicit (pattern) rules.
    1660 Knowing this, the possible uses for this feature are almost endless.
    1661 For example:
    1662 
    1663 @example
     1678Knowing this, the possible uses for this feature increase
     1679dramatically.  For example:
     1680
     1681@example
     1682.SECONDEXPANSION:
    16641683main_OBJS := main.o try.o test.o
    16651684lib_OBJS := lib.o api.o
     
    16821701lib_SRCS := lib.c api.c
    16831702
     1703.SECONDEXPANSION:
    16841704main lib: $$(patsubst %.c,%.o,$$($$@@_SRCS))
    16851705@end example
     
    17081728of all prerequisites of rules @emph{that have already appeared} for
    17091729the same target (@code{$$+} with repetitions and @code{$$^}
    1710 without). The following example will help illustrate these behaviors:
    1711 
    1712 @example
     1730without).  The following example will help illustrate these behaviors:
     1731
     1732@example
     1733.SECONDEXPANSION:
     1734
    17131735foo: foo.1 bar.1 $$< $$^ $$+    # line #1
    17141736
     
    17181740@end example
    17191741
    1720 For the first line, all three variables (@code{$$<}, @code{$$^}, and
    1721 @code{$$+}) expand to the empty string. For the second line, they will
    1722 have values @code{foo.1}, @code{foo.1 bar.1}, and @code{foo.1 bar.1}
    1723 respectively. For the third they will have values @code{foo.1},
    1724 @code{foo.1 bar.1 foo.2 bar.2}, and @code{foo.1 bar.1 foo.2 bar.2}
    1725 respectively.
     1742In the first prerequisite list, all three variables (@code{$$<},
     1743@code{$$^}, and @code{$$+}) expand to the empty string.  In the
     1744second, they will have values @code{foo.1}, @code{foo.1 bar.1}, and
     1745@code{foo.1 bar.1} respectively.  In the third they will have values
     1746@code{foo.1}, @code{foo.1 bar.1 foo.2 bar.2}, and @code{foo.1 bar.1
     1747foo.2 bar.2} respectively.
    17261748
    17271749Rules undergo secondary expansion in makefile order, except that
     
    17511773
    17521774@example
     1775.SECONDEXPANSION:
     1776
    17531777foo: bar
    17541778
     
    17691793
    17701794@example
     1795.SECONDEXPANSION:
     1796
    17711797/tmp/foo.o:
    17721798
     
    18161842* Phony Targets::               Using a target that is not a real file's name.
    18171843* Force Targets::               You can use a target without commands
    1818                                   or prerequisites to mark other
    1819                                   targets as phony.
     1844                                  or prerequisites to mark other targets
     1845                                  as phony.
    18201846* Empty Targets::               When only the date matters and the
    18211847                                  files are empty.
     
    19011927appear on the line after the prerequisites, with a tab character, or may
    19021928appear on the same line, with a semicolon.  Either way, the effect is the
    1903 same.  @xref{Commands, ,Writing the Commands in Rules}.
     1929same.  There are other differences in the syntax of command lines.
     1930@xref{Commands, ,Writing the Commands in Rules}.
    19041931
    19051932@cindex dollar sign (@code{$}), in rules
    19061933@cindex @code{$}, in rules
    1907 @cindex rule, and @code{$}
    1908 Because dollar signs are used to start variable references, if you really
    1909 want a dollar sign in a rule you must write two of them, @samp{$$}
    1910 (@pxref{Using Variables, ,How to Use Variables}).  In prerequisite
    1911 lists you must actually write @emph{four} dollar signs (@samp{$$$$}),
    1912 due to secondary expansion (@pxref{Secondary Expansion}).
    1913 You may split a long line by inserting a backslash
    1914 followed by a newline, but this is not required, as @code{make} places no
    1915 limit on the length of a line in a makefile.
     1934@cindex rules, and @code{$}
     1935Because dollar signs are used to start @code{make} variable
     1936references, if you really want a dollar sign in a target or
     1937prerequisite you must write two of them, @samp{$$} (@pxref{Using
     1938Variables, ,How to Use Variables}).  If you have enabled secondary
     1939expansion (@pxref{Secondary Expansion}) and you want a literal dollar
     1940sign in the prerequisites lise, you must actually write @emph{four}
     1941dollar signs (@samp{$$$$}).
     1942
     1943You may split a long line by inserting a backslash followed by a
     1944newline, but this is not required, as @code{make} places no limit on
     1945the length of a line in a makefile.
    19161946
    19171947A rule tells @code{make} two things: when the targets are out of date,
     
    20042034@var{HOME}.@refill
    20052035
    2006 Wildcard expansion happens automatically in targets, in prerequisites,
    2007 and in commands (where the shell does the expansion).  In other
    2008 contexts, wildcard expansion happens only if you request it explicitly
    2009 with the @code{wildcard} function.
     2036Wildcard expansion is performed by @code{make} automatically in
     2037targets and in prerequisites.  In commands the shell is responsible
     2038for wildcard expansion.  In other contexts, wildcard expansion happens
     2039only if you request it explicitly with the @code{wildcard} function.
    20102040
    20112041The special significance of a wildcard character can be turned off by
     
    25532583word in the list will be used.
    25542584
    2555 The default value for @code{.LIBPATTERNS} is ``@samp{lib%.so lib%.a}'',
     2585The default value for @code{.LIBPATTERNS} is @samp{lib%.so lib%.a},
    25562586which provides the default behavior described above.
    25572587
     
    26442674it will do so even if @code{make} is invoked with the @code{-k} option,
    26452675which is unfortunate.  Second, and perhaps more importantly, you cannot
    2646 take advantage of the parallel build capabilities of make using this
    2647 method, since there is only one rule.
     2676take advantage of @code{make}'s ability to build targets in parallel
     2677(@pxref{Parallel, ,Parallel Execution}), since there is only one rule.
    26482678
    26492679By declaring the subdirectories as phony targets (you must do this as
     
    28672897as secondary (i.e., no target is removed because it is considered
    28682898intermediate).
     2899
     2900@findex .SECONDEXPANSION
     2901@item .SECONDEXPANSION
     2902
     2903If @code{.SECONDEXPANSION} is mentioned as a target anywhere in the
     2904makefile, then all prerequisite lists defined @emph{after} it appears
     2905will be expanded a second time after all makefiles have been read in.
     2906@xref{Secondary Expansion, ,Secondary Expansion}.
     2907
     2908The prerequisites of the special target @code{.SUFFIXES} are the list
     2909of suffixes to be used in checking for suffix rules.
     2910@xref{Suffix Rules, , Old-Fashioned Suffix Rules}.
    28692911
    28702912@findex .DELETE_ON_ERROR
     
    33763418@group
    33773419%.d: %.c
    3378         @set -e; rm -f $@@; \
     3420        @@set -e; rm -f $@@; \
    33793421         $(CC) -M $(CPPFLAGS) $< > $@@.$$$$; \
    33803422         sed 's,\($*\)\.o[ :]*,\1.o $@@ : ,g' < $@@.$$$$ > $@@; \
     
    34493491@cindex writing rule commands
    34503492
    3451 The commands of a rule consist of shell command lines to be executed one
    3452 by one.  Each command line must start with a tab, except that the first
    3453 command line may be attached to the target-and-prerequisites line with a
    3454 semicolon in between.  Blank lines and lines of just comments may appear
    3455 among the command lines; they are ignored.  (But beware, an apparently
    3456 ``blank'' line that begins with a tab is @emph{not} blank!  It is an
    3457 empty command; @pxref{Empty Commands}.)
     3493The commands of a rule consist of one or more shell command lines to
     3494be executed, one at a time, in the order they appear.  Typically, the
     3495result of executing these commands is that the target of the rule is
     3496brought up to date.
    34583497
    34593498Users use many different shell programs, but commands in makefiles are
     
    34613500otherwise.  @xref{Execution, ,Command Execution}.
    34623501
    3463 @cindex comments, in commands
    3464 @cindex commands, comments in
    3465 @cindex @code{#} (comments), in commands
    3466 The shell that is in use determines whether comments can be written on
    3467 command lines, and what syntax they use.  When the shell is
    3468 @file{/bin/sh}, a @samp{#} starts a comment that extends to the end of
    3469 the line.  The @samp{#} does not have to be at the beginning of a line.
    3470 Text on a line before a @samp{#} is not part of the comment.
    3471 
    34723502@menu
     3503* Command Syntax::              Command syntax features and pitfalls.
    34733504* Echoing::                     How to control when commands are echoed.
    34743505* Execution::                   How commands are executed.
     
    34813512@end menu
    34823513
    3483 @node Echoing, Execution, Commands, Commands
     3514@node Command Syntax, Echoing, Commands, Commands
     3515@section Command Syntax
     3516@cindex command syntax
     3517@cindex syntax of commands
     3518
     3519Makefiles have the unusual property that there are really two distinct
     3520syntaxes in one file.  Most of the makefile uses @code{make} syntax
     3521(@pxref{Makefiles, ,Writing Makefiles}).  However, commands are meant to be
     3522interpreted by the shell and so they are written using shell syntax.
     3523The @code{make} program does not try to understand shell syntax: it
     3524performs only a very few specific translations on the content of the
     3525command before handing it to the shell.
     3526
     3527Each command line must start with a tab, except that the first command
     3528line may be attached to the target-and-prerequisites line with a
     3529semicolon in between.  @emph{Any} line in the makefile that begins
     3530with a tab and appears in a ``rule context'' (that is, after a rule
     3531has been started until another rule or variable definition) will be
     3532considered a command line for that rule.  Blank lines and lines of
     3533just comments may appear among the command lines; they are ignored.
     3534
     3535Some consequences of these rules include:
     3536
     3537@itemize @bullet
     3538@item
     3539A blank line that begins with a tab is not blank: it's an empty
     3540command (@pxref{Empty Commands}).
     3541
     3542@cindex comments, in commands
     3543@cindex commands, comments in
     3544@cindex @code{#} (comments), in commands
     3545@item
     3546A comment in a command line is not a @code{make} comment; it will be
     3547passed to the shell as-is.  Whether the shell treats it as a comment
     3548or not depends on your shell.
     3549
     3550@item
     3551A variable definition in a ``rule context'' which is indented by a tab
     3552as the first character on the line, will be considered a command line,
     3553not a @code{make} variable definition, and passed to the shell.
     3554
     3555@item
     3556A conditional expression (@code{ifdef}, @code{ifeq},
     3557etc. @pxref{Conditional Syntax, ,Syntax of Conditionals}) in a ``rule
     3558context'' which is indented by a tab as the first character on the
     3559line, will be considered a command line and be passed to the shell.
     3560
     3561@end itemize
     3562
     3563@menu
     3564* Splitting Lines::             Breaking long command lines for readability.
     3565* Variables in Commands::       Using @code{make} variables in commands.
     3566@end menu
     3567
     3568@node Splitting Lines, Variables in Commands, Command Syntax, Command Syntax
     3569@subsection Splitting Command Lines
     3570@cindex commands, splitting
     3571@cindex splitting commands
     3572@cindex commands, backslash (@code{\}) in
     3573@cindex commands, quoting newlines in
     3574@cindex backslash (@code{\}), in commands
     3575@cindex @code{\} (backslash), in commands
     3576@cindex quoting newline, in commands
     3577@cindex newline, quoting, in commands
     3578
     3579One of the few ways in which @code{make} does interpret command lines
     3580is checking for a backslash just before the newline.  As in normal
     3581makefile syntax, a single command can be split into multiple lines in
     3582the makefile by placing a backslash before each newline.  A sequence
     3583of lines like this is considered a single command, and one instance of
     3584the shell will be invoked to run it.
     3585
     3586However, in contrast to how they are treated in other places in a
     3587makefile, backslash-newline pairs are @emph{not} removed from the
     3588command.  Both the backslash and the newline characters are preserved
     3589and passed to the shell.  How the backslash-newline is interpreted
     3590depends on your shell.  If the first character of the next line
     3591after the backslash-newline is a tab, then that tab (and only that
     3592tab) is removed.  Whitespace is never added to the command.
     3593
     3594For example, this makefile:
     3595
     3596@example
     3597@group
     3598all :
     3599        @@echo no\
     3600space
     3601        @@echo no\
     3602        space
     3603        @@echo one \
     3604        space
     3605        @@echo one\
     3606         space
     3607@end group
     3608@end example
     3609
     3610@noindent
     3611consists of four separate shell commands where the output is:
     3612
     3613@example
     3614@group
     3615nospace
     3616nospace
     3617one space
     3618one space
     3619@end group
     3620@end example
     3621
     3622As a more complex example, this makefile:
     3623
     3624@example
     3625@group
     3626all : ; @@echo 'hello \
     3627        world' ; echo "hello \
     3628    world"
     3629@end group
     3630@end example
     3631
     3632@noindent
     3633will run one shell with a command script of:
     3634
     3635@example
     3636@group
     3637echo 'hello \
     3638world' ; echo "hello \
     3639    world"
     3640@end group
     3641@end example
     3642
     3643@noindent
     3644which, according to shell quoting rules, will yield the following output:
     3645
     3646@example
     3647@group
     3648hello \
     3649world
     3650hello     world
     3651@end group
     3652@end example
     3653
     3654@noindent
     3655Notice how the backslash/newline pair was removed inside the string quoted
     3656with double quotes (@code{"..."}), but not from the string quoted with single
     3657quotes (@code{'...'}).  This is the way the default shell (@file{/bin/sh})
     3658handles backslash/newline pairs.  If you specify a different shell in your
     3659makefiles it may treat them differently.
     3660
     3661Sometimes you want to split a long line inside of single quotes, but
     3662you don't want the backslash-newline to appear in the quoted content.
     3663This is often the case when passing scripts to languages such as Perl,
     3664where extraneous backslashes inside the script can change its meaning
     3665or even be a syntax error.  One simple way of handling this is to
     3666place the quoted string, or even the entire command, into a
     3667@code{make} variable then use the variable in the command.  In this
     3668situation the newline quoting rules for makefiles will be used, and
     3669the backslash-newline will be removed.  If we rewrite our example
     3670above using this method:
     3671
     3672@example
     3673@group
     3674HELLO = 'hello \
     3675world'
     3676
     3677all : ; @@echo $(HELLO)
     3678@end group
     3679@end example
     3680
     3681@noindent
     3682we will get output like this:
     3683
     3684@example
     3685@group
     3686hello world
     3687@end group
     3688@end example
     3689
     3690If you like, you can also use target-specific variables
     3691(@pxref{Target-specific, ,Target-specific Variable Values}) to obtain
     3692a tighter correspondence between the variable and the command that
     3693uses it.
     3694
     3695@node Variables in Commands,  , Splitting Lines, Command Syntax
     3696@subsection Using Variables in Commands
     3697@cindex variable references in commands
     3698@cindex commands, using variables in
     3699
     3700The other way in which @code{make} processes commands is by expanding
     3701any variable references in them (@pxref{Reference,Basics of Variable
     3702References}).  This occurs after make has finished reading all the
     3703makefiles and the target is determined to be out of date; so, the
     3704commands for targets which are not rebuilt are never expanded.
     3705
     3706Variable and function references in commands have identical syntax and
     3707semantics to references elsewhere in the makefile.  They also have the
     3708same quoting rules: if you want a dollar sign to appear in your
     3709command, you must double it (@samp{$$}).  For shells like the default
     3710shell, that use dollar signs to introduce variables, it's important to
     3711keep clear in your mind whether the variable you want to reference is
     3712a @code{make} variable (use a single dollar sign) or a shell variable
     3713(use two dollar signs).  For example:
     3714
     3715@example
     3716@group
     3717LIST = one two three
     3718all:
     3719        for i in $(LIST); do \
     3720            echo $$i; \
     3721        done
     3722@end group
     3723@end example
     3724
     3725@noindent
     3726results in the following command being passed to the shell:
     3727
     3728@example
     3729@group
     3730for i in one two three; do \
     3731    echo $i; \
     3732done
     3733@end group
     3734@end example
     3735
     3736@noindent
     3737which generates the expected result:
     3738
     3739@example
     3740@group
     3741one
     3742two
     3743three
     3744@end group
     3745@end example
     3746
     3747@node Echoing, Execution, Command Syntax, Commands
    34843748@section Command Echoing
    34853749@cindex echoing of commands
     
    35303794@cindex execution, of commands
    35313795@cindex shell command, execution
    3532 @vindex SHELL @r{(command execution)}
    3533 
    3534 When it is time to execute commands to update a target, they are executed
    3535 by making a new subshell for each line.  (In practice, @code{make} may
    3536 take shortcuts that do not affect the results.)
     3796@vindex @code{SHELL} @r{(command execution)}
     3797
     3798When it is time to execute commands to update a target, they are
     3799executed by invoking a new subshell for each command line.  (In
     3800practice, @code{make} may take shortcuts that do not affect the
     3801results.)
    35373802
    35383803@cindex @code{cd} (shell command)
    3539 @strong{Please note:} this implies that shell commands such as @code{cd}
    3540 that set variables local to each process will not affect the following
    3541 command lines. @footnote{On MS-DOS, the value of current working
    3542 directory is @strong{global}, so changing it @emph{will} affect the
    3543 following command lines on those systems.}  If you want to use @code{cd}
    3544 to affect the next command, put the two on a single line with a
    3545 semicolon between them.  Then @code{make} will consider them a single
    3546 command and pass them, together, to a shell which will execute them in
    3547 sequence.  For example:
     3804@cindex shell variables, setting in commands
     3805@cindex commands setting shell variables
     3806@strong{Please note:} this implies that setting shell variables and
     3807invoking shell commands such as @code{cd} that set a context local to
     3808each process will not affect the following command lines.@footnote{On
     3809MS-DOS, the value of current working directory is @strong{global}, so
     3810changing it @emph{will} affect the following command lines on those
     3811systems.}  If you want to use @code{cd} to affect the next statement,
     3812put both statements in a single command line.  Then @code{make} will
     3813invoke one shell to run the entire line, and the shell will execute
     3814the statements in sequence.  For example:
    35483815
    35493816@example
    35503817foo : bar/lose
    3551         cd bar; gobble lose > ../foo
    3552 @end example
    3553 
    3554 @cindex commands, backslash (@code{\}) in
    3555 @cindex commands, quoting newlines in
    3556 @cindex backslash (@code{\}), in commands
    3557 @cindex @code{\} (backslash), in commands
    3558 @cindex quoting newline, in commands
    3559 @cindex newline, quoting, in commands
    3560 If you would like to split a single shell command into multiple lines of
    3561 text, you must use a backslash at the end of all but the last subline.
    3562 Such a sequence of lines is combined into a single line, by deleting the
    3563 backslash-newline sequences, before passing it to the shell.  Thus, the
    3564 following is equivalent to the preceding example:
    3565 
    3566 @example
    3567 @group
    3568 foo : bar/lose
    3569         cd bar;  \
    3570         gobble lose > ../foo
    3571 @end group
    3572 @end example
     3818        cd $(@@D) && gobble $(@@F) > ../$@@
     3819@end example
     3820
     3821@noindent
     3822Here we use the shell AND operator (@code{&&}) so that if the
     3823@code{cd} command fails, the script will fail without trying to invoke
     3824the @code{gobble} command in the wrong directory, which could cause
     3825problems (in this case it would certainly cause @file{../foo} to be
     3826truncated, at least).
     3827
     3828@menu
     3829* Choosing the Shell::          How @code{make} chooses the shell used
     3830                                  to run commands.
     3831@end menu
     3832
     3833@node Choosing the Shell,  , Execution, Execution
     3834@subsection Choosing the Shell
     3835@cindex shell, choosing the
     3836@cindex @code{SHELL}, value of
    35733837
    35743838@vindex SHELL
    35753839The program used as the shell is taken from the variable @code{SHELL}.
    3576 By default, the program @file{/bin/sh} is used.
     3840If this variable is not set in your makefile, the program
     3841@file{/bin/sh} is used as the shell.
     3842
     3843@cindex environment, @code{SHELL} in
     3844Unlike most variables, the variable @code{SHELL} is never set from the
     3845environment.  This is because the @code{SHELL} environment variable is
     3846used to specify your personal choice of shell program for interactive
     3847use.  It would be very bad for personal choices like this to affect the
     3848functioning of makefiles.  @xref{Environment, ,Variables from the
     3849Environment}.
     3850
     3851Furthermore, when you do set @code{SHELL} in your makefile that value
     3852is @emph{not} exported in the environment to commands that @code{make}
     3853invokes.  Instead, the value inherited from the user's environment, if
     3854any, is exported.  You can override this behavior by explicitly
     3855exporting @code{SHELL} (@pxref{Variables/Recursion, ,Communicating
     3856Variables to a Sub-@code{make}}), forcing it to be passed in the
     3857environment to commands.
     3858
     3859@vindex @code{MAKESHELL} @r{(MS-DOS alternative to @code{SHELL})}
     3860However, on MS-DOS and MS-Windows the value of @code{SHELL} in the
     3861environment @strong{is} used, since on those systems most users do not
     3862set this variable, and therefore it is most likely set specifically to
     3863be used by @code{make}.  On MS-DOS, if the setting of @code{SHELL} is
     3864not suitable for @code{make}, you can set the variable
     3865@code{MAKESHELL} to the shell that @code{make} should use; if set it
     3866will be used as the shell instead of the value of @code{SHELL}.
     3867
     3868@subsubheading Choosing a Shell in DOS and Windows
     3869@cindex shell, in DOS and Windows
     3870@cindex DOS, choosing a shell in
     3871@cindex Windows, choosing a shell in
     3872
     3873Choosing a shell in MS-DOS and MS-Windows is much more complex than on
     3874other systems.
    35773875
    35783876@vindex COMSPEC
     
    36283926
    36293927The effect of the above DOS-specific processing is that a Makefile that
    3630 says @samp{SHELL = /bin/sh} (as many Unix makefiles do), will work
    3631 on MS-DOS unaltered if you have e.g. @file{sh.exe} installed in some
     3928contains @samp{SHELL = /bin/sh} (as many Unix makefiles do), will work
     3929on MS-DOS unaltered if you have e.g.@: @file{sh.exe} installed in some
    36323930directory along your @code{PATH}.
    3633 
    3634 @cindex environment, @code{SHELL} in
    3635 @vindex MAKESHELL @r{(MS-DOS alternative to @code{SHELL})}
    3636 Unlike most variables, the variable @code{SHELL} is never set from the
    3637 environment.  This is because the @code{SHELL} environment variable is
    3638 used to specify your personal choice of shell program for interactive
    3639 use.  It would be very bad for personal choices like this to affect the
    3640 functioning of makefiles.  @xref{Environment, ,Variables from the
    3641 Environment}.  However, on MS-DOS and MS-Windows the value of
    3642 @code{SHELL} in the environment @strong{is} used, since on those systems
    3643 most users do not set this variable, and therefore it is most likely set
    3644 specifically to be used by @code{make}.  On MS-DOS, if the setting of
    3645 @code{SHELL} is not suitable for @code{make}, you can set the variable
    3646 @code{MAKESHELL} to the shell that @code{make} should use; this will
    3647 override the value of @code{SHELL}.
    36483931
    36493932@node Parallel, Errors, Execution, Commands
     
    40154298environment is passed to the sub-@code{make}.  You can force
    40164299@code{make} to export its value for @code{SHELL} by using the
    4017 @code{export} directive, described below.
     4300@code{export} directive, described below.  @xref{Choosing the Shell}.
    40184301
    40194302The special variable @code{MAKEFLAGS} is always exported (unless you
     
    47124995@group
    47134996ifeq (0,$@{MAKELEVEL@})
    4714 cur-dir   := $(shell pwd)
    47154997whoami    := $(shell whoami)
    47164998host-type := $(shell arch)
     
    47275009@group
    47285010$@{subdirs@}:
    4729       $@{MAKE@} cur-dir=$@{cur-dir@}/$@@ -C $@@ all
     5011        $@{MAKE@} -C $@@ all
    47305012@end group
    47315013@end example
     
    51975479simply-expanded definition, and expands the new text before appending it
    51985480to the old value just as @samp{:=} does
    5199 (@pxref{Setting, ,Setting Variables}, for a full explanation of @samp{:=}).
     5481(see @ref{Setting, ,Setting Variables}, for a full explanation of @samp{:=}).
    52005482In fact,
    52015483
     
    54385720When @code{make} runs a command script, variables defined in the
    54395721makefile are placed into the environment of that command.  This allows
    5440 you to pass values to sub-@code{make} invocations. (@pxref{Recursion,
     5722you to pass values to sub-@code{make} invocations (@pxref{Recursion,
    54415723,Recursive Use of @code{make}}).  By default, only variables that came
    54425724from the environment or the command line are passed to recursive
     
    54525734
    54535735@cindex SHELL, import from environment
    5454 Such problems would be especially likely with the variable @code{SHELL},
    5455 which is normally present in the environment to specify the user's choice
    5456 of interactive shell.  It would be very undesirable for this choice to
    5457 affect @code{make}.  So @code{make} ignores the environment value of
    5458 @code{SHELL} (except on MS-DOS and MS-Windows, where @code{SHELL} is
    5459 usually not set.  @xref{Execution, ,Special handling of SHELL on
    5460 MS-DOS}.)@refill
    5461 
    5462 @cindex SHELL, export to environment
    5463 The @code{SHELL} variable is special in another way: just as the value
    5464 of the @code{make} variable @code{SHELL} is not taken from the
    5465 environment, so also it is not placed into the environment of commands
    5466 that @code{make} invokes.  Instead, the value of @code{SHELL} from the
    5467 invoking environment is provided to the command.  You can use
    5468 @code{export SHELL} to force the value of the @code{make} variable
    5469 @code{SHELL} to be placed in the environment of commands.
     5736Such problems would be especially likely with the variable
     5737@code{SHELL}, which is normally present in the environment to specify
     5738the user's choice of interactive shell.  It would be very undesirable
     5739for this choice to affect @code{make}; so, @code{make} handles the
     5740@code{SHELL} environment variable in a special way; see @ref{Choosing
     5741the Shell}.@refill
    54705742
    54715743@node Target-specific, Pattern-specific, Environment, Using Variables
     
    55155787will be in effect.  Note that this variable is actually distinct from
    55165788any ``global'' value: the two variables do not have to have the same
    5517 flavor (recursive vs. static).
     5789flavor (recursive vs.@: static).
    55185790
    55195791Target-specific variables have the same priority as any other makefile
     
    55265798you define a target-specific variable that variable value is also in
    55275799effect for all prerequisites of this target, and all their
    5528 prerequisites, etc. (unless those prerequisites override that variable
     5800prerequisites, etc.@: (unless those prerequisites override that variable
    55295801with their own target-specific variable value).  So, for example, a
    55305802statement like this:
     
    59256197* Text Functions::              General-purpose text manipulation functions.
    59266198* File Name Functions::         Functions for manipulating file names.
     6199* Conditional Functions::       Functions that implement conditions.
    59276200* Foreach Function::            Repeat some text with controlled variation.
    5928 * If Function::                 Conditionally expand a value.
    59296201* Call Function::               Expand a user-defined function.
    59306202* Value Function::              Return the un-expanded value of a variable.
    59316203* Eval Function::               Evaluate the arguments as makefile syntax.
    59326204* Origin Function::             Find where a variable got its value.
     6205* Flavor Function::             Find out the flavor of a variable.
    59336206* Shell Function::              Substitute the output of a shell command.
    59346207* Make Control Functions::      Functions that control how make runs.
     
    63456618Directive, , The @code{override} Directive}).
    63466619
    6347 @node File Name Functions, Foreach Function, Text Functions, Functions
     6620@node File Name Functions, Conditional Functions, Text Functions, Functions
    63486621@section Functions for File Names
    63496622@cindex functions, for file names
     
    65056778For each file name in @var{names} return the canonical absolute name.
    65066779A canonical name does not contain any @code{.} or @code{..} components,
    6507 nor any repeated path separators (@code{/}) or symlinks. In case of a
    6508 failure the empty string is returned. Consult the @code{realpath(3)}
     6780nor any repeated path separators (@code{/}) or symlinks.  In case of a
     6781failure the empty string is returned.  Consult the @code{realpath(3)}
    65096782documentation for a list of possible failure causes.
    65106783
     
    65156788For each file name in @var{names} return an absolute name that does
    65166789not contain any @code{.} or @code{..} components, nor any repeated path
    6517 separators (@code{/}). Note that in contrast to @code{realpath}
     6790separators (@code{/}).  Note that, in contrast to @code{realpath}
    65186791function, @code{abspath} does not resolve symlinks and does not require
    6519 the file names to refer to an existing file or directory. Use the
     6792the file names to refer to an existing file or directory.  Use the
    65206793@code{wildcard} function to test for existence.
    65216794@end table
    65226795
    6523 @node Foreach Function, If Function, File Name Functions, Functions
     6796@node Conditional Functions, Foreach Function, File Name Functions, Functions
     6797@section Functions for Conditionals
     6798@findex if
     6799@cindex conditional expansion
     6800There are three functions that provide conditional expansion.  A key
     6801aspect of these functions is that not all of the arguments are
     6802expanded initially.  Only those arguments which need to be expanded,
     6803will be expanded.
     6804
     6805@table @code
     6806@item $(if @var{condition},@var{then-part}[,@var{else-part}])
     6807@findex if
     6808The @code{if} function provides support for conditional expansion in a
     6809functional context (as opposed to the GNU @code{make} makefile
     6810conditionals such as @code{ifeq} (@pxref{Conditional Syntax, ,Syntax of
     6811Conditionals}).
     6812
     6813The first argument, @var{condition}, first has all preceding and
     6814trailing whitespace stripped, then is expanded.  If it expands to any
     6815non-empty string, then the condition is considered to be true.  If it
     6816expands to an empty string, the condition is considered to be false.
     6817
     6818If the condition is true then the second argument, @var{then-part}, is
     6819evaluated and this is used as the result of the evaluation of the entire
     6820@code{if} function.
     6821
     6822If the condition is false then the third argument, @var{else-part}, is
     6823evaluated and this is the result of the @code{if} function.  If there is
     6824no third argument, the @code{if} function evaluates to nothing (the
     6825empty string).
     6826
     6827Note that only one of the @var{then-part} or the @var{else-part} will be
     6828evaluated, never both.  Thus, either can contain side-effects (such as
     6829@code{shell} function calls, etc.)
     6830
     6831@item $(or @var{condition1}[,@var{condition2}[,@var{condition3}@dots{}]])
     6832@findex or
     6833The @code{or} function provides a ``short-circuiting'' OR operation.
     6834Each argument is expanded, in order.  If an argument expands to a
     6835non-empty string the processing stops and the result of the expansion
     6836is that string.  If, after all arguments are expanded, all of them are
     6837false (empty), then the result of the expansion is the empty string.
     6838
     6839@item $(and @var{condition1}[,@var{condition2}[,@var{condition3}@dots{}]])
     6840@findex and
     6841The @code{and} function provides a ``short-circuiting'' AND operation.
     6842Each argument is expanded, in order.  If an argument expands to an
     6843empty string the processing stops and the result of the expansion is
     6844the empty string.  If all arguments expand to a non-empty string then
     6845the result of the expansion is the expansion of the last argument.
     6846
     6847@end table
     6848
     6849@node Foreach Function, Call Function, Conditional Functions, Functions
    65246850@section The @code{foreach} Function
    65256851@findex foreach
     
    66096935no?), but it is more likely to be a mistake.
    66106936
    6611 @node If Function, Call Function, Foreach Function, Functions
    6612 @section The @code{if} Function
    6613 @findex if
    6614 @cindex conditional expansion
    6615 
    6616 The @code{if} function provides support for conditional expansion in a
    6617 functional context (as opposed to the GNU @code{make} makefile
    6618 conditionals such as @code{ifeq} (@pxref{Conditional Syntax, ,Syntax of
    6619 Conditionals}).
    6620 
    6621 An @code{if} function call can contain either two or three arguments:
    6622 
    6623 @example
    6624 $(if @var{condition},@var{then-part}[,@var{else-part}])
    6625 @end example
    6626 
    6627 The first argument, @var{condition}, first has all preceding and
    6628 trailing whitespace stripped, then is expanded.  If it expands to any
    6629 non-empty string, then the condition is considered to be true.  If it
    6630 expands to an empty string, the condition is considered to be false.
    6631 
    6632 If the condition is true then the second argument, @var{then-part}, is
    6633 evaluated and this is used as the result of the evaluation of the entire
    6634 @code{if} function.
    6635 
    6636 If the condition is false then the third argument, @var{else-part}, is
    6637 evaluated and this is the result of the @code{if} function.  If there is
    6638 no third argument, the @code{if} function evaluates to nothing (the
    6639 empty string).
    6640 
    6641 Note that only one of the @var{then-part} or the @var{else-part} will be
    6642 evaluated, never both.  Thus, either can contain side-effects (such as
    6643 @code{shell} function calls, etc.)
    6644 
    6645 @node Call Function, Value Function, If Function, Functions
     6937@node Call Function, Value Function, Foreach Function, Functions
    66466938@section The @code{call} Function
    66476939@findex call
     
    67137005
    67147006The @code{call} function can be nested.  Each recursive invocation gets
    6715 its own local values for @code{$(1)}, etc. that mask the values of
     7007its own local values for @code{$(1)}, etc.@: that mask the values of
    67167008higher-level @code{call}.  For example, here is an implementation of a
    67177009@dfn{map} function:
     
    68507142@end example
    68517143
    6852 @node Origin Function, Shell Function, Eval Function, Functions
     7144@node Origin Function, Flavor Function, Eval Function, Functions
    68537145@section The @code{origin} Function
    68547146@findex origin
     
    69597251@xref{Text Functions, , Functions for String Substitution and Analysis}.
    69607252
    6961 @node Shell Function, Make Control Functions, Origin Function, Functions
     7253@node Flavor Function, Shell Function, Origin Function, Functions
     7254@section The @code{flavor} Function
     7255@findex flavor
     7256@cindex variables, flavor of
     7257@cindex flavor of variable
     7258
     7259The @code{flavor} function is unlike most other functions (and like
     7260@code{origin} function) in that it does not operate on the values of
     7261variables; it tells you something @emph{about} a variable.
     7262Specifically, it tells you the flavor of a variable (@pxref{Flavors,
     7263,The Two Flavors of Variables}).
     7264
     7265The syntax of the @code{flavor} function is:
     7266
     7267@example
     7268$(flavor @var{variable})
     7269@end example
     7270
     7271Note that @var{variable} is the @emph{name} of a variable to inquire about;
     7272not a @emph{reference} to that variable.  Therefore you would not normally
     7273use a @samp{$} or parentheses when writing it.  (You can, however, use a
     7274variable reference in the name if you want the name not to be a constant.)
     7275
     7276The result of this function is a string that identifies the flavor of the
     7277variable @var{variable}:
     7278
     7279@table @samp
     7280@item undefined
     7281
     7282if @var{variable} was never defined.
     7283
     7284@item recursive
     7285
     7286if @var{variable} is a recursively expanded variable.
     7287
     7288@item simple
     7289
     7290if @var{variable} is a simply expanded variable.
     7291
     7292@end table
     7293
     7294
     7295@node Shell Function, Make Control Functions, Flavor Function, Functions
    69627296@section The @code{shell} Function
    69637297@findex shell
     
    69847318spawning a new shell, you should carefully consider the performance
    69857319implications of using the @code{shell} function within recursively
    6986 expanded variables vs. simply expanded variables (@pxref{Flavors, ,The
     7320expanded variables vs.@: simply expanded variables (@pxref{Flavors, ,The
    69877321Two Flavors of Variables}).
    69887322
     
    70847418things and many others.
    70857419
     7420@cindex exit status of make
    70867421The exit status of @code{make} is always one of three values:
    70877422@table @code
     
    75507885Consider all targets out-of-date.  GNU @code{make} proceeds to
    75517886consider targets and their prerequisites using the normal algorithms;
    7552 however, all these targets are remade, regardless of the status of
    7553 their prerequisites.
     7887however, all targets so considered are always remade regardless of the
     7888status of their prerequisites.  To avoid infinite recursion, if
     7889@code{MAKE_RESTARTS} (@pxref{Special Variables, , Other Special
     7890Variables}) is set to a number greater than 0 this option is disabled
     7891when considering whether to remake makefiles (@pxref{Remaking
     7892Makefiles, , How Makefiles Are Remade}).
    75547893
    75557894@item -C @var{dir}
     
    79078246* Pattern Rules::               How to define new implicit rules.
    79088247* Last Resort::                 How to define commands for rules which
    7909                                 cannot find any.
     8248                                  cannot find any.
    79108249* Suffix Rules::                The old-fashioned style of implicit rule.
    79118250* Implicit Rule Search::        The precise algorithm for applying
     
    80028341@samp{--no-builtin-rules} option cancels all predefined rules.
    80038342
     8343This manual only documents the default rules available on POSIX-based
     8344operating systems.  Other operating systems, such as VMS, Windows,
     8345OS/2, etc. may have different sets of default rules.  To see the full
     8346list of default rules and variables available in your version of GNU
     8347@code{make}, run @samp{make -p} in a directory with no makefile.
     8348
    80048349Not all of these rules will always be defined, even when the @samp{-r}
    80058350option is not given.  Many of the predefined implicit rules are
     
    80088353the special target @code{.SUFFIXES}).  The default suffix list is:
    80098354@code{.out}, @code{.a}, @code{.ln}, @code{.o}, @code{.c}, @code{.cc},
    8010 @code{.C}, @code{.p}, @code{.f}, @code{.F}, @code{.r}, @code{.y},
     8355@code{.C}, @code{.cpp}, @code{.p}, @code{.f}, @code{.F}, @code{.r}, @code{.y},
    80118356@code{.l}, @code{.s}, @code{.S}, @code{.mod}, @code{.sym}, @code{.def},
    80128357@code{.h}, @code{.info}, @code{.dvi}, @code{.tex}, @code{.texinfo},
     
    80338378@cindex C++, rule to compile
    80348379@pindex g++
     8380@pindex .cc
     8381@pindex .cpp
    80358382@pindex .C
    8036 @pindex .cc
    8037 @file{@var{n}.o} is made automatically from @file{@var{n}.cc} or
    8038 @file{@var{n}.C} with a command of the form @samp{$(CXX) -c $(CPPFLAGS)
    8039 $(CXXFLAGS)}.  We encourage you to use the suffix @samp{.cc} for C++
    8040 source files instead of @samp{.C}.@refill
     8383@file{@var{n}.o} is made automatically from @file{@var{n}.cc},
     8384@file{@var{n}.cpp}, or @file{@var{n}.C} with a command of the form
     8385@samp{$(CXX) -c $(CPPFLAGS) $(CXXFLAGS)}.  We encourage you to use the
     8386suffix @samp{.cc} for C++ source files instead of @samp{.C}.@refill
    80418387
    80428388@item Compiling Pascal programs
     
    82998645
    83008646The commands in built-in implicit rules make liberal use of certain
    8301 predefined variables.  You can alter these variables in the makefile,
    8302 with arguments to @code{make}, or in the environment to alter how the
    8303 implicit rules work without redefining the rules themselves.  You can
    8304 cancel all variables used by implicit rules with the @samp{-R} or
    8305 @samp{--no-builtin-variables} option.
     8647predefined variables.  You can alter the values of these variables in
     8648the makefile, with arguments to @code{make}, or in the environment to
     8649alter how the implicit rules work without redefining the rules
     8650themselves.  You can cancel all variables used by implicit rules with
     8651the @samp{-R} or @samp{--no-builtin-variables} option.
    83068652
    83078653For example, the command used to compile a C source file actually says
     
    83228668with spaces.
    83238669
    8324 Here is a table of variables used as names of programs in built-in rules:
     8670The following tables describe of some of the more commonly-used predefined
     8671variables.  This list is not exhaustive, and the default values shown here may
     8672not be what are selected by @code{make} for your environment.  To see the
     8673complete list of predefined variables for your instance of GNU @code{make} you
     8674can run @samp{make -p} in a directory with no makefiles.
     8675
     8676Here is a table of some of the more common variables used as names of
     8677programs in built-in rules:
     8678makefiles.
    83258679
    83268680@table @code
     
    83328686@item AS
    83338687@vindex AS
    8334 Program for doing assembly; default @samp{as}.
     8688Program for compiling assembly files; default @samp{as}.
    83358689@pindex as
    83368690
     
    83388692@vindex CC
    83398693Program for compiling C programs; default @samp{cc}.
     8694@pindex cc
     8695
     8696@item CO
     8697@vindex CO
     8698Program for checking out files from RCS; default @samp{co}.
    83408699@pindex cc
    83418700
     
    83688727@item LEX
    83698728@vindex LEX
    8370 Program to use to turn Lex grammars into C programs or Ratfor programs;
    8371 default @samp{lex}.
     8729Program to use to turn Lex grammars into source code; default @samp{lex}.
    83728730@pindex lex
     8731
     8732@item YACC
     8733@vindex YACC
     8734Program to use to turn Yacc grammars into source code; default @samp{yacc}.
     8735@pindex yacc
     8736
     8737@item LINT
     8738@vindex LINT
     8739Program to use to run lint on source code; default @samp{lint}.
     8740@pindex lint
     8741
     8742@item M2C
     8743@vindex M2C
     8744Program to use to compile Modula-2 source code; default @samp{m2c}.
     8745@pindex m2c
    83738746
    83748747@item PC
     
    83768749Program for compiling Pascal programs; default @samp{pc}.
    83778750@pindex pc
    8378 
    8379 @item YACC
    8380 @vindex YACC
    8381 Program to use to turn Yacc grammars into C programs; default @samp{yacc}.
    8382 @pindex yacc
    8383 
    8384 @item YACCR
    8385 @vindex YACCR
    8386 Program to use to turn Yacc grammars into Ratfor
    8387 programs; default @samp{yacc -r}.
    83888751
    83898752@item MAKEINFO
     
    84728835@item LDFLAGS
    84738836@vindex LDFLAGS
    8474 Extra flags to give to compilers when they are
    8475 supposed to invoke the linker, @samp{ld}.
     8837Extra flags to give to compilers when they are supposed to invoke the linker,
     8838@samp{ld}.
    84768839
    84778840@item LFLAGS
     
    84798842Extra flags to give to Lex.
    84808843
     8844@item YFLAGS
     8845@vindex YFLAGS
     8846Extra flags to give to Yacc.
     8847
    84818848@item PFLAGS
    84828849@vindex PFLAGS
     
    84878854Extra flags to give to the Fortran compiler for Ratfor programs.
    84888855
    8489 @item YFLAGS
    8490 @vindex YFLAGS
    8491 Extra flags to give to Yacc.
     8856@item LINTFLAGS
     8857@vindex LINTFLAGS
     8858Extra flags to give to lint.
    84928859@end table
    84938860
     
    86298996
    86308997@samp{%} in a prerequisite of a pattern rule stands for the same stem
    8631 that was matched by the @samp{%} in the target.  In order for
    8632 the pattern rule to apply, its target pattern must match the file name
    8633 under consideration, and its prerequisite patterns must name files that
    8634 exist or can be made.  These files become prerequisites of the target.
     8998that was matched by the @samp{%} in the target.  In order for the
     8999pattern rule to apply, its target pattern must match the file name
     9000under consideration and all of its prerequisites (after pattern
     9001substitution) must name files that exist or can be made.  These files
     9002become prerequisites of the target.
    86359003@cindex prerequisite pattern, implicit
    86369004
     
    89829350names, along with the slash that ends them, are added on to the
    89839351prerequisite file names generated from the pattern rule's prerequisite
    8984 patterns and the file name. The directories are ignored only for the
     9352patterns and the file name.  The directories are ignored only for the
    89859353purpose of finding an implicit rule to use, not in the application of
    89869354that rule.  Thus, @samp{e%t} matches the file name @file{src/eat},
     
    93869754
    93879755In fact, nearly all archive member targets are updated in just this way
    9388 and there is an implicit rule to do it for you.  @strong{Note:} The
     9756and there is an implicit rule to do it for you.  @strong{Please note:} The
    93899757@samp{c} flag to @code{ar} is required if the archive file does not
    93909758already exist.
     
    1012410492@xref{Origin Function, , The @code{origin} Function}.
    1012510493
     10494@item $(flavor @var{variable})
     10495
     10496Return a string describing the flavor of the @code{make} variable
     10497@var{variable}.@*
     10498@xref{Flavor Function, , The @code{flavor} Function}.
     10499
    1012610500@item $(foreach @var{var},@var{words},@var{text})
    1012710501
     
    1013310507
    1013410508Evaluate the variable @var{var} replacing any references to @code{$(1)},
    10135 @code{$(2)} with the first, second, etc. @var{param} values.@*
     10509@code{$(2)} with the first, second, etc.@: @var{param} values.@*
    1013610510@xref{Call Function, ,The @code{call} Function}.
    1013710511
     
    1022810602commands.  @xref{Execution, ,Command Execution}.  The @code{SHELL}
    1022910603variable is handled specially when importing from and exporting to the
    10230 environment.  @xref{Environment, ,Using Variable from the Environment}.
     10604environment.  @xref{Choosing the Shell}.
    1023110605
    1023210606@item MAKESHELL
    1023310607
    1023410608On MS-DOS only, the name of the command interpreter that is to be used
    10235 by @code{make}. This value takes precedence over the value of
     10609by @code{make}.  This value takes precedence over the value of
    1023610610@code{SHELL}.  @xref{Execution, ,MAKESHELL variable}.
    1023710611
     
    1072811102@printindex fn
    1072911103
    10730 @summarycontents
    10731 @contents
    1073211104@bye
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette