home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / tools / make / pdmake / make.doc < prev    next >
Text File  |  1990-07-06  |  20KB  |  503 lines

  1. NAME
  2.      make - maintain, update, and reconstruct groups of programs
  3.  
  4. SYNOPSIS
  5.      make [-f file] [-dDeiknqrsStWb-] [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.      -k  When a nonzero error status is returned by a command, abandon
  43.          work on the current target, but continue with other branches
  44.          that do not depend on this target.
  45.  
  46.      -n  No execution mode.  Print commands, but do not execute them.
  47.          Even lines beginning with an @ are printed.  However, if a
  48.          command line is an invocation of MAKE, that line is always
  49.          executed.
  50.  
  51.      -q  Question mode.  MAKE returns a zero or non-zero status code,
  52.          depending on whether or not the target file is up to date.
  53.  
  54.      -r  Do not read in the default file `default.mk'.
  55.  
  56.      -s  Silent mode.  Do not print command lines before executing them.
  57.          This is equivalent to the special target .SILENT:.
  58.  
  59.      -S  Undo the effect of the -k option.  Stop processing when a
  60.          non-zero exit status is returned by a command.
  61.  
  62.      -t  Touch the target files, bringing them up to date, rather than
  63.          performing the rules to reconstruct them.
  64.  
  65.      -W target
  66.          Perform the make as if this target has a modification time of
  67.          "right now".  This is the "What If?" option.
  68.  
  69.      -b  This option is accepted and ignored.  It allows compatibility
  70.          with older makefiles (and scripts).
  71.  
  72.      --  This option is accepted and ignored.  It allows compatibility
  73.          with SCO Xenix which requires -$(MAKEFLAGS).  This version of
  74.          make includes a '-' within $(MAKEFLAGS).
  75.  
  76.      macro=value
  77.          Macro definition.  This definition remains fixed for the MAKE
  78.          invocation.  It overrides any regular definitions for the
  79.          specified macro within the makefiles and from the environment.
  80.          It is inherited by subordinate MAKE's but act as an environment
  81.          variable for these.  That is, depending on the -e setting, it
  82.          may be overridden by a makefile definition.
  83.  
  84. USAGE
  85.   Makefiles
  86.      The first makefile read is `default.mk', which can be located any-
  87.      where along the PATH.  It typically contains predefined macros and
  88.      implicit rules.  For non-DOS systems (e.g.  Unix), it is searched
  89.      for in the current directory, then in the users home directory, and
  90.      finally along the PATH.
  91.  
  92.      The default name of the makefile is `makefile' in the current
  93.      directory.  If this file is not found on a non-DOS system, the file
  94.      `Makefile' is then used as the default.  Alternate makefiles can be
  95.      specified using one or more '-f' options on the command line.
  96.      Multiple '-f's act as the concatenation of all the makefiles in a
  97.      left-to-right order.
  98.  
  99.      The makefile(s) may contain a mixture of comment lines, macro
  100.      definitions, include lines, and target lines.  Lines may be
  101.      continued across input lines by escaping the NEWLINE with a
  102.      backslash (\).
  103.  
  104.      Anything after a "#" is considered to be a comment, and is stripped
  105.      from the line, including spaces immediately before the "#.  If the
  106.      "#" is inside a quoted string, it is not treated as a comment.
  107.      Completely blank lines are ignored.
  108.  
  109.      An include line is used to include the text of another makefile.
  110.      It consists of the word "include" left justified, followed by
  111.      spaces, and followed by the name of the file that is to be included
  112.      at this line.  Macros in the name of the included file are expanded
  113.      before the file is included.  Include files may be nested.
  114.  
  115.   Macros
  116.      Macros have the form `WORD = text and more text'.  The WORD need
  117.      not be uppercase, but this is an accepted standard.  Later lines
  118.      which contain $(WORD) or ${WORD} will have this replaced by `text
  119.      and more text'.  If the macro name is a single character, the
  120.      parentheses are optional.  Note that the expansion is done
  121.      recursively, so the body of a macro may contain other macro
  122.      invocations.
  123.  
  124.     e.g.    FLINTSTONES = wilma and fred
  125.         RUBBLES = barney and betty
  126.         BEDROCK = $(FLINTSTONES) and $(RUBBLES)
  127.  
  128.      `$(BEDROCK)' becomes `wilma and fred and barney and betty'
  129.  
  130.      Also note that whitespace around the equal sign is not relevant
  131.      when defining a macro.  The following four macro definitions are
  132.      all equivalent:
  133.  
  134.         MACRO = body
  135.         MACRO=  body
  136.         MACRO  =body
  137.         MACRO=body
  138.  
  139.      Macros may be added to by using the `+=' notation.  Thus
  140.  
  141.         FLINTSTONES += and pebbles and dino
  142.  
  143.      would be (given the examples above) the same as
  144.  
  145.         FLINTSTONES = wilma and fred and pebbles and dino
  146.  
  147.   Special Macros
  148.      MAKE
  149.          This normally has the value "make".  Any line which invokes
  150.          MAKE temporarily overrides the -n option, just for the duration
  151.          of the one line.  This allows nested invocations of MAKE to be
  152.          tested with the -n option.
  153.  
  154.      MAKEFLAGS
  155.          This macro has the set of options provided to MAKE as its
  156.          value.  If this is set as an environment variable, the set of
  157.          options is processed before any command line options.  This
  158.          macro may be explicitly passed to nested MAKEs, but it is also
  159.          available to these invocations as an environment variable.  The
  160.          -f and -d flags are not recorded in this macro.
  161.  
  162.      SUFFIXES
  163.          This contains the default list of suffixes supplied to the
  164.          special target .SUFFIXES:.  It is not sufficient to simply
  165.          change this macro in order to change the .SUFFIXES: list.  That
  166.          target must be specified in your makefile.
  167.  
  168.      SHELLCMD
  169.          This contains the default list of commands which are local to
  170.          the SHELL.  If a rule is an invocation of one of these
  171.          commands, a SHELL is automatically spawned to handle it.
  172.  
  173.      $   This macro translates to a dollar sign.  Thus you can use "$$"
  174.          in the makefile to represent a single "$".
  175.  
  176.      There are several dynamically maintained macros that are useful as
  177.      abbreviations within rules.  It is best not to define them
  178.      explicitly.
  179.  
  180.      $*  The basename of the current target.
  181.  
  182.      $<  The name of the current dependency file.
  183.  
  184.      $@  The name of the current target.
  185.  
  186.      $?  The names of dependents which are younger than the target.
  187.  
  188.      The $< and $* macros are normally used for implicit rules.  They
  189.      may be unreliable when used within explicit target command lines.
  190.      These may be suffixed with D and F, to specify the Directory and
  191.      Filename components (e.g. ${*D}, ${@F}).  If there is no directory
  192.      in the name, "." is supplied.
  193.  
  194.   Targets
  195.      A target entry in the makefile has the following format:
  196.  
  197.     target ... : [dependency ...] [; rule]
  198.         [rule]
  199.         ...
  200.  
  201.      Any line which does not have leading whitespace (other than macro
  202.      definitions) is a `target' line.  Target lines consist of one or
  203.      more filenames (or macros which expand into same) called targets,
  204.      followed by a colon (:).  The ':' is followed by a list of
  205.      dependent files.  The dependency list may be terminated with a
  206.      semicolon (;) which may be followed by a rule or shell command.
  207.  
  208.      Special allowance is made on MSDOS for the colons which are needed
  209.      to specify files on other drives, so for example, the following
  210.      will work as intended:
  211.  
  212.         c:foo.bar : a:fee.ber
  213.  
  214.      If a target is named in more than one target line, the dependencies
  215.      and rules are added to form the target's complete dependency list
  216.      and rule list.
  217.  
  218.      The dependents are ones from which a target is constructed.  They
  219.      in turn may be targets of other dependents.  In general, for a
  220.      particular target file, each of its dependent files is `made', to
  221.      make sure that each is up to date with respect to it's dependents.
  222.  
  223.      The modification time of the target is compared to the modification
  224.      times of each dependent file.  If the target is older, one or more
  225.      of the dependents have changed, so the target must be constructed.
  226.      Of course, this checking is done recursively, so that all
  227.      dependents of dependents of dependents of ...  are up to date.
  228.  
  229.      To reconstruct a target, MAKE expands macros, strips off initial
  230.      whitespace, and either executes the rules directly, or passes each
  231.      to a shell or COMMAND.COM for execution.
  232.  
  233.      For target lines, macros are expanded on input.  All other lines
  234.      have macro expansion delayed until absolutely required.
  235.  
  236.   Special Targets
  237.      .DEFAULT:
  238.          The rule for this target is used to process a target when there
  239.          is no other entry for it, and no implicit rule for building it.
  240.          MAKE ignores all dependencies for this target.
  241.  
  242.      .DONE:
  243.          This target and its dependencies are processed after all other
  244.          targets are built.
  245.  
  246.      .IGNORE:
  247.          Non-zero error codes returned from commands are ignored.
  248.          Encountering this in a makefile is the same as specifying -i on
  249.          the command line.
  250.  
  251.      .INIT:
  252.          This target and its dependencies are processed before any other
  253.          targets are processed.
  254.  
  255.      .SILENT:
  256.          Commands are not echoed before executing them.  Encountering
  257.          this in a makefile is the same as specifying -s on the command
  258.          line.
  259.  
  260.      .SUFFIXES:
  261.          The suffixes list for selecting implicit rules.  Specifying
  262.          this target with dependents adds these to the end of the
  263.          suffixes list.  Specifying it with no dependents clears the
  264.          list.  In order to add your own dependents to the head of the
  265.          list, you could enter:
  266.  
  267.         .SUFFIXES:
  268.         .SUFFIXES:    .abc $(SUFFIXES)
  269.  
  270.   Rules
  271.      A line in a makefile that starts with a TAB or SPACE is a shell
  272.      line or rule.  This line is associated with the most recently
  273.      preceding dependency line.  A sequence of these may be associated
  274.      with a single dependency line.  When a target is out of date with
  275.      respect to a dependent, the sequence of commands is executed.
  276.      Shell lines may have any combination of the following characters to
  277.      the left of the command:
  278.  
  279.      @   will not echo the command line, except if -n is used.
  280.  
  281.      -   MAKE will ignore the exit code of the command, i.e.  the
  282.          ERRORLEVEL of MSDOS.  Without this, MAKE terminates when a
  283.          nonzero exit code is returned.
  284.  
  285.      +   MAKE will use a shell or COMMAND.COM to execute the command.
  286.  
  287.      If the '+' is not attached to a shell line, but the command is a
  288.      DOS command or if redirection is used (<, |, >), the shell line is
  289.      passed to COMMAND.COM anyway.  For Unix, redirection, backquote (`)
  290.      parentheses and variables ($vname) force the use of a shell.
  291.  
  292.      For DOS, inline stdin (<<) operator is emulated with a temporary
  293.      file.  That is, subsequent commands are written to a temporary
  294.      file, and the name of the temporary file is placed in the command
  295.      line.  For example, if you want to link a number of objects
  296.      together, you can have a rule such as
  297.  
  298.          link $(OBJS),$(NAME),$(LDFLAGS),$(LIBS)
  299.  
  300.      If the resulting command line (after expansion) is greater than
  301.      128, you can specify in the following manner.
  302.  
  303.     link @<<END_OF_LINK
  304.         $(OBJS)
  305.         $(NAME)
  306.         $(LDFLAGS)
  307.         $(LIBS)
  308.     END_OF_LINK
  309.  
  310.      The four lines between the tags (END_OF_LINK) are written to a
  311.      temporary file (e.g.  "\mk2"), and the command line is rewritten as
  312.      "link @\mk2".
  313.  
  314.      The rules for redirection and tags are as follows:
  315.  
  316.         1)  If the redirector (<<) is immediately followed by some text,
  317.             the text is used as the tag.  E.g.  "<<END_OF_LINK".
  318.  
  319.         2)  If the redirector is not immediately followed by some text,
  320.             the next token is used as the tag.  E.g.  "<< END_OF_LINK".
  321.  
  322.         3)  If the redirector is the last token on a line, there is no
  323.             tag.
  324.  
  325.         4)  Lines immediately following the command are written to a
  326.             temporary file, until a line beginning with the tag is
  327.             encountered or until the end of the current set of rules.
  328.  
  329.       The following are all equivalent.
  330.  
  331.     link @<<        link @<<END_OF_LINK    link @<<END_OF_LINK
  332.         $(OBJS)            $(OBJS)            $(OBJS)
  333.         $(PROG)            $(PROG)            $(PROG)
  334.         $(LDFLAGS)        $(LDFLAGS)        $(LDFLAGS)
  335.         $(LIBS)            $(LIBS)            $(LIBS)
  336.                 END_OF_LINK
  337.  
  338.   Implicit Rules
  339.      Implicit rules are intimately tied to the .SUFFIXES: special
  340.      target.  Each entry in the .SUFFIXES defines an extension to a
  341.      filename which may be used to build another file.  The implicit
  342.      rules then define how to actually build one file from another.
  343.      These files are related, in that they must share a common basename,
  344.      but have different extensions.
  345.  
  346.      If a file that is being made does not have an explicit target line,
  347.      an implicit rule is looked for.  Each entry in the .SUFFIXES: list
  348.      is combined with the extension of the target, to get the name of an
  349.      implicit target.  If this target exists, it gives the rules used to
  350.      transform a file with the dependent extension to the target file.
  351.      Any dependents of the implicit target are ignored.
  352.  
  353.      In the following example, the .SUFFIXES: list is .c .y .l, and the
  354.      target file is fred.o which does not have a target line.  An
  355.      implicit rule target `.c.o' is constructed and searched for.  If it
  356.      does not exist, the next suffix is tried.  If the implicit rule
  357.      target does exist, MAKE looks for a file `fred.c'.  If this file
  358.      does not exist, the next extension is tried.  If `fred.c' does
  359.      exist, then the associated rules are executed to create fred.o from
  360.      fred.c, presumably invoking the C compiler.
  361.  
  362.      If the next extension must be tried, MAKE reiterates the above with
  363.      target `.y.o' and a file named `fred.y', and potentially with
  364.      `.l.o' and `fred.l'.
  365.  
  366.      If a file that is being made has an explicit target, but no rules,
  367.      a similar search is made for implicit rules.  Each entry in the
  368.      .SUFFIXES: list is combined with the extension of the target, to
  369.      get the name of an implicit target.  If such a target exists, then
  370.      the list of dependents is searched for a file with the correct
  371.      extension, and the implicit rules are invoked to create the target.
  372.  
  373. EXAMPLES
  374.      This makefile says that pgm.exe depends on two files a.obj and
  375.      b.obj, and that they in turn depend on their corresponding source
  376.      files (a.c and b.c) along with the common file incl.h.
  377.  
  378.     pgm.exe: a.obj b.obj
  379.         $(CC) a.obj b.obj -o $@
  380.  
  381.     a.obj:    incl.h a.c
  382.         $(CC) -c a.c
  383.  
  384.     b.obj:    incl.h b.c
  385.         $(CC) -c b.c
  386.  
  387.      The following makefile uses implicit rules to express the same
  388.      dependencies.
  389.  
  390.     pgm.exe: a.obj b.obj
  391.         $(CC) a.obj b.obj -o $@
  392.  
  393.     a.obj b.obj: incl.h
  394.  
  395.      This final makefile uses implicit rules to create targets with
  396.      dependencies in a different directory.  Note: this cannot be done
  397.      with standard Unix make.
  398.  
  399.     pgm.exe: a.obj b.obj
  400.         $(CC) a.obj b.obj -o $@
  401.  
  402.     a.obj:    incl.h ../a.c
  403.  
  404.     b.obj:    incl.h ../b.c
  405.  
  406. FILES
  407.      makefile            Current version(s) of make description file.
  408.      Makefile            Alternative to makefile, for Unix.
  409.      default.mk          Default file for user-defined targets, macros,
  410.                          and implicit rules.
  411.  
  412. DIAGNOSTICS
  413.      MAKE returns an exit status of 1 when it halts as a result of an
  414.      error.  Otherwise it returns an exit status of 0.
  415.  
  416.      Badly formed macro
  417.          A macro definition has been encountered which has incorrect
  418.          syntax.  Most likely, the name is missing.
  419.  
  420.      cannot open file
  421.          The makefile indicated in an include directive was not found or
  422.          was not accessible.
  423.  
  424.      Don't know how to make target
  425.          There is no makefile entry for target, none of MAKE's implicit
  426.          rules apply, and there is no .DEFAULT: rule.
  427.  
  428.      Improper Macro.
  429.          An error has occurred during macro expansion.  The most likely
  430.          error is a missing closing bracket.
  431.  
  432.      Macro too long (limit 100 chars):
  433.          A macro name is too long for the internal buffer.  Try shortening
  434.      it to 100 characters or less.
  435.  
  436.      rules must be after target
  437.          A makefile syntax error, where a line beginning with a SPACE or
  438.          TAB has been encountered before a target line.
  439.  
  440.      too many options
  441.          MAKE has run out of allocated space while processing command
  442.          line options or a target list.
  443.  
  444.      Too many rules defined for target
  445.      A target occurs multiple times, and each time has rules.  A
  446.      target may only have one set of rules.
  447.  
  448.      Unexpected end of line seen
  449.          A target line without a colon has been encountered.
  450.  
  451. AUTHOR
  452.      Greg Yachuk      Informix Software Inc., Menlo Park, CA 92025
  453.      greggy@informix.com | {uunet,pyramid}!infmx!greggy    (415) 926-6300
  454.  
  455.      Parts of this program are based on the work by Larry Campbell of
  456.      DEC, Mike Hickey of University of DC, and by Dan Grayson.
  457.  
  458.      Some of this documentation is based on text written by Jeffrey
  459.      Spidle of Iowa State University and by Dan Grayson.
  460.  
  461.      Some of the formatting of this documentation follows the example of
  462.      Sun Microsystems for their UNIX 4.2 Release.
  463.  
  464. BUGS
  465.      The -n does not always correctly identify the targets which need to
  466.      be made.  It never misses required makes, but sometimes includes
  467.      unrequired makes.  It also incorrectly sets up the $?  macro in
  468.      these circumstances.  This does not happen during full execution.
  469.  
  470.      MAKE allows spaces as well as TABs to introduce shell command
  471.      lines.
  472.  
  473.      Target lines cannot use the double colon (::) syntax.
  474.  
  475.      Once a dependency is made, MAKE assumes that the dependency file is
  476.      present for the remainder of the run.  If a rule subsequently
  477.      removes that file and future targets depend on it's existence,
  478.      unexpected errors may result.
  479.  
  480.      Sometimes MAKE gets confused when searching for implicit rules, and
  481.      uses several rules instead of a single rule.  For example, the two
  482.      rules .c.o and .l.c may be used, rather than the more direct .l.o
  483.      rule.
  484.  
  485.      If a number of command line flags are run together, and contains
  486.      either `f' or `d', the whole set of flags is dropped from
  487.      MAKEFLAGS.
  488.  
  489.      The following flags are NOT supported:
  490.  
  491.      -p  Print out the compete set of macro definitions and target
  492.          descriptions.
  493.  
  494.      -P  Report dependencies recursively to show the entire dependency
  495.          hierarchy, without rebuilding any targets.
  496.  
  497.      The following special targets are NOT supported:
  498.  
  499.      .KEEP_STATE:
  500.      .MAKE_VERSION:
  501.      .PRECIOUS:
  502.      .SCCS_GET:
  503.