home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 May / W2KPRK.iso / apps / posix / source / MAN / MAKE.PRT < prev    next >
Text File  |  1999-11-17  |  21KB  |  397 lines

  1.                                                          MAKE (1)
  2.  
  3. NAME
  4.  
  5.   make - maintain program dependencies
  6.  
  7. SYNOPSIS
  8.  
  9.   make [ eiknqrstv ] [ D ]  [  d  ]  [  f  ]  [  I  ]  [  j  ]  [
  10. variable=value ] [ target ]
  11. DESCRIPTION
  12.  
  13.   Make is a program designed to simplify the maintenance of other
  14. programs.   Its input is a list of specifications as to the files
  15. upon which programs and other files depend.  If the file [Pa] ex-
  16. ists, it is read for this list of specifications.  If it does not
  17. exist, the file [Pa] is read.  If the file  [Pa]  exists,  it  is
  18. read (see mkdep (1)) .
  19.   This manual page is intended as a reference document only.  For
  20. a  more  thorough description of make and makefiles, please refer
  21. to
  22.   The options are as follows:
  23.      D - Define Ar variable to be 1, in the global context.
  24.      d - Turn on debugging, and specify which  portions  of  make
  25.      are to print debugging information.  Flags is one or more of
  26.      the following:
  27.           A  -  Print   all   possible   debugging   information;
  28.           equivalent to specifying all of the debugging flags.
  29.           a - Print debugging information about archive searching
  30.           and caching.
  31.           c  -  Print  debugging  information  about  conditional
  32.           evaluation.
  33.           d - Print debugging information about directory search-
  34.           ing and caching.
  35.           g1 - Print the input graph before making anything.
  36.           g2 - Print the input graph after making everything,  or
  37.           before exiting on error.
  38.           j - Print debugging information about running  multiple
  39.           shells.
  40.           m - Print debugging information about  making  targets,
  41.           including modification dates.
  42.           s  -  Print   debugging   information   about   suffix-
  43.           transformation rules.
  44.           t -  Print  debugging  information  about  target  list
  45.           maintenance.
  46.           v - Print debugging information about variable  assign-
  47.           ment.
  48.      e - Specify that environmental variables override macro  as-
  49.      signments within makefiles.
  50.      f - Specify a makefile to read instead of the  default  [Pa]
  51.      and [Pa] If makefile is [Fl] standard input is read.  Multi-
  52.      ple makefile's may be specified, and are read in  the  order
  53.      specified.
  54.      I - Specify a directory in which to search for makefiles and
  55.      included  makefiles.   The  system makefile directory is au-
  56.      tomatically included as part of this list.
  57.      i - Ignore non-zero exit of shell commands in the  makefile.
  58.      Equivalent  to  specifying  [Fl] before each command line in
  59.      the makefile.
  60.      j - Specify the maximum number of jobs that  make  may  have
  61.      running at any one time.
  62.      k - Continue processing after errors  are  encountered,  but
  63.      only on those targets that do not depend on the target whose
  64.      creation caused the error.
  65.      n - Display the commands that would have been executed,  but
  66.      do not actually execute them.
  67.      q - Do not execute any commands, but exit 0 if the specified
  68.      targets are up-to-date and 1, otherwise.
  69.      r - Do not use the built-in rules specified  in  the  system
  70.      makefile.
  71.      s  -  Do  not  echo  any  commands  as  they  are  executed.
  72.      Equivalent  to  specifying  [Ic] before each command line in
  73.      the makefile.
  74.      t - Rather than re-building a target  as  specified  in  the
  75.      makefile,  create it or update its modification time to make
  76.      it appear up-to-date.
  77.      variable=value - Set the value of the variable  variable  to
  78.      value .
  79.   There are six different types of  lines  in  a  makefile:  file
  80. dependency  specifications, shell commands, variable assignments,
  81. include statements, conditional directives, and comments.
  82.   In general, lines may be continued from one line to the next by
  83. ending  them  with a backslash The trailing newline character and
  84. initial whitespace on the following line are  compressed  into  a
  85. single space.
  86. FILE DEPENDENCY SPECIFICATIONS
  87.  
  88.   Dependency lines consist of one or more targets,  an  operator,
  89. and  zero or more sources.  This creates a relationship where the
  90. targets ``depend'' on the sources and are  usually  created  from
  91. them.   The  exact relationship between the target and the source
  92. is determined by the operator that  separates  them.   The  three
  93. operators are as follows:
  94.      : - A target is considered out-of-date if  its  modification
  95.      time  is less than those of any of its sources.  Sources for
  96.      a target accumulate over dependency lines when this operator
  97.      is used.  The target is removed if make is interrupted.
  98.      ! - Targets are always re-created, but not until all sources
  99.      have been examined and re-created as necessary.  Sources for
  100.      a target accumulate over dependency lines when this operator
  101.      is used.  The target is removed if make is interrupted.
  102.      :: - If no sources are specified, the target is  always  re-
  103.      created.   Otherwise,  a target is considered out-of-date if
  104.      any of its sources has been modified more recently than  the
  105.      target.   Sources for a target do not accumulate over depen-
  106.      dency lines when this operator is used.  The target will not
  107.      be removed if make is interrupted.
  108.   Targets and sources may contain the shell wildcard  values  [?]
  109. [*] [[]] and [{}] The values [?] [*] and [[]] may only be used as
  110. part of the final component of the target or source, and must  be
  111. used  to describe existing files.  The value [{}] need not neces-
  112. sarily be used to  describe  existing  files.   Expansion  is  in
  113. directory order, not alphabetically as done in the shell.
  114. SHELL COMMANDS
  115.  
  116.   Each target may have associated with it a series of shell  com-
  117. mands,  normally used to create the target.  Each of the commands
  118. in this script be preceded by a tab.  While any target may appear
  119. on  a dependency line, only one of these dependencies may be fol-
  120. lowed by a creation script, unless the [Ic] operator is used.
  121.   If the first or first two characters of the  command  line  are
  122. [Ic] and/or [Ic] the command is treated specially.  A [Ic] causes
  123. the command not to be echoed  before  it  is  executed.   A  [Ic]
  124. causes  any  non-zero  exit  status of the command line to be ig-
  125. nored.
  126. VARIABLE ASSIGNMENTS
  127.  
  128.   Variables in make are much like variables in the shell, and, by
  129. tradition, consist of all upper-case letters.  The five operators
  130. that can be used to assign values to variables are as follows:
  131.      = - Assign the value to the variable.  Any previous value is
  132.      overridden.
  133.      += - Append the value to the current value of the variable.
  134.      ?= - Assign the value to the variable if it is  not  already
  135.      defined.
  136.      := - Assign with expansion, i.e. expand the value before as-
  137.      signing it to the variable.  Normally, expansion is not done
  138.      until the variable is referenced.
  139.      != - Expand the value and pass it to the shell for execution
  140.      and  assign the result to the variable.  Any newlines in the
  141.      result are replaced with spaces.
  142.   Any white-space before the assigned value is  removed;  if  the
  143. value  is  being appended, a single space is inserted between the
  144. previous contents of the variable and the appended value.
  145.   Variables are expanded by surrounding the  variable  name  with
  146. either curly braces or parenthesis and preceding it with a dollar
  147. sign If the variable name contains only a single letter, the sur-
  148. rounding  braces  or  parenthesis are not required.  This shorter
  149. form is not recommended.
  150.   Variable substitution occurs at two distinct  times,  depending
  151. on  where  the  variable  is being used.  Variables in dependency
  152. lines are expanded as the line is read.  Variables in shell  com-
  153. mands are expanded when the shell command is executed.
  154.   The four different classes of variables (in order of increasing
  155. precedence) are:
  156.      variables - Variables defined as part of make environment.
  157.      variables - Variables defined in the makefile or in included
  158.      makefiles.
  159.      line - Variables defined as part of the command line.
  160.      variables - Variables that are defined specific to a certain
  161.      target.  The seven local variables are as follows:
  162.           The list of all sources for this target; also known  as
  163.           [Va]
  164.           The name of the archive file.
  165.           The name/path of the source from which the target is to
  166.           be  transformed (the ``implied'' source); also known as
  167.           [Va]
  168.           The name of the archive member.
  169.           The list of sources for this target  that  were  deemed
  170.           out-of-date; also known as [Va]
  171.           The file prefix of the file, containing only  the  file
  172.           portion,  no  suffix or preceding directory components;
  173.           also known as [Va]
  174.           The name of the target; also known as [Va]
  175.        The shorter forms [Va] [Va] [Va] and  [Va]  are  permitted
  176.      for backward compatibility with historical makefiles and are
  177.      not recommended.  The six variables [Va] [Va] [Va] [Va] [Va]
  178.      and  [Va] are permitted for compatibility with makefiles and
  179.      are not recommended.
  180.        Four of the local variables may  be  used  in  sources  on
  181.      dependency lines because they expand to the proper value for
  182.      each target on the line.  These variables are [Va] [Va] [Va]
  183.      and [Va]
  184.        In addition, make sets or knows about the following  vari-
  185.      ables:
  186.           $ - A single dollar sign [$] i.e.  [$$]  expands  to  a
  187.           single dollar sign.
  188.           The name that make was executed with
  189.           A path to the directory where make was executed.
  190.           MAKEFLAGS - The environment variable [Ev]  may  contain
  191.           anything  that  may  be specified on make command line.
  192.           Anything specified on make command line is appended  to
  193.           the  [Ev]  variable  which is then entered into the en-
  194.           vironment for all programs which make executes.
  195.        Variable expansion may be modified  to  select  or  modify
  196.      each  word  of the variable (where a ``word'' is white-space
  197.      delimited sequence of characters).  The general format of  a
  198.      variable expansion is as follows:
  199.        Each modifier begins with a colon and one of the following
  200.      special  characters.   The  colon  may  be  escaped  with  a
  201.      backslash
  202.           E - Replaces each word in the variable with its suffix.
  203.           H - Replaces each word in the variable with  everything
  204.           but the last component.
  205.           M - Select only those words that match the rest of  the
  206.           modifier.   The  standard shell wildcard characters [?]
  207.           and [Op] may be used.  The wildcard characters  may  be
  208.           escaped with a backslash
  209.           N - This is identical to [Cm]  but  selects  all  words
  210.           which do not match the rest of the modifier.
  211.           R - Replaces each word in the variable with  everything
  212.           but its suffix.
  213.           S - Modify the first occurrence of old_pattern in  each
  214.           word  to be replaced with new_pattern . If a [g] is ap-
  215.           pended to the  last  slash  of  the  pattern,  all  oc-
  216.           currences  in  each  word are replaced.  If old_pattern
  217.           begins with a carat old_pattern is anchored at the  be-
  218.           ginning  of each word.  If old_pattern ends with a dol-
  219.           lar sign it is anchored at the end of each  word.   In-
  220.           side   new_string   ,   an  ampersand  is  replaced  by
  221.           old_pattern . Any character may be used as a  delimiter
  222.           for  the  parts of the modifier string.  The anchoring,
  223.           ampersand and delimiter characters may be escaped  with
  224.           a backslash
  225.             Variable expansion occurs in the normal  fashion  in-
  226.           side both old_string and new_string with the single ex-
  227.           ception that a backslash is used to prevent the  expan-
  228.           sion of a dollar sign not a preceding dollar sign as is
  229.           usual.
  230.           T - Replaces each word in the variable  with  its  last
  231.           component.
  232.           old_string=new_string - This is the style variable sub-
  233.           stitution.   It  must  be  the last modifier specified.
  234.           Old_string is anchored at the end of each word, so only
  235.           suffixes or entire words may be replaced.
  236.      INCLUDE STATEMENTS AND CONDITIONALS
  237.  
  238.        Makefile inclusion and conditional structures  reminiscent
  239.      of  the C programming language are provided in make All such
  240.      structures are identified by a line beginning with a  single
  241.      dot character.  Files are included with either [.include] or
  242.      [.include] Variables between the angle  brackets  or  double
  243.      quotes  are expanded to form the file name.  If angle brack-
  244.      ets are used, the included makefile is expected to be in the
  245.      system  makefile  directory.  If double quotes are used, the
  246.      including makefile's directory and any directories specified
  247.      using  the  option  are  searched before the system makefile
  248.      directory.
  249.        Conditional expressions are also preceded by a single  dot
  250.      as  the first chraracter of a line.  The possible condition-
  251.      als are as follows:
  252.           Un-define the specified global variable.   Only  global
  253.           variables may be un-defined.
  254.            - [ operator ] Test the value of an expression.
  255.            - [ operator ] Test the value of an variable.
  256.            - [ operator ] Test the value of an variable.
  257.            - [ operator ] Test the the target being built.
  258.            - [ operator ] Test the target being built.
  259.           Reverse the sense of the last conditional.
  260.            - [ operator ] A combination of [Ic] followed by [Ic]
  261.            - [ operator ] A combination of [Ic] followed by [Ic]
  262.            - [ operator ] A combination of [Ic] followed by [Ic]
  263.            - [ operator ] A combination of [Ic] followed by [Ic]
  264.            - [ operator ] A combination of [Ic] followed by [Ic]
  265.           End the body of the conditional.
  266.        The operator may be any one of the following:
  267.           || - logical OR
  268.           && - Logical of higher precedence than
  269.        As in C, make will only evaluate a conditional as  far  as
  270.      is  necessary  to  determine  its value.  Parenthesis may be
  271.      used to change the order of evaluation.  The boolean  opera-
  272.      tor  [Ic]  may  be used to logically negate an entire condi-
  273.      tional.  It is of higher precendence than [Ic]
  274.        The value of expression may be any of the following:
  275.           defined - Takes a variable  name  as  an  argument  and
  276.           evaluates to true if the variable has been defined.
  277.           make - Takes a target name as an argument and evaluates
  278.           to  true  if  the  target was specified as part of make
  279.           command line or was declared the default target (either
  280.           implicitly  or explicitly, see before the line contain-
  281.           ing the conditional.
  282.           empty - Takes a variable, with possible modifiers,  and
  283.           evalutes to true if the expansion of the variable would
  284.           result in an empty string.
  285.           exists - Takes a file name as an argument and evaluates
  286.           to  true  if the file exists.  The file is searched for
  287.           on the system search path (see
  288.           target - Takes a target name as an argument and  evalu-
  289.           ates to true if the target has been defined.
  290.        Expression may also be an arithmetic or string comparison,
  291.      with  the  left-hand  side  being a variable expansion.  The
  292.      standard C relational operators are all supported,  and  the
  293.      usual  number/base  conversion  is  performed.   Note, octal
  294.      numbers are not supported.  If the righthand value of a [Ic]
  295.      or  [Ic] operator begins with a quotation mark a string com-
  296.      parison is done between the expanded variable and  the  text
  297.      between  the  quotation marks.  If no relational operator is
  298.      given, it is assumed that the  expanded  variable  is  being
  299.      compared against 0.
  300.        When make is evaluating one of these  conditional  expres-
  301.      sion,  and it encounters a word it doesn't recognize, either
  302.      the ``make'' or ``defined'' expression  is  applied  to  it,
  303.      depending  on  the  form of the conditional.  If the form is
  304.      [Ic] or [Ic] the ``defined'' expression is  applied.   Simi-
  305.      larly, if the form is [Ic] or [Ic] expression is applied.
  306.        If the conditional evaluates to true the  parsing  of  the
  307.      makefile continues as before.  If it evaluates to false, the
  308.      following lines are skipped.  In both cases  this  continues
  309.      until a [Ic] or [Ic] is found.
  310.      COMMENTS
  311.  
  312.        Comments begin with a hash character, anywhere  but  in  a
  313.      shell command line, and continue to the end of the line.
  314.      SPECIAL SOURCES
  315.  
  316.           Ignore any errors from  the  commands  associated  with
  317.           this  target, exactly as if they all were preceded by a
  318.           dash
  319.           Execute the commands associated with this  target  even
  320.           if  the  or  options  were specified.  Normally used to
  321.           mark recursive make
  322.           Normally make selects the first target it encounters as
  323.           the  default target to be built if no target was speci-
  324.           fied.  This source  prevents  this  target  from  being
  325.           selected.
  326.           If a target is marked  with  this  attribute  and  make
  327.           can't  figure out how to create it, it will ignore this
  328.           fact and assume the file isn't needed  or  already  ex-
  329.           ists.
  330.           When make is interrupted, it removes any partially made
  331.           targets.   This  source  prevents the target from being
  332.           removed.
  333.           Do not echo any of the commands  associated  with  this
  334.           target,  exactly  as if they all were preceded by an at
  335.           sign
  336.           Turn the target into make version of a macro.  When the
  337.           target is used as a source for another target, the oth-
  338.           er target acquires the commands,  sources,  and  attri-
  339.           butes (except for of the source.  If the target already
  340.           has commands, the target's  commands  are  appended  to
  341.           them.
  342.      SPECIAL TARGETS
  343.  
  344.        Special targets may not be included  with  other  targets,
  345.      i.e. they must be the only target specified.
  346.           Any command lines attached to this target are  executed
  347.           before anything else is done.
  348.           This is sort of a rule for any target  (that  was  used
  349.           only  as a source) that make can't figure out any other
  350.           way to create.  Only the shell  script  is  used.   The
  351.           variable  of  a target that inherits commands is set to
  352.           the target's own name.
  353.           Any command lines attached to this target are  executed
  354.           after everything else is done.
  355.           Mark each of the sources with  the  attribute.   If  no
  356.           sources are specified, this is the equivalent of speci-
  357.           fying the option.
  358.           If make is interrupted, the commands  for  this  target
  359.           will be executed.
  360.           If no target is specified when make  is  invoked,  this
  361.           target will be built.
  362.           This target provides a way to specify  flags  for  make
  363.           when  the  makefile is used.  The flags are as if typed
  364.           to the shell, though the option will have no effect.
  365.           The sources are directories which are  to  be  searched
  366.           for  files  not  found in the current directory.  If no
  367.           sources are specified, any previously specified  direc-
  368.           tories are deleted.
  369.           Apply the attribute to any specified  sources.   If  no
  370.           sources  are  specified,  the  attribute  is applied to
  371.           every target in the file.
  372.           Apply the attribute to any specified  sources.   If  no
  373.           sources  are  specified,  the  attribute  is applied to
  374.           every command in the file.
  375.           Each source specifies a suffix to make  If  no  sources
  376.           are  specified,  any  previous  specifies  suffices are
  377.           deleted.
  378.           ENVIRONMENT
  379.  
  380.             Make utilizes the following environment variables, if
  381.           they exist: and
  382.           FILES
  383.  
  384.                 - list of dependencies
  385.                 - list of dependencies
  386.                 - list of dependencies
  387.                 - system makefile
  388.                 - system makefile directory
  389.           SEE ALSO
  390.  
  391.             mkdep (1)
  392.           HISTORY
  393.  
  394.             A Make command appeared in
  395.  
  396.  
  397.