home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / c / abmake14.arc / make.man < prev    next >
Text File  |  1989-07-20  |  17KB  |  529 lines

  1.  
  2.  
  3.  
  4. MAKE(1)                MAKE User's Manual                 MAKE(1)
  5.  
  6.  
  7.  
  8. NAME
  9.      make - maintain, update, and regenerate groups of programs
  10.  
  11. SYNOPSIS
  12.      make [-f filename] [-CdeiknrstFV] [target ...] [macro=value
  13.      ...]
  14.  
  15. DESCRIPTION
  16.      Make reads an input file containing a listing of dependen-
  17.      cies between files, and associated rules to maintain the
  18.      dependencies.  The format is generally a target file name,
  19.      followed by a list of files that it is dependent upon, fol-
  20.      lowed by a set of commands to be used to recreate the target
  21.      from the dependents.  Each dependent is in its own right a
  22.      target, and so the maintenance of each dependent is per-
  23.      formed recursively, before attempting to maintain the
  24.      current target.  If, after processing its all of its depen-
  25.      dencies, a target file is found either to be missing, or to
  26.      be older than any of its dependency files, make uses the
  27.      supplied commands or an implicit rule to rebuild it.
  28.  
  29.      If no makefile is specified with a -f option, make reads a
  30.      file named `makefile', if it exists.
  31.  
  32.      If no target is specified on the command line, make uses the
  33.      first target defined in makefile.
  34.  
  35.      If a target has no makefile entry, or if its entry has no
  36.      rule, make attempts to derive a rule by each of the follow-
  37.      ing methods:
  38.  
  39.      o    implicit rules, read in from a user-supplied makefile.
  40.  
  41.      o    standard implict rules typically read in from the file
  42.           `default.mk'.
  43.  
  44.      o    the rule from the .DEFAULT: entry target, if there is
  45.           such an entry in the makefile.
  46.  
  47.      If there is no makefile entry for a target, and no rule can
  48.      be derived for building it, and if no file by that name is
  49.      present, make issues an error message and stops.
  50.  
  51. OPTIONS
  52.      -f  makefile
  53.           Use the description file `makefile'.  A - as the
  54.           makefile argument denotes the standard input.  The con-
  55.           tents of `makefile', when present, override the stan-
  56.           dard set of implicit rules and predefined macros.  When
  57.           more than one -f makefile argument pair appears, make
  58.           uses the concatenation of those files, in order of
  59.           appearance.
  60.  
  61.  
  62.  
  63. Printed 7/20/89          April 30, 1989                         1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. MAKE(1)                  Programmer's Manual              MAKE(1)
  71.  
  72.  
  73.  
  74.      -d   Display the reasons why make chooses to rebuild a tar-
  75.           get; make displays any and all dependencies that are
  76.           newer.
  77.  
  78.      -e   Do not override any assignments with present environ-
  79.           ment variables.
  80.  
  81.      -F   Force all target updates.  Build target even when no
  82.           update is needed according to file time/date.
  83.  
  84.      -i   Ignore error codes returned by commands.  Equivalent to
  85.           the special-function target .IGNORE:.
  86.  
  87.      -k   Abandon building the current target as soon as an error
  88.           code is returned during building. Continue with other
  89.           targets.
  90.  
  91.      -n   No execution mode.  Print commands, but do not execute
  92.           them.  Even lines beginning with an @ are printed.
  93.           However, if a command line contains a reference to the
  94.           $(MAKE) macro, that line is always executed.
  95.  
  96.      -r   Do not read in the default file (default.mk).
  97.  
  98.      -s   Silent mode.  Do not print command lines before execut-
  99.           ing them.  Equivalent to the special-function target
  100.           .SILENT:.
  101.  
  102.      -S   Undo the effect of the -k option.  With this switch,
  103.           the -k option is undone, which means that any error
  104.           code returned by a child process during building, will
  105.           halt 'make' and display the error code.
  106.  
  107.      -t   Touch the target files (bringing them up to date)
  108.           rather than performing their rules.
  109.  
  110.      -V   List the current version number of 'make'.
  111.  
  112.      macro=value
  113.           Macro definition.  This definition remains fixed for
  114.           the make invocation.  It overrides any regular defini-
  115.           tion for the specified macro within the makefile
  116.           itself.
  117.  
  118. USAGE
  119.      Reading Makefiles
  120.      When make first starts, it reads the environment setting of
  121.      MAKE_FLAGS and scans all present options. Then it reads the
  122.      command line for a list of options, after which it reads in
  123.      a default makefile that typically contains predefined macro
  124.      definitions and target entries for implicit rules.  If
  125.      present, make uses the file `default.mk' in the current
  126.  
  127.  
  128.  
  129. Printed 7/20/89          April 30, 1989                         2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. MAKE(1)                  Programmer's Manual              MAKE(1)
  137.  
  138.  
  139.  
  140.      directory.  Otherwise it looks for this file along the
  141.      search path.
  142.  
  143.      Next, make reads any makefiles you specify with -f, or (if
  144.      present, in order) `Makefile', and then `makefile', if no -f
  145.      makefile's are specified.  Finally, make reads in all macro
  146.      definitions from the command line.  These override macro
  147.      definitions in the makefile.
  148.  
  149.      The makefile(s) may contain a mixture of comment lines,
  150.      macro definitions, include lines, and target lines.  Lines
  151.      may be continued across input lines by escaping the NEWLINE
  152.      with a backslash (\).
  153.  
  154.      A comment line is any line whose first non-space character
  155.      is a '#'.  The comment ends at the next unescaped NEWLINE.
  156.  
  157.      An include line is used to include the text of another
  158.      makefile.  The first seven letters of the line is the word
  159.      "include" followed by a space.  The string that follows is
  160.      taken as a filename to include at this line.
  161.  
  162.      Macros
  163.      A macro definition line has the form of `WORD=text...'.  The
  164.      word to the left of the equal sign (without surrounding
  165.      white space) is the macro name.  Text to the right is the
  166.      value of the macro.  Leading white space between the = and
  167.      the first word of the value is ignored.  A word break fol-
  168.      lowing the = is implied.  Trailing white space (up to but
  169.      not including a comment character) is included in the value.
  170.  
  171.      Macros are referenced with a $.  The following character, or
  172.      the parenthesized ( ) or bracketed { } string, is inter-
  173.      preted as a macro reference.  make expands the reference
  174.      (including the $) by replacing it with the macro's value.
  175.      If a macro contains another macro, the interior one is
  176.      expanded first.  Note that this may lead to infinite expan-
  177.      sion, if a macro references itself.
  178.  
  179.      The MAKE macro is special.  It has the value "make" by
  180.      default, and temporarily overrides the -n option for any
  181.      line in which it is referred to.  This allows nested invoca-
  182.      tions of make written as:
  183.  
  184.           $(MAKE) ...
  185.  
  186.      to run recursively, with the -n flag in effect for all com-
  187.      mands but make.
  188.  
  189.      make supplies predefined macros in the `default.mk' file.
  190.      If -r is in effect, make does not supply these macro defini-
  191.      tions.
  192.  
  193.  
  194.  
  195. Printed 7/20/89          April 30, 1989                         3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. MAKE(1)                  Programmer's Manual              MAKE(1)
  203.  
  204.  
  205.  
  206.      There are several dynamically maintained macros that are
  207.      useful as abbreviations within rules.  They are shown here
  208.      as references; it is best not to define them explicitly.
  209.  
  210.      $*   The basename of the current target, derived as if
  211.           selected for use with an implicit rule.
  212.  
  213.      $<   The name of a dependency file, derived as if selected
  214.           for use with an implicit rule.
  215.  
  216.      $@   The name of the current target.
  217.  
  218.      Because make assigns $< and $* as it would for implicit
  219.      rules (according to the suffixes list and the directory con-
  220.      tents), they may be unreliable when used within explicit
  221.      target entries.
  222.  
  223.      A line of the form `WORD += text...' is used to append the
  224.      given text to the end of a macro.  The += must be surrounded
  225.      by white space.
  226.  
  227.      Makefile Target Entries
  228.      A target entry in the makefile has the following format:
  229.  
  230.           target ...  : [dependency] ...
  231.                [command]
  232.                ...
  233.  
  234.      The first line contains the name of a target, or a list of
  235.      target names separated by white space.  This may be followed
  236.      by a dependency, or a dependency list that make checks in
  237.      order.  Subsequent lines in the target entry begin with a
  238.      space or TAB, and contain shell commands.  These commands
  239.      comprise a rule for building the target.
  240.  
  241.      If a target it named in more than one colon-terminated tar-
  242.      get entry, the dependencies and rules are added to form the
  243.      target's complete dependency list and rule list.
  244.  
  245.      To rebuild a target, make expands macros, strips off initial
  246.      TABs, and either executes the command directly (if it con-
  247.      tains no shell metacharacters), or passes each command line
  248.      to a shell for execution.
  249.  
  250.      The first line that does not begin with a space, TAB or #
  251.      begins another target or macro definition.
  252.  
  253.      Macros are expanded during input, for target lines.  All
  254.      other lines have macro expansion delayed until absolutely
  255.      required.
  256.  
  257.  
  258.  
  259.  
  260.  
  261. Printed 7/20/89          April 30, 1989                         4
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. MAKE(1)                  Programmer's Manual              MAKE(1)
  269.  
  270.  
  271.  
  272.      Special-Function Targets
  273.      When incorporated in a makefile, the following target names
  274.      perform special-functions:
  275.  
  276.      .DEFAULT:
  277.           The rule for this target is used to process a target
  278.           when there is no other entry for it, and no rule for
  279.           building it.  make ignores any dependencies for this
  280.           target.
  281.  
  282.      .DONE:
  283.           make processes this target and its dependencies after
  284.           all other targets are built.
  285.  
  286.      .IGNORE:
  287.           make ignores non-zero error codes returned from com-
  288.           mands.
  289.  
  290.      .INIT:
  291.           This target and its dependencies are built before any
  292.           other targets are processed.
  293.  
  294.      .RESPONSE:
  295.           This target is used for DOS only and specifies all pro-
  296.           grams that can cope with a response file as soon as the
  297.           command line grows past 128 characters (the limit for
  298.           DOS command lines). The command line for the child pro-
  299.           cess to spawn is then reformatted and will look some-
  300.           thing like : '@MAKxxxxx' with in this response file the
  301.           original version of the command line, with all blanks
  302.           used as line seperators.
  303.  
  304.      .SILENT:
  305.           make does not echo commands before executing them.
  306.  
  307.      .SUFFIXES:
  308.           The suffixes list for selecting implicit rules.
  309.  
  310.      Rules
  311.      When processing rules, the first non-space character may
  312.      imply special handling.  Lines beginning with the following
  313.      special cahracters are handled as follows:
  314.  
  315.      -    make ingores any nonzero error code.  Normally, make
  316.           terminates when a command returns a nonzero status,
  317.           unless the -i option or the .IGNORE target is used.
  318.  
  319.      @    make does not print the command line before executing
  320.           it.  Normally, each line is displayed before being exe-
  321.           cuted, unless the -s option or the .SILENT target is
  322.           used.
  323.  
  324.  
  325.  
  326.  
  327. Printed 7/20/89          April 30, 1989                         5
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. MAKE(1)                  Programmer's Manual              MAKE(1)
  335.  
  336.  
  337.  
  338.      +    a shell is used to execute this command.  Normally the
  339.           shell is used (via system()) only if metacharacters are
  340.           found, and for certain implicitly known commands.
  341.  
  342.      When any combination of -, @ or + appear as the first char-
  343.      acters after the spaces or TABs, all apply.  None are passed
  344.      to the shell.
  345.  
  346.      Implicit Rules
  347.      A target file name is made of a basename and a suffix.  The
  348.      suffix may be null.  When a target has no explicit target
  349.      entry, make looks for an implicit target made of an element
  350.      from the suffixes list concatenated with the suffix of the
  351.      target.  If such an implicit target exists, a dependecy file
  352.      name consisting of the basename and the suffix from the suf-
  353.      fix list is recursively made.  If successful, the implicit
  354.      rule is invoked to build the target.
  355.  
  356.      An implicit rule is a target of the form:
  357.  
  358.           .Ds.Ts :
  359.                rule
  360.  
  361.      where .Ts is the suffix of the target, .Ds is the suffix of
  362.      the dependency file, and `rule' is the implicit rule for
  363.      building such a target from such a dependency file.
  364.  
  365.      The Suffixes List
  366.      The suffixes list is given as the list of dependencies for
  367.      the .SUFFIXES: special-function target.  The default list is
  368.      contained in the SUFFIXES macro .  You can define additional
  369.      .SUFFIXES: targets; a SUFFIXES target with no dependencies
  370.      clears the list of suffixes.  Order is significant within
  371.      the list; make selects a rule that corresponds to the
  372.      target's suffix and the first dependency-file suffix found
  373.      in the list.  To place suffixes at the head of the list,
  374.      clear the list and replace it with the new suffixes, fol-
  375.      lowed by the default list:
  376.  
  377.           .SUFFIXES:
  378.           .SUFFIXES: suffixes $(SUFFIXES)
  379.  
  380. EXAMPLES
  381.      This makefile says that pgm.exe depends on two files a.o and
  382.      b.o, and that they in turn depend on their corresponding
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393. Printed 7/20/89          April 30, 1989                         6
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. MAKE(1)                  Programmer's Manual              MAKE(1)
  401.  
  402.  
  403.  
  404.      source files (a.c and b.c) along with a common file incl.h:
  405.  
  406.           pgm.exe: a.o b.o
  407.                $(CC) a.o b.o -o $@
  408.  
  409.           a.o: incl.h a.c
  410.                $(CC) -c a.c
  411.  
  412.           b.o: incl.h b.c
  413.                $(CC) -c b.c
  414.  
  415.      The following makefile uses implicit rules to express the
  416.      same dependencies:
  417.  
  418.           pgm.exe: a.o b.o
  419.                $(CC) a.o b.o -o pgm.exe
  420.  
  421.           a.o b.o: incl.h
  422.  
  423. FILES
  424.      makefile       Current version(s) of make description file.
  425.      default.mk     Default file for user-defined targets, mac-
  426.                     ros, and implicit rules.
  427.  
  428. DIAGNOSTICS
  429.      make returns a exit status of 1 when it halts as a result of
  430.      an error.  Otherwise it returns and exit status of 0.
  431.  
  432.      Badly formed macro
  433.           A macro definition has been encountered which has
  434.           incorrect syntax.  Most likely, the name is missing.
  435.  
  436.      cannot open file
  437.           The makefile indicated in an include directive was not
  438.           found or was not accessible.
  439.  
  440.      Don't know how to make target
  441.           There is no makefile entry for target, none of make's
  442.           implicit rules apply, and there is no .DEFAULT: rule.
  443.  
  444.      Improper Macro.
  445.           An error has occurred during macro expansion.  The most
  446.           likely error is a missing closing bracket.
  447.  
  448.      rules must be after target
  449.           makefile syntax error, where a line beginning with a
  450.           space or TAB has been encountered before a target line.
  451.  
  452.      too many options
  453.           make has run out of allocated space while processing
  454.  
  455.  
  456.  
  457.  
  458.  
  459. Printed 7/20/89          April 30, 1989                         7
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. MAKE(1)                  Programmer's Manual              MAKE(1)
  467.  
  468.  
  469.  
  470.           command line options or a target list.
  471.  
  472. BUGS
  473.      make does not allow a target line to end with a semi-colon
  474.      (;) and a command.  All commands must be on subsequent
  475.      lines.
  476.  
  477.      make allows spaces as well as TABs to introduce shell comand
  478.      lines.
  479.  
  480.      target lines cannot use the double colon (::) syntax.
  481.  
  482.      make attempts to derive values for the dynamic macros $* and
  483.      $<, while processing explicit targets.  It uses the same
  484.      methods as for implicit rules.  In some cases, this can lead
  485.      to unexpected values.
  486.  
  487.      Once a dependency is made, make assumes that the dependency
  488.      file is present for the remainder of the run.  If a rule
  489.      subsequently removes that file, and future targets depend on
  490.      its existence, unexpected errors may result.
  491.  
  492.      Sometimes make gets confused when searching for implicit
  493.      rules, and uses severla rules instead of a single rule.  For
  494.      example, the two rules .c.o and .l.c may be used, rather
  495.      than the more direct .l.o rule.
  496.  
  497.      Environment variables are neither read nor written.
  498.  
  499.  
  500.      -p   Print out the complete set of macro definitions and
  501.           target descriptions.
  502.  
  503.      -P   Report dependencies recursively to show the entire
  504.           dependency hierarchy, without rebuilding any targets.
  505.  
  506.      -q   Question mode.  make returns a zero or nonzero status
  507.           code depending on whether or not the target file is up
  508.           to date.
  509.  
  510.      The following special-function targets are NOT supported:
  511.  
  512.      .KEEP_STATE:
  513.      .MAKE_VERSION:
  514.      .PRECIOUS:
  515.      .SCCS_GET:
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525. Printed 7/20/89          April 30, 1989                         8
  526.  
  527.  
  528.  
  529.