home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / c / gymake12.arc / MAKE.DOC < prev    next >
Text File  |  1988-11-18  |  16KB  |  390 lines

  1. NAME
  2.      make - maintain, update, and reconstruct groups of programs
  3.  
  4. SYNOPSIS
  5.      make [-f makefile] [-dDeinrst] [target...] [macro=value ...]
  6.  
  7. DESCRIPTION
  8.      MAKE takes a file of dependencies (a 'makefile') and decides what
  9.      commands have to be executed to bring the files up to date.  These
  10.      commands are either executed directly from MAKE or written to the
  11.      standard output without executing them.
  12.  
  13.      If no makefile is specified with a -f option, MAKE reads a file
  14.      named `makefile', if it exists.
  15.  
  16.      If no target is specified on the command line, MAKE uses the first
  17.      target defined in the first makefile.
  18.  
  19. OPTIONS
  20.      -f makefile
  21.          Use the description file `makefile'.  A - as the makefile
  22.          argument denotes the standard input.
  23.  
  24.      -d  Display the reasons why MAKE chooses to rebuild a target.  All
  25.          dependencies which are newer are displayed
  26.  
  27.      -dd Display the dependency checks in more detail.  Dependencies
  28.          which are older are displayed, as well as newer.
  29.  
  30.      -D  Display the text of the makefiles as read in.
  31.  
  32.      -DD Display the text of the makefiles and `default.mk'.
  33.  
  34.      -e  Let environment variables override macro definitions from
  35.          makefiles.  Normally, makefile macros override environment
  36.          variables.  Command line macro definitions always override both
  37.          environment variables and makefile macros definitions.
  38.  
  39.      -i  Ignore error codes returned by commands.  This is equivalent to
  40.          the special target .IGNORE:.
  41.  
  42.      -n  No execution mode.  Print commands, but do not execute them.
  43.          Even lines beginning with an @ are printed.  However, if a
  44.          command line is an invocation of MAKE, that line is always
  45.          executed.
  46.  
  47.      -r  Do not read in the default file `default.mk'.
  48.  
  49.      -s  Silent mode.  Do not print command lines before executing them.
  50.          This is equivalent to the special target .SILENT:.
  51.  
  52.      -t  Touch the target files, bringing them up to date, rather than
  53.          performing the rules to reconstruct them.
  54.  
  55.      macro=value
  56.          Macro definition.  This definition remains fixed for the MAKE
  57.          invocation.  It overrides any regular definitions for the
  58.          specified macro within the makefiles and from the environment.
  59.          It is inherited by subordinate MAKE's but act as an environment
  60.          variable for these.  That is, depending on the -e setting, it
  61.          may be overridden by a makefile definition.
  62.  
  63. USAGE
  64.   Makefiles
  65.      The first makefile read is `default.mk', which can be located any-
  66.      where along the PATH.  It typically contains predefined macros and
  67.      implicit rules.
  68.  
  69.      The default name of the makefile is `makefile' in the current
  70.      directory.  An alternate makefile can be specified using one or
  71.      more '-f' options on the command line.  Multiple '-f's act as the
  72.      concatenation of all the makefiles in a left-to-right order.
  73.  
  74.      The makefile(s) may contain a mixture of comment lines, macro
  75.      definitions, include lines, and target lines.  Lines may be
  76.      continued across input lines by escaping the NEWLINE with a
  77.      backslash (\).
  78.  
  79.      Anything after a "#" is considered to be a comment, and is stripped
  80.      from the line.  Completely blank lines are ignored.
  81.  
  82.      An include line is used to include the text of another makefile.
  83.      It consists of the word "include" left justified, followed by
  84.      spaces, and followed by the name of the file that is to be included
  85.      at this line.  Include files may be nested.
  86.  
  87.   Macros
  88.      Macros have the form `WORD = text and more text'.  The WORD need
  89.      not be uppercase, but this is an accepted standard.  Later lines
  90.      which contain $(WORD) or ${WORD} will have this replaced by `text
  91.      and more text'.  If the macro name is a single character, the
  92.      parentheses are optional.  Note that the expansion is done
  93.      recursively, so the body of a macro may contain other macro
  94.      invocations.
  95.  
  96.     e.g.    FLINTSTONES = wilma and fred
  97.         RUBBLES = barney and betty
  98.         BEDROCK = $(FLINTSTONES) and $(RUBBLES)
  99.  
  100.      `$(BEDROCK)' becomes `wilma and fred and barney and betty'
  101.  
  102.      Also note that whitespace around the equal sign is not relevant
  103.      when defining a macro.  The following four macro definitions are
  104.      all equivalent:
  105.  
  106.         MACRO = body
  107.         MACRO=  body
  108.         MACRO  =body
  109.         MACRO=body
  110.  
  111.      Macros may be added to by using the `+=' notation.  Thus
  112.  
  113.         FLINTSTONES += pebbles and dino
  114.  
  115.      would be (given the examples above) the same as
  116.  
  117.         FLINTSTONES = wilma and fred and pebbles and dino
  118.  
  119.   Special Macros
  120.      MAKE
  121.          This normally has the value "make".  Any line which invokes
  122.          MAKE temporarily overrides the -n option, just for the duration
  123.          of the one line.  This allows nested invocations of MAKE to be
  124.          tested with the -n option.
  125.  
  126.      MAKEFLAGS
  127.          This macro has the set of options provided to MAKE as its
  128.          value.  If this is set as an environment variable, the set of
  129.          options is processed before any command line options.  This
  130.          macro may be explicitly passed to nested MAKEs, but it is also
  131.          available to these invocations as an environment variable.
  132.  
  133.      SUFFIXES
  134.          This contains the default list of suffixes supplied to the
  135.          special target .SUFFIXES:.  It is not sufficient to simply
  136.          change this macro in order to change the .SUFFIXES: list.  That
  137.          target must be specified in your makefile.
  138.  
  139.      There are several dynamically maintained macros that are useful as
  140.      abbreviations within rules.  It is best not to define them
  141.      explicitly.
  142.  
  143.      $*  The basename of the current target.
  144.  
  145.      $<  The name of the current dependency file.
  146.  
  147.      $@  The name of the current target.
  148.  
  149.      The $< and $* macros are normally used for implicit rules.  They
  150.      may be unreliable when used within explicit target command lines.
  151.  
  152.   Targets
  153.      A target entry in the makefile has the following format:
  154.  
  155.     target ... : [dependency ...]
  156.         [rule]
  157.         ...
  158.  
  159.      Any line which does not have leading whitespace (other than macro
  160.      definitions) is a `target' line.  Target lines consist of one or
  161.      more filenames (or macros which expand into same) called targets,
  162.      followed by a semi-colon (:).  The ':' is followed by a list of
  163.      dependent files.
  164.  
  165.      Special allowance is made on MSDOS for the colons which are needed
  166.      to specify files on other drives, so for example, the following
  167.      will work as intended:
  168.  
  169.         c:foo.bar : a:fee.ber
  170.  
  171.      If a target is named in more than one target line, the dependencies
  172.      and rules are added to form the target's complete dependency list
  173.      and rule list.
  174.  
  175.      The dependents are ones from which a target is constructed.  They
  176.      in turn may be targets of other dependents.  In general, for a
  177.      particular target file, each of its dependent files is `made', to
  178.      make sure that each is up to date with respect to it's dependents.
  179.  
  180.      The modification time of the target is compared to the modification
  181.      times of each dependent file.  If the target is older, one or more
  182.      of the dependents have changed, so the target must be constructed.
  183.      Of course, this checking is done recursively, so that all
  184.      dependents of dependents of dependents of ...  are up to date.
  185.  
  186.      To reconstruct a target, MAKE expands macros, strips off initial
  187.      whitespace, and either executes the rules directly, or passes each
  188.      to a shell or COMMAND.COM for execution.
  189.  
  190.      For target lines, macros are expanded on input.  All other lines
  191.      have macro expansion delayed until absolutely required.
  192.  
  193.   Special Targets
  194.      .DEFAULT:
  195.          The rule for this target is used to process a target when there
  196.          is no other entry for it, and no implicit rule for building it.
  197.          MAKE ignores all dependencies for this target.
  198.  
  199.      .DONE:
  200.          This target and its dependencies are processed after all other
  201.          targets are built.
  202.  
  203.      .IGNORE:
  204.          Non-zero error codes returned from commands are ignored.
  205.          Encountering this in a makefile is the same as specifying -i on
  206.          the command line.
  207.  
  208.      .INIT:
  209.          This target and its dependencies are processed before any other
  210.          targets are processed.
  211.  
  212.      .SILENT:
  213.          Commands are not echoed before executing them.  Encountering
  214.          this in a makefile is the same as specifying -s on the command
  215.          line.
  216.  
  217.      .SUFFIXES:
  218.          The suffixes list for selecting implicit rules.  Specifying
  219.          this target with dependents adds these to the end of the
  220.          suffixes list.  Specifying it with no dependents clears the
  221.          list.  In order to add your own dependents to the head of the
  222.          list, you could enter:
  223.  
  224.         .SUFFIXES:
  225.         .SUFFIXES:    .abc $(SUFFIXES)
  226.  
  227.   Rules
  228.      A line in a makefile that starts with a TAB or SPACE is a shell
  229.      line or rule.  This line is associated with the most recently
  230.      preceding dependency line.  A sequence of these may be associated
  231.      with a single dependency line.  When a target is out of date with
  232.      respect to a dependent, the sequence of commands is executed.
  233.      Shell lines may have any combination of the following characters to
  234.      the left of the command:
  235.  
  236.      @   will not echo the command line.
  237.  
  238.      -   MAKE will ignore the exit code of the command, i.e.  the
  239.          ERRORLEVEL of MSDOS.  Without this, MAKE terminates when a
  240.          nonzero exit code is returned.
  241.  
  242.      +   MAKE will use COMMAND.COM to execute the command.
  243.  
  244.      If the '+' is not attached to a shell line, but the command is a
  245.      DOS command or if redirection is used (<, |, >), the shell line is
  246.      passed to COMMAND.COM anyway.
  247.  
  248.   Implicit Rules
  249.      Implicit rules are intimately tied to the .SUFFIXES: special
  250.      target.  Each entry in the .SUFFIXES defines an extension to a
  251.      filename which may be used to build another file.  The implicit
  252.      rules then define how to actually build one file from another.
  253.      These files are related, in that they must share a common basename,
  254.      but have different extensions.
  255.  
  256.      If a file that is being made does not have an explicit target line,
  257.      an implicit rule is looked for.  Each entry in the .SUFFIXES: list
  258.      is combined with the extension of the target, to get the name of an
  259.      implicit target.  If this target exists, it gives the rules used to
  260.      transform a file with the dependent extension to the target file.
  261.      Any dependents of the implicit target are ignored.
  262.  
  263.      In the following example, the .SUFFIXES: list is .c .y .l, and the
  264.      target file is fred.o which does not have a target line.  An
  265.      implicit rule target `.c.o' is constructed and searched for.  If it
  266.      does not exist, the next suffix is tried.  If the implicit rule
  267.      target does exist, MAKE looks for a file `fred.c'.  If this file
  268.      does not exist, the next extension is tried.  If `fred.c' does
  269.      exist, then the associated rules are executed to create fred.o from
  270.      fred.c, presumably invoking the C compiler.
  271.  
  272.      If the next extension must be tried, MAKE reiterates the above with
  273.      target `.y.o' and a file named `fred.y', and potentially with
  274.      `.l.o' and `fred.l'.
  275.  
  276. EXAMPLES
  277.      This makefile says that pgm.exe depends on two files a.obj and
  278.      b.obj, and that they in turn depend on their corresponding source
  279.      files (a.c and b.c) along with the common file incl.h.
  280.  
  281.     pgm.exe: a.obj b.obj
  282.         $(CC) a.obj b.obj -o $@
  283.  
  284.     a.obj:    incl.h a.c
  285.         $(CC) -c a.c
  286.  
  287.     b.obj:    incl.h b.c
  288.         $(CC) -c b.c
  289.  
  290.      The following makefile uses implicit rules to express the same
  291.      dependencies.
  292.  
  293.     pgm.exe: a.obj b.obj
  294.         $(CC) a.o b.o -o $@
  295.  
  296.     a.obj b.obj: incl.h
  297.  
  298. FILES
  299.      makefile            Current version(s) of make description file.
  300.      default.mk          Default file for user-defined targets, macros,
  301.                          and implicit rules.
  302.  
  303. DIAGNOSTICS
  304.      MAKE returns an exit status of 1 when it halts as a result of an
  305.      error.  Otherwise it returns an exit status of 0.
  306.  
  307.     Badly formed macro
  308.          A macro definition has been encountered which has incorrect
  309.          syntax.  Most likely, the name is missing.
  310.  
  311.     cannot open file
  312.          The makefile indicated in an include directive was not found or
  313.          was not accessible.
  314.  
  315.     Don't know how to make target
  316.          There is no makefile entry for target, none of MAKE's implicit
  317.          rules apply, and there is no .DEFAULT: rule.
  318.  
  319.     Improper Macro.
  320.          An error has occurred during macro expansion.  The most likely
  321.          error is a missing closing bracket.
  322.  
  323.     rules must be after target
  324.          A makefile syntax error, where a line beginning with a SPACE or
  325.          TAB has been encountered before a target line.
  326.  
  327.     too many options
  328.          MAKE has run out of allocated space while processing command
  329.          line options or a target list.
  330.  
  331. AUTHOR
  332.      Greg Yachuk    Informix Software Inc., Menlo Park CA 94114
  333.  
  334.      Parts of this program are based on the work by Larry Campbell of
  335.      DEC, Mike Hickey of University of DC, and by Dan Grayson.
  336.  
  337.      Some of this documentation is based on text written by Jeffrey
  338.      Spidle of Iowa State University and by Dan Grayson.
  339.  
  340.      Some of the formatting of this documentation follows the example of
  341.      Sun Microsystems for their UNIX 4.3 Release.
  342.  
  343. BUGS
  344.      MAKE does not allow a target line to end with a semi-colon (;) and
  345.      a command.  All commands must be on separate lines.
  346.  
  347.      MAKE allows spaces as well as TABs to introduce shell command
  348.      lines.
  349.  
  350.      Target lines cannot use the double colon (::) syntax.
  351.  
  352.      Once a dependency is made, MAKE assumes that the dependency file is
  353.      present for the remainder of the run.  If a rule subsequently
  354.      removes that file and future targets depend on it's existence,
  355.      unexpected errors may result.
  356.  
  357.      Sometimes MAKE gets confused when searching for implicit rules, and
  358.      uses several rules instead of a single rule.  For example, the two
  359.      rules .c.o and .l.c may be used, rather than the more direct .l.o
  360.      rule.
  361.  
  362.      The -f options are included in MAKEFLAGS for subordinate MAKEs.
  363.      These are safely ignored, as long as $(MAKEFLAGS) is NOT specified
  364.      on the $(MAKE) command line.
  365.  
  366.      The following flags are NOT supported:
  367.  
  368.      -k  When a nonzero error status is returned by a command, abandon
  369.          work on the current target, but continue with other branches
  370.          that do not depend on this target.
  371.  
  372.      -p  Print out the compete set of macro definitions and target
  373.          descriptions.
  374.  
  375.      -P  Report dependencies recursively to show the entire dependency
  376.          hierarchy, without rebuilding any targets.
  377.  
  378.      -q  Question mode.  MAKE returns a zero or non-zero status code,
  379.          depending on whether or not the target file is up to date.
  380.  
  381.      -S  Undo the effect of the -k option.  Stop processing when a
  382.          non-zero exit status is returned by a command.
  383.  
  384.      The following special targets are NOT supported:
  385.  
  386.      .KEEP_STATE:
  387.      .MAKE_VERSION:
  388.      .PRECIOUS:
  389.      .SCCS_GET:
  390.