home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / elan / man / dmake.nc next >
Text File  |  1991-05-06  |  117KB  |  3,137 lines

  1.  
  2.  
  3.  
  4.  
  5. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  6.  
  7.  
  8.  
  9. NAME
  10.      dmake - maintain program groups, or interdependent files
  11.  
  12. SYNOPSIS
  13.      dmake [-AceEhiknpqrsStTuVx] [-v{dfimt}] [-P#] [-{f|C|K}
  14.      file] [macro[*][+][:]=value ...] [target ...]
  15.  
  16. DESCRIPTION
  17.      dmake executes commands found in an external file called a
  18.      makefile to update one or more target names.  Each target
  19.      may depend on zero or more prerequisite targets.  If any of
  20.      the target's prerequisites is newer than the target or if
  21.      the target itself does not exist, then dmake will attempt to
  22.      make the target.
  23.  
  24.      If no -f command line option is present then dmake searches
  25.      for an existing makefile from the list of prerequisites
  26.      specified for the special target .MAKEFILES (see the STARTUP
  27.      section for more details).  If "-" is the name of the file
  28.      specified to the -f flag then dmake uses standard input as
  29.      the source of the makefile text.
  30.  
  31.      Any macro definitions (arguments with embedded "=" signs)
  32.      that appear on the command line are processed first and
  33.      supersede definitions for macros of the same name found
  34.      within the makefile.  In general it is impossible for defin-
  35.      itions found inside the makefile to redefine a macro defined
  36.      on the command line, see the MACROS section for an excep-
  37.      tion.
  38.  
  39.      If no target names are specified on the command line, then
  40.      dmake uses the first non-special target found in the
  41.      makefile as the default target.  See the SPECIAL TARGETS
  42.      section for the list of special targets and their function.
  43.      dmake is a re-implementation of the UNIX Make utility with
  44.      significant enhancements.  Makefiles written for most previ-
  45.      ous versions of Make will be handled correctly by dmake.
  46.      Known differences between dmake and other versions of make
  47.      are discussed in the COMPATIBILITY section found at the end
  48.      of this document.
  49.  
  50. OPTIONS
  51.      -A   Enable AUGMAKE special inference rule transformations
  52.           (see the "PERCENT(%) RULES" section), these are set to
  53.           off by default.
  54.  
  55.      -c   Use non-standard comment stripping.  If you specify -c
  56.           then dmake will treat any # character as a start of
  57.           comment character wherever it may appear unless it is
  58.           escaped by a \.
  59.  
  60.  
  61.  
  62.  
  63.  
  64. Version 3.70                    UW                              1
  65.  
  66.  
  67.  
  68.  
  69. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  70.  
  71.  
  72.  
  73.      -C [+]file
  74.           This option writes to file a copy of standard output
  75.           and standard error from any child processes and from
  76.           the dmake process itself.  If you specify a + prior to
  77.           the file name then the text is appended to the previous
  78.           contents of file.  This option is active in the MSDOS
  79.           implementation only and is ignored by non-MSDOS ver-
  80.           sions of dmake.
  81.  
  82.      -e   Read the environment and define all strings of the form
  83.           'ENV-VAR=evalue' defined within as macros whose name is
  84.           ENV-VAR, and whose value is 'evalue'.  The environment
  85.           is processed prior to processing the user specified
  86.           makefile thereby allowing definitions in the makefile
  87.           to override definitions in the environment.
  88.  
  89.      -E   Same as -e, except that the environment is processed
  90.           after the user specified makefile has been processed
  91.           (thus definitions in the environment override defini-
  92.           tions in the makefile).  The -e and -E options are
  93.           mutually exclusive.  If both are given the latter takes
  94.           effect.
  95.  
  96.      -f file
  97.           Use file as the source for the makefile text.  Only one
  98.           -f option is allowed.
  99.  
  100.      -h   Print the command summary for dmake.
  101.  
  102.      -i   Tells dmake to ignore errors, and continue making other
  103.           targets.  This is equivalent to the .IGNORE attribute
  104.           or macro.
  105.  
  106.      -K file
  107.           Turns on .KEEP_STATE state tracking and tells dmake to
  108.           use file as the state file.
  109.  
  110.      -k   Causes dmake to ignore errors caused by command execu-
  111.           tion and to make all targets not depending on targets
  112.           that could not be made. Ordinarily dmake stops after a
  113.           command returns a non-zero status, specifying -k causes
  114.           dmake to ignore the error and continue to make as much
  115.           as possible.
  116.  
  117.      -n   Causes dmake to print out what it would have executed,
  118.           but does not actually execute the commands.  A special
  119.           check is made for the string "$(MAKE)" inside a recipe
  120.           line, if found, the line is expanded and invoked,
  121.           thereby enabling recursive makes to give a full
  122.           description of all that they will do.  The check for
  123.           "$(MAKE)" is disabled inside group recipes.
  124.  
  125.  
  126.  
  127.  
  128. Version 3.70                    UW                              2
  129.  
  130.  
  131.  
  132.  
  133. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  134.  
  135.  
  136.  
  137.      -p   Print out a version of the digested makefile in human
  138.           readable form.  (useful for debugging, but cannot be
  139.           re-read by dmake)
  140.  
  141.      -P#  On systems that support multi-processing cause dmake to
  142.           use # concurrent child processes to make targets.  See
  143.           the "MULTI PROCESSING" section for more information.
  144.  
  145.      -q   Check and see if the target is up to date.  Exits with
  146.           code 0 if up to date, 1 otherwise.
  147.  
  148.      -r   Tells dmake not to read the initial startup makefile,
  149.           see STARTUP section for more details.
  150.  
  151.      -s   Tells dmake to do all its work silently and not echo
  152.           the commands it is executing to stdout (also suppresses
  153.           warnings).  This  is equivalent to the .SILENT attri-
  154.           bute or macro.
  155.  
  156.      -S   Force sequential execution of recipes on architectures
  157.           which support concurrent makes.  For backward compati-
  158.           bility with old makefiles that have nasty side-effect
  159.           prerequisite dependencies.
  160.  
  161.      -t   Causes dmake to touch the targets and bring them up to
  162.           date without executing any commands.
  163.  
  164.      -T   Tells dmake to not perform transitive closure on the
  165.           inference graph.
  166.  
  167.      -u   Force an unconditional update.  (ie. do everything that
  168.           would be done if everything that a target depended on
  169.           was out of date)
  170.  
  171.      -v[dfimt]
  172.           Verbose flag, when making targets print to stdout what
  173.           we are going to make and what we think its time stamp
  174.           is.  The optional flags [dfimt] can be used to restrict
  175.           the information that is displayed.  In the absence of
  176.           any optional flags all are assumed to be given (ie. -v
  177.           is equivalent to -vdfimt).  The meanings of the
  178.           optional flags are:
  179.  
  180.           d    Notify of change directory operations only.
  181.  
  182.           f    Notify of file I/O operations only.
  183.  
  184.           i    Notify of inference algorithm operation only.
  185.  
  186.           m    Notify of target update operations only.
  187.  
  188.  
  189.  
  190.  
  191.  
  192. Version 3.70                    UW                              3
  193.  
  194.  
  195.  
  196.  
  197. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  198.  
  199.  
  200.  
  201.           t    Keep any temporary files created; normally they
  202.                are automatically deleted.
  203.  
  204.      -V   Print the version of dmake, and values of builtin mac-
  205.           ros.
  206.  
  207.      -x   Upon processing the user makefile export all non-
  208.           internally defined macros to the user's environment.
  209.           This option together with the -e option allows SYSV
  210.           AUGMAKE recursive makes to function as expected.
  211.  
  212. INDEX
  213.      Here is a list of the sections that follow and a short
  214.      description of each.  Perhaps you won't have to read the
  215.      whole man page to find what you need.
  216.  
  217.      STARTUP            Describes dmake initialization.
  218.  
  219.      SYNTAX             Describes the syntax of makefile expres-
  220.                         sions.
  221.  
  222.      ATTRIBUTES         Describes the notion of attributes and
  223.                         how they are used when making targets.
  224.  
  225.      MACROS             Defining and expanding macros.
  226.  
  227.      RULES AND TARGETS  How to define targets and their prere-
  228.                         quisites.
  229.  
  230.      RECIPES            How to tell dmake how to make a target.
  231.  
  232.      TEXT DIVERSIONS    How to use text diversions in recipes and
  233.                         macro expansions.
  234.  
  235.      SPECIAL TARGETS    Some targets are special.
  236.  
  237.      SPECIAL MACROS     Macros used by dmake to alter the pro-
  238.                         cessing of the makefile, and those
  239.                         defined by dmake for the user.
  240.  
  241.      CONTROL MACROS     Itemized list of special control macros.
  242.  
  243.      RUN-TIME MACROS    Discussion of special run-time macros
  244.                         such as $@ and $<.
  245.  
  246.      FUNCTION MACROS    GNU style function macros, only $(mktmp
  247.                         ...) for now.
  248.  
  249.      DYNAMIC PREREQUISITES
  250.                         Processing of prerequisites which contain
  251.                         macro expansions in their name.
  252.  
  253.  
  254.  
  255.  
  256. Version 3.70                    UW                              4
  257.  
  258.  
  259.  
  260.  
  261. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  262.  
  263.  
  264.  
  265.      BINDING TARGETS    The rules that dmake uses to bind a tar-
  266.                         get to an existing file in the file sys-
  267.                         tem.
  268.  
  269.      PERCENT(%) RULES   Specification of recipes to be used by
  270.                         the inference algorithm.
  271.  
  272.      MAKING INFERENCES  The rules that dmake uses when inferring
  273.                         how to make a target which has no expli-
  274.                         cit recipe.  This and the previous sec-
  275.                         tion are really a single section in the
  276.                         text.
  277.  
  278.      MAKING TARGETS     How dmake makes targets other than
  279.                         libraries.
  280.  
  281.      MAKING LIBRARIES   How dmake makes libraries.
  282.  
  283.      KEEP STATE         A discussion of how .KEEP_STATE works.
  284.  
  285.      MULTI PROCESSING   Discussion of dmake's parallel make
  286.                         facilities for architectures that support
  287.                         them.
  288.  
  289.      CONDITIONALS       Conditional expressions which control the
  290.                         processing of the makefile.
  291.  
  292.      EXAMPLES           Some hopefully useful examples.
  293.  
  294.      COMPATIBILITY      How dmake compares with previous versions
  295.                         of make.
  296.  
  297.      LIMITS             Limitations of dmake.
  298.  
  299.      PORTABILITY        Comments on writing portable makefiles.
  300.  
  301.      FILES              Files used by dmake.
  302.  
  303.      SEE ALSO           Other related programs, and man pages.
  304.  
  305.      AUTHOR             The guy responsible for this thing.
  306.  
  307.      BUGS               Hope not.
  308.  
  309. STARTUP
  310.      When dmake begins execution it first processes the command
  311.      line and then processes an initial startup-makefile.  This
  312.      is followed by an attempt to locate and process a user sup-
  313.      plied makefile.  The startup file defines the default values
  314.      of all required control macros and the set of default rules
  315.      for making targets and inferences.  When searching for the
  316.      startup makefile, dmake searches the following locations, in
  317.  
  318.  
  319.  
  320. Version 3.70                    UW                              5
  321.  
  322.  
  323.  
  324.  
  325. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  326.  
  327.  
  328.  
  329.      the order specified, until a startup file is located:
  330.  
  331.           1.   The location given as the value of the macro MAK-
  332.                ESTARTUP defined on the command line.
  333.  
  334.           2.   The location given as the value of the environment
  335.                variable MAKESTARTUP defined in the current
  336.                environment.
  337.  
  338.           3.   The location given as the value of the macro MAK-
  339.                ESTARTUP defined internally within dmake.
  340.  
  341.      The above search is disabled by specifying the -r option on
  342.      the command line.  An error is issued if a startup makefile
  343.      cannot be found and the -r option was not specified.  A user
  344.      may substitute a custom startup file by defining the MAKES-
  345.      TARTUP environment variable or by redefining the MAKESTARTUP
  346.      macro on the command line.  To determine where dmake looks
  347.      for the default startup file, check your environment or
  348.      issue the command "dmake -V".
  349.  
  350.      A similar search is performed to locate a default user
  351.      makefile when no -f command line option is specified.  By
  352.      default, the prerequisite list of the special target
  353.      .MAKEFILES specifies the names of possible makefiles and the
  354.      search order that dmake should use to determine if one
  355.      exists.  A typical definition for this target is:
  356.  
  357.           .MAKEFILES : makefile.mk Makefile makefile
  358.  
  359.      dmake will first look for makefile.mk and then the others.
  360.      If a prerequisite cannot be found dmake will try to make it
  361.      before going on to the next prerequisite.  For example,
  362.      makefile.mk can be checked out of an RCS file if the proper
  363.      rules for doing so are defined in the startup file.
  364.  
  365. SYNTAX
  366.      This section is a summary of the syntax of makefile state-
  367.      ments.  The description is given in a style similar to BNF,
  368.      where { } enclose items that may appear zero or more times,
  369.      and [ ] enclose items that are optional.  Alternative pro-
  370.      ductions for a left hand side are indicated by '->', and
  371.      newlines are significant.  All symbols in bold type are text
  372.      or names representing text supplied by the user.
  373.  
  374.  
  375.  
  376.           Makefile -> { Statement }
  377.  
  378.           Statement -> Macro-Definition
  379.                     -> Conditional
  380.                     -> Rule-Definition
  381.  
  382.  
  383.  
  384. Version 3.70                    UW                              6
  385.  
  386.  
  387.  
  388.  
  389. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  390.  
  391.  
  392.  
  393.                     -> Attribute-Definition
  394.  
  395.           Macro-Definition -> MACRO = LINE
  396.                            -> MACRO *= LINE
  397.                            -> MACRO := LINE
  398.                            -> MACRO *:= LINE
  399.                            -> MACRO += LINE
  400.                            -> MACRO +:= LINE
  401.  
  402.           Conditional ->  .IF expression
  403.                              Makefile
  404.                           [ .ELIF expression
  405.                              Makefile ]
  406.                           [ .ELSE
  407.                              Makefile ]
  408.                           .END
  409.  
  410.           expression -> LINE
  411.                      -> STRING == LINE
  412.                      -> STRING != LINE
  413.  
  414.  
  415.           Rule-Definition ->  target-definition
  416.                                  [ recipe ]
  417.  
  418.           target-definition -> targets [attrs] op { PREREQUISITE } [; rcp-line]
  419.  
  420.           targets -> target { targets }
  421.                   -> "target" { targets }
  422.  
  423.           target -> special-target
  424.                  -> TARGET
  425.  
  426.           attrs -> attribute { attrs }
  427.                 -> "attribute" { attrs }
  428.  
  429.           op -> : { modifier }
  430.  
  431.           modifier -> :
  432.                    -> ^
  433.                    -> !
  434.                    -> -
  435.  
  436.           recipe -> { TAB rcp-line }
  437.                  -> [@][%][-] [
  438.                        { LINE }
  439.                     ]
  440.  
  441.           rcp-line -> [@][%][-][+] LINE
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448. Version 3.70                    UW                              7
  449.  
  450.  
  451.  
  452.  
  453. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  454.  
  455.  
  456.  
  457.           Attribute-Definition -> attrs : targets
  458.  
  459.  
  460.           attribute -> .EPILOG
  461.                     -> .IGNORE
  462.                     -> .LIBRARY
  463.                     -> .MKSARGS
  464.                     -> .NOINFER
  465.                     -> .NOSTATE
  466.                     -> .PHONY
  467.                     -> .PRECIOUS
  468.                     -> .PROLOG
  469.                     -> .SETDIR=path
  470.                     -> .SILENT
  471.                     -> .SEQUENTIAL
  472.                     -> .SWAP
  473.                     -> .USESHELL
  474.                     -> .SYMBOL
  475.                     -> .UPDATEALL
  476.  
  477.           special-target -> .ERROR
  478.                          -> .EXPORT
  479.                          -> .GROUPEPILOG
  480.                          -> .GROUPPROLOG
  481.                          -> .IMPORT
  482.                          -> .INCLUDE
  483.                          -> .INCLUDEDIRS
  484.                          -> .MAKEFILES
  485.                          -> .REMOVE
  486.                          -> .SOURCE
  487.                          -> .SOURCE.suffix
  488.                          -> .suffix1.suffix2
  489.  
  490.  
  491.      Where, TAB represents a <tab> character, STRING represents
  492.      an arbitrary sequence of characters, and LINE represents a
  493.      possibly empty sequence of characters terminated by a non-
  494.      escaped (not immediately preceded by a backslash '\') new-
  495.      line character.  MACRO, PREREQUISITE, and TARGET each
  496.      represent a string of characters not including space or tab
  497.      which respectively form the name of a macro, prerequisite or
  498.      target.  The name may itself be a macro expansion expres-
  499.      sion.  A LINE can be continued over several physical lines
  500.      by terminating it with a single backslash character.  Com-
  501.      ments are initiated by the pound # character and extend to
  502.      the end of line.  All comment text is discarded, a '#' may
  503.      be placed into the makefile text by escaping it with '\'
  504.      (ie. \# translates to # when it is parsed).  An exception to
  505.      this occurs when a # is seen inside a recipe line that
  506.      begins with a <tab> or is inside a group recipe.  If you
  507.      specify the -c command line switch then this behavior is
  508.      disabled and dmake will treat all # characters as start of
  509.  
  510.  
  511.  
  512. Version 3.70                    UW                              8
  513.  
  514.  
  515.  
  516.  
  517. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  518.  
  519.  
  520.  
  521.      comment indicators unless they are escaped by \.  A set of
  522.      continued lines may be commented out by placing a single #
  523.      at the start of the first line.  A continued line cannot
  524.      span more than one makefile.
  525.  
  526.      white space is defined to be any combination of <space>,
  527.      <tab>, and the sequence \<nl> when \<nl> is used to ter-
  528.      minate a LINE.  When processing macro definition lines, any
  529.      amount of white space is allowed on either side of the macro
  530.      operator (=, *=, :=, *:=, += or +:=), and white space is
  531.      stripped from both before and after the macro value string.
  532.      The sequence \<nl> is treated as white space during recipe
  533.      expansion and is deleted from the final recipe string.  You
  534.      must escape the \<nl> with another \ in order to get a \ at
  535.      the end of a recipe line.  The \<nl> sequence is deleted
  536.      from macro values when they are expanded.
  537.  
  538.      When processing target definition lines, the recipe for a
  539.      target must, in general, follow the first definition of the
  540.      target (See the RULES AND TARGETS section for an exception),
  541.      and the recipe may not span across multiple makefiles.  Any
  542.      targets and prerequisites found on a target definition line
  543.      are taken to be white space separated tokens.  The rule
  544.      operator (op in SYNTAX section) is also considered to be a
  545.      token but does not require white space to precede or follow
  546.      it.  Since the rule operator begins with a `:', traditional
  547.      versions of make do not allow the `:' character to form a
  548.      valid target name.  dmake allows `:' to be present in
  549.      target/prerequisite names as long as the entire
  550.      target/prerequisite name is quoted.  For example:
  551.  
  552.           a:fred : test
  553.  
  554.      would be parsed as TARGET = a, PREREQUISITES={fred, :,
  555.      test}, which is not what was intended.  To fix this you must
  556.      write:
  557.  
  558.           "a:fred" : test
  559.  
  560.      Which will be parsed as expected.  See the EXAMPLES section
  561.      for how to apply " quoting to a list of targets.
  562.  
  563. ATTRIBUTES
  564.      dmake defines several target attributes.  Attributes may be
  565.      assigned to a single target, a group of targets, or to all
  566.      targets in the makefile.  Attributes are used to modify
  567.      dmake actions during target update.  The recognized attri-
  568.      butes are:
  569.  
  570.  
  571.      .EPILOG     Insert shell epilog code when executing a group
  572.                  recipe associated with any target having this
  573.  
  574.  
  575.  
  576. Version 3.70                    UW                              9
  577.  
  578.  
  579.  
  580.  
  581. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  582.  
  583.  
  584.  
  585.                  attribute set.
  586.  
  587.      .IGNORE     Ignore an error when trying to make any target
  588.                  with this attribute set.
  589.  
  590.      .LIBRARY    Target is a library.
  591.  
  592.      .MKSARGS    If running in an MSDOS environment then use MKS
  593.                  extended argument passing conventions to pass
  594.                  arguments to commands.  Non-MSDOS environments
  595.                  ignore this attribute.
  596.  
  597.      .NOINFER    Any target with this attribute set will not be
  598.                  subjected to transitive closure if it is
  599.                  inferred as a prerequisite of a target whose
  600.                  recipe and prerequisites are being inferred.
  601.                  (i.e. the inference algorithm will not use any
  602.                  prerequisite with this attribute set, as a tar-
  603.                  get) If specified as '.NOINFER:' (ie. with no
  604.                  prerequisites or targets) then the effect is
  605.                  equivalent to specifying -T on the command line.
  606.  
  607.      .NOSTATE    Any target with this attribute set will not have
  608.                  command line flag information stored in the
  609.                  state file if .KEEP_STATE has been enabled.
  610.  
  611.      .PHONY      Any target with this attribute set will have its
  612.                  recipe executed each time the target is made
  613.                  even if a file matching the target name can be
  614.                  located.  Any targets that have a .PHONY attri-
  615.                  buted target as a prerequisite will be made each
  616.                  time the .PHONY attributed prerequisite is made.
  617.  
  618.      .PRECIOUS   Do not remove associated target under any cir-
  619.                  cumstances.  Set by default for any targets
  620.                  whose corresponding files exist in the file sys-
  621.                  tem prior to the execution of dmake.
  622.  
  623.      .PROLOG     Insert shell prolog code when executing a group
  624.                  recipe associated with any target having this
  625.                  attribute set.
  626.  
  627.      .SEQUENTIAL Force a sequential make of the associated
  628.                  target's prerequisites.
  629.  
  630.      .SETDIR     Change current working directory to specified
  631.                  directory when making the associated target.
  632.                  You must specify the directory at the time the
  633.                  attribute is specified.  To do this simply give
  634.                  .SETDIR=path as the attribute.  path is expanded
  635.                  and the result is used as the value of the
  636.                  directory to change to.  If path is surrounded
  637.  
  638.  
  639.  
  640. Version 3.70                    UW                             10
  641.  
  642.  
  643.  
  644.  
  645. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  646.  
  647.  
  648.  
  649.                  by single quotes then path is not expanded, and
  650.                  is used literally as the directory name.  If the
  651.                  path contains any `:' characters then the entire
  652.                  attribute string must be quoted using ".  If a
  653.                  target having this attribute set also has the
  654.                  .IGNORE attribute set then if the change to the
  655.                  specified directory fails it will be ignored,
  656.                  and no error message will be issued.
  657.  
  658.      .SILENT     Do not echo the recipe lines when making any
  659.                  target with this attribute set, and do not issue
  660.                  any warnings.
  661.  
  662.      .SWAP       Under MSDOS when making a target with this
  663.                  attribute set swap the dmake executable to disk
  664.                  prior to executing the recipe line.  Also see
  665.                  the '%' recipe line flag defined in the RECIPES
  666.                  section.
  667.  
  668.      .SYMBOL     Target is a library member and is an entry point
  669.                  into a module in the library.  This attribute is
  670.                  used only when searching a library for a target.
  671.                  Targets of the form lib((entry)) have this
  672.                  attribute set automatically.
  673.  
  674.      .USESHELL   Force each recipe line of a target to be exe-
  675.                  cuted using a shell.  Specifying this attribute
  676.                  is equivalent to specifying the '+' character at
  677.                  the start of each line of a non-group recipe.
  678.  
  679.      .UPDATEALL  Indicates that all the targets listed in this
  680.                  rule are updated by the execution of the accom-
  681.                  panying recipe.  A common example is the produc-
  682.                  tion of the y.tab.c and y.tab.h files by yacc
  683.                  when it is run on a grammar.  Specifying
  684.                  .UPDATEALL in such a rule prevents the running
  685.                  of yacc twice, once for the y.tab.c file and
  686.                  once for the y.tab.h file.
  687.  
  688.  
  689.      All attributes are user setable and except for .UPDATEALL,
  690.      .SETDIR and .MKSARGS may be used in one of two forms.  The
  691.      .MKSARGS attribute is restricted to use as a global attri-
  692.      bute, and the use of the .UPDATEALL and .SETDIR attributes
  693.      is restricted to rules of the second form only.
  694.  
  695.           ATTRIBUTE_LIST : targets
  696.  
  697.      assigns the attributes specified by ATTRIBUTE_LIST to each
  698.      target in targets or
  699.  
  700.           targets ATTRIBUTE_LIST : ...
  701.  
  702.  
  703.  
  704. Version 3.70                    UW                             11
  705.  
  706.  
  707.  
  708.  
  709. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  710.  
  711.  
  712.  
  713.      assigns the attributes specified by ATTRIBUTE_LIST to each
  714.      target in targets. In the first form if targets is empty
  715.      (ie. a NULL list), then the list of attributes will apply to
  716.      all targets in the makefile (this is equivalent to the com-
  717.      mon Make construct of ".IGNORE :" but has been modified to
  718.      the notion of an attribute instead of a special target).
  719.      Not all of the attributes have global meaning.  In particu-
  720.      lar, .LIBRARY, .SYMBOL, and .UPDATEALL have no assigned glo-
  721.      bal meaning.
  722.  
  723.      Any attribute may be used with any target, even with the
  724.      special targets.  Some combinations are useless (e.g.
  725.      .INCLUDE .PRECIOUS: ... ), while others are useful (e.g.
  726.      .INCLUDE .IGNORE : "file.mk" will not complain if file.mk
  727.      cannot be found using the include file search rules, see the
  728.      section on SPECIAL TARGETS for a description of .INCLUDE).
  729.      If a specified attribute will not be used with the special
  730.      target a warning is issued and the attribute is ignored.
  731.  
  732. MACROS
  733.      dmake supports six types of macro assignment.
  734.  
  735.  
  736.      MACRO = LINE    This is the most common and familiar form of
  737.                      macro assignment.  It assigns LINE literally
  738.                      as the value of MACRO.  Future expansions of
  739.                      MACRO recursively expand its value.
  740.  
  741.      MACRO *= LINE   This form behaves exactly as the simple '='
  742.                      form with the exception that if MACRO
  743.                      already has a value then the assignment is
  744.                      not performed.
  745.  
  746.      MACRO := LINE   This form differs from the simple '=' form
  747.                      in that it expands LINE prior to assigning
  748.                      it as the value of MACRO.  Future expansions
  749.                      of MACRO do not recursively expand its
  750.                      value.
  751.  
  752.      MACRO *:= LINE  This form behaves exactly as the ':=' form
  753.                      with the exception that if MACRO already has
  754.                      a value then the assignment and expansion
  755.                      are not performed.
  756.  
  757.      MACRO += LINE   This form of macro assignment allows macro
  758.                      values to grow.  It takes the literal value
  759.                      of LINE and appends it to the previous value
  760.                      of MACRO separating the two by a single
  761.                      space.  Future expansions of MACRO recur-
  762.                      sively expand its value.
  763.  
  764.  
  765.  
  766.  
  767.  
  768. Version 3.70                    UW                             12
  769.  
  770.  
  771.  
  772.  
  773. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  774.  
  775.  
  776.  
  777.      MACRO +:= LINE  This form is similar to the '+=' form except
  778.                      that the value of LINE is expanded prior to
  779.                      being added to the value of MACRO.
  780.  
  781.      Macro expressions specified on the command line allow the
  782.      macro value to be redefined within the makefile only if the
  783.      macro is defined using the '+=' and '+:=' operators.  Other
  784.      operators will define a macro that cannot be further modi-
  785.      fied.
  786.  
  787.      When dmake defines a non-environment macro it strips leading
  788.      and trailing white space from the macro value.  Macros
  789.      imported from the environment via either the .IMPORT special
  790.      target (see the SPECIAL TARGETS section), or the -e, or -E
  791.      flags are an exception to this rule.  Their values are
  792.      always taken literally and white space is never stripped.
  793.      In addition, named macros defined using the .IMPORT special
  794.      target do not have their values expanded when they are used
  795.      within a makefile.  In contrast, environment macros that are
  796.      imported due to the specification of the -e or -E flags are
  797.      subject to expansion when used.
  798.  
  799.      To specify a macro expansion enclose the name in () or {}
  800.      and precede it with a dollar sign $.  Thus $(TEST)
  801.      represents an expansion of the macro variable named TEST.
  802.      If TEST is defined then $(TEST) is replaced by its expanded
  803.      value.  If TEST is not defined then $(TEST) expands to the
  804.      NULL string (this is equivalent to defining a macro as
  805.      'TEST=' ).  A short form may be used for single character
  806.      named macros.  In this case the parentheses are optional,
  807.      and $(I) is equivalent to $I.  Macro expansion is recursive,
  808.      hence, if the value string contains an expression represent-
  809.      ing a macro expansion, the expansion is performed.  Circular
  810.      macro expansions are detected and cause an error to be
  811.      issued.
  812.  
  813.      When defining a macro the given macro name is first expanded
  814.      before being used to define the macro.  Thus it is possible
  815.      to define macros whose names depend on values of other mac-
  816.      ros.  For example, suppose CWD is defined as
  817.  
  818.           CWD = $(PWD:b)
  819.  
  820.      then the value of $(CWD) is the name of the current direc-
  821.      tory.  This can be used to define macros specific to this
  822.      directory, for example:
  823.  
  824.           _$(CWD).prt = list of files to print...
  825.  
  826.      The actual name of the defined macro is a function of the
  827.      current directory.  A construct such as this is useful when
  828.      processing a hierarchy of directories using .SETDIR
  829.  
  830.  
  831.  
  832. Version 3.70                    UW                             13
  833.  
  834.  
  835.  
  836.  
  837. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  838.  
  839.  
  840.  
  841.      attributed targets and a collection of small distributed
  842.      makefile stubs.
  843.  
  844.      Macro variables may be defined within the makefile, on the
  845.      command line, or imported from the environment.
  846.  
  847.      dmake supports several non-standard macro expansions: The
  848.      first is of the form:
  849.  
  850.           $(macro_name:modifier_list:modifier_list:...)
  851.  
  852.      where modifier_list is chosen from the set { D or d, F or f,
  853.      B or b, S or s, T or t } and
  854.  
  855.           d - directory portion of all path names
  856.           f - file (including suffix) portion of path names
  857.           b - file (not including suffix) portion of path names
  858.           s - simple pattern substitution
  859.           t - tokenization.
  860.  
  861.      Thus if we have the example:
  862.  
  863.           test = d1/d2/d3/a.out f.out d1/k.out
  864.  
  865.      The following macro expansions produce the values on the
  866.      right of '-->' after expansion.
  867.  
  868.           $(test:d)            --> d1/d2/d3/ d1/
  869.           $(test:b)            --> a f k
  870.           $(test:f)            --> a.out f.out k.out
  871.           ${test:db}           --> d1/d2/d3/a f d1/k
  872.           ${test:s/out/in/:f}  --> a.in f.in k.in
  873.           $(test:f:t"+")       --> a.out+f.out+k.out
  874.  
  875.      If a token ends in a string composed from the value of the
  876.      macro DIRBRKSTR (ie. ends in a directory separator string,
  877.      e.g. '/' in UNIX) and you use the :d modifier then the
  878.      expansion returns the directory name less the final direc-
  879.      tory separator string.  Thus successive pairs of :d modif-
  880.      iers each remove a level of directory in the token string.
  881.  
  882.      The tokenization modifier takes all white space separated
  883.      tokens from the macro value and separates them by the quoted
  884.      separator string.  The separator string may contain the fol-
  885.      lowing escape codes \a => <bel>, \b => <backspace>, \f =>
  886.      <formfeed>, \n => <nl>, \r => <cr>, \t => <tab>, \v =>
  887.      <vertical tab>, \" => ", and \xxx => <xxx> where xxx is the
  888.      octal representation of a character.  Thus the expansion:
  889.  
  890.           $(test:f:t"+\n")
  891.      produces:
  892.           a.out+
  893.  
  894.  
  895.  
  896. Version 3.70                    UW                             14
  897.  
  898.  
  899.  
  900.  
  901. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  902.  
  903.  
  904.  
  905.           f.out+
  906.           k.out
  907.  
  908.      The second non-standard form of macro expansion allows for
  909.      recursive macros.  It is possible to specify a $(macro_name)
  910.      or ${macro_name} expansion where macro_name contains more $(
  911.      ... ) or ${ ... } macro expansions itself.
  912.  
  913.      For example $(CC$(_HOST)$(_COMPILER)) will first expand
  914.      CC$(_HOST)$(_COMPILER) to get a result and use that result
  915.      as the name of the macro to expand.  This is useful for
  916.      writing a makefile for more than one target environment.  As
  917.      an example consider the following hypothetical case. Suppose
  918.      that _HOST and _COMPILER are imported from the environment
  919.      and are set to represent the host machine type and the host
  920.      compiler respectively.
  921.  
  922.           CFLAGS_VAX_CC = -c -O    # _HOST == "_VAX", _COMPILER == "_CC"
  923.           CFLAGS_PC_MSC = -c -ML   # _HOST == "_PC",  _COMPILER == "_MSC"
  924.  
  925.           # redefine CFLAGS macro as:
  926.  
  927.           CFLAGS := $(CFLAGS$(_HOST)$(_COMPILER))
  928.  
  929.      This causes CFLAGS to take on a value that corresponds to
  930.      the environment in which the make is being invoked.
  931.  
  932.      The final non-standard macro expansion is of the form:
  933.  
  934.           string1{token_list}string2
  935.  
  936.      where string1, string2 and token_list are expanded.  After
  937.      expansion, string1 is prepended to each token found in
  938.      token_list and string2 is appended to each resulting token
  939.      from the previous prepend.  string1 and string2 are not del-
  940.      imited by white space whereas the tokens in token_list are.
  941.      A null token in the token list is specified using "".  Thus
  942.      using another example we have:
  943.  
  944.           test/{f1 f2}.o     --> test/f1.o test/f2.o
  945.           test/ {f1 f2}.o    --> test/ f1.o f2.o
  946.           test/{f1 f2} .o    --> test/f1 test/f2 .o
  947.           test/{"f1"  ""}.o  --> test/f1.o test/.o
  948.  
  949.           and
  950.  
  951.           test/{d1 d2}/{f1 f2}.o --> test/d1/f1.o test/d1/f2.o
  952.                                      test/d2/f1.o test/d2/f2.o
  953.  
  954.      This last expansion is activated only when the first charac-
  955.      ters of token_list appear immediately after the opening '{'
  956.      with no intervening white space.  The reason for this
  957.  
  958.  
  959.  
  960. Version 3.70                    UW                             15
  961.  
  962.  
  963.  
  964.  
  965. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  966.  
  967.  
  968.  
  969.      restriction is the following incompatibility with Bourne
  970.      Shell recipes.  The line
  971.  
  972.           { echo hello;}
  973.  
  974.      is valid /bin/sh syntax; while
  975.  
  976.           {echo hello;}
  977.  
  978.      is not.  Hence the latter triggers the enhanced macro expan-
  979.      sion while the former causes it to be suppressed.  See the
  980.      SPECIAL MACROS section for a description of the special mac-
  981.      ros that dmake defines and understands.
  982.  
  983. RULES AND TARGETS
  984.      A makefile contains a series of entries that specify depen-
  985.      dencies.  Such entries are called target/prerequisite or
  986.      rule definitions.  Each rule definition is optionally fol-
  987.      lowed by a set of lines that provide a recipe for updating
  988.      any targets defined by the rule.  Whenever dmake attempts to
  989.      bring a target up to date and an explicit recipe is provided
  990.      with a rule defining the target, that recipe is used to
  991.      update the target.  A rule definition begins with a line
  992.      having the following syntax:
  993.  
  994.           <targets> [<attributes>] <ruleop> [<prerequisites>] [;<recipe>]
  995.  
  996.      targets is a non-empty list of targets.  If the target is a
  997.      special target (see SPECIAL TARGETS section below) then it
  998.      must appear alone on the rule line.  For example:
  999.  
  1000.           .IMPORT .ERROR : ...
  1001.  
  1002.      is not allowed since both .IMPORT and .ERROR are special
  1003.      targets.  Special targets are not used in the construction
  1004.      of the dependency graph and will not be made.
  1005.  
  1006.      attributes is a possibly empty list of attributes.  Any
  1007.      attribute defined in the ATTRIBUTES section above may be
  1008.      specified.  All attributes will be applied to the list of
  1009.      named targets in the rule definition.  No other targets will
  1010.      be affected.
  1011.  
  1012.  
  1013.      NOTE:   As stated earlier, if both the target list and
  1014.              prerequisite list are empty but the attributes list
  1015.              is not, then the specified attributes affect all
  1016.              targets in the makefile.
  1017.  
  1018.  
  1019.      ruleop is a separator which is used to identify the targets
  1020.      from the prerequisites.  Optionally it also provides a
  1021.  
  1022.  
  1023.  
  1024. Version 3.70                    UW                             16
  1025.  
  1026.  
  1027.  
  1028.  
  1029. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1030.  
  1031.  
  1032.  
  1033.      facility for modifying the way in which dmake handles the
  1034.      making of the associated targets.  In its simplest form the
  1035.      operator is a single ':', and need not be separated by white
  1036.      space from its neighboring tokens.  It may additionally be
  1037.      followed by any of the modifiers { !, ^, -, : }, where:
  1038.  
  1039.  
  1040.      !    says execute the recipe for the associated targets once
  1041.           for each out of date prerequisite.  Ordinarily the
  1042.           recipe is executed once for all out of date prere-
  1043.           quisites at the same time.
  1044.  
  1045.      ^    says to insert the specified prerequisites, if any,
  1046.           before any other prerequisites already associated with
  1047.           the specified targets.  In general, it is not useful to
  1048.           specify ^ with an empty list of prerequisites.
  1049.  
  1050.      -    says to clear the previous list of prerequisites before
  1051.           adding the new prerequisites.  Thus,
  1052.  
  1053.                .SUFFIXES :
  1054.                .SUFFIXES : .a .b
  1055.  
  1056.           can be replaced by
  1057.  
  1058.                .SUFFIXES :- .a .b
  1059.  
  1060.           however the old form still works as expected.  NOTE:
  1061.           .SUFFIXES is ignored by dmake it is used here simply as
  1062.           an example.
  1063.  
  1064.      :    When the rule operator is not modified by a second ':'
  1065.           only one set of rules may be specified for making a
  1066.           target.  Multiple definitions may be used to add to the
  1067.           list of prerequisites that a target depends on.  How-
  1068.           ever, if a target is multiply defined only one defini-
  1069.           tion may specify a recipe for making the target.
  1070.  
  1071.           When a target's rule operator is modified by a second
  1072.           ':' (:: for example) then this definition may not be
  1073.           the only definition with a recipe for the target.
  1074.           There may be other :: target definition lines that
  1075.           specify a different set of prerequisites with a dif-
  1076.           ferent recipe for updating the target. Any such target
  1077.           is made if any of the definitions find it to be out of
  1078.           date with respect to the related prerequisites and the
  1079.           corresponding recipe is used to update the target.
  1080.  
  1081.           In the following simple example, each rule has a `::'
  1082.           ruleop.  In such an operator we call the first `:' the
  1083.           operator, and the second `:' the modifier.
  1084.  
  1085.  
  1086.  
  1087.  
  1088. Version 3.70                    UW                             17
  1089.  
  1090.  
  1091.  
  1092.  
  1093. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1094.  
  1095.  
  1096.  
  1097.           a.o :: a.c b.h
  1098.              first recipe for making a.o
  1099.  
  1100.           a.o :: a.y b.h
  1101.              second recipe for making a.o
  1102.  
  1103.           If a.o is found to be out of date with respect to a.c
  1104.           then the first recipe is used to make a.o.  If it is
  1105.           found out of date with respect to a.y then the second
  1106.           recipe is used.  If a.o is out of date with respect to
  1107.           b.h then both recipes are invoked to make a.o.  In the
  1108.           last case the order of invocation corresponds to the
  1109.           order in which the rule definitions appear in the
  1110.           makefile.
  1111.  
  1112.      Targets defined using a single `:' operator with a recipe
  1113.      may be redefined again with a new recipe by using a `:'
  1114.      operator with a `:' modifier.  This is equivalent to a tar-
  1115.      get having been initially defined with a rule using a `:'
  1116.      modifier.  Once a target is defined using a `:' modifier it
  1117.      may not be defined again with a recipe using only the `:'
  1118.      operator with no `:' modifier.  In both cases the use of a
  1119.      `:' modifier creates a new list of prerequisites and makes
  1120.      it the current prerequisite list for the target.  The `:'
  1121.      operator with no recipe always modifies the current list of
  1122.      prerequisites.  Thus assuming each of the following defini-
  1123.      tions has a recipe attached, then:
  1124.  
  1125.           joe :  fred ...     (1)
  1126.           joe :: more ...     (2)
  1127.  
  1128.           and
  1129.  
  1130.           joe :: fred ...     (3)
  1131.           joe :: more ...     (4)
  1132.  
  1133.      are legal and mean:  add the recipe associated with (2), or
  1134.      (4) to the set of recipes for joe, placing them after exist-
  1135.      ing recipes for making joe.  The constructs:
  1136.  
  1137.           joe :: fred ...     (5)
  1138.           joe : more ... (6)
  1139.  
  1140.           and
  1141.  
  1142.           joe : fred ... (7)
  1143.           joe : more ... (8)
  1144.  
  1145.      are errors since we have two sets of perfectly good recipes
  1146.      for making the target.
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152. Version 3.70                    UW                             18
  1153.  
  1154.  
  1155.  
  1156.  
  1157. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1158.  
  1159.  
  1160.  
  1161.      prerequisites is a possibly empty list of targets that must
  1162.      be brought up to date before making the current target.
  1163.  
  1164.      recipe is a short form and allows the user to specify short
  1165.      rule definitions on a single line.  It is taken to be the
  1166.      first recipe line in a larger recipe if additional lines
  1167.      follow the rule definition.  If the semi-colon is present
  1168.      but the recipe line is empty (ie. null string) then it is
  1169.      taken to be an empty rule.  Any target so defined causes the
  1170.      Don't know how to make ... error message to be suppressed
  1171.      when dmake tries to make the target and fails.  This silence
  1172.      is maintained for rules that are terminated by a semicolon
  1173.      and have no following recipe lines, for targets listed on
  1174.      the command line, for the first target found in the
  1175.      makefile, and for any target having no recipe but containing
  1176.      a list of prerequisites (see the COMPATIBILITY section for
  1177.      an exception to this rule if the AUGMAKE (-A) flag was
  1178.      specified.
  1179.  
  1180. RECIPES
  1181.      The traditional format used by most versions of Make defines
  1182.      the recipe lines as arbitrary strings that may contain macro
  1183.      expansions.  They follow a rule definition line and may be
  1184.      spaced apart by comment or blank lines.  The list of recipe
  1185.      lines defining the recipe is terminated by a new target
  1186.      definition, a macro definition, or end-of-file.  Each recipe
  1187.      line MUST begin with a <TAB> character which may optionally
  1188.      be followed with one or all of the characters '@%+-'.  The
  1189.      '-' indicates that non-zero exit values (ie. errors) are to
  1190.      be ignored when this recipe line is executed, the '+' indi-
  1191.      cates that the current recipe line is to be executed using
  1192.      the shell, the '%' indicates that dmake should swap itself
  1193.      out to secondary storage (MSDOS only) before running the
  1194.      recipe and the '@' indicates that the recipe line should NOT
  1195.      be echoed to the terminal prior to being executed.  Each
  1196.      switch is off by default (ie. by default, errors are signi-
  1197.      ficant, commands are echoed, no swapping is done and a shell
  1198.      is used only if the recipe line contains a character found
  1199.      in the value of the SHELLMETAS macro).  Global settings
  1200.      activated via command line options or special attribute or
  1201.      target names may also affect these settings.  An example
  1202.      recipe:
  1203.  
  1204.           target :
  1205.                first recipe line
  1206.                second recipe line, executed independently of the first.
  1207.                @a recipe line that is not echoed
  1208.                -and one that has errors ignored
  1209.                %and one that causes dmake to swap out
  1210.                +and one that is executed using a shell.
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216. Version 3.70                    UW                             19
  1217.  
  1218.  
  1219.  
  1220.  
  1221. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1222.  
  1223.  
  1224.  
  1225.      The second and new format of the recipe block begins the
  1226.      block with the character '[' (the open group character) in
  1227.      the last non-white space position of a line, and terminates
  1228.      the block with the character ']' (the close group character)
  1229.      in the first non-white space position of a line.  In this
  1230.      form each recipe line need not have a leading TAB.  This is
  1231.      called a recipe group.  Groups so defined are fed intact as
  1232.      a single unit to a shell for execution whenever the
  1233.      corresponding target needs to be updated.  If the open group
  1234.      character '[' is preceded by one or all of -, @ or % then
  1235.      they apply to the entire group in the same way that they
  1236.      apply to single recipe lines.  You may also specify '+' but
  1237.      it is redundant as a shell is already being used to run the
  1238.      recipe.  See the MAKING TARGETS section for a description of
  1239.      how dmake invokes recipes.  Here is an example of a group
  1240.      recipe:
  1241.  
  1242.           target :
  1243.           [
  1244.                first recipe line
  1245.                second recipe line
  1246.                all of these recipe lines are fed to a
  1247.                single copy of a shell for execution.
  1248.           ]
  1249.  
  1250.  
  1251. TEXT DIVERSIONS
  1252.      dmake supports the notion of text diversions.  If a recipe
  1253.      line contains the macro expression
  1254.  
  1255.           $(mktmp[,[file][,text]] data)
  1256.  
  1257.      then all text contained in the data expression is expanded
  1258.      and is written to a temporary file.  The return value of the
  1259.      macro is the name of the temporary file.
  1260.  
  1261.      data can be any text and must be separated from the 'mktmp'
  1262.      portion of the macro name by white-space.  The only restric-
  1263.      tion on the data text is that it must contain a balanced
  1264.      number of parentheses of the same kind as are used to ini-
  1265.      tiate the $(mktmp ...) expression.  For example:
  1266.  
  1267.           $(mktmp $(XXX))
  1268.  
  1269.      is legal and works as expected, but:
  1270.  
  1271.           $(mktmp text (to dump to file)
  1272.  
  1273.      is not legal.  You can achieve what you wish by either
  1274.      defining a macro that expands to '(' or by using {} in the
  1275.      macro expression; like this:
  1276.  
  1277.  
  1278.  
  1279.  
  1280. Version 3.70                    UW                             20
  1281.  
  1282.  
  1283.  
  1284.  
  1285. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1286.  
  1287.  
  1288.  
  1289.           ${mktmp text (to dump to file}
  1290.  
  1291.      Since the temporary file is opened when the macro containing
  1292.      the text diversion expression is expanded, diversions may
  1293.      now be nested and any diversions that are created as part of
  1294.      ':=' macro expansions persist for the duration of the dmake
  1295.      run.  The diversion text may contain the same escape codes
  1296.      as those described in the MACROS section.  Thus if the data
  1297.      text is to contain new lines they must be inserted using the
  1298.      \n escape sequence.  For example the expression:
  1299.  
  1300.           all:
  1301.                cat $(mktmp this is a\n\
  1302.                test of the text diversion\n)
  1303.  
  1304.      is replaced by:
  1305.  
  1306.           cat /tmp/mk12294AA
  1307.  
  1308.      where the temporary file contains two lines both of which
  1309.      are terminated by a new-line.  If the data text spans multi-
  1310.      ple lines in the makefile then each line must be continued
  1311.      via the use of a \.  A second more illustrative example gen-
  1312.      erates a response file to an MSDOS link command:
  1313.  
  1314.           OBJ = fred.obj mary.obj joe.obj
  1315.           all : $(OBJ)
  1316.                link @$(mktmp $(^:t"+\n")\n)
  1317.  
  1318.      The result of making `all' in the second example is the com-
  1319.      mand:
  1320.  
  1321.           link @/tmp/mk02394AA
  1322.  
  1323.      where the temporary file contains:
  1324.  
  1325.           fred.obj+
  1326.           mary.obj+
  1327.           joe.obj
  1328.  
  1329.      The last line of the file is terminated by a new-line which
  1330.      is inserted due to the \n found at the end of the data
  1331.      string.
  1332.  
  1333.      If the optional file specifier is present then its expanded
  1334.      value is the name of the temporary file to create.  Whenever
  1335.      a $(mktmp ...) macro is expanded the macro $(TMPFILE) is set
  1336.      to a new temporary file name.  Thus the construct:
  1337.  
  1338.           $(mktmp,$(TMPFILE) data)
  1339.  
  1340.      is completely equivalent to not specifying the $(TMPFILE)
  1341.  
  1342.  
  1343.  
  1344. Version 3.70                    UW                             21
  1345.  
  1346.  
  1347.  
  1348.  
  1349. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1350.  
  1351.  
  1352.  
  1353.      optional argument.  Another example that would be useful for
  1354.      MSDOS users with a Turbo-C compiler
  1355.  
  1356.           $(mktmp,turboc.cfg $(CFLAGS))
  1357.  
  1358.      will place the contents of CFLAGS into a local turboc.cfg
  1359.      file.  The second optional argument, text, if present alters
  1360.      the name of the value returned by the $(mktmp ...) macro.
  1361.  
  1362.      Under MS-DOS text diversions may be a problem.  Many DOS
  1363.      tools require that path names which contain directories use
  1364.      the \ character to delimit the directories.  Some users how-
  1365.      ever wish to use the '/' to delimit pathnames and use
  1366.      environments that allow them to do so.  The macro USESHELL
  1367.      is set to "yes" if the current recipe is forced to use a
  1368.      shell via the .USESHELL or '+' directives, otherwise its
  1369.      value is "no".  The dmake startup files define the macro
  1370.      DIVFILE whose value is either the value of TMPFILE or the
  1371.      value of TMPFILE edited to replace any '/' characters to the
  1372.      appropriate value based on the current shell and whether it
  1373.      will be used to execute the recipe.
  1374.  
  1375.      Previous versions of dmake defined text diversions using <+,
  1376.      +> strings, where <+ started a text diversion and +> ter-
  1377.      minated one.  dmake is backward compatible with this con-
  1378.      struct if the <+ and +> appear literally on the same recipe
  1379.      line or in the same macro value string.  In such instances
  1380.      the expression:
  1381.  
  1382.           <+data+>
  1383.  
  1384.      is mapped to:
  1385.  
  1386.           $(mktmp data)
  1387.  
  1388.      which is fully output compatible with the earlier construct.
  1389.      <+, +> constructs whose text spans multiple lines must be
  1390.      converted by hand to use $(mktmp ...).
  1391.  
  1392.      If the environment variable TMPDIR is defined then the tem-
  1393.      porary file is placed into the directory specified by that
  1394.      variable.  A makefile can modify the location of temporary
  1395.      files by defining a macro named TMPDIR and exporting it
  1396.      using the .EXPORT special target.
  1397.  
  1398. SPECIAL TARGETS
  1399.      This section describes the special targets that are recog-
  1400.      nized by dmake.  Some are affected by attributes and others
  1401.      are not.
  1402.  
  1403.      .ERROR        If defined then the recipe associated with
  1404.                    this target is executed whenever an error
  1405.  
  1406.  
  1407.  
  1408. Version 3.70                    UW                             22
  1409.  
  1410.  
  1411.  
  1412.  
  1413. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1414.  
  1415.  
  1416.  
  1417.                    condition is detected by dmake.  All attri-
  1418.                    butes that can be used with any other target
  1419.                    may be used with this target.  Any prere-
  1420.                    quisites of this target will be brought up to
  1421.                    date during its processing.  NOTE:  errors
  1422.                    will be ignored while making this target, in
  1423.                    extreme cases this may cause some problems.
  1424.  
  1425.      .EXPORT       All prerequisites associated with this target
  1426.                    are assumed to correspond to macro names and
  1427.                    they and their values are exported to the
  1428.                    environment as environment strings at the
  1429.                    point in the makefile at which this target
  1430.                    appears.  Any attributes specified with this
  1431.                    target are ignored.  Only macros which have
  1432.                    been assigned a value in the makefile prior to
  1433.                    the export directive are exported, macros as
  1434.                    yet undefined are not exported.
  1435.  
  1436.      .IMPORT       Prerequisite names specified for this target
  1437.                    are searched for in the environment and
  1438.                    defined as macros with their value taken from
  1439.                    the environment.  If the special name .EVERY-
  1440.                    THING is used as a prerequisite name then all
  1441.                    environment variables defined in the environ-
  1442.                    ment are imported.  The functionality of the
  1443.                    -e flag can be forced by placing the construct
  1444.                    .IMPORT : .EVERYTHING at the start of a
  1445.                    makefile.  Similarly, by placing the construct
  1446.                    at the end, one can emulate the effect of the
  1447.                    -E command line flag.  If a prerequisite name
  1448.                    cannot be found in the environment an error
  1449.                    message is issued.  .IMPORT accepts the
  1450.                    .IGNORE attribute.  When given, it causes
  1451.                    dmake to ignore the above error.  See the MAC-
  1452.                    ROS section for a description of the process-
  1453.                    ing of imported macro values.
  1454.  
  1455.      .INCLUDE      Parse another makefile just as if it had been
  1456.                    located at the point of the .INCLUDE in the
  1457.                    current makefile.  The list of prerequisites
  1458.                    gives the list of makefiles to try to read.
  1459.                    If the list contains multiple makefiles then
  1460.                    they are read in order from left to right.
  1461.                    The following search rules are used when try-
  1462.                    ing to locate the file.  If the filename is
  1463.                    surrounded by " or just by itself then it is
  1464.                    searched for in the current directory.  If it
  1465.                    is not found it is then searched for in each
  1466.                    of the directories specified for the .INCLU-
  1467.                    DEDIRS special target.  If the file name is
  1468.                    surrounded by < and >, (ie.
  1469.  
  1470.  
  1471.  
  1472. Version 3.70                    UW                             23
  1473.  
  1474.  
  1475.  
  1476.  
  1477. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1478.  
  1479.  
  1480.  
  1481.                    <my_spiffy_new_makefile>) then it is searched
  1482.                    for only in the directories given by the
  1483.                    .INCLUDEDIRS special target.  In both cases if
  1484.                    the file name is a fully qualified name start-
  1485.                    ing at the root of the file system then it is
  1486.                    only searched for once, and the .INCLUDEDIRS
  1487.                    list is ignored.  .INCLUDE accepts the .IGNORE
  1488.                    and .SETDIR attributes.  If .IGNORE attribute
  1489.                    is given and the file cannot be found then
  1490.                    dmake continues processing, otherwise an error
  1491.                    message is generated.  The .SETDIR attribute
  1492.                    causes dmake to change directories to the
  1493.                    specified directory prior to attempting the
  1494.                    include operation.
  1495.  
  1496.      .INCLUDEDIRS  The list of prerequisites specified for this
  1497.                    target defines the set of directories to
  1498.                    search when trying to include a makefile.
  1499.  
  1500.      .KEEP_STATE   This special target is a synonym for the macro
  1501.                    definition
  1502.  
  1503.                         .KEEP_STATE := _state.mk
  1504.  
  1505.                    It's effect is to turn on STATE keeping and to
  1506.                    define _state.mk as the state file.
  1507.  
  1508.      .MAKEFILES    The list of prerequisites is the set of files
  1509.                    to try to read as the default makefile.  By
  1510.                    default this target is defined as:
  1511.  
  1512.                         .MAKEFILES : makefile.mk Makefile
  1513.                    makefile
  1514.  
  1515.  
  1516.      .SOURCE       The prerequisite list of this target defines a
  1517.                    set of directories to check when trying to
  1518.                    locate a target file name.  See the section on
  1519.                    BINDING of targets for more information.
  1520.  
  1521.      .SOURCE.suff  The same as .SOURCE, except that the
  1522.                    .SOURCE.suff list is searched first when try-
  1523.                    ing to locate a file matching the a target
  1524.                    whose name ends in the suffix .suff.
  1525.  
  1526.      .REMOVE       The recipe of this target is used whenever
  1527.                    dmake needs to remove intermediate targets
  1528.                    that were made but do not need to be kept
  1529.                    around.  Such targets result from the applica-
  1530.                    tion of transitive closure on the dependency
  1531.                    graph.
  1532.  
  1533.  
  1534.  
  1535.  
  1536. Version 3.70                    UW                             24
  1537.  
  1538.  
  1539.  
  1540.  
  1541. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1542.  
  1543.  
  1544.  
  1545.      In addition to the special targets above, several other
  1546.      forms of targets are recognized and are considered special,
  1547.      their exact form and use is defined in the sections that
  1548.      follow.
  1549.  
  1550. SPECIAL MACROS
  1551.      dmake defines a number of special macros.  They are divided
  1552.      into three classes: control macros, run-time macros, and
  1553.      function macros.  The control macros are used by dmake to
  1554.      configure its actions, and are the preferred method of doing
  1555.      so.  In the case when a control macro has the same function
  1556.      as a special target or attribute they share the same name as
  1557.      the special target or attribute.  The run-time macros are
  1558.      defined when dmake makes targets and may be used by the user
  1559.      inside recipes.  The function macros provide higher level
  1560.      functions dealing with macro expansion and diversion file
  1561.      processing.
  1562.  
  1563. CONTROL MACROS
  1564.      To use the control macros simply assign them a value just
  1565.      like any other macro.  The control macros are divided into
  1566.      three groups: string valued macros, character valued macros,
  1567.      and boolean valued macros.
  1568.  
  1569.      The following are all of the string valued macros.  This
  1570.      list is divided into two groups.  The first group gives the
  1571.      string valued macros that are defined internally and cannot
  1572.      be directly set by the user.
  1573.  
  1574.      DIRBRKSTR     Contains the string of chars used to terminate
  1575.                    the name of a directory in a pathname.  Under
  1576.                    UNIX its value is "/", under MSDOS its value
  1577.                    is "/\:".
  1578.  
  1579.      INCDEPTH      This macro's value is a string of digits
  1580.                    representing the current depth of makefile
  1581.                    inclusion.  In the first makefile level this
  1582.                    value is zero.
  1583.  
  1584.      MFLAGS        Is the list of flags that were given on the
  1585.                    command line including a leading switch char-
  1586.                    acter.  The -f flag is not included in this
  1587.                    list.
  1588.  
  1589.      MAKECMD       Is the name with which dmake was invoked.
  1590.  
  1591.      MAKEDIR       Is the full path to the initial directory in
  1592.                    which dmake was invoked.
  1593.  
  1594.      MAKEFILE      Contains the string "-f makefile" where,
  1595.                    makefile is the name of initial user makefile
  1596.                    that was first read.
  1597.  
  1598.  
  1599.  
  1600. Version 3.70                    UW                             25
  1601.  
  1602.  
  1603.  
  1604.  
  1605. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1606.  
  1607.  
  1608.  
  1609.      MAKEFLAGS     Is the same as $(MFLAGS) but has no leading
  1610.                    switch character. (ie. MFLAGS = -$(MAKEFLAGS))
  1611.  
  1612.      MAKEMACROS    Contains the complete list of macro expres-
  1613.                    sions that were specified on the command line.
  1614.  
  1615.      MAKETARGETS   Contains the name(s) of the target(s), if any,
  1616.                    that were specified on the command line.
  1617.  
  1618.      MAXPROCESSLIMIT
  1619.                    Is a numeric string representing the maximum
  1620.                    number of processes that dmake can use when
  1621.                    making targets using parallel mode.
  1622.  
  1623.      NULL          Is permanently defined to be the NULL string.
  1624.                    This is useful when comparing a conditional
  1625.                    expression to an NULL value.
  1626.  
  1627.      PWD           Is the full path to the current directory in
  1628.                    which make is executing.
  1629.  
  1630.      TMPFILE       Is set to the name of the most recent tem-
  1631.                    porary file opened by dmake.  Temporary files
  1632.                    are used for text diversions and for group
  1633.                    recipe processing.
  1634.  
  1635.      TMD           Stands for "To Make Dir", and is the path from
  1636.                    the present directory (value of $(PWD)) to the
  1637.                    directory that dmake was started up in (value
  1638.                    of $(MAKEDIR)).  This macro is modified when
  1639.                    .SETDIR attributes are processed.
  1640.  
  1641.      USESHELL      The value of this macro is set to "yes" if the
  1642.                    current recipe is forced to use a shell for
  1643.                    its execution via the .USESHELL or '+' direc-
  1644.                    tives, its value is "no" otherwise.
  1645.  
  1646.  
  1647.      The second group of string valued macros control dmake
  1648.      behavior and may be set by the user.
  1649.  
  1650.      .SETDIR         If this macro is assigned a value then dmake
  1651.                      will change to the directory given by that
  1652.                      value before making any targets.
  1653.  
  1654.      AUGMAKE         If set to a non NULL value will enable the
  1655.                      transformation of special meta targets to
  1656.                      support special AUGMAKE inferences (See the
  1657.                      COMPATIBILITY section).
  1658.  
  1659.      DIRSEPSTR       Contains the string that is used to separate
  1660.                      directory components when path names are
  1661.  
  1662.  
  1663.  
  1664. Version 3.70                    UW                             26
  1665.  
  1666.  
  1667.  
  1668.  
  1669. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1670.  
  1671.  
  1672.  
  1673.                      constructed.  It is defined with a default
  1674.                      value at startup.
  1675.  
  1676.      DIVFILE         Is defined in the startup file and gives the
  1677.                      name that should be returned for the diver-
  1678.                      sion file name when used in $(mktmp ...)
  1679.                      expansions, see the TEXT DIVERSION section
  1680.                      for details.
  1681.  
  1682.      .KEEP_STATE     Assigning this macro a value tells dmake the
  1683.                      name of the state file to use and turns on
  1684.                      the keeping of state information for any
  1685.                      targets that are brought up to date by the
  1686.                      make.
  1687.  
  1688.      GROUPFLAGS      This macro gives the set of flags to pass to
  1689.                      the shell when invoking it to execute a
  1690.                      group recipe.  The value of the macro is the
  1691.                      list of flags with a leading switch indica-
  1692.                      tor.  (ie. `-' under UNIX)
  1693.  
  1694.      GROUPSHELL      This macro defines the full path to the exe-
  1695.                      cutable image to be used as the shell when
  1696.                      processing group recipes.  This macro must
  1697.                      be defined if group recipes are used.  It is
  1698.                      assigned a default value in the startup
  1699.                      makefile.  Under UNIX this value is /bin/sh.
  1700.  
  1701.      GROUPSUFFIX     If defined, this macro gives the string to
  1702.                      use as a suffix when creating group recipe
  1703.                      files to be handed to the command inter-
  1704.                      preter.  For example, if it is defined as
  1705.                      .sh, then all temporary files created by
  1706.                      dmake will end in the suffix .sh.  Under
  1707.                      MSDOS if you are using command.com as your
  1708.                      GROUPSHELL, then this suffix must be set to
  1709.                      .bat in order for group recipes to function
  1710.                      correctly.  The setting of GROUPSUFFIX and
  1711.                      GROUPSHELL is done automatically for
  1712.                      command.com in the startup.mk files.
  1713.  
  1714.      MAKE            Is defined in the startup file by default.
  1715.                      The string $(MAKE) is recognized when using
  1716.                      the -n option for single line recipes.  Ini-
  1717.                      tially this macro is defined to have the
  1718.                      value "$(MAKECMD) $(MFLAGS)".
  1719.  
  1720.      MAKESTARTUP     This macro defines the full path to the ini-
  1721.                      tial startup makefile.  Use the -V command
  1722.                      line option to discover its initial value.
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728. Version 3.70                    UW                             27
  1729.  
  1730.  
  1731.  
  1732.  
  1733. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1734.  
  1735.  
  1736.  
  1737.      MAXLINELENGTH   This macro defines the maximum size of a
  1738.                      single line of makefile input text.  The
  1739.                      size is specified as a number, the default
  1740.                      value is defined internally and is shown via
  1741.                      the -V option.  A buffer of this size plus 2
  1742.                      is allocated for reading makefile text.  The
  1743.                      buffer is freed before any targets are made,
  1744.                      thereby allowing files containing long input
  1745.                      lines to be processed without consuming
  1746.                      memory during the actual make.
  1747.  
  1748.      MAXPROCESS      Specify the maximum number of child
  1749.                      processes to use when making targets.  The
  1750.                      default value of this macro is "1" and its
  1751.                      value cannot exceed the value of the macro
  1752.                      MAXPROCESSLIMIT.  Setting the value of MAX-
  1753.                      PROCESS on the command line or in the
  1754.                      makefile is equivalent to supplying a
  1755.                      corresponding value to the -P flag on the
  1756.                      command line.
  1757.  
  1758.      PREP            This macro defines the number of iterations
  1759.                      to be expanded automatically when processing
  1760.                      % rule definitions of the form:
  1761.  
  1762.                      % : %.suff
  1763.  
  1764.                      See the sections on PERCENT(%) RULES for
  1765.                      details on how PREP is used.
  1766.  
  1767.      SHELL           This macro defines the full path to the exe-
  1768.                      cutable image to be used as the shell when
  1769.                      processing single line recipes.  This macro
  1770.                      must be defined if recipes requiring the
  1771.                      shell for execution are to be used.  It is
  1772.                      assigned a default value in the startup
  1773.                      makefile.  Under UNIX this value is /bin/sh.
  1774.  
  1775.      SHELLFLAGS      This macro gives the set of flags to pass to
  1776.                      the shell when invoking it to execute a sin-
  1777.                      gle line recipe.  The value of the macro is
  1778.                      the list of flags with a leading switch
  1779.                      indicator.  (ie. `-' under UNIX)
  1780.  
  1781.      SHELLMETAS      Each time dmake executes a single recipe
  1782.                      line (not a group recipe) the line is
  1783.                      searched for any occurrence of a character
  1784.                      defined in the value of SHELLMETAS.  If such
  1785.                      a character is found the recipe line is
  1786.                      defined to require a shell to ensure its
  1787.                      correct execution.  In such instances a
  1788.                      shell is used to invoke the recipe line.  If
  1789.  
  1790.  
  1791.  
  1792. Version 3.70                    UW                             28
  1793.  
  1794.  
  1795.  
  1796.  
  1797. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1798.  
  1799.  
  1800.  
  1801.                      no match is found the recipe line is exe-
  1802.                      cuted without the use of a shell.
  1803.  
  1804.  
  1805.      There is only one character valued macro defined by dmake:
  1806.      SWITCHAR contains the switch character used to introduce
  1807.      options on command lines.  For UNIX its value is '-', and
  1808.      for MSDOS its value may be '/' or '-'.  The macro is inter-
  1809.      nally defined and is not user setable.  The MSDOS version of
  1810.      dmake attempts to first extract SWITCHAR from an environment
  1811.      variable of the same name.  If that fails it then attempts
  1812.      to use the undocumented getswitchar system call, and returns
  1813.      the result of that.  Under MSDOS version 4.0 you must set
  1814.      the value of the environment macro SWITCHAR to '/' to obtain
  1815.      predictable behavior.
  1816.  
  1817.      All boolean macros currently understood by dmake correspond
  1818.      directly to the previously defined attributes.  These macros
  1819.      provide a second way to apply global attributes, and
  1820.      represent the preferred method of doing so.  They are used
  1821.      by assigning them a value.  If the value is not a NULL
  1822.      string then the boolean condition is set to on.  If the
  1823.      value is a NULL string then the condition is set to off.
  1824.      There are five conditions defined and they correspond
  1825.      directly to the attributes of the same name.  Their meanings
  1826.      are defined in the ATTRIBUTES section above.  The macros
  1827.      are: .EPILOG, .IGNORE, .MKSARGS, .NOINFER, .PRECIOUS, .PRO-
  1828.      LOG, .SEQUENTIAL, .SILENT, .SWAP, and .USESHELL.  Assigning
  1829.      any of these a non NULL value will globally set the
  1830.      corresponding attribute to on.
  1831.  
  1832. RUN_TIME MACROS
  1833.      These macros are defined when dmake is making targets, and
  1834.      may take on different values for each target.  $@ is defined
  1835.      to be the full target name, $? is the list of all out of
  1836.      date prerequisites, $& is the list of all prerequisites, $>
  1837.      is the name of the library if the current target is a
  1838.      library member, and $< is the list of prerequisites speci-
  1839.      fied in the current rule.  If the current target had a
  1840.      recipe inferred then $< is the name of the inferred prere-
  1841.      quisite even if the target had a list of prerequisites sup-
  1842.      plied using an explicit rule that did not provide a recipe.
  1843.      In such situations $& gives the full list of prerequisites.
  1844.  
  1845.      $* is defined as $(@:db) when making targets with explicit
  1846.      recipes and is defined as the value of % when making targets
  1847.      whose recipe is the result of an inference.  In the first
  1848.      case $* is the target name with no suffix, and in the second
  1849.      case, is the value of the matched % pattern from the associ-
  1850.      ated %-rule.  $^ expands to the set of out of date prere-
  1851.      quisites taken from the current value of $<.  In addition to
  1852.      these, $$ expands to $, {{ expands to {, }} expands to },
  1853.  
  1854.  
  1855.  
  1856. Version 3.70                    UW                             29
  1857.  
  1858.  
  1859.  
  1860.  
  1861. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1862.  
  1863.  
  1864.  
  1865.      and the strings <+ and +> are recognized as respectively
  1866.      starting and terminating a text diversion when they appear
  1867.      literally together in the same input line.
  1868.  
  1869.      The difference between $? and $^ can best be illustrated by
  1870.      an example, consider:
  1871.  
  1872.           fred.out : joe amy hello
  1873.                rules for making fred
  1874.  
  1875.           fred.out : my.c your.h his.h her.h   # more prerequisites
  1876.  
  1877.      Assume joe, amy, and my.c are newer then fred.out.  When
  1878.      dmake executes the recipe for making fred.out the values of
  1879.      the following macros will be:
  1880.  
  1881.           $@ --> fred.out
  1882.           $* --> fred
  1883.           $? --> joe amy my.c  # note the difference between $? and $^
  1884.           $^ --> joe amy
  1885.           $< --> joe amy hello
  1886.           $& --> joe amy hello my.c your.h his.h her.h
  1887.  
  1888.  
  1889. FUNCTION MACROS
  1890.      dmake supports a full set of functional macros.  One of
  1891.      these, the $(mktmp ...) macro, is discussed in detail in the
  1892.      TEXT DIVERSION section and is not covered here.
  1893.  
  1894.  
  1895.           $(null,text true false)
  1896.                expands the value of text. If it is NULL then the
  1897.                macro returns the value of the expansion of true
  1898.                and the expansion of false otherwise.  The terms
  1899.                true, and false must be strings containing no
  1900.                white-space.
  1901.  
  1902.           $(!null,text true false)
  1903.                Behaves identically to the previous macro except
  1904.                that the true string is chosen if the expansion of
  1905.                text is not NULL.
  1906.  
  1907.           $(eq,text_a,text_b true false)
  1908.                expands text_a and text_b and compares their
  1909.                results.  If equal it returns the result of the
  1910.                expansion of the true term, otherwise it returns
  1911.                the expansion of the false term.
  1912.  
  1913.           $(!eq,text_a,text_b true false)
  1914.                Behaves identically to the previous macro except
  1915.                that the true string is chosen if the expansions
  1916.                of the two strings are not equal
  1917.  
  1918.  
  1919.  
  1920. Version 3.70                    UW                             30
  1921.  
  1922.  
  1923.  
  1924.  
  1925. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1926.  
  1927.  
  1928.  
  1929.           $(shell command)
  1930.                Runs command as if it were part of a recipe and
  1931.                returns, separated by a single space, all the
  1932.                non-white space terms written to stdout by the
  1933.                command.  For example:
  1934.  
  1935.                     $(shell ls *.c)
  1936.  
  1937.                will return "a.c b.c c.c d.c" if the files exist
  1938.                in the current directory.  The recipe modification
  1939.                flags [+@%-] are honored if they appear as the
  1940.                first characters in the command.  For example:
  1941.  
  1942.                     $(shell +ls *.c)
  1943.  
  1944.                will run the command using the current shell.
  1945.  
  1946.           $(sort list)
  1947.                Will take all white-space separated tokens in list
  1948.                and will return their sorted equivalent list.
  1949.  
  1950.           $(strip data)
  1951.                Will replace all strings of white-space in data by
  1952.                a single space.
  1953.  
  1954.           $(subst,pat,replacement data)
  1955.                Will search for pat in data and will replace any
  1956.                occurrence of pat with the replacement string.
  1957.                The expansion
  1958.  
  1959.                     $(subst,.o,.c $(OBJECTS))
  1960.  
  1961.                is equivalent to:
  1962.  
  1963.                     $(OBJECTS:s/.o/.c/)
  1964.  
  1965.  
  1966. DYNAMIC PREREQUISITES
  1967.      dmake looks for prerequisites whose names contain macro
  1968.      expansions during target processing.  Any such prerequisites
  1969.      are expanded and the result of the expansion is used as the
  1970.      prerequisite name.  As an example the line:
  1971.  
  1972.           fred : $$@.c
  1973.  
  1974.      causes the $$@ to be expanded when dmake is making fred, and
  1975.      it resolves to the target fred.  This enables dynamic prere-
  1976.      quisites to be generated.  The value of @ may be modified by
  1977.      any of the valid macro modifiers.  So you can say for exam-
  1978.      ple:
  1979.  
  1980.           fred.out : $$(@:b).c
  1981.  
  1982.  
  1983.  
  1984. Version 3.70                    UW                             31
  1985.  
  1986.  
  1987.  
  1988.  
  1989. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1990.  
  1991.  
  1992.  
  1993.      where the $$(@:b) expands to fred.  Note the use of $$
  1994.      instead of $ to indicate the dynamic expansion, this is due
  1995.      to the fact that the rule line is expanded when it is ini-
  1996.      tially parsed, and $$ then returns $ which later triggers
  1997.      the dynamic prerequisite expansion.  If you really want a $
  1998.      to be part of a prerequisite name you must use $$$$.
  1999.      Dynamic macro expansion is performed in all user defined
  2000.      rules, and the special targets .SOURCE*, and .INCLUDEDIRS.
  2001.  
  2002. BINDING TARGETS
  2003.      This operation takes a target name and binds it to an exist-
  2004.      ing file, if possible.  dmake makes a distinction between
  2005.      the internal target name of a target and its associated
  2006.      external file name.  Thus it is possible for a target's
  2007.      internal name and its external file name to differ.  To per-
  2008.      form the binding, the following set of rules is used.
  2009.      Assume that we are trying to bind a target whose name is of
  2010.      the form X.suff, where .suff is the suffix and X is the stem
  2011.      portion (ie. that part which contains the directory and the
  2012.      basename).  dmake takes this target name and performs a
  2013.      series of search operations that try to find a suitably
  2014.      named file in the external file system.  The search opera-
  2015.      tion is user controlled via the settings of the various
  2016.      .SOURCE targets.
  2017.  
  2018.           1.   If target has the .SYMBOL attribute set then look
  2019.                for it in the library.  If found, replace the tar-
  2020.                get name with the library member name and continue
  2021.                with step 2.  If the name is not found then
  2022.                return.
  2023.  
  2024.           2.   Extract the suffix portion (that following the
  2025.                `.') of the target name.  If the suffix is not
  2026.                null, look up the special target .SOURCE.<suff>
  2027.                (<suff> is the suffix). If the special target
  2028.                exists then search each directory given in the
  2029.                .SOURCE.<suff> prerequisite list for the target.
  2030.                If the target's suffix was null (ie. .suff was
  2031.                empty) then perform the above search but use the
  2032.                special target .SOURCE.NULL instead.  If at any
  2033.                point a match is found then terminate the search.
  2034.                If a directory in the prerequisite list is the
  2035.                special name `.NULL ' perform a search for the
  2036.                full target name without prepending any directory
  2037.                portion (ie. prepend the NULL directory).  (a
  2038.                default target of '.SOURCE : .NULL' is defined by
  2039.                dmake at startup, and is user redefinable)
  2040.  
  2041.           3.   The search in step 2. failed.  Repeat the same
  2042.                search but this time use the special target
  2043.                .SOURCE.
  2044.  
  2045.  
  2046.  
  2047.  
  2048. Version 3.70                    UW                             32
  2049.  
  2050.  
  2051.  
  2052.  
  2053. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  2054.  
  2055.  
  2056.  
  2057.           4.   The search in step 3. failed.  If the target has
  2058.                the library member attribute (.LIBMEMBER) set then
  2059.                try to find the target in the library which was
  2060.                passed along with the .LIBMEMBER attribute (see
  2061.                the MAKING LIBRARIES section).  The bound file
  2062.                name assigned to a target which is successfully
  2063.                located in a library is the same name that would
  2064.                be assigned had the search failed (see 5.).
  2065.  
  2066.           5.   The search failed.  Either the target was not
  2067.                found in any of the search directories or no
  2068.                applicable .SOURCE special targets exist.  If
  2069.                applicable .SOURCE special targets exist, but the
  2070.                target was not found, then dmake assigns the first
  2071.                name searched as the bound file name.  If no
  2072.                applicable .SOURCE special targets exist, then the
  2073.                full original target name becomes the bound file
  2074.                name.
  2075.  
  2076.      There is potential here for a lot of search operations.  The
  2077.      trick is to define .SOURCE.x special targets with short
  2078.      search lists and leave .SOURCE as short as possible.  The
  2079.      search algorithm has the following useful side effect.  When
  2080.      a target having the .LIBMEMBER (library member) attribute is
  2081.      searched for, it is first searched for as an ordinary file.
  2082.      When a number of library members require updating it is
  2083.      desirable to compile all of them first and to update the
  2084.      library at the end in a single operation.  If one of the
  2085.      members does not compile and dmake stops, then the user may
  2086.      fix the error and make again.  dmake will not remake any of
  2087.      the targets whose object files have already been generated
  2088.      as long as none of their prerequisite files have been modi-
  2089.      fied as a result of the fix.
  2090.  
  2091.      When defining .SOURCE and .SOURCE.x targets the construct
  2092.  
  2093.           .SOURCE :
  2094.           .SOURCE : fred gery
  2095.  
  2096.      is equivalent to
  2097.  
  2098.           .SOURCE :- fred gery
  2099.  
  2100.      dmake correctly handles the UNIX Make variable VPATH.  By
  2101.      definition VPATH contains a list of ':' separated direc-
  2102.      tories to search when looking for a target.  dmake maps
  2103.      VPATH to the following special rule:
  2104.  
  2105.           .SOURCE :^ $(VPATH:s/:/ /)
  2106.  
  2107.      Which takes the value of VPATH and sets .SOURCE to the same
  2108.      set of directories as specified in VPATH.
  2109.  
  2110.  
  2111.  
  2112. Version 3.70                    UW                             33
  2113.  
  2114.  
  2115.  
  2116.  
  2117. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  2118.  
  2119.  
  2120.  
  2121. PERCENT(%) RULES AND MAKING INFERENCES
  2122.      When dmake makes a target, the target's set of prerequisites
  2123.      (if any) must exist and the target must have a recipe which
  2124.      dmake can use to make it.  If the makefile does not specify
  2125.      an explicit recipe for the target then dmake uses special
  2126.      rules to try to infer a recipe which it can use to make the
  2127.      target.  Previous versions of Make perform this task by
  2128.      using rules that are defined by targets of the form
  2129.      .<suffix>.<suffix> and by using the .SUFFIXES list of suf-
  2130.      fixes.  The exact workings of this mechanism were sometimes
  2131.      difficult to understand and often limiting in their useful-
  2132.      ness.  Instead, dmake supports the concept of %-meta rules.
  2133.      The syntax and semantics of these rules differ from standard
  2134.      rule lines as follows:
  2135.  
  2136.           <%-target> [<attributes>] <ruleop> [<%-prerequisites>] [;<recipe>]
  2137.  
  2138.      where %-target is a target containing exactly a single `%'
  2139.      sign, attributes is a list (possibly empty) of attributes,
  2140.      ruleop is the standard set of rule operators, %-prere-
  2141.      quisites , if present, is a list of prerequisites containing
  2142.      zero or more `%' signs, and recipe, if present, is the first
  2143.      line of the recipe.
  2144.  
  2145.      The %-target defines a pattern against which a target whose
  2146.      recipe is being inferred gets matched.  The pattern match
  2147.      goes as follows:  all chars are matched exactly from left to
  2148.      right up to but not including the % sign in the pattern, %
  2149.      then matches the longest string from the actual target name
  2150.      not ending in the suffix given after the % sign in the pat-
  2151.      tern.  Consider the following examples:
  2152.  
  2153.           %.c       matches fred.c but not joe.c.Z
  2154.           dir/%.c   matches dir/fred.c but not dd/fred.c
  2155.           fred/%    matches fred/joe.c but not f/joe.c
  2156.           %         matches anything
  2157.  
  2158.      In each case the part of the target name that matched the %
  2159.      sign is retained and is substituted for any % signs in the
  2160.      prerequisite list of the %-meta rule when the rule is
  2161.      selected during inference and dmake constructs the new
  2162.      dependency.  As an example the following %-meta rules
  2163.      describe the following:
  2164.  
  2165.           %.c : %.y ; recipe...
  2166.  
  2167.      describes how to make any file ending in .c if a correspond-
  2168.      ing file ending in .y can be found.
  2169.  
  2170.           foo%.o : fee%.k ; recipe...
  2171.  
  2172.      is used to describe how to make fooxxxx.o from feexxxx.k.
  2173.  
  2174.  
  2175.  
  2176. Version 3.70                    UW                             34
  2177.  
  2178.  
  2179.  
  2180.  
  2181. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  2182.  
  2183.  
  2184.  
  2185.           %.a :; recipe...
  2186.  
  2187.      describes how to make a file whose suffix is .a without
  2188.      inferring any prerequisites.
  2189.  
  2190.           %.c : %.y yaccsrc/%.y ; recipe...
  2191.  
  2192.      is a short form for the construct:
  2193.  
  2194.           %.c : %.y ; recipe...
  2195.           %.c : yaccsrc/%.y ; recipe...
  2196.  
  2197.      ie. It is possible to specify the same recipe for two
  2198.      %-rules by giving more than one prerequisite in the prere-
  2199.      quisite list.  A more interesting example is:
  2200.  
  2201.           % : RCS/%,v ; co $@
  2202.  
  2203.      which describes how to take any target and check it out of
  2204.      the RCS directory if the corresponding file exists in the
  2205.      RCS directory.  The equivalent SCCS rule would be:
  2206.  
  2207.           % : s.% ; get $@
  2208.  
  2209.  
  2210.      The previous RCS example defines an infinite rule, because
  2211.      it says how to make anything from RCS/%,v, and anything also
  2212.      includes RCS/fred.c,v.  To limit the size of the graph that
  2213.      results from such rules dmake uses the macro variable PREP
  2214.      (stands for % repetition).  By default the value of this
  2215.      variable is 0, which says that no repetitions of a %-rule
  2216.      are to be generated.  If it is set to something greater than
  2217.      0, then that many repetitions of any infinite %-rule are
  2218.      allowed.  If in the above example PREP was set to 1, then
  2219.      dmake would generate the dependency graph:
  2220.  
  2221.           % --> RCS/%,v --> RCS/RCS/%,v,v
  2222.  
  2223.      Where each link is assigned the same recipe as the first
  2224.      link.  PREP should be used only in special cases, since it
  2225.      may result in a large increase in the number of possible
  2226.      prerequisites tested.  dmake further assumes that any target
  2227.      that has no suffix can be made from a prerequisite that has
  2228.      at least one suffix.
  2229.  
  2230.      dmake supports dynamic prerequisite generation for prere-
  2231.      quisites of %-meta rules.  This is best illustrated by an
  2232.      example.  The RCS rule shown above can infer how to check
  2233.      out a file from a corresponding RCS file only if the target
  2234.      is a simple file name with no directory information.  That
  2235.      is, the above rule can infer how to find RCS/fred.c,v from
  2236.      the target fred.c, but cannot infer how to find
  2237.  
  2238.  
  2239.  
  2240. Version 3.70                    UW                             35
  2241.  
  2242.  
  2243.  
  2244.  
  2245. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  2246.  
  2247.  
  2248.  
  2249.      srcdir/RCS/fred.c,v from srcdir/fred.c because the above
  2250.      rule will cause dmake to look for RCS/srcdir/fred.c,v; which
  2251.      does not exist (assume that srcdir has its own RCS directory
  2252.      as is the common case).
  2253.  
  2254.      A more versatile formulation of the above RCS check out rule
  2255.      is the following:
  2256.  
  2257.           % :  $$(@:d)RCS/$$(@:f),v : co $@
  2258.  
  2259.      This rule uses the dynamic macro $@ to specify the prere-
  2260.      quisite to try to infer.  During inference of this rule the
  2261.      macro $@ is set to the value of the target of the %-meta
  2262.      rule and the appropriate prerequisite is generated by
  2263.      extracting the directory portion of the target name (if
  2264.      any), appending the string RCS/ to it, and appending the
  2265.      target file name with a trailing ,v attached to the previous
  2266.      result.
  2267.  
  2268.      dmake can also infer indirect prerequisites.  An inferred
  2269.      target can have a list of prerequisites added that will not
  2270.      show up in the value of $< but will show up in the value of
  2271.      $? and $&.  Indirect prerequisites are specified in an
  2272.      inference rule by quoting the prerequisite with single
  2273.      quotes.  For example, if you had the explicit dependency:
  2274.  
  2275.           fred.o : fred.c ; rule to make fred.o
  2276.           fred.o : local.h
  2277.  
  2278.      then this can be inferred for fred.o from the following
  2279.      inference rule:
  2280.  
  2281.           %.o : %.c 'local.h' ; rule to make a .o from a .c
  2282.  
  2283.      You may infer indirect prerequisites that are a function of
  2284.      the value of '%' in the current rule.  The meta-rule:
  2285.  
  2286.           %.o : %.c '$(INC)/%.h' ; rule to make a .o from a .c
  2287.  
  2288.      infers an indirect prerequisite found in the INC directory
  2289.      whose name is the same as the expansion of $(INC), and the
  2290.      prerequisite name depends on the base name of the current
  2291.      target.  The set of indirect prerequisites is attached to
  2292.      the meta rule in which they are specified and are inferred
  2293.      only if the rule is used to infer a recipe for a target.
  2294.      They do not play an active role in driving the inference
  2295.      algorithm.  The construct:
  2296.  
  2297.           %.o : %.c %.f 'local.h'; recipe
  2298.  
  2299.      is equivalent to:
  2300.  
  2301.  
  2302.  
  2303.  
  2304. Version 3.70                    UW                             36
  2305.  
  2306.  
  2307.  
  2308.  
  2309. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  2310.  
  2311.  
  2312.  
  2313.           %.o : %.c 'local.h' : recipe
  2314.           %.o : %.f 'local.h' : recipe
  2315.  
  2316.  
  2317.      If any of the attributes .SETDIR, .EPILOG, .PROLOG, .SILENT,
  2318.      .USESHELL, .SWAP, .PRECIOUS, .LIBRARY, .NOSTATE and .IGNORE
  2319.      are given for a %-rule then when that rule is bound to a
  2320.      target as the result of an inference, the target's set of
  2321.      attributes is augmented by the attributes from the above set
  2322.      that are specified in the bound %-rule.  Other attributes
  2323.      specified for %-meta rules are not inherited by the target.
  2324.      The .SETDIR attribute is treated in a special way.  If the
  2325.      target already had a .SETDIR attribute set then dmake
  2326.      changes to that directory prior to performing the inference.
  2327.      During inference any .SETDIR attributes for the inferred
  2328.      prerequisite are honored.  The directories must exist for a
  2329.      %-meta rule to be selected as a possible inference path.  If
  2330.      the directories do not exist no error message is issued,
  2331.      instead the corresponding path in the inference graph is
  2332.      rejected.
  2333.  
  2334.      dmake also supports the old format special target
  2335.      .<suffix>.<suffix> by identifying any rules of this form and
  2336.      mapping them to the appropriate %-rule.  So for example if
  2337.      an old makefile contains the construct:
  2338.  
  2339.           .c.o :; cc -c $< -o $@
  2340.  
  2341.      dmake maps this into the following %-rule:
  2342.  
  2343.           %.o : %.c; cc -c $< -o $@
  2344.  
  2345.      Furthermore, dmake understands several SYSV AUGMAKE special
  2346.      targets and maps them into corresponding %-meta rules.
  2347.      These transformation must be enabled by providing the -A
  2348.      flag on the command line or by setting the value of AUGMAKE
  2349.      to non-NULL.  The construct
  2350.  
  2351.           .suff :; recipe
  2352.  
  2353.      gets mapped into:
  2354.  
  2355.           % : %.suff; recipe
  2356.  
  2357.      and the construct
  2358.  
  2359.           .c~.o :; recipe
  2360.  
  2361.      gets mapped into:
  2362.  
  2363.           %.o : s.%.c ; recipe
  2364.  
  2365.  
  2366.  
  2367.  
  2368. Version 3.70                    UW                             37
  2369.  
  2370.  
  2371.  
  2372.  
  2373. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  2374.  
  2375.  
  2376.  
  2377.      In general, a special target of the form .<str>~ is replaced
  2378.      by the %-rule construct s.%.<str>, thereby providing support
  2379.      for the syntax used by SYSV AUGMAKE for providing SCCS sup-
  2380.      port.  When enabled, these mappings allow processing of
  2381.      existing SYSV makefiles without modifications.
  2382.  
  2383.      dmake bases all of its inferences on the inference graph
  2384.      constructed from the %-rules defined in the makefile.  It
  2385.      knows exactly which targets can be made from which prere-
  2386.      quisites by making queries on the inference graph.  For this
  2387.      reason .SUFFIXES is not needed and is completely ignored.
  2388.  
  2389.      For a %-meta rule to be inferred as the rule whose recipe
  2390.      will be used to make a target, the target's name must match
  2391.      the %-target pattern, and any inferred %-prerequisite must
  2392.      already exist or have an explicit recipe so that the prere-
  2393.      quisite can be made.  Without transitive closure on the
  2394.      inference graph the above rule describes precisely when an
  2395.      inference match terminates the search.  If transitive clo-
  2396.      sure is enabled (the usual case), and a prerequisite does
  2397.      not exist or cannot be made, then dmake invokes the infer-
  2398.      ence algorithm recursively on the prerequisite to see if
  2399.      there is some way the prerequisite can be manufactured.
  2400.      For, if the prerequisite can be made then the current target
  2401.      can also be made using the current %-meta rule.  This means
  2402.      that there is no longer a need to give a rule for making a
  2403.      .o from a .y if you have already given a rule for making a
  2404.      .o from a .c and a .c from a .y.  In such cases dmake can
  2405.      infer how to make the .o from the .y via the intermediary .c
  2406.      and will remove the .c when the .o is made.  Transitive clo-
  2407.      sure can be disabled by giving the -T switch on the command
  2408.      line.
  2409.  
  2410.      A word of caution.  dmake bases its transitive closure on
  2411.      the %-meta rule targets.  When it performs transitive clo-
  2412.      sure it infers how to make a target from a prerequisite by
  2413.      performing a pattern match as if the potential prerequisite
  2414.      were a new target.  The set of rules:
  2415.  
  2416.           %.o : %.c :; rule for making .o from .c
  2417.           %.c : %.y :; rule for making .c from .y
  2418.           % : RCS/%,v :; check out of RCS file
  2419.  
  2420.      will, by performing transitive closure, allow dmake to infer
  2421.      how to make a .o from a .y using a .c as an intermediate
  2422.      temporary file.  Additionally it will be able to infer how
  2423.      to make a .y from an RCS file, as long as that RCS file is
  2424.      in the RCS directory and has a name which ends in .y,v.  The
  2425.      transitivity computation is performed dynamically for each
  2426.      target that does not have a recipe.  This has potential to
  2427.      be costly if the %-meta rules are not carefully specified.
  2428.      The .NOINFER attribute is used to mark a %-meta node as
  2429.  
  2430.  
  2431.  
  2432. Version 3.70                    UW                             38
  2433.  
  2434.  
  2435.  
  2436.  
  2437. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  2438.  
  2439.  
  2440.  
  2441.      being a final target during inference.  Any node with this
  2442.      attribute set will not be used for subsequent inferences.
  2443.      As an example the node RCS/%,v is marked as a final node
  2444.      since we know that if the RCS file does not exist there
  2445.      likely is no other way to make it.  Thus the standard
  2446.      startup makefile contains an entry similar to:
  2447.           .NOINFER : RCS/%,v
  2448.      Thereby indicating that the RCS file is the end of the
  2449.      inference chain.
  2450.  
  2451.      Whenever the inference algorithm determines that a target
  2452.      can be made from more than one prerequisite and the infer-
  2453.      ence chains for the two methods are the same length the
  2454.      algorithm reports an ambiguity and prints the ambiguous
  2455.      inference chains.
  2456.  
  2457.      dmake tries to remove intermediate files resulting from
  2458.      transitive closure if the file is not marked as being PRE-
  2459.      CIOUS, or the -u flag was not given on the command line, and
  2460.      if the inferred intermediate did not previously exist.
  2461.      Intermediate targets that existed prior to being made are
  2462.      never removed.  This is in keeping with the philosophy that
  2463.      dmake should never remove things from the file system that
  2464.      it did not add.  If the special target .REMOVE is defined
  2465.      and has a recipe then dmake constructs a list of the inter-
  2466.      mediate files to be removed and makes them prerequisites of
  2467.      .REMOVE.  It then makes .REMOVE thereby removing the prere-
  2468.      quisites if the recipe of .REMOVE says to.  Typically
  2469.      .REMOVE is defined in the startup file as:
  2470.  
  2471.           .REMOVE :; $(RM) $<
  2472.  
  2473. MAKING TARGETS
  2474.      In order to update a target dmake must execute a recipe.
  2475.      When a recipe needs to be executed it is first expanded so
  2476.      that any macros in the recipe text are expanded, and it is
  2477.      then either executed directly or passed to a shell.  dmake
  2478.      supports two types of recipes.  The regular recipes and
  2479.      group recipes.
  2480.  
  2481.      When a regular recipe is invoked dmake executes each line of
  2482.      the recipe separately using a new copy of a shell if a shell
  2483.      is required.  Thus effects of commands do not generally per-
  2484.      sist across recipe lines.  (e.g. cd requests in a recipe
  2485.      line do not carry over to the next recipe line) The decision
  2486.      on whether a shell is required to execute a command is based
  2487.      on the value of the macro SHELLMETAS or on the specification
  2488.      of '+' or .USESHELL for the current recipe or target respec-
  2489.      tively.  If any character in the value of SHELLMETAS is
  2490.      found in the expanded recipe text-line or the use of a shell
  2491.      is requested explicitly via '+' or .USESHELL then the com-
  2492.      mand is executed using a shell, otherwise the command is
  2493.  
  2494.  
  2495.  
  2496. Version 3.70                    UW                             39
  2497.  
  2498.  
  2499.  
  2500.  
  2501. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  2502.  
  2503.  
  2504.  
  2505.      executed directly.  The shell that is used for execution is
  2506.      given by the value of the macro SHELL.  The flags that are
  2507.      passed to the shell are given by the value of SHELLFLAGS.
  2508.      Thus dmake constructs the command line:
  2509.  
  2510.           $(SHELL) $(SHELLFLAGS) $(expanded_recipe_command)
  2511.  
  2512.      Normally dmake writes the command line that it is about to
  2513.      invoke to standard output.  If the .SILENT attribute is set
  2514.      for the target or for the recipe line (via @), then the
  2515.      recipe line is not echoed.
  2516.  
  2517.      Group recipe processing is similar to that of regular
  2518.      recipes, except that a shell is always invoked.  The shell
  2519.      that is invoked is given by the value of the macro GROUP-
  2520.      SHELL, and its flags are taken from the value of the macro
  2521.      GROUPFLAGS.  If a target has the .PROLOG attribute set then
  2522.      dmake prepends to the shell script the recipe associated
  2523.      with the special target .GROUPPROLOG, and if the attribute
  2524.      .EPILOG is set as well, then the recipe associated with the
  2525.      special target .GROUPEPILOG is appended to the script file.
  2526.      This facility can be used to always prepend a common header
  2527.      and common trailer to group recipes.  Group recipes are
  2528.      echoed to standard output just like standard recipes, but
  2529.      are enclosed by lines beginning with [ and ].
  2530.  
  2531.      The recipe flags [+,-,%,@] are recognized at the start of a
  2532.      recipe line even if they appear in a macro.  For example:
  2533.  
  2534.           SH = +
  2535.           all:
  2536.                $(SH)echo hi
  2537.  
  2538.      is completely equivalent to writing
  2539.  
  2540.           SH = +
  2541.           all:
  2542.                +echo hi
  2543.  
  2544.  
  2545.      The last step performed by dmake prior to running a recipe
  2546.      is to set the macro CMNDNAME to the name of the command to
  2547.      execute (determined by finding the first white-space ending
  2548.      token in the command line).  It then sets the macro CMNDARGS
  2549.      to be the remainder of the line.  dmake then expands the
  2550.      macro COMMAND which by default is set to
  2551.  
  2552.           COMMAND = $(CMNDNAME) $(CMNDARGS)
  2553.  
  2554.      The result of this final expansion is the command that will
  2555.      be executed.  The reason for this expansion is to allow for
  2556.      a different interface to the argument passing facilities
  2557.  
  2558.  
  2559.  
  2560. Version 3.70                    UW                             40
  2561.  
  2562.  
  2563.  
  2564.  
  2565. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  2566.  
  2567.  
  2568.  
  2569.      (esp. under DOS) than that provided by dmake. You can for
  2570.      example define COMMAND to be
  2571.  
  2572.           COMMAND = $(CMNDNAME) @$(mktmp $(CMNDARGS))
  2573.  
  2574.      which dumps the arguments into a temporary file and runs the
  2575.      command
  2576.  
  2577.           $(CMNDNAME) @/tmp/ASAD23043
  2578.  
  2579.      which has a much shorter argument list.  It is now up to the
  2580.      command to use the supplied argument as the source for all
  2581.      other arguments.  As an optimization, if COMMAND is not
  2582.      defined dmake does not perform the above expansion.  On sys-
  2583.      tems, such as UNIX, that handle long command lines this pro-
  2584.      vides a slight saving in processing the makefiles.
  2585.  
  2586. MAKING LIBRARIES
  2587.      Libraries are easy to maintain using dmake.  A library is a
  2588.      file containing a collection of object files.  Thus to make
  2589.      a library you simply specify it as a target with the
  2590.      .LIBRARY attribute set and specify its list of prere-
  2591.      quisites.  The prerequisites should be the object members
  2592.      that are to go into the library.  When dmake makes the
  2593.      library target it uses the .LIBRARY attribute to pass to the
  2594.      prerequisites the .LIBMEMBER attribute and the name of the
  2595.      library.  This enables the file binding mechanism to look
  2596.      for the member in the library if an appropriate object file
  2597.      cannot be found. A small example best illustrates this.
  2598.  
  2599.           mylib.a .LIBRARY : mem1.o mem2.o mem3.o
  2600.                rules for making library...
  2601.                # remember to remove .o's when lib is made
  2602.  
  2603.           # equivalent to:  '%.o : %.c ; ...'
  2604.           .c.o :; rules for making .o from .c say
  2605.  
  2606.      dmake will use the .c.o rule for making the library members
  2607.      if appropriate .c files can be found using the search rules.
  2608.      NOTE:  this is not specific in any way to C programs, they
  2609.      are simply used as an example.
  2610.  
  2611.      dmake tries to handle the old library construct format in a
  2612.      sensible way.  The construct lib(member.o) is separated and
  2613.      the lib portion is declared as a library target.  The new
  2614.      target is defined with the .LIBRARY attribute set and the
  2615.      member.o portion of the construct is declared as a prere-
  2616.      quisite of the lib target.  If the construct lib(member.o)
  2617.      appears as a prerequisite of a target in the makefile, that
  2618.      target has the new name of the lib assigned as its prere-
  2619.      quisite.  Thus the following example:
  2620.  
  2621.  
  2622.  
  2623.  
  2624. Version 3.70                    UW                             41
  2625.  
  2626.  
  2627.  
  2628.  
  2629. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  2630.  
  2631.  
  2632.  
  2633.           a.out : ml.a(a.o) ml.a(b.o); $(CC) -o $@  $<
  2634.  
  2635.           .c.o :; $(CC) -c $(CFLAGS) -o $@  $<
  2636.           %.a:
  2637.                ar rv $@ $<
  2638.                ranlib $@
  2639.                rm -rf $<
  2640.  
  2641.      constructs the following dependency graph.
  2642.  
  2643.           a.out : ml.a; $(CC) -o $@  $<
  2644.           ml.a .LIBRARY : a.o b.o
  2645.  
  2646.           %.o : %.c ; $(CC) -c $(CFLAGS) -o $@  $<
  2647.           %.a :
  2648.                ar rv $@ $<
  2649.                ranlib $@
  2650.                rm -rf $<
  2651.  
  2652.      and making a.out then works as expected.
  2653.  
  2654.      The same thing happens for any target of the form
  2655.      lib((entry)).  These targets have an additional feature in
  2656.      that the entry target has the .SYMBOL attribute set automat-
  2657.      ically.
  2658.  
  2659.      NOTE:  If the notion of entry points is supported by the
  2660.      archive and by dmake (currently not the case) then dmake
  2661.      will search the archive for the entry point and return not
  2662.      only the modification time of the member which defines the
  2663.      entry but also the name of the member file.  This name will
  2664.      then replace entry and will be used for making the member
  2665.      file.  Once bound to an archive member the .SYMBOL attribute
  2666.      is removed from the target.  This feature is presently dis-
  2667.      abled as there is little standardization among archive for-
  2668.      mats, and we have yet to find a makefile utilizing this
  2669.      feature (possibly due to the fact that it is unimplemented
  2670.      in most versions of UNIX Make).
  2671.  
  2672.      Finally, when dmake looks for a library member it must first
  2673.      locate the library file.  It does so by first looking for
  2674.      the library relative to the current directory and if it is
  2675.      not found it then looks relative to the current value of
  2676.      $(TMD).  This allows commonly used libraries to be kept near
  2677.      the root of a source tree and to be easily found by dmake.
  2678.  
  2679. KEEP STATE
  2680.      dmake supports the keeping of state information for targets
  2681.      that it makes whenever the macro .KEEP_STATE is assigned a
  2682.      value.  The value of the macro should be the name of a state
  2683.      file that will contain the state information.  If state
  2684.      keeping is enabled then each target that does not poses the
  2685.  
  2686.  
  2687.  
  2688. Version 3.70                    UW                             42
  2689.  
  2690.  
  2691.  
  2692.  
  2693. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  2694.  
  2695.  
  2696.  
  2697.      .NOSTATE attribute will have a record written into the state
  2698.      file indicating the target's name, the current directory,
  2699.      the command used to update the target, and which, if any, ::
  2700.      rule is being used.  When you make this target again if any
  2701.      of this information does not match the previous settings and
  2702.      the target is not out dated it will still be re-made.  The
  2703.      assumption is that one of the conditions above has changed
  2704.      and that we wish to remake the target.  For example, state
  2705.      keeping is used in the maintenance of dmake to test compile
  2706.      different versions of the source using different compilers.
  2707.      Changing the compiler causes the compilation flags to be
  2708.      modified and hence all sources to be recompiled.
  2709.  
  2710.      The state file is an ascii file and is portable, however it
  2711.      is not in human readable form as the entries represent hash
  2712.      keys of the above information.
  2713.  
  2714.      The Sun Microsystem's Make construct
  2715.  
  2716.           .KEEP_STATE :
  2717.  
  2718.      is recognized and is mapped to .KEEP_STATE:=_state.mk.  The
  2719.      dmake version of state keeping does not include scanning C
  2720.      source files for dependencies like Sun Make.  This is
  2721.      specific to C programs and it was felt that it does not
  2722.      belong in make.  dmake instead provides the tool, cdepend,
  2723.      to scan C source files and to produce depedency information.
  2724.      Users are free to modify cdepend to produce other dependency
  2725.      files.  (NOTE: cdepend does not come with the distribution
  2726.      at this time, but will be available in a patch in the near
  2727.      future)
  2728.  
  2729. MULTI PROCESSING
  2730.      If the architecture supports it then dmake is capable of
  2731.      making a target's prerequisites in parallel.  dmake will
  2732.      make as much in parallel as it can and use a number of child
  2733.      processes up to the maximum specified by MAXPROCESS or by
  2734.      the value supplied to the -P command line flag.  A parallel
  2735.      make is enabled by setting the value of MAXPROCESS (either
  2736.      directly or via -P option) to a value which is > 1.  dmake
  2737.      guarantees that all dependencies as specified in the
  2738.      makefile are honored.  A target will not be made until all
  2739.      of its prerequisites have been made.  If a parallel make is
  2740.      being performed then the following restrictions on parallel-
  2741.      ism are enforced.
  2742.  
  2743.           1.   Individual recipe lines in a non-group recipe are
  2744.                performed sequentially in the order in which they
  2745.                are specified within the makefile and in parallel
  2746.                with the recipes of other targets.
  2747.  
  2748.  
  2749.  
  2750.  
  2751.  
  2752. Version 3.70                    UW                             43
  2753.  
  2754.  
  2755.  
  2756.  
  2757. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  2758.  
  2759.  
  2760.  
  2761.           2.   If a target contains multiple recipe definitions
  2762.                (cf. :: rules) then these are performed sequen-
  2763.                tially in the order in which the :: rules are
  2764.                specified within the makefile and in parallel with
  2765.                the recipes of other targets.
  2766.  
  2767.           3.   If a target rule contains the `!' modifier, then
  2768.                the recipe is performed sequentially for the list
  2769.                of outdated prerequisites and in parallel with the
  2770.                recipes of other targets.
  2771.  
  2772.           4.   If a target has the .SEQUENTIAL attribute set then
  2773.                all of its prerequisites are made sequentially
  2774.                relative to one another (as if MAXPROCESS=1), but
  2775.                in parallel with other targets in the makefile.
  2776.  
  2777.      Note:  If you specify a parallel make then the order of tar-
  2778.      get update and the order in which the associated recipes are
  2779.      invoked will not correspond to that displayed by the -n
  2780.      flag.
  2781.  
  2782. CONDITIONALS
  2783.      dmake supports a makefile construct called a conditional.
  2784.      It allows the user to conditionally select portions of
  2785.      makefile text for input processing and to discard other por-
  2786.      tions.  This becomes useful for writing makefiles that are
  2787.      intended to function for more than one target host and
  2788.      environment.  The conditional expression is specified as
  2789.      follows:
  2790.  
  2791.           .IF  expression
  2792.              ... if text ...
  2793.           .ELIF  expression
  2794.              ... if text ...
  2795.           .ELSE
  2796.              ... else text ...
  2797.           .END
  2798.  
  2799.      The .ELSE and .ELIF portions are optional, and the condi-
  2800.      tionals may be nested (ie.  the text may contain another
  2801.      conditional).  .IF, .ELSE, and .END may appear anywhere in
  2802.      the makefile, but a single conditional expression may not
  2803.      span multiple makefiles.
  2804.  
  2805.      expression can be one of the following three forms:
  2806.  
  2807.           <text> | <text> == <text> | <text> != <text>
  2808.  
  2809.      where text is either text or a macro expression.  In any
  2810.      case, before the comparison is made, the expression is
  2811.      expanded.  The text portions are then selected and compared.
  2812.      White space at the start and end of the text portion is
  2813.  
  2814.  
  2815.  
  2816. Version 3.70                    UW                             44
  2817.  
  2818.  
  2819.  
  2820.  
  2821. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  2822.  
  2823.  
  2824.  
  2825.      discarded before the comparison.  This means that a macro
  2826.      that evaluates to nothing but white space is considered a
  2827.      NULL value for the purpose of the comparison.  In the first
  2828.      case the expression evaluates TRUE if the text is not NULL
  2829.      otherwise it evaluates FALSE.  The remaining two cases both
  2830.      evaluate the expression on the basis of a string comparison.
  2831.      If a macro expression needs to be equated to a NULL string
  2832.      then compare it to the value of the macro $(NULL).  You can
  2833.      use the $(shell ...) macro to construct more complex test
  2834.      expressions.
  2835.  
  2836. EXAMPLES
  2837.           # A simple example showing how to use make
  2838.           #
  2839.           prgm : a.o b.o
  2840.                cc a.o b.o -o prgm
  2841.           a.o : a.c g.h
  2842.                cc a.c -o $@
  2843.           b.o : b.c g.h
  2844.                cc b.c -o $@
  2845.  
  2846.      In the previous example prgm is remade only if a.o and/or
  2847.      b.o is out of date with respect to prgm.  These dependencies
  2848.      can be stated more concisely by using the inference rules
  2849.      defined in the standard startup file.  The default rule for
  2850.      making .o's from .c's looks something like this:
  2851.  
  2852.           %.o : %.c; cc -c $(CFLAGS) -o $@ $<
  2853.  
  2854.      Since there exists a rule (defined in the startup file) for
  2855.      making .o's from .c's dmake will use that rule for manufac-
  2856.      turing a .o from a .c and we can specify our dependencies
  2857.      more concisely.
  2858.  
  2859.           prgm : a.o b.o
  2860.                cc -o prgm $<
  2861.           a.o b.o : g.h
  2862.  
  2863.      A more general way to say the above using the new macro
  2864.      expansions would be:
  2865.  
  2866.           SRC = a b
  2867.           OBJ = {$(SRC)}.o
  2868.  
  2869.           prgm : $(OBJ)
  2870.                cc -o $@ $<
  2871.  
  2872.           $(OBJ) : g.h
  2873.  
  2874.      If we want to keep the objects in a separate directory,
  2875.      called objdir, then we would write something like this.
  2876.  
  2877.  
  2878.  
  2879.  
  2880. Version 3.70                    UW                             45
  2881.  
  2882.  
  2883.  
  2884.  
  2885. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  2886.  
  2887.  
  2888.  
  2889.           SRC = a b
  2890.           OBJ = {$(SRC)}.o
  2891.  
  2892.           prgm : $(OBJ)
  2893.                cc $< -o $@
  2894.  
  2895.           $(OBJ) : g.h
  2896.           %.o : %.c
  2897.                $(CC) -c $(CFLAGS) -o $(@:f) $<
  2898.                mv $(@:f) objdir
  2899.  
  2900.           .SOURCE.o : objdir       # tell make to look here for .o's
  2901.  
  2902.      An example of building library members would go something
  2903.      like this: (NOTE:  The same rules as above will be used to
  2904.      produce .o's from .c's)
  2905.  
  2906.           SRC  = a b
  2907.           LIB  = lib
  2908.           LIBm = { $(SRC) }.o
  2909.  
  2910.           prgm: $(LIB)
  2911.                cc -o $@ $(LIB)
  2912.  
  2913.           $(LIB) .LIBRARY : $(LIBm)
  2914.                ar rv $@ $<
  2915.                rm $<
  2916.  
  2917.      Finally, suppose that each of the source files in the previ-
  2918.      ous example had the `:' character in their target name.
  2919.      Then we would write the above example as:
  2920.  
  2921.           SRC  = f:a f:b
  2922.           LIB  = lib
  2923.           LIBm = "{ $(SRC) }.o"         # put quotes around each token
  2924.  
  2925.           prgm: $(LIB)
  2926.                cc -o $@ $(LIB)
  2927.  
  2928.           $(LIB) .LIBRARY : $(LIBm)
  2929.                ar rv $@ $<
  2930.                rm $<
  2931.  
  2932. COMPATIBILITY
  2933.      There are two notable differences between dmake and the
  2934.      standard version of BSD UNIX 4.2/4.3 Make.
  2935.  
  2936.           1. BSD UNIX 4.2/4.3 Make supports wild card filename
  2937.              expansion for prerequisite names.  Thus if a direc-
  2938.              tory contains a.h, b.h and c.h, then a line like
  2939.  
  2940.                   target: *.h
  2941.  
  2942.  
  2943.  
  2944. Version 3.70                    UW                             46
  2945.  
  2946.  
  2947.  
  2948.  
  2949. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  2950.  
  2951.  
  2952.  
  2953.              will cause UNIX make to expand the *.h into "a.h b.h
  2954.              c.h".  dmake does not support this type of filename
  2955.              expansion.
  2956.  
  2957.           2. Unlike UNIX make, touching a library member causes
  2958.              dmake to search the library for the member name and
  2959.              to update the library time stamp.  This is only
  2960.              implemented in the UNIX version.  MSDOS and other
  2961.              versions may not have librarians that keep file time
  2962.              stamps, as a result dmake touches the library file
  2963.              itself, and prints a warning.
  2964.  
  2965.      dmake is not compatible with GNU Make.  In particular it
  2966.      does not understand GNU Make's macro expansions that query
  2967.      the file system.
  2968.  
  2969.      dmake is fully compatible with SYSV AUGMAKE, and supports
  2970.      the following AUGMAKE features:
  2971.  
  2972.           1. The word include appearing at the start of a line
  2973.              can be used instead of the ".INCLUDE :" construct
  2974.              understood by dmake.
  2975.  
  2976.           2. The macro modifier expression $(macro:str=sub) is
  2977.              understood and is equivalent to the expression
  2978.              $(macro:s/str/sub), with the restriction that str
  2979.              must match the following regular expression:
  2980.  
  2981.                   str[ |\t][ |\t]*
  2982.  
  2983.              (ie. str only matches at the end of a token where
  2984.              str is a suffix and is terminated by a space, a tab,
  2985.              or end of line)
  2986.  
  2987.           3. The macro % is defined to be $@ (ie. $% expands to
  2988.              the same value as $@).
  2989.  
  2990.           4. The AUGMAKE notion of libraries is handled
  2991.              correctly.
  2992.  
  2993.           5. When defining special targets for the inference
  2994.              rules and the AUGMAKE special target handling is
  2995.              enabled then the special target .X is equivalent to
  2996.              the %-rule "% : %.X".
  2997.  
  2998.           6. Directories are always made if you specify -A.  This
  2999.              is consistent with other UNIX versions of Make.
  3000.  
  3001.           7. Makefiles that utilize virtual targets to force mak-
  3002.              ing of other targets work as expected if AUGMAKE
  3003.              special target handling is enabled.  For example:
  3004.  
  3005.  
  3006.  
  3007.  
  3008. Version 3.70                    UW                             47
  3009.  
  3010.  
  3011.  
  3012.  
  3013. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  3014.  
  3015.  
  3016.  
  3017.                   FRC:
  3018.                   myprog.o : myprog.c $(FRC) ; ...
  3019.  
  3020.              Works as expected if you issue the command
  3021.  
  3022.                   'dmake -A FRC=FRC'
  3023.  
  3024.              but fails with a 'don't know how to make FRC' error
  3025.              message if you do not specify AUGMAKE special target
  3026.              handling via the -A flag (or by setting AUGMAKE:=yes
  3027.              internally).
  3028.  
  3029. LIMITS
  3030.      In some environments the length of an argument string is
  3031.      restricted.  (e.g. MSDOS command line arguments cannot be
  3032.      longer than 128 bytes if you are using the standard
  3033.      command.com command interpreter as your shell, dmake text
  3034.      diversions may help in these situations.)
  3035.  
  3036. PORTABILITY
  3037.      To write makefiles that can be moved from one environment to
  3038.      another requires some forethought.  In particular you must
  3039.      define as macros all those things that may be different in
  3040.      the new environment.  dmake has two facilities that help to
  3041.      support writing portable makefiles, recursive macros and
  3042.      conditional expressions.  The recursive macros, allow one to
  3043.      define environment configurations that allow different
  3044.      environments for similar types of operating systems.  For
  3045.      example the same make script can be used for SYSV and BSD
  3046.      but with different macro definitions.
  3047.  
  3048.      To write a makefile that is portable between UNIX and MSDOS
  3049.      requires both features since in almost all cases you will
  3050.      need to define new recipes for making targets.  The recipes
  3051.      will probably be quite different since the capabilities of
  3052.      the tools on each machine are different.  Different macros
  3053.      will be needed to help handle the smaller differences in the
  3054.      two environments.
  3055.  
  3056.      NOTE:  Unlike UNIX, MSDOS does maintain cd requests cross
  3057.      single recipe lines.  This is not portable, and your
  3058.      makefiles will not work the same way if you depend on it.
  3059.      Use the .IF ... .ELSE ... .END conditionals to supply dif-
  3060.      ferent make scripts as necessary.
  3061.  
  3062. FILES
  3063.      Makefile, makefile, startup.mk (use dmake -V to tell you
  3064.      where the startup file is)
  3065.  
  3066. SEE ALSO
  3067.      sh(1), csh(1), touch(1), f77(1), pc(1), cc(1)
  3068.      S.I. Feldman  Make - A Program for Maintaining Computer
  3069.  
  3070.  
  3071.  
  3072. Version 3.70                    UW                             48
  3073.  
  3074.  
  3075.  
  3076.  
  3077. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  3078.  
  3079.  
  3080.  
  3081.      Programs
  3082.  
  3083. AUTHOR
  3084.      Dennis Vadura, CS Dept. University of Waterloo.
  3085.      dvadura@watdragon.uwaterloo.ca
  3086.      Many thanks to Carl Seger for his helpful suggestions, and
  3087.      to Trevor John Thompson for his many excellent ideas and
  3088.      informative bug reports.
  3089.  
  3090. BUGS
  3091.      Some system commands return non-zero status inappropriately.
  3092.      Use -i (`-' within the makefile) to overcome the difficulty.
  3093.  
  3094.      Some systems do not have easily accessible time stamps for
  3095.      library members (MSDOS, AMIGA, etc) for these dmake uses the
  3096.      time stamp of the library instead and prints a warning the
  3097.      first time it does so.  This is almost always ok, except
  3098.      when multiple makefiles update a single library file.  In
  3099.      these instances it is possible to miss an update if one is
  3100.      not careful.
  3101.  
  3102.      This man page is way too long.
  3103.  
  3104.  
  3105.  
  3106.  
  3107.  
  3108.  
  3109.  
  3110.  
  3111.  
  3112.  
  3113.  
  3114.  
  3115.  
  3116.  
  3117.  
  3118.  
  3119.  
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127.  
  3128.  
  3129.  
  3130.  
  3131.  
  3132.  
  3133.  
  3134.  
  3135.  
  3136. Version 3.70                    UW                             49
  3137.