make: Remaking Makefiles

1 
1 3.5 How Makefiles Are Remade
1 ============================
1 
1 Sometimes makefiles can be remade from other files, such as RCS or SCCS
1 files.  If a makefile can be remade from other files, you probably want
1 'make' to get an up-to-date version of the makefile to read in.
1 
1    To this end, after reading in all makefiles, 'make' will consider
1 each as a goal target and attempt to update it.  If a makefile has a
1 rule which says how to update it (found either in that very makefile or
11 in another one) or if an implicit rule applies to it (⇒Using
 Implicit Rules Implicit Rules.), it will be updated if necessary.
1 After all makefiles have been checked, if any have actually been
1 changed, 'make' starts with a clean slate and reads all the makefiles
1 over again.  (It will also attempt to update each of them over again,
1 but normally this will not change them again, since they are already up
1 to date.)
1 
1    If you know that one or more of your makefiles cannot be remade and
1 you want to keep 'make' from performing an implicit rule search on them,
1 perhaps for efficiency reasons, you can use any normal method of
1 preventing implicit rule look-up to do so.  For example, you can write
1 an explicit rule with the makefile as the target, and an empty recipe
1 (⇒Using Empty Recipes Empty Recipes.).
1 
1    If the makefiles specify a double-colon rule to remake a file with a
11 recipe but no prerequisites, that file will always be remade (⇒
 Double-Colon).  In the case of makefiles, a makefile that has a
1 double-colon rule with a recipe but no prerequisites will be remade
1 every time 'make' is run, and then again after 'make' starts over and
1 reads the makefiles in again.  This would cause an infinite loop: 'make'
1 would constantly remake the makefile, and never do anything else.  So,
1 to avoid this, 'make' will *not* attempt to remake makefiles which are
1 specified as targets of a double-colon rule with a recipe but no
1 prerequisites.
1 
1    If you do not specify any makefiles to be read with '-f' or '--file'
11 options, 'make' will try the default makefile names; ⇒What Name to
 Give Your Makefile Makefile Names.  Unlike makefiles explicitly
1 requested with '-f' or '--file' options, 'make' is not certain that
1 these makefiles should exist.  However, if a default makefile does not
1 exist but can be created by running 'make' rules, you probably want the
1 rules to be run so that the makefile can be used.
1 
1    Therefore, if none of the default makefiles exists, 'make' will try
1 to make each of them in the same order in which they are searched for
1 (⇒What Name to Give Your Makefile Makefile Names.) until it
1 succeeds in making one, or it runs out of names to try.  Note that it is
1 not an error if 'make' cannot find or make any makefile; a makefile is
1 not always necessary.
1 
11    When you use the '-t' or '--touch' option (⇒Instead of Executing
 Recipes Instead of Execution.), you would not want to use an
1 out-of-date makefile to decide which targets to touch.  So the '-t'
1 option has no effect on updating makefiles; they are really updated even
1 if '-t' is specified.  Likewise, '-q' (or '--question') and '-n' (or
1 '--just-print') do not prevent updating of makefiles, because an
1 out-of-date makefile would result in the wrong output for other targets.
1 Thus, 'make -f mfile -n foo' will update 'mfile', read it in, and then
1 print the recipe to update 'foo' and its prerequisites without running
1 it.  The recipe printed for 'foo' will be the one specified in the
1 updated contents of 'mfile'.
1 
1    However, on occasion you might actually wish to prevent updating of
1 even the makefiles.  You can do this by specifying the makefiles as
1 goals in the command line as well as specifying them as makefiles.  When
1 the makefile name is specified explicitly as a goal, the options '-t'
1 and so on do apply to them.
1 
1    Thus, 'make -f mfile -n mfile foo' would read the makefile 'mfile',
1 print the recipe needed to update it without actually running it, and
1 then print the recipe needed to update 'foo' without running that.  The
1 recipe for 'foo' will be the one specified by the existing contents of
1 'mfile'.
1