home *** CD-ROM | disk | FTP | other *** search
/ TOS Silver 2000 / TOS Silver 2000.iso / programm / GNU_C++ / LIB / MAKE3761.LZH / info / make.info-4 < prev    next >
Encoding:
GNU Info File  |  1998-07-20  |  48.0 KB  |  1,235 lines

  1. This is Info file make.info, produced by Makeinfo version 1.67 from the
  2. input file make.texinfo.
  3.  
  4. INFO-DIR-SECTION The GNU make utility
  5. START-INFO-DIR-ENTRY
  6. * GNU make: (make.info).           The GNU make utility.
  7. END-INFO-DIR-ENTRY
  8.  
  9.    This file documents the GNU Make utility, which determines
  10. automatically which pieces of a large program need to be recompiled,
  11. and issues the commands to recompile them.
  12.  
  13.    This is Edition 0.51, last updated 26 Aug 1997, of `The GNU Make
  14. Manual', for `make', Version 3.76 Beta.
  15.  
  16.    Copyright (C) 1988, '89, '90, '91, '92, '93, '94, '95, '96, '97     Free
  17. Software Foundation, Inc.
  18.  
  19.    Permission is granted to make and distribute verbatim copies of this
  20. manual provided the copyright notice and this permission notice are
  21. preserved on all copies.
  22.  
  23.    Permission is granted to copy and distribute modified versions of
  24. this manual under the conditions for verbatim copying, provided that
  25. the entire resulting derived work is distributed under the terms of a
  26. permission notice identical to this one.
  27.  
  28.    Permission is granted to copy and distribute translations of this
  29. manual into another language, under the above conditions for modified
  30. versions, except that this permission notice may be stated in a
  31. translation approved by the Free Software Foundation.
  32.  
  33. File: make.info,  Node: Setting,  Next: Appending,  Prev: Values,  Up: Using Variables
  34.  
  35. Setting Variables
  36. =================
  37.  
  38.    To set a variable from the makefile, write a line starting with the
  39. variable name followed by `=' or `:='.  Whatever follows the `=' or
  40. `:=' on the line becomes the value.  For example,
  41.  
  42.      objects = main.o foo.o bar.o utils.o
  43.  
  44. defines a variable named `objects'.  Whitespace around the variable
  45. name and immediately after the `=' is ignored.
  46.  
  47.    Variables defined with `=' are "recursively expanded" variables.
  48. Variables defined with `:=' are "simply expanded" variables; these
  49. definitions can contain variable references which will be expanded
  50. before the definition is made.  *Note The Two Flavors of Variables:
  51. Flavors.
  52.  
  53.    The variable name may contain function and variable references, which
  54. are expanded when the line is read to find the actual variable name to
  55. use.
  56.  
  57.    There is no limit on the length of the value of a variable except the
  58. amount of swapping space on the computer.  When a variable definition is
  59. long, it is a good idea to break it into several lines by inserting
  60. backslash-newline at convenient places in the definition.  This will not
  61. affect the functioning of `make', but it will make the makefile easier
  62. to read.
  63.  
  64.    Most variable names are considered to have the empty string as a
  65. value if you have never set them.  Several variables have built-in
  66. initial values that are not empty, but you can set them in the usual
  67. ways (*note Variables Used by Implicit Rules: Implicit Variables.).
  68. Several special variables are set automatically to a new value for each
  69. rule; these are called the "automatic" variables (*note Automatic
  70. Variables: Automatic.).
  71.  
  72. File: make.info,  Node: Appending,  Next: Override Directive,  Prev: Setting,  Up: Using Variables
  73.  
  74. Appending More Text to Variables
  75. ================================
  76.  
  77.    Often it is useful to add more text to the value of a variable
  78. already defined.  You do this with a line containing `+=', like this:
  79.  
  80.      objects += another.o
  81.  
  82. This takes the value of the variable `objects', and adds the text
  83. `another.o' to it (preceded by a single space).  Thus:
  84.  
  85.      objects = main.o foo.o bar.o utils.o
  86.      objects += another.o
  87.  
  88. sets `objects' to `main.o foo.o bar.o utils.o another.o'.
  89.  
  90.    Using `+=' is similar to:
  91.  
  92.      objects = main.o foo.o bar.o utils.o
  93.      objects := $(objects) another.o
  94.  
  95. but differs in ways that become important when you use more complex
  96. values.
  97.  
  98.    When the variable in question has not been defined before, `+=' acts
  99. just like normal `=': it defines a recursively-expanded variable.
  100. However, when there *is* a previous definition, exactly what `+=' does
  101. depends on what flavor of variable you defined originally.  *Note The
  102. Two Flavors of Variables: Flavors, for an explanation of the two
  103. flavors of variables.
  104.  
  105.    When you add to a variable's value with `+=', `make' acts
  106. essentially as if you had included the extra text in the initial
  107. definition of the variable.  If you defined it first with `:=', making
  108. it a simply-expanded variable, `+=' adds to that simply-expanded
  109. definition, and expands the new text before appending it to the old
  110. value just as `:=' does (*note Setting Variables: Setting., for a full
  111. explanation of `:=').  In fact,
  112.  
  113.      variable := value
  114.      variable += more
  115.  
  116. is exactly equivalent to:
  117.  
  118.      variable := value
  119.      variable := $(variable) more
  120.  
  121.    On the other hand, when you use `+=' with a variable that you defined
  122. first to be recursively-expanded using plain `=', `make' does something
  123. a bit different.  Recall that when you define a recursively-expanded
  124. variable, `make' does not expand the value you set for variable and
  125. function references immediately.  Instead it stores the text verbatim,
  126. and saves these variable and function references to be expanded later,
  127. when you refer to the new variable (*note The Two Flavors of Variables:
  128. Flavors.).  When you use `+=' on a recursively-expanded variable, it is
  129. this unexpanded text to which `make' appends the new text you specify.
  130.  
  131.      variable = value
  132.      variable += more
  133.  
  134. is roughly equivalent to:
  135.  
  136.      temp = value
  137.      variable = $(temp) more
  138.  
  139. except that of course it never defines a variable called `temp'.  The
  140. importance of this comes when the variable's old value contains
  141. variable references.  Take this common example:
  142.  
  143.      CFLAGS = $(includes) -O
  144.      ...
  145.      CFLAGS += -pg # enable profiling
  146.  
  147. The first line defines the `CFLAGS' variable with a reference to another
  148. variable, `includes'.  (`CFLAGS' is used by the rules for C
  149. compilation; *note Catalogue of Implicit Rules: Catalogue of Rules..)
  150. Using `=' for the definition makes `CFLAGS' a recursively-expanded
  151. variable, meaning `$(includes) -O' is *not* expanded when `make'
  152. processes the definition of `CFLAGS'.  Thus, `includes' need not be
  153. defined yet for its value to take effect.  It only has to be defined
  154. before any reference to `CFLAGS'.  If we tried to append to the value
  155. of `CFLAGS' without using `+=', we might do it like this:
  156.  
  157.      CFLAGS := $(CFLAGS) -pg # enable profiling
  158.  
  159. This is pretty close, but not quite what we want.  Using `:=' redefines
  160. `CFLAGS' as a simply-expanded variable; this means `make' expands the
  161. text `$(CFLAGS) -pg' before setting the variable.  If `includes' is not
  162. yet defined, we get ` -O -pg', and a later definition of `includes'
  163. will have no effect.  Conversely, by using `+=' we set `CFLAGS' to the
  164. *unexpanded* value `$(includes) -O -pg'.  Thus we preserve the
  165. reference to `includes', so if that variable gets defined at any later
  166. point, a reference like `$(CFLAGS)' still uses its value.
  167.  
  168. File: make.info,  Node: Override Directive,  Next: Defining,  Prev: Appending,  Up: Using Variables
  169.  
  170. The `override' Directive
  171. ========================
  172.  
  173.    If a variable has been set with a command argument (*note Overriding
  174. Variables: Overriding.), then ordinary assignments in the makefile are
  175. ignored.  If you want to set the variable in the makefile even though
  176. it was set with a command argument, you can use an `override'
  177. directive, which is a line that looks like this:
  178.  
  179.      override VARIABLE = VALUE
  180.  
  181. or
  182.  
  183.      override VARIABLE := VALUE
  184.  
  185.    To append more text to a variable defined on the command line, use:
  186.  
  187.      override VARIABLE += MORE TEXT
  188.  
  189. *Note Appending More Text to Variables: Appending.
  190.  
  191.    The `override' directive was not invented for escalation in the war
  192. between makefiles and command arguments.  It was invented so you can
  193. alter and add to values that the user specifies with command arguments.
  194.  
  195.    For example, suppose you always want the `-g' switch when you run the
  196. C compiler, but you would like to allow the user to specify the other
  197. switches with a command argument just as usual.  You could use this
  198. `override' directive:
  199.  
  200.      override CFLAGS += -g
  201.  
  202.    You can also use `override' directives with `define' directives.
  203. This is done as you might expect:
  204.  
  205.      override define foo
  206.      bar
  207.      endef
  208.  
  209. *Note Defining Variables Verbatim: Defining.
  210.  
  211. File: make.info,  Node: Defining,  Next: Environment,  Prev: Override Directive,  Up: Using Variables
  212.  
  213. Defining Variables Verbatim
  214. ===========================
  215.  
  216. Another way to set the value of a variable is to use the `define'
  217. directive.  This directive has an unusual syntax which allows newline
  218. characters to be included in the value, which is convenient for defining
  219. canned sequences of commands (*note Defining Canned Command Sequences:
  220. Sequences.).
  221.  
  222.    The `define' directive is followed on the same line by the name of
  223. the variable and nothing more.  The value to give the variable appears
  224. on the following lines.  The end of the value is marked by a line
  225. containing just the word `endef'.  Aside from this difference in
  226. syntax, `define' works just like `=': it creates a recursively-expanded
  227. variable (*note The Two Flavors of Variables: Flavors.).  The variable
  228. name may contain function and variable references, which are expanded
  229. when the directive is read to find the actual variable name to use.
  230.  
  231.      define two-lines
  232.      echo foo
  233.      echo $(bar)
  234.      endef
  235.  
  236.    The value in an ordinary assignment cannot contain a newline; but the
  237. newlines that separate the lines of the value in a `define' become part
  238. of the variable's value (except for the final newline which precedes
  239. the `endef' and is not considered part of the value).
  240.  
  241.    The previous example is functionally equivalent to this:
  242.  
  243.      two-lines = echo foo; echo $(bar)
  244.  
  245. since two commands separated by semicolon behave much like two separate
  246. shell commands.  However, note that using two separate lines means
  247. `make' will invoke the shell twice, running an independent subshell for
  248. each line.  *Note Command Execution: Execution.
  249.  
  250.    If you want variable definitions made with `define' to take
  251. precedence over command-line variable definitions, you can use the
  252. `override' directive together with `define':
  253.  
  254.      override define two-lines
  255.      foo
  256.      $(bar)
  257.      endef
  258.  
  259. *Note The `override' Directive: Override Directive.
  260.  
  261. File: make.info,  Node: Environment,  Prev: Defining,  Up: Using Variables
  262.  
  263. Variables from the Environment
  264. ==============================
  265.  
  266.    Variables in `make' can come from the environment in which `make' is
  267. run.  Every environment variable that `make' sees when it starts up is
  268. transformed into a `make' variable with the same name and value.  But
  269. an explicit assignment in the makefile, or with a command argument,
  270. overrides the environment.  (If the `-e' flag is specified, then values
  271. from the environment override assignments in the makefile.  *Note
  272. Summary of Options: Options Summary.  But this is not recommended
  273. practice.)
  274.  
  275.    Thus, by setting the variable `CFLAGS' in your environment, you can
  276. cause all C compilations in most makefiles to use the compiler switches
  277. you prefer.  This is safe for variables with standard or conventional
  278. meanings because you know that no makefile will use them for other
  279. things.  (But this is not totally reliable; some makefiles set `CFLAGS'
  280. explicitly and therefore are not affected by the value in the
  281. environment.)
  282.  
  283.    When `make' is invoked recursively, variables defined in the outer
  284. invocation can be passed to inner invocations through the environment
  285. (*note Recursive Use of `make': Recursion.).  By default, only
  286. variables that came from the environment or the command line are passed
  287. to recursive invocations.  You can use the `export' directive to pass
  288. other variables.  *Note Communicating Variables to a Sub-`make':
  289. Variables/Recursion, for full details.
  290.  
  291.    Other use of variables from the environment is not recommended.  It
  292. is not wise for makefiles to depend for their functioning on
  293. environment variables set up outside their control, since this would
  294. cause different users to get different results from the same makefile.
  295. This is against the whole purpose of most makefiles.
  296.  
  297.    Such problems would be especially likely with the variable `SHELL',
  298. which is normally present in the environment to specify the user's
  299. choice of interactive shell.  It would be very undesirable for this
  300. choice to affect `make'.  So `make' ignores the environment value of
  301. `SHELL' (except on MS-DOS and MS-Windows, where `SHELL' is usually not
  302. set.  *Note Special handling of SHELL on MS-DOS: Execution.)
  303.  
  304. File: make.info,  Node: Conditionals,  Next: Functions,  Prev: Using Variables,  Up: Top
  305.  
  306. Conditional Parts of Makefiles
  307. ******************************
  308.  
  309.    A "conditional" causes part of a makefile to be obeyed or ignored
  310. depending on the values of variables.  Conditionals can compare the
  311. value of one variable to another, or the value of a variable to a
  312. constant string.  Conditionals control what `make' actually "sees" in
  313. the makefile, so they *cannot* be used to control shell commands at the
  314. time of execution.
  315.  
  316. * Menu:
  317.  
  318. * Conditional Example::         Example of a conditional
  319. * Conditional Syntax::          The syntax of conditionals.
  320. * Testing Flags::               Conditionals that test flags.
  321.  
  322. File: make.info,  Node: Conditional Example,  Next: Conditional Syntax,  Up: Conditionals
  323.  
  324. Example of a Conditional
  325. ========================
  326.  
  327.    The following example of a conditional tells `make' to use one set
  328. of libraries if the `CC' variable is `gcc', and a different set of
  329. libraries otherwise.  It works by controlling which of two command
  330. lines will be used as the command for a rule.  The result is that
  331. `CC=gcc' as an argument to `make' changes not only which compiler is
  332. used but also which libraries are linked.
  333.  
  334.      libs_for_gcc = -lgnu
  335.      normal_libs =
  336.      
  337.      foo: $(objects)
  338.      ifeq ($(CC),gcc)
  339.              $(CC) -o foo $(objects) $(libs_for_gcc)
  340.      else
  341.              $(CC) -o foo $(objects) $(normal_libs)
  342.      endif
  343.  
  344.    This conditional uses three directives: one `ifeq', one `else' and
  345. one `endif'.
  346.  
  347.    The `ifeq' directive begins the conditional, and specifies the
  348. condition.  It contains two arguments, separated by a comma and
  349. surrounded by parentheses.  Variable substitution is performed on both
  350. arguments and then they are compared.  The lines of the makefile
  351. following the `ifeq' are obeyed if the two arguments match; otherwise
  352. they are ignored.
  353.  
  354.    The `else' directive causes the following lines to be obeyed if the
  355. previous conditional failed.  In the example above, this means that the
  356. second alternative linking command is used whenever the first
  357. alternative is not used.  It is optional to have an `else' in a
  358. conditional.
  359.  
  360.    The `endif' directive ends the conditional.  Every conditional must
  361. end with an `endif'.  Unconditional makefile text follows.
  362.  
  363.    As this example illustrates, conditionals work at the textual level:
  364. the lines of the conditional are treated as part of the makefile, or
  365. ignored, according to the condition.  This is why the larger syntactic
  366. units of the makefile, such as rules, may cross the beginning or the
  367. end of the conditional.
  368.  
  369.    When the variable `CC' has the value `gcc', the above example has
  370. this effect:
  371.  
  372.      foo: $(objects)
  373.              $(CC) -o foo $(objects) $(libs_for_gcc)
  374.  
  375. When the variable `CC' has any other value, the effect is this:
  376.  
  377.      foo: $(objects)
  378.              $(CC) -o foo $(objects) $(normal_libs)
  379.  
  380.    Equivalent results can be obtained in another way by
  381. conditionalizing a variable assignment and then using the variable
  382. unconditionally:
  383.  
  384.      libs_for_gcc = -lgnu
  385.      normal_libs =
  386.      
  387.      ifeq ($(CC),gcc)
  388.        libs=$(libs_for_gcc)
  389.      else
  390.        libs=$(normal_libs)
  391.      endif
  392.      
  393.      foo: $(objects)
  394.              $(CC) -o foo $(objects) $(libs)
  395.  
  396. File: make.info,  Node: Conditional Syntax,  Next: Testing Flags,  Prev: Conditional Example,  Up: Conditionals
  397.  
  398. Syntax of Conditionals
  399. ======================
  400.  
  401.    The syntax of a simple conditional with no `else' is as follows:
  402.  
  403.      CONDITIONAL-DIRECTIVE
  404.      TEXT-IF-TRUE
  405.      endif
  406.  
  407. The TEXT-IF-TRUE may be any lines of text, to be considered as part of
  408. the makefile if the condition is true.  If the condition is false, no
  409. text is used instead.
  410.  
  411.    The syntax of a complex conditional is as follows:
  412.  
  413.      CONDITIONAL-DIRECTIVE
  414.      TEXT-IF-TRUE
  415.      else
  416.      TEXT-IF-FALSE
  417.      endif
  418.  
  419. If the condition is true, TEXT-IF-TRUE is used; otherwise,
  420. TEXT-IF-FALSE is used instead.  The TEXT-IF-FALSE can be any number of
  421. lines of text.
  422.  
  423.    The syntax of the CONDITIONAL-DIRECTIVE is the same whether the
  424. conditional is simple or complex.  There are four different directives
  425. that test different conditions.  Here is a table of them:
  426.  
  427. `ifeq (ARG1, ARG2)'
  428. `ifeq 'ARG1' 'ARG2''
  429. `ifeq "ARG1" "ARG2"'
  430. `ifeq "ARG1" 'ARG2''
  431. `ifeq 'ARG1' "ARG2"'
  432.      Expand all variable references in ARG1 and ARG2 and compare them.
  433.      If they are identical, the TEXT-IF-TRUE is effective; otherwise,
  434.      the TEXT-IF-FALSE, if any, is effective.
  435.  
  436.      Often you want to test if a variable has a non-empty value.  When
  437.      the value results from complex expansions of variables and
  438.      functions, expansions you would consider empty may actually
  439.      contain whitespace characters and thus are not seen as empty.
  440.      However, you can use the `strip' function (*note Text
  441.      Functions::.) to avoid interpreting whitespace as a non-empty
  442.      value.  For example:
  443.  
  444.           ifeq ($(strip $(foo)),)
  445.           TEXT-IF-EMPTY
  446.           endif
  447.  
  448.      will evaluate TEXT-IF-EMPTY even if the expansion of `$(foo)'
  449.      contains whitespace characters.
  450.  
  451. `ifneq (ARG1, ARG2)'
  452. `ifneq 'ARG1' 'ARG2''
  453. `ifneq "ARG1" "ARG2"'
  454. `ifneq "ARG1" 'ARG2''
  455. `ifneq 'ARG1' "ARG2"'
  456.      Expand all variable references in ARG1 and ARG2 and compare them.
  457.      If they are different, the TEXT-IF-TRUE is effective; otherwise,
  458.      the TEXT-IF-FALSE, if any, is effective.
  459.  
  460. `ifdef VARIABLE-NAME'
  461.      If the variable VARIABLE-NAME has a non-empty value, the
  462.      TEXT-IF-TRUE is effective; otherwise, the TEXT-IF-FALSE, if any,
  463.      is effective.  Variables that have never been defined have an
  464.      empty value.
  465.  
  466.      Note that `ifdef' only tests whether a variable has a value.  It
  467.      does not expand the variable to see if that value is nonempty.
  468.      Consequently, tests using `ifdef' return true for all definitions
  469.      except those like `foo ='.  To test for an empty value, use
  470.      `ifeq ($(foo),)'.  For example,
  471.  
  472.           bar =
  473.           foo = $(bar)
  474.           ifdef foo
  475.           frobozz = yes
  476.           else
  477.           frobozz = no
  478.           endif
  479.  
  480.      sets `frobozz' to `yes', while:
  481.  
  482.           foo =
  483.           ifdef foo
  484.           frobozz = yes
  485.           else
  486.           frobozz = no
  487.           endif
  488.  
  489.      sets `frobozz' to `no'.
  490.  
  491. `ifndef VARIABLE-NAME'
  492.      If the variable VARIABLE-NAME has an empty value, the TEXT-IF-TRUE
  493.      is effective; otherwise, the TEXT-IF-FALSE, if any, is effective.
  494.  
  495.    Extra spaces are allowed and ignored at the beginning of the
  496. conditional directive line, but a tab is not allowed.  (If the line
  497. begins with a tab, it will be considered a command for a rule.)  Aside
  498. from this, extra spaces or tabs may be inserted with no effect anywhere
  499. except within the directive name or within an argument.  A comment
  500. starting with `#' may appear at the end of the line.
  501.  
  502.    The other two directives that play a part in a conditional are `else'
  503. and `endif'.  Each of these directives is written as one word, with no
  504. arguments.  Extra spaces are allowed and ignored at the beginning of the
  505. line, and spaces or tabs at the end.  A comment starting with `#' may
  506. appear at the end of the line.
  507.  
  508.    Conditionals affect which lines of the makefile `make' uses.  If the
  509. condition is true, `make' reads the lines of the TEXT-IF-TRUE as part
  510. of the makefile; if the condition is false, `make' ignores those lines
  511. completely.  It follows that syntactic units of the makefile, such as
  512. rules, may safely be split across the beginning or the end of the
  513. conditional.
  514.  
  515.    `make' evaluates conditionals when it reads a makefile.
  516. Consequently, you cannot use automatic variables in the tests of
  517. conditionals because they are not defined until commands are run (*note
  518. Automatic Variables: Automatic.).
  519.  
  520.    To prevent intolerable confusion, it is not permitted to start a
  521. conditional in one makefile and end it in another.  However, you may
  522. write an `include' directive within a conditional, provided you do not
  523. attempt to terminate the conditional inside the included file.
  524.  
  525. File: make.info,  Node: Testing Flags,  Prev: Conditional Syntax,  Up: Conditionals
  526.  
  527. Conditionals that Test Flags
  528. ============================
  529.  
  530.    You can write a conditional that tests `make' command flags such as
  531. `-t' by using the variable `MAKEFLAGS' together with the `findstring'
  532. function (*note Functions for String Substitution and Analysis: Text
  533. Functions.).  This is useful when `touch' is not enough to make a file
  534. appear up to date.
  535.  
  536.    The `findstring' function determines whether one string appears as a
  537. substring of another.  If you want to test for the `-t' flag, use `t'
  538. as the first string and the value of `MAKEFLAGS' as the other.
  539.  
  540.    For example, here is how to arrange to use `ranlib -t' to finish
  541. marking an archive file up to date:
  542.  
  543.      archive.a: ...
  544.      ifneq (,$(findstring t,$(MAKEFLAGS)))
  545.              +touch archive.a
  546.              +ranlib -t archive.a
  547.      else
  548.              ranlib archive.a
  549.      endif
  550.  
  551. The `+' prefix marks those command lines as "recursive" so that they
  552. will be executed despite use of the `-t' flag.  *Note Recursive Use of
  553. `make': Recursion.
  554.  
  555. File: make.info,  Node: Functions,  Next: Running,  Prev: Conditionals,  Up: Top
  556.  
  557. Functions for Transforming Text
  558. *******************************
  559.  
  560.    "Functions" allow you to do text processing in the makefile to
  561. compute the files to operate on or the commands to use.  You use a
  562. function in a "function call", where you give the name of the function
  563. and some text (the "arguments") for the function to operate on.  The
  564. result of the function's processing is substituted into the makefile at
  565. the point of the call, just as a variable might be substituted.
  566.  
  567. * Menu:
  568.  
  569. * Syntax of Functions::         How to write a function call.
  570. * Text Functions::              General-purpose text manipulation functions.
  571. * File Name Functions::         Functions for manipulating file names.
  572. * Foreach Function::            Repeat some text with controlled variation.
  573. * Origin Function::             Find where a variable got its value.
  574. * Shell Function::              Substitute the output of a shell command.
  575.  
  576. File: make.info,  Node: Syntax of Functions,  Next: Text Functions,  Up: Functions
  577.  
  578. Function Call Syntax
  579. ====================
  580.  
  581.    A function call resembles a variable reference.  It looks like this:
  582.  
  583.      $(FUNCTION ARGUMENTS)
  584.  
  585. or like this:
  586.  
  587.      ${FUNCTION ARGUMENTS}
  588.  
  589.    Here FUNCTION is a function name; one of a short list of names that
  590. are part of `make'.  There is no provision for defining new functions.
  591.  
  592.    The ARGUMENTS are the arguments of the function.  They are separated
  593. from the function name by one or more spaces or tabs, and if there is
  594. more than one argument, then they are separated by commas.  Such
  595. whitespace and commas are not part of an argument's value.  The
  596. delimiters which you use to surround the function call, whether
  597. parentheses or braces, can appear in an argument only in matching pairs;
  598. the other kind of delimiters may appear singly.  If the arguments
  599. themselves contain other function calls or variable references, it is
  600. wisest to use the same kind of delimiters for all the references; write
  601. `$(subst a,b,$(x))', not `$(subst a,b,${x})'.  This is because it is
  602. clearer, and because only one type of delimiter is matched to find the
  603. end of the reference.
  604.  
  605.    The text written for each argument is processed by substitution of
  606. variables and function calls to produce the argument value, which is
  607. the text on which the function acts.  The substitution is done in the
  608. order in which the arguments appear.
  609.  
  610.    Commas and unmatched parentheses or braces cannot appear in the text
  611. of an argument as written; leading spaces cannot appear in the text of
  612. the first argument as written.  These characters can be put into the
  613. argument value by variable substitution.  First define variables
  614. `comma' and `space' whose values are isolated comma and space
  615. characters, then substitute these variables where such characters are
  616. wanted, like this:
  617.  
  618.      comma:= ,
  619.      empty:=
  620.      space:= $(empty) $(empty)
  621.      foo:= a b c
  622.      bar:= $(subst $(space),$(comma),$(foo))
  623.      # bar is now `a,b,c'.
  624.  
  625. Here the `subst' function replaces each space with a comma, through the
  626. value of `foo', and substitutes the result.
  627.  
  628. File: make.info,  Node: Text Functions,  Next: File Name Functions,  Prev: Syntax of Functions,  Up: Functions
  629.  
  630. Functions for String Substitution and Analysis
  631. ==============================================
  632.  
  633.    Here are some functions that operate on strings:
  634.  
  635. `$(subst FROM,TO,TEXT)'
  636.      Performs a textual replacement on the text TEXT: each occurrence
  637.      of FROM is replaced by TO.  The result is substituted for the
  638.      function call.  For example,
  639.  
  640.           $(subst ee,EE,feet on the street)
  641.  
  642.      substitutes the string `fEEt on the strEEt'.
  643.  
  644. `$(patsubst PATTERN,REPLACEMENT,TEXT)'
  645.      Finds whitespace-separated words in TEXT that match PATTERN and
  646.      replaces them with REPLACEMENT.  Here PATTERN may contain a `%'
  647.      which acts as a wildcard, matching any number of any characters
  648.      within a word.  If REPLACEMENT also contains a `%', the `%' is
  649.      replaced by the text that matched the `%' in PATTERN.
  650.  
  651.      `%' characters in `patsubst' function invocations can be quoted
  652.      with preceding backslashes (`\').  Backslashes that would
  653.      otherwise quote `%' characters can be quoted with more backslashes.
  654.      Backslashes that quote `%' characters or other backslashes are
  655.      removed from the pattern before it is compared file names or has a
  656.      stem substituted into it.  Backslashes that are not in danger of
  657.      quoting `%' characters go unmolested.  For example, the pattern
  658.      `the\%weird\\%pattern\\' has `the%weird\' preceding the operative
  659.      `%' character, and `pattern\\' following it.  The final two
  660.      backslashes are left alone because they cannot affect any `%'
  661.      character.
  662.  
  663.      Whitespace between words is folded into single space characters;
  664.      leading and trailing whitespace is discarded.
  665.  
  666.      For example,
  667.  
  668.           $(patsubst %.c,%.o,x.c.c bar.c)
  669.  
  670.      produces the value `x.c.o bar.o'.
  671.  
  672.      Substitution references (*note Substitution References:
  673.      Substitution Refs.) are a simpler way to get the effect of the
  674.      `patsubst' function:
  675.  
  676.           $(VAR:PATTERN=REPLACEMENT)
  677.  
  678.      is equivalent to
  679.  
  680.           $(patsubst PATTERN,REPLACEMENT,$(VAR))
  681.  
  682.      The second shorthand simplifies one of the most common uses of
  683.      `patsubst': replacing the suffix at the end of file names.
  684.  
  685.           $(VAR:SUFFIX=REPLACEMENT)
  686.  
  687.      is equivalent to
  688.  
  689.           $(patsubst %SUFFIX,%REPLACEMENT,$(VAR))
  690.  
  691.      For example, you might have a list of object files:
  692.  
  693.           objects = foo.o bar.o baz.o
  694.  
  695.      To get the list of corresponding source files, you could simply
  696.      write:
  697.  
  698.           $(objects:.o=.c)
  699.  
  700.      instead of using the general form:
  701.  
  702.           $(patsubst %.o,%.c,$(objects))
  703.  
  704. `$(strip STRING)'
  705.      Removes leading and trailing whitespace from STRING and replaces
  706.      each internal sequence of one or more whitespace characters with a
  707.      single space.  Thus, `$(strip a b  c )' results in `a b c'.
  708.  
  709.      The function `strip' can be very useful when used in conjunction
  710.      with conditionals.  When comparing something with the empty string
  711.      `' using `ifeq' or `ifneq', you usually want a string of just
  712.      whitespace to match the empty string (*note Conditionals::.).
  713.  
  714.      Thus, the following may fail to have the desired results:
  715.  
  716.           .PHONY: all
  717.           ifneq   "$(needs_made)" ""
  718.           all: $(needs_made)
  719.           else
  720.           all:;@echo 'Nothing to make!'
  721.           endif
  722.  
  723.      Replacing the variable reference `$(needs_made)' with the function
  724.      call `$(strip $(needs_made))' in the `ifneq' directive would make
  725.      it more robust.
  726.  
  727. `$(findstring FIND,IN)'
  728.      Searches IN for an occurrence of FIND.  If it occurs, the value is
  729.      FIND; otherwise, the value is empty.  You can use this function in
  730.      a conditional to test for the presence of a specific substring in
  731.      a given string.  Thus, the two examples,
  732.  
  733.           $(findstring a,a b c)
  734.           $(findstring a,b c)
  735.  
  736.      produce the values `a' and `' (the empty string), respectively.
  737.      *Note Testing Flags::, for a practical application of `findstring'.
  738.  
  739. `$(filter PATTERN...,TEXT)'
  740.      Removes all whitespace-separated words in TEXT that do *not* match
  741.      any of the PATTERN words, returning only matching words.  The
  742.      patterns are written using `%', just like the patterns used in the
  743.      `patsubst' function above.
  744.  
  745.      The `filter' function can be used to separate out different types
  746.      of strings (such as file names) in a variable.  For example:
  747.  
  748.           sources := foo.c bar.c baz.s ugh.h
  749.           foo: $(sources)
  750.                   cc $(filter %.c %.s,$(sources)) -o foo
  751.  
  752.      says that `foo' depends of `foo.c', `bar.c', `baz.s' and `ugh.h'
  753.      but only `foo.c', `bar.c' and `baz.s' should be specified in the
  754.      command to the compiler.
  755.  
  756. `$(filter-out PATTERN...,TEXT)'
  757.      Removes all whitespace-separated words in TEXT that *do* match the
  758.      PATTERN words, returning only the words that *do not* match.  This
  759.      is the exact opposite of the `filter' function.
  760.  
  761.      For example, given:
  762.  
  763.           objects=main1.o foo.o main2.o bar.o
  764.           mains=main1.o main2.o
  765.  
  766.      the following generates a list which contains all the object files
  767.      not in `mains':
  768.  
  769.           $(filter-out $(mains),$(objects))
  770.  
  771. `$(sort LIST)'
  772.      Sorts the words of LIST in lexical order, removing duplicate
  773.      words.  The output is a list of words separated by single spaces.
  774.      Thus,
  775.  
  776.           $(sort foo bar lose)
  777.  
  778.      returns the value `bar foo lose'.
  779.  
  780.      Incidentally, since `sort' removes duplicate words, you can use it
  781.      for this purpose even if you don't care about the sort order.
  782.  
  783.    Here is a realistic example of the use of `subst' and `patsubst'.
  784. Suppose that a makefile uses the `VPATH' variable to specify a list of
  785. directories that `make' should search for dependency files (*note
  786. `VPATH' Search Path for All Dependencies: General Search.).  This
  787. example shows how to tell the C compiler to search for header files in
  788. the same list of directories.
  789.  
  790.    The value of `VPATH' is a list of directories separated by colons,
  791. such as `src:../headers'.  First, the `subst' function is used to
  792. change the colons to spaces:
  793.  
  794.      $(subst :, ,$(VPATH))
  795.  
  796. This produces `src ../headers'.  Then `patsubst' is used to turn each
  797. directory name into a `-I' flag.  These can be added to the value of
  798. the variable `CFLAGS', which is passed automatically to the C compiler,
  799. like this:
  800.  
  801.      override CFLAGS += $(patsubst %,-I%,$(subst :, ,$(VPATH)))
  802.  
  803. The effect is to append the text `-Isrc -I../headers' to the previously
  804. given value of `CFLAGS'.  The `override' directive is used so that the
  805. new value is assigned even if the previous value of `CFLAGS' was
  806. specified with a command argument (*note The `override' Directive:
  807. Override Directive.).
  808.  
  809. File: make.info,  Node: File Name Functions,  Next: Foreach Function,  Prev: Text Functions,  Up: Functions
  810.  
  811. Functions for File Names
  812. ========================
  813.  
  814.    Several of the built-in expansion functions relate specifically to
  815. taking apart file names or lists of file names.
  816.  
  817.    Each of the following functions performs a specific transformation
  818. on a file name.  The argument of the function is regarded as a series
  819. of file names, separated by whitespace.  (Leading and trailing
  820. whitespace is ignored.)  Each file name in the series is transformed in
  821. the same way and the results are concatenated with single spaces
  822. between them.
  823.  
  824. `$(dir NAMES...)'
  825.      Extracts the directory-part of each file name in NAMES.  The
  826.      directory-part of the file name is everything up through (and
  827.      including) the last slash in it.  If the file name contains no
  828.      slash, the directory part is the string `./'.  For example,
  829.  
  830.           $(dir src/foo.c hacks)
  831.  
  832.      produces the result `src/ ./'.
  833.  
  834. `$(notdir NAMES...)'
  835.      Extracts all but the directory-part of each file name in NAMES.
  836.      If the file name contains no slash, it is left unchanged.
  837.      Otherwise, everything through the last slash is removed from it.
  838.  
  839.      A file name that ends with a slash becomes an empty string.  This
  840.      is unfortunate, because it means that the result does not always
  841.      have the same number of whitespace-separated file names as the
  842.      argument had; but we do not see any other valid alternative.
  843.  
  844.      For example,
  845.  
  846.           $(notdir src/foo.c hacks)
  847.  
  848.      produces the result `foo.c hacks'.
  849.  
  850. `$(suffix NAMES...)'
  851.      Extracts the suffix of each file name in NAMES.  If the file name
  852.      contains a period, the suffix is everything starting with the last
  853.      period.  Otherwise, the suffix is the empty string.  This
  854.      frequently means that the result will be empty when NAMES is not,
  855.      and if NAMES contains multiple file names, the result may contain
  856.      fewer file names.
  857.  
  858.      For example,
  859.  
  860.           $(suffix src/foo.c src-1.0/bar.c hacks)
  861.  
  862.      produces the result `.c .c'.
  863.  
  864. `$(basename NAMES...)'
  865.      Extracts all but the suffix of each file name in NAMES.  If the
  866.      file name contains a period, the basename is everything starting
  867.      up to (and not including) the last period.  Periods in the
  868.      directory part are ignored.  If there is no period, the basename
  869.      is the entire file name.  For example,
  870.  
  871.           $(basename src/foo.c src-1.0/bar hacks)
  872.  
  873.      produces the result `src/foo src-1.0/bar hacks'.
  874.  
  875. `$(addsuffix SUFFIX,NAMES...)'
  876.      The argument NAMES is regarded as a series of names, separated by
  877.      whitespace; SUFFIX is used as a unit.  The value of SUFFIX is
  878.      appended to the end of each individual name and the resulting
  879.      larger names are concatenated with single spaces between them.
  880.      For example,
  881.  
  882.           $(addsuffix .c,foo bar)
  883.  
  884.      produces the result `foo.c bar.c'.
  885.  
  886. `$(addprefix PREFIX,NAMES...)'
  887.      The argument NAMES is regarded as a series of names, separated by
  888.      whitespace; PREFIX is used as a unit.  The value of PREFIX is
  889.      prepended to the front of each individual name and the resulting
  890.      larger names are concatenated with single spaces between them.
  891.      For example,
  892.  
  893.           $(addprefix src/,foo bar)
  894.  
  895.      produces the result `src/foo src/bar'.
  896.  
  897. `$(join LIST1,LIST2)'
  898.      Concatenates the two arguments word by word: the two first words
  899.      (one from each argument) concatenated form the first word of the
  900.      result, the two second words form the second word of the result,
  901.      and so on.  So the Nth word of the result comes from the Nth word
  902.      of each argument.  If one argument has more words that the other,
  903.      the extra words are copied unchanged into the result.
  904.  
  905.      For example, `$(join a b,.c .o)' produces `a.c b.o'.
  906.  
  907.      Whitespace between the words in the lists is not preserved; it is
  908.      replaced with a single space.
  909.  
  910.      This function can merge the results of the `dir' and `notdir'
  911.      functions, to produce the original list of files which was given
  912.      to those two functions.
  913.  
  914. `$(word N,TEXT)'
  915.      Returns the Nth word of TEXT.  The legitimate values of N start
  916.      from 1.  If N is bigger than the number of words in TEXT, the
  917.      value is empty.  For example,
  918.  
  919.           $(word 2, foo bar baz)
  920.  
  921.      returns `bar'.
  922.  
  923. `$(wordlist S,E,TEXT)'
  924.      Returns the list of words in TEXT starting with word S and ending
  925.      with word E (inclusive).  The legitimate values of S and E start
  926.      from 1.  If S is bigger than the number of words in TEXT, the
  927.      value is empty.  If E is bigger than the number of words in TEXT,
  928.      words up to the end of TEXT are returned.  If S is greater than E,
  929.      `make' swaps them for you.  For example,
  930.  
  931.           $(wordlist 2, 3, foo bar baz)
  932.  
  933.      returns `bar baz'.
  934.  
  935. `$(words TEXT)'
  936.      Returns the number of words in TEXT.  Thus, the last word of TEXT
  937.      is `$(word $(words TEXT),TEXT)'.
  938.  
  939. `$(firstword NAMES...)'
  940.      The argument NAMES is regarded as a series of names, separated by
  941.      whitespace.  The value is the first name in the series.  The rest
  942.      of the names are ignored.
  943.  
  944.      For example,
  945.  
  946.           $(firstword foo bar)
  947.  
  948.      produces the result `foo'.  Although `$(firstword TEXT)' is the
  949.      same as `$(word 1,TEXT)', the `firstword' function is retained for
  950.      its simplicity.
  951.  
  952. `$(wildcard PATTERN)'
  953.      The argument PATTERN is a file name pattern, typically containing
  954.      wildcard characters (as in shell file name patterns).  The result
  955.      of `wildcard' is a space-separated list of the names of existing
  956.      files that match the pattern.  *Note Using Wildcard Characters in
  957.      File Names: Wildcards.
  958.  
  959. File: make.info,  Node: Foreach Function,  Next: Origin Function,  Prev: File Name Functions,  Up: Functions
  960.  
  961. The `foreach' Function
  962. ======================
  963.  
  964.    The `foreach' function is very different from other functions.  It
  965. causes one piece of text to be used repeatedly, each time with a
  966. different substitution performed on it.  It resembles the `for' command
  967. in the shell `sh' and the `foreach' command in the C-shell `csh'.
  968.  
  969.    The syntax of the `foreach' function is:
  970.  
  971.      $(foreach VAR,LIST,TEXT)
  972.  
  973. The first two arguments, VAR and LIST, are expanded before anything
  974. else is done; note that the last argument, TEXT, is *not* expanded at
  975. the same time.  Then for each word of the expanded value of LIST, the
  976. variable named by the expanded value of VAR is set to that word, and
  977. TEXT is expanded.  Presumably TEXT contains references to that
  978. variable, so its expansion will be different each time.
  979.  
  980.    The result is that TEXT is expanded as many times as there are
  981. whitespace-separated words in LIST.  The multiple expansions of TEXT
  982. are concatenated, with spaces between them, to make the result of
  983. `foreach'.
  984.  
  985.    This simple example sets the variable `files' to the list of all
  986. files in the directories in the list `dirs':
  987.  
  988.      dirs := a b c d
  989.      files := $(foreach dir,$(dirs),$(wildcard $(dir)/*))
  990.  
  991.    Here TEXT is `$(wildcard $(dir)/*)'.  The first repetition finds the
  992. value `a' for `dir', so it produces the same result as `$(wildcard
  993. a/*)'; the second repetition produces the result of `$(wildcard b/*)';
  994. and the third, that of `$(wildcard c/*)'.
  995.  
  996.    This example has the same result (except for setting `dirs') as the
  997. following example:
  998.  
  999.      files := $(wildcard a/* b/* c/* d/*)
  1000.  
  1001.    When TEXT is complicated, you can improve readability by giving it a
  1002. name, with an additional variable:
  1003.  
  1004.      find_files = $(wildcard $(dir)/*)
  1005.      dirs := a b c d
  1006.      files := $(foreach dir,$(dirs),$(find_files))
  1007.  
  1008. Here we use the variable `find_files' this way.  We use plain `=' to
  1009. define a recursively-expanding variable, so that its value contains an
  1010. actual function call to be reexpanded under the control of `foreach'; a
  1011. simply-expanded variable would not do, since `wildcard' would be called
  1012. only once at the time of defining `find_files'.
  1013.  
  1014.    The `foreach' function has no permanent effect on the variable VAR;
  1015. its value and flavor after the `foreach' function call are the same as
  1016. they were beforehand.  The other values which are taken from LIST are
  1017. in effect only temporarily, during the execution of `foreach'.  The
  1018. variable VAR is a simply-expanded variable during the execution of
  1019. `foreach'.  If VAR was undefined before the `foreach' function call, it
  1020. is undefined after the call.  *Note The Two Flavors of Variables:
  1021. Flavors.
  1022.  
  1023.    You must take care when using complex variable expressions that
  1024. result in variable names because many strange things are valid variable
  1025. names, but are probably not what you intended.  For example,
  1026.  
  1027.      files := $(foreach Esta escrito en espanol!,b c ch,$(find_files))
  1028.  
  1029. might be useful if the value of `find_files' references the variable
  1030. whose name is `Esta escrito en espanol!' (es un nombre bastante largo,
  1031. no?), but it is more likely to be a mistake.
  1032.  
  1033. File: make.info,  Node: Origin Function,  Next: Shell Function,  Prev: Foreach Function,  Up: Functions
  1034.  
  1035. The `origin' Function
  1036. =====================
  1037.  
  1038.    The `origin' function is unlike most other functions in that it does
  1039. not operate on the values of variables; it tells you something *about*
  1040. a variable.  Specifically, it tells you where it came from.
  1041.  
  1042.    The syntax of the `origin' function is:
  1043.  
  1044.      $(origin VARIABLE)
  1045.  
  1046.    Note that VARIABLE is the *name* of a variable to inquire about; not
  1047. a *reference* to that variable.  Therefore you would not normally use a
  1048. `$' or parentheses when writing it.  (You can, however, use a variable
  1049. reference in the name if you want the name not to be a constant.)
  1050.  
  1051.    The result of this function is a string telling you how the variable
  1052. VARIABLE was defined:
  1053.  
  1054. `undefined'
  1055.      if VARIABLE was never defined.
  1056.  
  1057. `default'
  1058.      if VARIABLE has a default definition, as is usual with `CC' and so
  1059.      on.  *Note Variables Used by Implicit Rules: Implicit Variables.
  1060.      Note that if you have redefined a default variable, the `origin'
  1061.      function will return the origin of the later definition.
  1062.  
  1063. `environment'
  1064.      if VARIABLE was defined as an environment variable and the `-e'
  1065.      option is *not* turned on (*note Summary of Options: Options
  1066.      Summary.).
  1067.  
  1068. `environment override'
  1069.      if VARIABLE was defined as an environment variable and the `-e'
  1070.      option *is* turned on (*note Summary of Options: Options Summary.).
  1071.  
  1072. `file'
  1073.      if VARIABLE was defined in a makefile.
  1074.  
  1075. `command line'
  1076.      if VARIABLE was defined on the command line.
  1077.  
  1078. `override'
  1079.      if VARIABLE was defined with an `override' directive in a makefile
  1080.      (*note The `override' Directive: Override Directive.).
  1081.  
  1082. `automatic'
  1083.      if VARIABLE is an automatic variable defined for the execution of
  1084.      the commands for each rule (*note Automatic Variables: Automatic.).
  1085.  
  1086.    This information is primarily useful (other than for your curiosity)
  1087. to determine if you want to believe the value of a variable.  For
  1088. example, suppose you have a makefile `foo' that includes another
  1089. makefile `bar'.  You want a variable `bletch' to be defined in `bar' if
  1090. you run the command `make -f bar', even if the environment contains a
  1091. definition of `bletch'.  However, if `foo' defined `bletch' before
  1092. including `bar', you do not want to override that definition.  This
  1093. could be done by using an `override' directive in `foo', giving that
  1094. definition precedence over the later definition in `bar';
  1095. unfortunately, the `override' directive would also override any command
  1096. line definitions.  So, `bar' could include:
  1097.  
  1098.      ifdef bletch
  1099.      ifeq "$(origin bletch)" "environment"
  1100.      bletch = barf, gag, etc.
  1101.      endif
  1102.      endif
  1103.  
  1104. If `bletch' has been defined from the environment, this will redefine
  1105. it.
  1106.  
  1107.    If you want to override a previous definition of `bletch' if it came
  1108. from the environment, even under `-e', you could instead write:
  1109.  
  1110.      ifneq "$(findstring environment,$(origin bletch))" ""
  1111.      bletch = barf, gag, etc.
  1112.      endif
  1113.  
  1114.    Here the redefinition takes place if `$(origin bletch)' returns
  1115. either `environment' or `environment override'.  *Note Functions for
  1116. String Substitution and Analysis: Text Functions.
  1117.  
  1118. File: make.info,  Node: Shell Function,  Prev: Origin Function,  Up: Functions
  1119.  
  1120. The `shell' Function
  1121. ====================
  1122.  
  1123.    The `shell' function is unlike any other function except the
  1124. `wildcard' function (*note The Function `wildcard': Wildcard Function.)
  1125. in that it communicates with the world outside of `make'.
  1126.  
  1127.    The `shell' function performs the same function that backquotes
  1128. (``') perform in most shells: it does "command expansion".  This means
  1129. that it takes an argument that is a shell command and returns the
  1130. output of the command.  The only processing `make' does on the result,
  1131. before substituting it into the surrounding text, is to convert each
  1132. newline or carriage-return / newline pair to a single space.  It also
  1133. removes the trailing (carriage-return and) newline, if it's the last
  1134. thing in the result.
  1135.  
  1136.    The commands run by calls to the `shell' function are run when the
  1137. function calls are expanded.  In most cases, this is when the makefile
  1138. is read in.  The exception is that function calls in the commands of
  1139. the rules are expanded when the commands are run, and this applies to
  1140. `shell' function calls like all others.
  1141.  
  1142.    Here are some examples of the use of the `shell' function:
  1143.  
  1144.      contents := $(shell cat foo)
  1145.  
  1146. sets `contents' to the contents of the file `foo', with a space (rather
  1147. than a newline) separating each line.
  1148.  
  1149.      files := $(shell echo *.c)
  1150.  
  1151. sets `files' to the expansion of `*.c'.  Unless `make' is using a very
  1152. strange shell, this has the same result as `$(wildcard *.c)'.
  1153.  
  1154. File: make.info,  Node: Running,  Next: Implicit Rules,  Prev: Functions,  Up: Top
  1155.  
  1156. How to Run `make'
  1157. *****************
  1158.  
  1159.    A makefile that says how to recompile a program can be used in more
  1160. than one way.  The simplest use is to recompile every file that is out
  1161. of date.  Usually, makefiles are written so that if you run `make' with
  1162. no arguments, it does just that.
  1163.  
  1164.    But you might want to update only some of the files; you might want
  1165. to use a different compiler or different compiler options; you might
  1166. want just to find out which files are out of date without changing them.
  1167.  
  1168.    By giving arguments when you run `make', you can do any of these
  1169. things and many others.
  1170.  
  1171.    The exit status of `make' is always one of three values:
  1172. `0'
  1173.      The exit status is zero if `make' is successful.
  1174.  
  1175. `2'
  1176.      The exit status is two if `make' encounters any errors.  It will
  1177.      print messages describing the particular errors.
  1178.  
  1179. `1'
  1180.      The exit status is one if you use the `-q' flag and `make'
  1181.      determines that some target is not already up to date.  *Note
  1182.      Instead of Executing the Commands: Instead of Execution.
  1183.  
  1184. * Menu:
  1185.  
  1186. * Makefile Arguments::          How to specify which makefile to use.
  1187. * Goals::                       How to use goal arguments to specify which
  1188.                                   parts of the makefile to use.
  1189. * Instead of Execution::        How to use mode flags to specify what
  1190.                                   kind of thing to do with the commands
  1191.                                   in the makefile other than simply
  1192.                                   execute them.
  1193. * Avoiding Compilation::        How to avoid recompiling certain files.
  1194. * Overriding::                  How to override a variable to specify
  1195.                                   an alternate compiler and other things.
  1196. * Testing::                     How to proceed past some errors, to
  1197.                                   test compilation.
  1198. * Options Summary::             Summary of Options
  1199.  
  1200. File: make.info,  Node: Makefile Arguments,  Next: Goals,  Up: Running
  1201.  
  1202. Arguments to Specify the Makefile
  1203. =================================
  1204.  
  1205.    The way to specify the name of the makefile is with the `-f' or
  1206. `--file' option (`--makefile' also works).  For example, `-f altmake'
  1207. says to use the file `altmake' as the makefile.
  1208.  
  1209.    If you use the `-f' flag several times and follow each `-f' with an
  1210. argument, all the specified files are used jointly as makefiles.
  1211.  
  1212.    If you do not use the `-f' or `--file' flag, the default is to try
  1213. `GNUmakefile', `makefile', and `Makefile', in that order, and use the
  1214. first of these three which exists or can be made (*note Writing
  1215. Makefiles: Makefiles.).
  1216.  
  1217.