home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dmake40.zip / man / dmake.nc.B < prev    next >
Text File  |  1994-10-23  |  66KB  |  1,721 lines

  1.                      line.
  2.  
  3.      MAKETARGETS     Contains the name(s) of the target(s), if
  4.                      any, that were specified on the command
  5.                      line.
  6.  
  7.      MAXPROCESSLIMIT Is a numeric string representing the maximum
  8.                      number of processes that dmake can use when
  9.                      making targets using parallel mode.
  10.  
  11.      NULL            Is permanently defined to be the NULL
  12.                      string.  This is useful when comparing a
  13.                      conditional expression to an NULL value.
  14.  
  15.      PWD             Is the full path to the current directory in
  16.                      which make is executing.
  17.  
  18.      TMPFILE         Is set to the name of the most recent tem-
  19.                      porary file opened by dmake.  Temporary
  20.                      files are used for text diversions and for
  21.                      group recipe processing.
  22.  
  23.      TMD             Stands for "To Make Dir", and is the path
  24.                      from the present directory (value of $(PWD))
  25.                      to the directory that dmake was started up
  26.                      in (value of $(MAKEDIR)).  This macro is
  27.                      modified when .SETDIR attributes are pro-
  28.                      cessed.
  29.  
  30.      USESHELL        The value of this macro is set to "yes" if
  31.                      the current recipe is forced to use a shell
  32.                      for its execution via the .USESHELL or '+'
  33.                      directives, its value is "no" otherwise.
  34.  
  35.  
  36.      The second group of string valued macros control dmake
  37.      behavior and may be set by the user.
  38.  
  39.      .DIRCACHE       If set to "yes" enables the directory cache
  40.                      (this is the default).  If set to "no" dis-
  41.                      ables the directory cache (equivalent to -d
  42.                      commandline flag).
  43.  
  44.      .NAMEMAX        Defines the maximum length of a filename
  45.                      component.  The value of the variable is
  46.                      initialized at startup to the value of the
  47.                      compiled macro NAME_MAX.  On some systems
  48.                      the value of NAME_MAX is too short by
  49.                      default.  Setting a new value for .NAMEMAX
  50.                      will override the compiled value.
  51.  
  52.  
  53.  
  54.  
  55.  
  56. Version 3.9 PL0                 UW                             29
  57.  
  58.  
  59.  
  60.  
  61. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  62.  
  63.  
  64.  
  65.      .NOTABS         When set to non-NULL enables the use of
  66.                      spaces as well as <tabs> to begin recipe
  67.                      lines.  By default a non-group recipe is
  68.                      terminated by a line without any leading
  69.                      white-space or by a line not beggining with
  70.                      a <tab> character.  Enabling this mode modi-
  71.                      fies the first condition of the above termi-
  72.                      nation rule to terminate a non-group recipe
  73.                      with a line that contains only white-space.
  74.                      This mode does not effect the parsing of
  75.                      group recipes bracketed by [].
  76.  
  77.      AUGMAKE         If set to a non NULL value will enable the
  78.                      transformation of special meta targets to
  79.                      support special AUGMAKE inferences (See the
  80.                      COMPATIBILITY section).
  81.  
  82.      DIRBRKSTR       Contains the string of chars used to ter-
  83.                      minate the name of a directory in a path-
  84.                      name.  Under UNIX its value is "/", under
  85.                      MSDOS its value is "/\:".
  86.  
  87.      DIRSEPSTR       Contains the string that is used to separate
  88.                      directory components when path names are
  89.                      constructed.  It is defined with a default
  90.                      value at startup.
  91.  
  92.      DIVFILE         Is defined in the startup file and gives the
  93.                      name that should be returned for the diver-
  94.                      sion file name when used in $(mktmp ...)
  95.                      expansions, see the TEXT DIVERSION section
  96.                      for details.
  97.  
  98.      DYNAMICNESTINGLEVEL
  99.                      Specifies the maximum number of recursive
  100.                      dynamic macro expansions.  Its initial value
  101.                      is 100.
  102.  
  103.      .KEEP_STATE     Assigning this macro a value tells dmake the
  104.                      name of the state file to use and turns on
  105.                      the keeping of state information for any
  106.                      targets that are brought up to date by the
  107.                      make.
  108.  
  109.      GROUPFLAGS      This macro gives the set of flags to pass to
  110.                      the shell when invoking it to execute a
  111.                      group recipe.  The value of the macro is the
  112.                      list of flags with a leading switch indica-
  113.                      tor.  (ie. `-' under UNIX)
  114.  
  115.      GROUPSHELL      This macro defines the full path to the exe-
  116.                      cutable image to be used as the shell when
  117.  
  118.  
  119.  
  120. Version 3.9 PL0                 UW                             30
  121.  
  122.  
  123.  
  124.  
  125. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  126.  
  127.  
  128.  
  129.                      processing group recipes.  This macro must
  130.                      be defined if group recipes are used.  It is
  131.                      assigned a default value in the startup
  132.                      makefile.  Under UNIX this value is /bin/sh.
  133.  
  134.      GROUPSUFFIX     If defined, this macro gives the string to
  135.                      use as a suffix when creating group recipe
  136.                      files to be handed to the command inter-
  137.                      preter.  For example, if it is defined as
  138.                      .sh, then all temporary files created by
  139.                      dmake will end in the suffix .sh.  Under
  140.                      MSDOS if you are using command.com as your
  141.                      GROUPSHELL, then this suffix must be set to
  142.                      .bat in order for group recipes to function
  143.                      correctly.  The setting of GROUPSUFFIX and
  144.                      GROUPSHELL is done automatically for
  145.                      command.com in the startup.mk files.
  146.  
  147.      MAKE            Is defined in the startup file by default.
  148.                      The string $(MAKE) is recognized when using
  149.                      the -n option for single line recipes.  Ini-
  150.                      tially this macro is defined to have the
  151.                      value "$(MAKECMD) $(MFLAGS)".
  152.  
  153.      MAKESTARTUP     This macro defines the full path to the ini-
  154.                      tial startup makefile.  Use the -V command
  155.                      line option to discover its initial value.
  156.  
  157.      MAXLINELENGTH   This macro defines the maximum size of a
  158.                      single line of makefile input text.  The
  159.                      size is specified as a number, the default
  160.                      value is defined internally and is shown via
  161.                      the -V option.  A buffer of this size plus 2
  162.                      is allocated for reading makefile text.  The
  163.                      buffer is freed before any targets are made,
  164.                      thereby allowing files containing long input
  165.                      lines to be processed without consuming
  166.                      memory during the actual make.  This macro
  167.                      can only be used to extend the line length
  168.                      beyond it's default minimum value.
  169.  
  170.      MAXPROCESS      Specify the maximum number of child
  171.                      processes to use when making targets.  The
  172.                      default value of this macro is "1" and its
  173.                      value cannot exceed the value of the macro
  174.                      MAXPROCESSLIMIT.  Setting the value of MAX-
  175.                      PROCESS on the command line or in the
  176.                      makefile is equivalent to supplying a
  177.                      corresponding value to the -P flag on the
  178.                      command line.
  179.  
  180.  
  181.  
  182.  
  183.  
  184. Version 3.9 PL0                 UW                             31
  185.  
  186.  
  187.  
  188.  
  189. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  190.  
  191.  
  192.  
  193.      PREP            This macro defines the number of iterations
  194.                      to be expanded automatically when processing
  195.                      % rule definitions of the form:
  196.  
  197.                      % : %.suff
  198.  
  199.                      See the sections on PERCENT(%) RULES for
  200.                      details on how PREP is used.
  201.  
  202.      SHELL           This macro defines the full path to the exe-
  203.                      cutable image to be used as the shell when
  204.                      processing single line recipes.  This macro
  205.                      must be defined if recipes requiring the
  206.                      shell for execution are to be used.  It is
  207.                      assigned a default value in the startup
  208.                      makefile.  Under UNIX this value is /bin/sh.
  209.  
  210.      SHELLFLAGS      This macro gives the set of flags to pass to
  211.                      the shell when invoking it to execute a sin-
  212.                      gle line recipe.  The value of the macro is
  213.                      the list of flags with a leading switch
  214.                      indicator.  (ie. `-' under UNIX)
  215.  
  216.      SHELLMETAS      Each time dmake executes a single recipe
  217.                      line (not a group recipe) the line is
  218.                      searched for any occurrence of a character
  219.                      defined in the value of SHELLMETAS.  If such
  220.                      a character is found the recipe line is
  221.                      defined to require a shell to ensure its
  222.                      correct execution.  In such instances a
  223.                      shell is used to invoke the recipe line.  If
  224.                      no match is found the recipe line is exe-
  225.                      cuted without the use of a shell.
  226.  
  227.  
  228.      There is only one character valued macro defined by dmake:
  229.      SWITCHAR contains the switch character used to introduce
  230.      options on command lines.  For UNIX its value is `-', and
  231.      for MSDOS its value may be `/' or `-'.  The macro is inter-
  232.      nally defined and is not user setable.  The MSDOS version of
  233.      dmake attempts to first extract SWITCHAR from an environment
  234.      variable of the same name.  If that fails it then attempts
  235.      to use the undocumented getswitchar system call, and returns
  236.      the result of that.  Under MSDOS version 4.0 you must set
  237.      the value of the environment macro SWITCHAR to '/' to obtain
  238.      predictable behavior.
  239.  
  240.      All boolean macros currently understood by dmake correspond
  241.      directly to the previously defined attributes.  These macros
  242.      provide a second way to apply global attributes, and
  243.      represent the preferred method of doing so.  They are used
  244.      by assigning them a value.  If the value is not a NULL
  245.  
  246.  
  247.  
  248. Version 3.9 PL0                 UW                             32
  249.  
  250.  
  251.  
  252.  
  253. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  254.  
  255.  
  256.  
  257.      string then the boolean condition is set to on.  If the
  258.      value is a NULL string then the condition is set to off.
  259.      There are five conditions defined and they correspond
  260.      directly to the attributes of the same name.  Their meanings
  261.      are defined in the ATTRIBUTES section above.  The macros
  262.      are: .EPILOG, .IGNORE, .MKSARGS, .NOINFER, .PRECIOUS, .PRO-
  263.      LOG, .SEQUENTIAL, .SILENT, .SWAP, and .USESHELL.  Assigning
  264.      any of these a non NULL value will globally set the
  265.      corresponding attribute to on.
  266.  
  267. RUN_TIME MACROS
  268.      These macros are defined when dmake is making targets, and
  269.      may take on different values for each target.  $@ is defined
  270.      to be the full target name, $? is the list of all out of
  271.      date prerequisites, $& is the list of all prerequisites, $>
  272.      is the name of the library if the current target is a
  273.      library member, and $< is the list of prerequisites speci-
  274.      fied in the current rule.  If the current target had a
  275.      recipe inferred then $< is the name of the inferred prere-
  276.      quisite even if the target had a list of prerequisites sup-
  277.      plied using an explicit rule that did not provide a recipe.
  278.      In such situations $& gives the full list of prerequisites.
  279.  
  280.      $* is defined as $(@:db) when making targets with explicit
  281.      recipes and is defined as the value of % when making targets
  282.      whose recipe is the result of an inference.  In the first
  283.      case $* is the target name with no suffix, and in the second
  284.      case, is the value of the matched % pattern from the associ-
  285.      ated %-rule.  $^ expands to the set of out of date prere-
  286.      quisites taken from the current value of $<.  In addition to
  287.      these, $$ expands to $, {{ expands to {, }} expands to },
  288.      and the strings <+ and +> are recognized as respectively
  289.      starting and terminating a text diversion when they appear
  290.      literally together in the same input line.
  291.  
  292.      The difference between $? and $^ can best be illustrated by
  293.      an example, consider:
  294.  
  295.           fred.out : joe amy hello
  296.                rules for making fred
  297.  
  298.           fred.out : my.c your.h his.h her.h   # more prerequisites
  299.  
  300.      Assume joe, amy, and my.c are newer then fred.out.  When
  301.      dmake executes the recipe for making fred.out the values of
  302.      the following macros will be:
  303.  
  304.           $@ --> fred.out
  305.           $* --> fred
  306.           $? --> joe amy my.c  # note the difference between $? and $^
  307.           $^ --> joe amy
  308.           $< --> joe amy hello
  309.  
  310.  
  311.  
  312. Version 3.9 PL0                 UW                             33
  313.  
  314.  
  315.  
  316.  
  317. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  318.  
  319.  
  320.  
  321.           $& --> joe amy hello my.c your.h his.h her.h
  322.  
  323.  
  324. FUNCTION MACROS
  325.      dmake supports a full set of functional macros.  One of
  326.      these, the $(mktmp ...) macro, is discussed in detail in the
  327.      TEXT DIVERSION section and is not covered here.
  328.  
  329.  
  330.           $(assign expression)
  331.                Causes expression to be parsed as a macro assign-
  332.                ment expression and results in the specified
  333.                assignment being made.  An error is issued if the
  334.                assignment is not syntatically correct.  expres-
  335.                sion may contain white space.  This is in effect a
  336.                dynamic macro assignment facility and may appear
  337.                anywhere any other macro may appear.  The result
  338.                of the expanding a dynamic macro assignment
  339.                expression is the name of the macro that was
  340.                assigned and $(NULL) if the expression is not a
  341.                valid macro assignment expression.  Some examples
  342.                are:
  343.  
  344.                $(assign foo := fred)
  345.                $(assign $(indirect_macro_name) +:= $(morejunk))
  346.  
  347.           $(null,text true false)
  348.                expands the value of text. If it is NULL then the
  349.                macro returns the value of the expansion of true
  350.                and the expansion of false otherwise.  The terms
  351.                true, and false must be strings containing no
  352.                white-space.
  353.  
  354.           $(!null,text true false)
  355.                Behaves identically to the previous macro except
  356.                that the true string is chosen if the expansion of
  357.                text is not NULL.
  358.  
  359.           $(eq,text_a,text_b true false)
  360.                expands text_a and text_b and compares their
  361.                results.  If equal it returns the result of the
  362.                expansion of the true term, otherwise it returns
  363.                the expansion of the false term.
  364.  
  365.           $(!eq,text_a,text_b true false)
  366.                Behaves identically to the previous macro except
  367.                that the true string is chosen if the expansions
  368.                of the two strings are not equal
  369.  
  370.           $(nil expression)
  371.                Always returns the value of $(NULL) regardless of
  372.                what expression is.  This function macro can be
  373.  
  374.  
  375.  
  376. Version 3.9 PL0                 UW                             34
  377.  
  378.  
  379.  
  380.  
  381. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  382.  
  383.  
  384.  
  385.                used to discard results of expanding macro expres-
  386.                sions.
  387.  
  388.           $(shell command)
  389.                Runs command as if it were part of a recipe and
  390.                returns, separated by a single space, all the
  391.                non-white space terms written to stdout by the
  392.                command.  For example:
  393.  
  394.                     $(shell ls *.c)
  395.  
  396.                will return "a.c b.c c.c d.c" if the files exist
  397.                in the current directory.  The recipe modification
  398.                flags [+@%-] are honored if they appear as the
  399.                first characters in the command.  For example:
  400.  
  401.                     $(shell +ls *.c)
  402.  
  403.                will run the command using the current shell.
  404.  
  405.           $(shell,expand command)
  406.                Is an extension to the $(shell... function macro
  407.                that expands the result of running command.
  408.  
  409.           $(sort list)
  410.                Will take all white-space separated tokens in list
  411.                and will return their sorted equivalent list.
  412.  
  413.           $(strip data)
  414.                Will replace all strings of white-space in data by
  415.                a single space.
  416.  
  417.           $(subst,pat,replacement data)
  418.                Will search for pat in data and will replace any
  419.                occurrence of pat with the replacement string.
  420.                The expansion
  421.  
  422.                $(subst,.o,.c $(OBJECTS))
  423.  
  424.           is equivalent to:
  425.  
  426.                $(OBJECTS:s/.o/.c/)
  427.  
  428.  
  429. CONDITIONAL MACROS
  430.      dmake supports conditional macros.  These allow the defini-
  431.      tion of target specific macro values.  You can now say the
  432.      following:
  433.  
  434.           target ?= MacroName MacroOp Value
  435.  
  436.      This creates a definition for MacroName whose value is Value
  437.  
  438.  
  439.  
  440. Version 3.9 PL0                 UW                             35
  441.  
  442.  
  443.  
  444.  
  445. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  446.  
  447.  
  448.  
  449.      only when target is being made.  You may use a conditional
  450.      macro assignment anywhere that a regular macro assignment
  451.      may appear, including as the value of a $(assign ...) macro.
  452.  
  453.      The new definition is associated with the most recent cell
  454.      definition for target.  If no prior definition exists then
  455.      one is created.  The implications of this are immediately
  456.      evident in the following example:
  457.  
  458.           foo := hello
  459.  
  460.           all : cond;@echo "all done, foo=[$(foo)] bar=[$(bar)]"
  461.  
  462.           cond ?= bar := global decl
  463.  
  464.           cond .SETDIR=unix::;@echo $(foo) $(bar)
  465.           cond ?= foo := hi
  466.  
  467.           cond .SETDIR=msdos::;@echo $(foo) $(bar)
  468.                cond ?= foo := hihi
  469.  
  470.      The first conditional assignment creates a binding for 'bar'
  471.      that is activated when 'cond' is made.  The bindings follow-
  472.      ing the :: definitions are activated when their respective
  473.      recipe rules are used.  Thus the first binding serves to
  474.      provide a global value for 'bar' while any of the cond ::
  475.      rules are processed, and the local bindings for 'foo' come
  476.      into effect when their associated :: rule is processed.
  477.  
  478.      Conditionals for targets of .UPDATEALL are all activated
  479.      before the target group is made.  Assignments are processed
  480.      in order.  Note that the value of a conditional macro
  481.      assignment is NOT AVAILABLE until the associated target is
  482.      made, thus the construct
  483.  
  484.           mytarget ?= bar := hello
  485.           mytarget ?= foo := $(bar)
  486.  
  487.      results in $(foo) expanding to "", if you want the result to
  488.      be "hello" you must use:
  489.  
  490.           mytarget ?= bar := hello
  491.           mytarget ?= foo  = $(bar)
  492.  
  493.      Once a target is made any associated conditional macros are
  494.      deactivated and their values are no longer available.
  495.      Activation occurrs after all inference, and .SETDIR direc-
  496.      tives have been processed and after $@ is assigned, but
  497.      before prerequisites are processed; thereby making the
  498.      values of conditional macro definitions available during
  499.      construction of prerequisites.
  500.  
  501.  
  502.  
  503.  
  504. Version 3.9 PL0                 UW                             36
  505.  
  506.  
  507.  
  508.  
  509. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  510.  
  511.  
  512.  
  513.      If a %-meta rule target has associated conditional macro
  514.      assignments, and the rule is chosen by the inference algo-
  515.      rithm then the conditional macro assignments are inferred
  516.      together with the associated recipe.
  517.  
  518. DYNAMIC PREREQUISITES
  519.      dmake looks for prerequisites whose names contain macro
  520.      expansions during target processing.  Any such prerequisites
  521.      are expanded and the result of the expansion is used as the
  522.      prerequisite name.  As an example the line:
  523.  
  524.           fred : $$@.c
  525.  
  526.      causes the $$@ to be expanded when dmake is making fred, and
  527.      it resolves to the target fred.  This enables dynamic prere-
  528.      quisites to be generated.  The value of @ may be modified by
  529.      any of the valid macro modifiers.  So you can say for exam-
  530.      ple:
  531.  
  532.           fred.out : $$(@:b).c
  533.  
  534.      where the $$(@:b) expands to fred.  Note the use of $$
  535.      instead of $ to indicate the dynamic expansion, this is due
  536.      to the fact that the rule line is expanded when it is ini-
  537.      tially parsed, and $$ then returns $ which later triggers
  538.      the dynamic prerequisite expansion.  If you really want a $
  539.      to be part of a prerequisite name you must use $$$$.
  540.      Dynamic macro expansion is performed in all user defined
  541.      rules, and the special targets .SOURCE*, and .INCLUDEDIRS.
  542.  
  543.      If dynamic macro expansion results in multiple white space
  544.      separated tokens then these are inserted into the prere-
  545.      quisite list inplace of the dynamic prerequisite.  If the
  546.      new list contains additional dynamic prerequisites they will
  547.      be expanded when they are processed.  The level of recursion
  548.      in this expansion is controlled by the value of the variable
  549.      DYNAMICNESTINGLEVEL and is set to 100 by default.
  550.  
  551. BINDING TARGETS
  552.      This operation takes a target name and binds it to an exist-
  553.      ing file, if possible.  dmake makes a distinction between
  554.      the internal target name of a target and its associated
  555.      external file name.  Thus it is possible for a target's
  556.      internal name and its external file name to differ.  To per-
  557.      form the binding, the following set of rules is used.
  558.      Assume that we are trying to bind a target whose name is of
  559.      the form X.suff, where .suff is the suffix and X is the stem
  560.      portion (ie. that part which contains the directory and the
  561.      basename).  dmake takes this target name and performs a
  562.      series of search operations that try to find a suitably
  563.      named file in the external file system.  The search opera-
  564.      tion is user controlled via the settings of the various
  565.  
  566.  
  567.  
  568. Version 3.9 PL0                 UW                             37
  569.  
  570.  
  571.  
  572.  
  573. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  574.  
  575.  
  576.  
  577.      .SOURCE targets.
  578.  
  579.           1.   If target has the .SYMBOL attribute set then look
  580.                for it in the library.  If found, replace the tar-
  581.                get name with the library member name and continue
  582.                with step 2.  If the name is not found then
  583.                return.
  584.  
  585.           2.   Extract the suffix portion (that following the
  586.                `.') of the target name.  If the suffix is not
  587.                null, look up the special target .SOURCE.<suff>
  588.                (<suff> is the suffix). If the special target
  589.                exists then search each directory given in the
  590.                .SOURCE.<suff> prerequisite list for the target.
  591.                If the target's suffix was null (ie. .suff was
  592.                empty) then perform the above search but use the
  593.                special target .SOURCE.NULL instead.  If at any
  594.                point a match is found then terminate the search.
  595.                If a directory in the prerequisite list is the
  596.                special name `.NULL ' perform a search for the
  597.                full target name without prepending any directory
  598.                portion (ie. prepend the NULL directory).
  599.  
  600.           3.   The search in step 2. failed.  Repeat the same
  601.                search but this time use the special target
  602.                .SOURCE.  (a default target of '.SOURCE : .NULL'
  603.                is defined by dmake at startup, and is user rede-
  604.                finable)
  605.  
  606.           4.   The search in step 3. failed.  If the target has
  607.                the library member attribute (.LIBMEMBER) set then
  608.                try to find the target in the library which was
  609.                passed along with the .LIBMEMBER attribute (see
  610.                the MAKING LIBRARIES section).  The bound file
  611.                name assigned to a target which is successfully
  612.                located in a library is the same name that would
  613.                be assigned had the search failed (see 5.).
  614.  
  615.           5.   The search failed.  Either the target was not
  616.                found in any of the search directories or no
  617.                applicable .SOURCE special targets exist.  If
  618.                applicable .SOURCE special targets exist, but the
  619.                target was not found, then dmake assigns the first
  620.                name searched as the bound file name.  If no
  621.                applicable .SOURCE special targets exist, then the
  622.                full original target name becomes the bound file
  623.                name.
  624.  
  625.      There is potential here for a lot of search operations.  The
  626.      trick is to define .SOURCE.x special targets with short
  627.      search lists and leave .SOURCE as short as possible.  The
  628.      search algorithm has the following useful side effect.  When
  629.  
  630.  
  631.  
  632. Version 3.9 PL0                 UW                             38
  633.  
  634.  
  635.  
  636.  
  637. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  638.  
  639.  
  640.  
  641.      a target having the .LIBMEMBER (library member) attribute is
  642.      searched for, it is first searched for as an ordinary file.
  643.      When a number of library members require updating it is
  644.      desirable to compile all of them first and to update the
  645.      library at the end in a single operation.  If one of the
  646.      members does not compile and dmake stops, then the user may
  647.      fix the error and make again.  dmake will not remake any of
  648.      the targets whose object files have already been generated
  649.      as long as none of their prerequisite files have been modi-
  650.      fied as a result of the fix.
  651.  
  652.      When dmake constructs target pathnames './' substrings are
  653.      removed and substrings of the form 'foo/..' are eliminated.
  654.      This may result in somewhat unexpected values of the macro
  655.      expansion $@, but is infact the corect result.
  656.  
  657.      When defining .SOURCE and .SOURCE.x targets the construct
  658.  
  659.           .SOURCE :
  660.           .SOURCE : fred gery
  661.  
  662.      is equivalent to
  663.  
  664.           .SOURCE :- fred gery
  665.  
  666.      dmake correctly handles the UNIX Make variable VPATH.  By
  667.      definition VPATH contains a list of ':' separated direc-
  668.      tories to search when looking for a target.  dmake maps
  669.      VPATH to the following special rule:
  670.  
  671.           .SOURCE :^ $(VPATH:s/:/ /)
  672.  
  673.      Which takes the value of VPATH and sets .SOURCE to the same
  674.      set of directories as specified in VPATH.
  675.  
  676. PERCENT(%) RULES AND MAKING INFERENCES
  677.      When dmake makes a target, the target's set of prerequisites
  678.      (if any) must exist and the target must have a recipe which
  679.      dmake can use to make it.  If the makefile does not specify
  680.      an explicit recipe for the target then dmake uses special
  681.      rules to try to infer a recipe which it can use to make the
  682.      target.  Previous versions of Make perform this task by
  683.      using rules that are defined by targets of the form
  684.      .<suffix>.<suffix> and by using the .SUFFIXES list of suf-
  685.      fixes.  The exact workings of this mechanism were sometimes
  686.      difficult to understand and often limiting in their useful-
  687.      ness.  Instead, dmake supports the concept of %-meta rules.
  688.      The syntax and semantics of these rules differ from standard
  689.      rule lines as follows:
  690.  
  691.           <%-target> [<attributes>] <ruleop> [<%-prerequisites>] [;<recipe>]
  692.  
  693.  
  694.  
  695.  
  696. Version 3.9 PL0                 UW                             39
  697.  
  698.  
  699.  
  700.  
  701. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  702.  
  703.  
  704.  
  705.      where %-target is a target containing exactly a single `%'
  706.      sign, attributes is a list (possibly empty) of attributes,
  707.      ruleop is the standard set of rule operators, %-prere-
  708.      quisites , if present, is a list of prerequisites containing
  709.      zero or more `%' signs, and recipe, if present, is the first
  710.      line of the recipe.
  711.  
  712.      The %-target defines a pattern against which a target whose
  713.      recipe is being inferred gets matched.  The pattern match
  714.      goes as follows:  all chars are matched exactly from left to
  715.      right up to but not including the % sign in the pattern, %
  716.      then matches the longest string from the actual target name
  717.      not ending in the suffix given after the % sign in the pat-
  718.      tern.  Consider the following examples:
  719.  
  720.           %.c       matches fred.c but not joe.c.Z
  721.           dir/%.c   matches dir/fred.c but not dd/fred.c
  722.           fred/%    matches fred/joe.c but not f/joe.c
  723.           %         matches anything
  724.  
  725.      In each case the part of the target name that matched the %
  726.      sign is retained and is substituted for any % signs in the
  727.      prerequisite list of the %-meta rule when the rule is
  728.      selected during inference and dmake constructs the new
  729.      dependency.  As an example the following %-meta rules
  730.      describe the following:
  731.  
  732.           %.c : %.y ; recipe...
  733.  
  734.      describes how to make any file ending in .c if a correspond-
  735.      ing file ending in .y can be found.
  736.  
  737.           foo%.o : fee%.k ; recipe...
  738.  
  739.      is used to describe how to make fooxxxx.o from feexxxx.k.
  740.  
  741.           %.a :; recipe...
  742.  
  743.      describes how to make a file whose suffix is .a without
  744.      inferring any prerequisites.
  745.  
  746.           %.c : %.y yaccsrc/%.y ; recipe...
  747.  
  748.      is a short form for the construct:
  749.  
  750.           %.c : %.y ; recipe...
  751.           %.c : yaccsrc/%.y ; recipe...
  752.  
  753.      ie. It is possible to specify the same recipe for two
  754.      %-rules by giving more than one prerequisite in the prere-
  755.      quisite list.  A more interesting example is:
  756.  
  757.  
  758.  
  759.  
  760. Version 3.9 PL0                 UW                             40
  761.  
  762.  
  763.  
  764.  
  765. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  766.  
  767.  
  768.  
  769.           % : RCS/%,v ; co $<
  770.  
  771.      which describes how to take any target and check it out of
  772.      the RCS directory if the corresponding file exists in the
  773.      RCS directory.  The equivalent SCCS rule would be:
  774.  
  775.           % : s.% ; get $<
  776.  
  777.  
  778.      The previous RCS example defines an infinite rule, because
  779.      it says how to make anything from RCS/%,v, and anything also
  780.      includes RCS/fred.c,v.  To limit the size of the graph that
  781.      results from such rules dmake uses the macro variable PREP
  782.      (stands for % repetition).  By default the value of this
  783.      variable is 0, which says that no repetitions of a %-rule
  784.      are to be generated.  If it is set to something greater than
  785.      0, then that many repetitions of any infinite %-rule are
  786.      allowed.  If in the above example PREP was set to 1, then
  787.      dmake would generate the dependency graph:
  788.  
  789.           % --> RCS/%,v --> RCS/RCS/%,v,v
  790.  
  791.      Where each link is assigned the same recipe as the first
  792.      link.  PREP should be used only in special cases, since it
  793.      may result in a large increase in the number of possible
  794.      prerequisites tested.  dmake further assumes that any target
  795.      that has no suffix can be made from a prerequisite that has
  796.      at least one suffix.
  797.  
  798.      dmake supports dynamic prerequisite generation for prere-
  799.      quisites of %-meta rules.  This is best illustrated by an
  800.      example.  The RCS rule shown above can infer how to check
  801.      out a file from a corresponding RCS file only if the target
  802.      is a simple file name with no directory information.  That
  803.      is, the above rule can infer how to find RCS/fred.c,v from
  804.      the target fred.c, but cannot infer how to find
  805.      srcdir/RCS/fred.c,v from srcdir/fred.c because the above
  806.      rule will cause dmake to look for RCS/srcdir/fred.c,v; which
  807.      does not exist (assume that srcdir has its own RCS directory
  808.      as is the common case).
  809.  
  810.      A more versatile formulation of the above RCS check out rule
  811.      is the following:
  812.  
  813.           % :  $$(@:d)RCS/$$(@:f),v : co $@
  814.  
  815.      This rule uses the dynamic macro $@ to specify the prere-
  816.      quisite to try to infer.  During inference of this rule the
  817.      macro $@ is set to the value of the target of the %-meta
  818.      rule and the appropriate prerequisite is generated by
  819.      extracting the directory portion of the target name (if
  820.      any), appending the string RCS/ to it, and appending the
  821.  
  822.  
  823.  
  824. Version 3.9 PL0                 UW                             41
  825.  
  826.  
  827.  
  828.  
  829. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  830.  
  831.  
  832.  
  833.      target file name with a trailing ,v attached to the previous
  834.      result.
  835.  
  836.      dmake can also infer indirect prerequisites.  An inferred
  837.      target can have a list of prerequisites added that will not
  838.      show up in the value of $< but will show up in the value of
  839.      $? and $&.  Indirect prerequisites are specified in an
  840.      inference rule by quoting the prerequisite with single
  841.      quotes.  For example, if you had the explicit dependency:
  842.  
  843.           fred.o : fred.c ; rule to make fred.o
  844.           fred.o : local.h
  845.  
  846.      then this can be inferred for fred.o from the following
  847.      inference rule:
  848.  
  849.           %.o : %.c 'local.h' ; rule to make a .o from a .c
  850.  
  851.      You may infer indirect prerequisites that are a function of
  852.      the value of '%' in the current rule.  The meta-rule:
  853.  
  854.           %.o : %.c '$(INC)/%.h' ; rule to make a .o from a .c
  855.  
  856.      infers an indirect prerequisite found in the INC directory
  857.      whose name is the same as the expansion of $(INC), and the
  858.      prerequisite name depends on the base name of the current
  859.      target.  The set of indirect prerequisites is attached to
  860.      the meta rule in which they are specified and are inferred
  861.      only if the rule is used to infer a recipe for a target.
  862.      They do not play an active role in driving the inference
  863.      algorithm.  The construct:
  864.  
  865.           %.o : %.c %.f 'local.h'; recipe
  866.  
  867.      is equivalent to:
  868.  
  869.           %.o : %.c 'local.h' : recipe
  870.  
  871.      while:
  872.  
  873.           %.o :| %.c %.f 'local.h'; recipe
  874.  
  875.      is equivalent to:
  876.  
  877.           %.o : %.c 'local.h' : recipe
  878.           %.o : %.f 'local.h' : recipe
  879.  
  880.  
  881.      If any of the attributes .SETDIR, .EPILOG, .PROLOG, .SILENT,
  882.      .USESHELL, .SWAP, .PRECIOUS, .LIBRARY, .NOSTATE and .IGNORE
  883.      are given for a %-rule then when that rule is bound to a
  884.      target as the result of an inference, the target's set of
  885.  
  886.  
  887.  
  888. Version 3.9 PL0                 UW                             42
  889.  
  890.  
  891.  
  892.  
  893. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  894.  
  895.  
  896.  
  897.      attributes is augmented by the attributes from the above set
  898.      that are specified in the bound %-rule.  Other attributes
  899.      specified for %-meta rules are not inherited by the target.
  900.      The .SETDIR attribute is treated in a special way.  If the
  901.      target already had a .SETDIR attribute set then dmake
  902.      changes to that directory prior to performing the inference.
  903.      During inference any .SETDIR attributes for the inferred
  904.      prerequisite are honored.  The directories must exist for a
  905.      %-meta rule to be selected as a possible inference path.  If
  906.      the directories do not exist no error message is issued,
  907.      instead the corresponding path in the inference graph is
  908.      rejected.
  909.  
  910.      dmake also supports the old format special target
  911.      .<suffix>.<suffix> by identifying any rules of this form and
  912.      mapping them to the appropriate %-rule.  So for example if
  913.      an old makefile contains the construct:
  914.  
  915.           .c.o :; cc -c $< -o $@
  916.  
  917.      dmake maps this into the following %-rule:
  918.  
  919.           %.o : %.c; cc -c $< -o $@
  920.  
  921.      Furthermore, dmake understands several SYSV AUGMAKE special
  922.      targets and maps them into corresponding %-meta rules.
  923.      These transformation must be enabled by providing the -A
  924.      flag on the command line or by setting the value of AUGMAKE
  925.      to non-NULL.  The construct
  926.  
  927.           .suff :; recipe
  928.  
  929.      gets mapped into:
  930.  
  931.           % : %.suff; recipe
  932.  
  933.      and the construct
  934.  
  935.           .c~.o :; recipe
  936.  
  937.      gets mapped into:
  938.  
  939.           %.o : s.%.c ; recipe
  940.  
  941.      In general, a special target of the form .<str>~ is replaced
  942.      by the %-rule construct s.%.<str>, thereby providing support
  943.      for the syntax used by SYSV AUGMAKE for providing SCCS sup-
  944.      port.  When enabled, these mappings allow processing of
  945.      existing SYSV makefiles without modifications.
  946.  
  947.      dmake bases all of its inferences on the inference graph
  948.      constructed from the %-rules defined in the makefile.  It
  949.  
  950.  
  951.  
  952. Version 3.9 PL0                 UW                             43
  953.  
  954.  
  955.  
  956.  
  957. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  958.  
  959.  
  960.  
  961.      knows exactly which targets can be made from which prere-
  962.      quisites by making queries on the inference graph.  For this
  963.      reason .SUFFIXES is not needed and is completely ignored.
  964.  
  965.      For a %-meta rule to be inferred as the rule whose recipe
  966.      will be used to make a target, the target's name must match
  967.      the %-target pattern, and any inferred %-prerequisite must
  968.      already exist or have an explicit recipe so that the prere-
  969.      quisite can be made.  Without transitive closure on the
  970.      inference graph the above rule describes precisely when an
  971.      inference match terminates the search.  If transitive clo-
  972.      sure is enabled (the usual case), and a prerequisite does
  973.      not exist or cannot be made, then dmake invokes the infer-
  974.      ence algorithm recursively on the prerequisite to see if
  975.      there is some way the prerequisite can be manufactured.
  976.      For, if the prerequisite can be made then the current target
  977.      can also be made using the current %-meta rule.  This means
  978.      that there is no longer a need to give a rule for making a
  979.      .o from a .y if you have already given a rule for making a
  980.      .o from a .c and a .c from a .y.  In such cases dmake can
  981.      infer how to make the .o from the .y via the intermediary .c
  982.      and will remove the .c when the .o is made.  Transitive clo-
  983.      sure can be disabled by giving the -T switch on the command
  984.      line.
  985.  
  986.      A word of caution.  dmake bases its transitive closure on
  987.      the %-meta rule targets.  When it performs transitive clo-
  988.      sure it infers how to make a target from a prerequisite by
  989.      performing a pattern match as if the potential prerequisite
  990.      were a new target.  The set of rules:
  991.  
  992.           %.o : %.c :; rule for making .o from .c
  993.           %.c : %.y :; rule for making .c from .y
  994.           % : RCS/%,v :; check out of RCS file
  995.  
  996.      will, by performing transitive closure, allow dmake to infer
  997.      how to make a .o from a .y using a .c as an intermediate
  998.      temporary file.  Additionally it will be able to infer how
  999.      to make a .y from an RCS file, as long as that RCS file is
  1000.      in the RCS directory and has a name which ends in .y,v.  The
  1001.      transitivity computation is performed dynamically for each
  1002.      target that does not have a recipe.  This has potential to
  1003.      be costly if the %-meta rules are not carefully specified.
  1004.      The .NOINFER attribute is used to mark a %-meta node as
  1005.      being a final target during inference.  Any node with this
  1006.      attribute set will not be used for subsequent inferences.
  1007.      As an example the node RCS/%,v is marked as a final node
  1008.      since we know that if the RCS file does not exist there
  1009.      likely is no other way to make it.  Thus the standard
  1010.      startup makefile contains an entry similar to:
  1011.           .NOINFER : RCS/%,v
  1012.      Thereby indicating that the RCS file is the end of the
  1013.  
  1014.  
  1015.  
  1016. Version 3.9 PL0                 UW                             44
  1017.  
  1018.  
  1019.  
  1020.  
  1021. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1022.  
  1023.  
  1024.  
  1025.      inference chain.  Whenever the inference algorithm deter-
  1026.      mines that a target can be made from more than one prere-
  1027.      quisite and the inference chains for the two methods are the
  1028.      same length the algorithm reports an ambiguity and prints
  1029.      the ambiguous inference chains.
  1030.  
  1031.      dmake tries to remove intermediate files resulting from
  1032.      transitive closure if the file is not marked as being PRE-
  1033.      CIOUS, or the -u flag was not given on the command line, and
  1034.      if the inferred intermediate did not previously exist.
  1035.      Intermediate targets that existed prior to being made are
  1036.      never removed.  This is in keeping with the philosophy that
  1037.      dmake should never remove things from the file system that
  1038.      it did not add.  If the special target .REMOVE is defined
  1039.      and has a recipe then dmake constructs a list of the inter-
  1040.      mediate files to be removed and makes them prerequisites of
  1041.      .REMOVE.  It then makes .REMOVE thereby removing the prere-
  1042.      quisites if the recipe of .REMOVE says to.  Typically
  1043.      .REMOVE is defined in the startup file as:
  1044.  
  1045.           .REMOVE :; $(RM) $<
  1046.  
  1047. MAKING TARGETS
  1048.      In order to update a target dmake must execute a recipe.
  1049.      When a recipe needs to be executed it is first expanded so
  1050.      that any macros in the recipe text are expanded, and it is
  1051.      then either executed directly or passed to a shell.  dmake
  1052.      supports two types of recipes.  The regular recipes and
  1053.      group recipes.
  1054.  
  1055.      When a regular recipe is invoked dmake executes each line of
  1056.      the recipe separately using a new copy of a shell if a shell
  1057.      is required.  Thus effects of commands do not generally per-
  1058.      sist across recipe lines (e.g. cd requests in a recipe line
  1059.      do not carry over to the next recipe line).  This is true
  1060.      even in environments such as MSDOS, where dmake internally
  1061.      sets the current working director to match the directory it
  1062.      was in before the command was executed.
  1063.  
  1064.      The decision on whether a shell is required to execute a
  1065.      command is based on the value of the macro SHELLMETAS or on
  1066.      the specification of '+' or .USESHELL for the current recipe
  1067.      or target respectively.  If any character in the value of
  1068.      SHELLMETAS is found in the expanded recipe text-line or the
  1069.      use of a shell is requested explicitly via '+' or .USESHELL
  1070.      then the command is executed using a shell, otherwise the
  1071.      command is executed directly.  The shell that is used for
  1072.      execution is given by the value of the macro SHELL.  The
  1073.      flags that are passed to the shell are given by the value of
  1074.      SHELLFLAGS.  Thus dmake constructs the command line:
  1075.  
  1076.           $(SHELL) $(SHELLFLAGS) $(expanded_recipe_command)
  1077.  
  1078.  
  1079.  
  1080. Version 3.9 PL0                 UW                             45
  1081.  
  1082.  
  1083.  
  1084.  
  1085. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1086.  
  1087.  
  1088.  
  1089.      Normally dmake writes the command line that it is about to
  1090.      invoke to standard output.  If the .SILENT attribute is set
  1091.      for the target or for the recipe line (via @), then the
  1092.      recipe line is not echoed.
  1093.  
  1094.      Group recipe processing is similar to that of regular
  1095.      recipes, except that a shell is always invoked.  The shell
  1096.      that is invoked is given by the value of the macro GROUP-
  1097.      SHELL, and its flags are taken from the value of the macro
  1098.      GROUPFLAGS.  If a target has the .PROLOG attribute set then
  1099.      dmake prepends to the shell script the recipe associated
  1100.      with the special target .GROUPPROLOG, and if the attribute
  1101.      .EPILOG is set as well, then the recipe associated with the
  1102.      special target .GROUPEPILOG is appended to the script file.
  1103.      This facility can be used to always prepend a common header
  1104.      and common trailer to group recipes.  Group recipes are
  1105.      echoed to standard output just like standard recipes, but
  1106.      are enclosed by lines beginning with [ and ].
  1107.  
  1108.      The recipe flags [+,-,%,@] are recognized at the start of a
  1109.      recipe line even if they appear in a macro.  For example:
  1110.  
  1111.           SH = +
  1112.           all:
  1113.                $(SH)echo hi
  1114.  
  1115.      is completely equivalent to writing
  1116.  
  1117.           SH = +
  1118.           all:
  1119.                +echo hi
  1120.  
  1121.  
  1122.      The last step performed by dmake prior to running a recipe
  1123.      is to set the macro CMNDNAME to the name of the command to
  1124.      execute (determined by finding the first white-space ending
  1125.      token in the command line).  It then sets the macro CMNDARGS
  1126.      to be the remainder of the line.  dmake then expands the
  1127.      macro COMMAND which by default is set to
  1128.  
  1129.           COMMAND = $(CMNDNAME) $(CMNDARGS)
  1130.  
  1131.      The result of this final expansion is the command that will
  1132.      be executed.  The reason for this expansion is to allow for
  1133.      a different interface to the argument passing facilities
  1134.      (esp. under DOS) than that provided by dmake. You can for
  1135.      example define COMMAND to be
  1136.  
  1137.           COMMAND = $(CMNDNAME) @$(mktmp $(CMNDARGS))
  1138.  
  1139.      which dumps the arguments into a temporary file and runs the
  1140.      command
  1141.  
  1142.  
  1143.  
  1144. Version 3.9 PL0                 UW                             46
  1145.  
  1146.  
  1147.  
  1148.  
  1149. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1150.  
  1151.  
  1152.  
  1153.           $(CMNDNAME) @/tmp/ASAD23043
  1154.  
  1155.      which has a much shorter argument list.  It is now up to the
  1156.      command to use the supplied argument as the source for all
  1157.      other arguments.  As an optimization, if COMMAND is not
  1158.      defined dmake does not perform the above expansion.  On sys-
  1159.      tems, such as UNIX, that handle long command lines this pro-
  1160.      vides a slight saving in processing the makefiles.
  1161.  
  1162. MAKING LIBRARIES
  1163.      Libraries are easy to maintain using dmake.  A library is a
  1164.      file containing a collection of object files.  Thus to make
  1165.      a library you simply specify it as a target with the
  1166.      .LIBRARY attribute set and specify its list of prere-
  1167.      quisites.  The prerequisites should be the object members
  1168.      that are to go into the library.  When dmake makes the
  1169.      library target it uses the .LIBRARY attribute to pass to the
  1170.      prerequisites the .LIBMEMBER attribute and the name of the
  1171.      library.  This enables the file binding mechanism to look
  1172.      for the member in the library if an appropriate object file
  1173.      cannot be found. A small example best illustrates this.
  1174.  
  1175.           mylib.a .LIBRARY : mem1.o mem2.o mem3.o
  1176.                rules for making library...
  1177.                # remember to remove .o's when lib is made
  1178.  
  1179.           # equivalent to:  '%.o : %.c ; ...'
  1180.           .c.o :; rules for making .o from .c say
  1181.  
  1182.      dmake will use the .c.o rule for making the library members
  1183.      if appropriate .c files can be found using the search rules.
  1184.      NOTE:  this is not specific in any way to C programs, they
  1185.      are simply used as an example.
  1186.  
  1187.      dmake tries to handle the old library construct format in a
  1188.      sensible way.  The construct lib(member.o) is separated and
  1189.      the lib portion is declared as a library target.  The new
  1190.      target is defined with the .LIBRARY attribute set and the
  1191.      member.o portion of the construct is declared as a prere-
  1192.      quisite of the lib target.  If the construct lib(member.o)
  1193.      appears as a prerequisite of a target in the makefile, that
  1194.      target has the new name of the lib assigned as its prere-
  1195.      quisite.  Thus the following example:
  1196.  
  1197.           a.out : ml.a(a.o) ml.a(b.o); $(CC) -o $@  $<
  1198.  
  1199.           .c.o :; $(CC) -c $(CFLAGS) -o $@  $<
  1200.           %.a:
  1201.                ar rv $@ $?
  1202.                ranlib $@
  1203.                rm -rf $?
  1204.  
  1205.  
  1206.  
  1207.  
  1208. Version 3.9 PL0                 UW                             47
  1209.  
  1210.  
  1211.  
  1212.  
  1213. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1214.  
  1215.  
  1216.  
  1217.      constructs the following dependency graph.
  1218.  
  1219.           a.out : ml.a; $(CC) -o $@  $<
  1220.           ml.a .LIBRARY : a.o b.o
  1221.  
  1222.           %.o : %.c ; $(CC) -c $(CFLAGS) -o $@  $<
  1223.           %.a :
  1224.                ar rv $@ $?
  1225.                ranlib $@
  1226.                rm -rf $?
  1227.  
  1228.      and making a.out then works as expected.
  1229.  
  1230.      The same thing happens for any target of the form
  1231.      lib((entry)).  These targets have an additional feature in
  1232.      that the entry target has the .SYMBOL attribute set automat-
  1233.      ically.
  1234.  
  1235.      NOTE:  If the notion of entry points is supported by the
  1236.      archive and by dmake (currently not the case) then dmake
  1237.      will search the archive for the entry point and return not
  1238.      only the modification time of the member which defines the
  1239.      entry but also the name of the member file.  This name will
  1240.      then replace entry and will be used for making the member
  1241.      file.  Once bound to an archive member the .SYMBOL attribute
  1242.      is removed from the target.  This feature is presently dis-
  1243.      abled as there is little standardization among archive for-
  1244.      mats, and we have yet to find a makefile utilizing this
  1245.      feature (possibly due to the fact that it is unimplemented
  1246.      in most versions of UNIX Make).
  1247.  
  1248.      Finally, when dmake looks for a library member it must first
  1249.      locate the library file.  It does so by first looking for
  1250.      the library relative to the current directory and if it is
  1251.      not found it then looks relative to the current value of
  1252.      $(TMD).  This allows commonly used libraries to be kept near
  1253.      the root of a source tree and to be easily found by dmake.
  1254.  
  1255. KEEP STATE
  1256.      dmake supports the keeping of state information for targets
  1257.      that it makes whenever the macro .KEEP_STATE is assigned a
  1258.      value.  The value of the macro should be the name of a state
  1259.      file that will contain the state information.  If state
  1260.      keeping is enabled then each target that does not poses the
  1261.      .NOSTATE attribute will have a record written into the state
  1262.      file indicating the target's name, the current directory,
  1263.      the command used to update the target, and which, if any, ::
  1264.      rule is being used.  When you make this target again if any
  1265.      of this information does not match the previous settings and
  1266.      the target is not out dated it will still be re-made.  The
  1267.      assumption is that one of the conditions above has changed
  1268.      and that we wish to remake the target.  For example, state
  1269.  
  1270.  
  1271.  
  1272. Version 3.9 PL0                 UW                             48
  1273.  
  1274.  
  1275.  
  1276.  
  1277. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1278.  
  1279.  
  1280.  
  1281.      keeping is used in the maintenance of dmake to test compile
  1282.      different versions of the source using different compilers.
  1283.      Changing the compiler causes the compilation flags to be
  1284.      modified and hence all sources to be recompiled.
  1285.  
  1286.      The state file is an ascii file and is portable, however it
  1287.      is not in human readable form as the entries represent hash
  1288.      keys of the above information.
  1289.  
  1290.      The Sun Microsystem's Make construct
  1291.  
  1292.           .KEEP_STATE :
  1293.  
  1294.      is recognized and is mapped to .KEEP_STATE:=_state.mk.  The
  1295.      dmake version of state keeping does not include scanning C
  1296.      source files for dependencies like Sun Make.  This is
  1297.      specific to C programs and it was felt that it does not
  1298.      belong in make.  dmake instead provides the tool, cdepend,
  1299.      to scan C source files and to produce depedency information.
  1300.      Users are free to modify cdepend to produce other dependency
  1301.      files.  (NOTE: cdepend does not come with the distribution
  1302.      at this time, but will be available in a patch in the near
  1303.      future)
  1304.  
  1305. MULTI PROCESSING
  1306.      If the architecture supports it then dmake is capable of
  1307.      making a target's prerequisites in parallel.  dmake will
  1308.      make as much in parallel as it can and use a number of child
  1309.      processes up to the maximum specified by MAXPROCESS or by
  1310.      the value supplied to the -P command line flag.  A parallel
  1311.      make is enabled by setting the value of MAXPROCESS (either
  1312.      directly or via -P option) to a value which is > 1.  dmake
  1313.      guarantees that all dependencies as specified in the
  1314.      makefile are honored.  A target will not be made until all
  1315.      of its prerequisites have been made.  Note that when you
  1316.      specify -P 4 then four child processes are run concurrently
  1317.      but dmake actually displays the fifth command it will run
  1318.      immediately upon a child process becomming free.  This is an
  1319.      artifact of the method used to traverse the dependency graph
  1320.      and cannot be removed.  If a parallel make is being per-
  1321.      formed then the following restrictions on parallelism are
  1322.      enforced.
  1323.  
  1324.           1.   Individual recipe lines in a non-group recipe are
  1325.                performed sequentially in the order in which they
  1326.                are specified within the makefile and in parallel
  1327.                with the recipes of other targets.
  1328.  
  1329.           2.   If a target contains multiple recipe definitions
  1330.                (cf. :: rules) then these are performed sequen-
  1331.                tially in the order in which the :: rules are
  1332.                specified within the makefile and in parallel with
  1333.  
  1334.  
  1335.  
  1336. Version 3.9 PL0                 UW                             49
  1337.  
  1338.  
  1339.  
  1340.  
  1341. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1342.  
  1343.  
  1344.  
  1345.                the recipes of other targets.
  1346.  
  1347.           3.   If a target rule contains the `!' modifier, then
  1348.                the recipe is performed sequentially for the list
  1349.                of outdated prerequisites and in parallel with the
  1350.                recipes of other targets.
  1351.  
  1352.           4.   If a target has the .SEQUENTIAL attribute set then
  1353.                all of its prerequisites are made sequentially
  1354.                relative to one another (as if MAXPROCESS=1), but
  1355.                in parallel with other targets in the makefile.
  1356.  
  1357.      Note:  If you specify a parallel make then the order of tar-
  1358.      get update and the order in which the associated recipes are
  1359.      invoked will not correspond to that displayed by the -n
  1360.      flag.
  1361.  
  1362. CONDITIONALS
  1363.      dmake supports a makefile construct called a conditional.
  1364.      It allows the user to conditionally select portions of
  1365.      makefile text for input processing and to discard other por-
  1366.      tions.  This becomes useful for writing makefiles that are
  1367.      intended to function for more than one target host and
  1368.      environment.  The conditional expression is specified as
  1369.      follows:
  1370.  
  1371.           .IF  expression
  1372.              ... if text ...
  1373.           .ELIF  expression
  1374.              ... if text ...
  1375.           .ELSE
  1376.              ... else text ...
  1377.           .END
  1378.  
  1379.      The .ELSE and .ELIF portions are optional, and the condi-
  1380.      tionals may be nested (ie.  the text may contain another
  1381.      conditional).  .IF, .ELSE, and .END may appear anywhere in
  1382.      the makefile, but a single conditional expression may not
  1383.      span multiple makefiles.
  1384.  
  1385.      expression can be one of the following three forms:
  1386.  
  1387.           <text> | <text> == <text> | <text> != <text>
  1388.  
  1389.      where text is either text or a macro expression.  In any
  1390.      case, before the comparison is made, the expression is
  1391.      expanded.  The text portions are then selected and compared.
  1392.      White space at the start and end of the text portion is dis-
  1393.      carded before the comparison.  This means that a macro that
  1394.      evaluates to nothing but white space is considered a NULL
  1395.      value for the purpose of the comparison.  In the first case
  1396.      the expression evaluates TRUE if the text is not NULL
  1397.  
  1398.  
  1399.  
  1400. Version 3.9 PL0                 UW                             50
  1401.  
  1402.  
  1403.  
  1404.  
  1405. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1406.  
  1407.  
  1408.  
  1409.      otherwise it evaluates FALSE.  The remaining two cases both
  1410.      evaluate the expression on the basis of a string comparison.
  1411.      If a macro expression needs to be equated to a NULL string
  1412.      then compare it to the value of the macro $(NULL).  You can
  1413.      use the $(shell ...) macro to construct more complex test
  1414.      expressions.
  1415.  
  1416. EXAMPLES
  1417.           # A simple example showing how to use make
  1418.           #
  1419.           prgm : a.o b.o
  1420.                cc a.o b.o -o prgm
  1421.           a.o : a.c g.h
  1422.                cc a.c -o $@
  1423.           b.o : b.c g.h
  1424.                cc b.c -o $@
  1425.  
  1426.      In the previous example prgm is remade only if a.o and/or
  1427.      b.o is out of date with respect to prgm.  These dependencies
  1428.      can be stated more concisely by using the inference rules
  1429.      defined in the standard startup file.  The default rule for
  1430.      making .o's from .c's looks something like this:
  1431.  
  1432.           %.o : %.c; cc -c $(CFLAGS) -o $@ $<
  1433.  
  1434.      Since there exists a rule (defined in the startup file) for
  1435.      making .o's from .c's dmake will use that rule for manufac-
  1436.      turing a .o from a .c and we can specify our dependencies
  1437.      more concisely.
  1438.  
  1439.           prgm : a.o b.o
  1440.                cc -o prgm $<
  1441.           a.o b.o : g.h
  1442.  
  1443.      A more general way to say the above using the new macro
  1444.      expansions would be:
  1445.  
  1446.           SRC = a b
  1447.           OBJ = {$(SRC)}.o
  1448.  
  1449.           prgm : $(OBJ)
  1450.                cc -o $@ $<
  1451.  
  1452.           $(OBJ) : g.h
  1453.  
  1454.      If we want to keep the objects in a separate directory,
  1455.      called objdir, then we would write something like this.
  1456.  
  1457.           SRC = a b
  1458.           OBJ = {$(SRC)}.o
  1459.  
  1460.           prgm : $(OBJ)
  1461.  
  1462.  
  1463.  
  1464. Version 3.9 PL0                 UW                             51
  1465.  
  1466.  
  1467.  
  1468.  
  1469. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1470.  
  1471.  
  1472.  
  1473.                cc $< -o $@
  1474.  
  1475.           $(OBJ) : g.h
  1476.           %.o : %.c
  1477.                $(CC) -c $(CFLAGS) -o $(@:f) $<
  1478.                mv $(@:f) objdir
  1479.  
  1480.           .SOURCE.o : objdir       # tell make to look here for .o's
  1481.  
  1482.      An example of building library members would go something
  1483.      like this: (NOTE:  The same rules as above will be used to
  1484.      produce .o's from .c's)
  1485.  
  1486.           SRC  = a b
  1487.           LIB  = lib
  1488.           LIBm = { $(SRC) }.o
  1489.  
  1490.           prgm: $(LIB)
  1491.                cc -o $@ $(LIB)
  1492.  
  1493.           $(LIB) .LIBRARY : $(LIBm)
  1494.                ar rv $@ $<
  1495.                rm $<
  1496.  
  1497.      Finally, suppose that each of the source files in the previ-
  1498.      ous example had the `:' character in their target name.
  1499.      Then we would write the above example as:
  1500.  
  1501.           SRC  = f:a f:b
  1502.           LIB  = lib
  1503.           LIBm = "{ $(SRC) }.o"         # put quotes around each token
  1504.  
  1505.           prgm: $(LIB)
  1506.                cc -o $@ $(LIB)
  1507.  
  1508.           $(LIB) .LIBRARY : $(LIBm)
  1509.                ar rv $@ $<
  1510.                rm $<
  1511.  
  1512. COMPATIBILITY
  1513.      There are two notable differences between dmake and the
  1514.      standard version of BSD UNIX 4.2/4.3 Make.
  1515.  
  1516.           1. BSD UNIX 4.2/4.3 Make supports wild card filename
  1517.              expansion for prerequisite names.  Thus if a direc-
  1518.              tory contains a.h, b.h and c.h, then a line like
  1519.  
  1520.                   target: *.h
  1521.  
  1522.              will cause UNIX make to expand the *.h into "a.h b.h
  1523.              c.h".  dmake does not support this type of filename
  1524.              expansion.
  1525.  
  1526.  
  1527.  
  1528. Version 3.9 PL0                 UW                             52
  1529.  
  1530.  
  1531.  
  1532.  
  1533. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1534.  
  1535.  
  1536.  
  1537.           2. Unlike UNIX make, touching a library member causes
  1538.              dmake to search the library for the member name and
  1539.              to update the library time stamp.  This is only
  1540.              implemented in the UNIX version.  MSDOS and other
  1541.              versions may not have librarians that keep file time
  1542.              stamps, as a result dmake touches the library file
  1543.              itself, and prints a warning.
  1544.  
  1545.      dmake is not compatible with GNU Make.  In particular it
  1546.      does not understand GNU Make's macro expansions that query
  1547.      the file system.
  1548.  
  1549.      dmake is fully compatible with SYSV AUGMAKE, and supports
  1550.      the following AUGMAKE features:
  1551.  
  1552.           1. The word include appearing at the start of a line
  1553.              can be used instead of the ".INCLUDE :" construct
  1554.              understood by dmake.
  1555.  
  1556.           2. The macro modifier expression $(macro:str=sub) is
  1557.              understood and is equivalent to the expression
  1558.              $(macro:s/str/sub), with the restriction that str
  1559.              must match the following regular expression:
  1560.  
  1561.                   str[ |\t][ |\t]*
  1562.  
  1563.              (ie. str only matches at the end of a token where
  1564.              str is a suffix and is terminated by a space, a tab,
  1565.              or end of line) Normally sub is expanded before the
  1566.              substitution is made, if you specify -A on the com-
  1567.              mand line then sub is not expanded.
  1568.  
  1569.           3. The macro % is defined to be $@ (ie. $% expands to
  1570.              the same value as $@).
  1571.  
  1572.           4. The AUGMAKE notion of libraries is handled
  1573.              correctly.
  1574.  
  1575.           5. When defining special targets for the inference
  1576.              rules and the AUGMAKE special target handling is
  1577.              enabled then the special target .X is equivalent to
  1578.              the %-rule "% : %.X".
  1579.  
  1580.           6. Directories are always made if you specify -A.  This
  1581.              is consistent with other UNIX versions of Make.
  1582.  
  1583.           7. Makefiles that utilize virtual targets to force mak-
  1584.              ing of other targets work as expected if AUGMAKE
  1585.              special target handling is enabled.  For example:
  1586.  
  1587.                   FRC:
  1588.                   myprog.o : myprog.c $(FRC) ; ...
  1589.  
  1590.  
  1591.  
  1592. Version 3.9 PL0                 UW                             53
  1593.  
  1594.  
  1595.  
  1596.  
  1597. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1598.  
  1599.  
  1600.  
  1601.              Works as expected if you issue the command
  1602.  
  1603.                   'dmake -A FRC=FRC'
  1604.  
  1605.              but fails with a 'don't know how to make FRC' error
  1606.              message if you do not specify AUGMAKE special target
  1607.              handling via the -A flag (or by setting AUGMAKE:=yes
  1608.              internally).
  1609.  
  1610. LIMITS
  1611.      In some environments the length of an argument string is
  1612.      restricted.  (e.g. MSDOS command line arguments cannot be
  1613.      longer than 128 bytes if you are using the standard
  1614.      command.com command interpreter as your shell, dmake text
  1615.      diversions may help in these situations.)
  1616.  
  1617. PORTABILITY
  1618.      To write makefiles that can be moved from one environment to
  1619.      another requires some forethought.  In particular you must
  1620.      define as macros all those things that may be different in
  1621.      the new environment.  dmake has two facilities that help to
  1622.      support writing portable makefiles, recursive macros and
  1623.      conditional expressions.  The recursive macros, allow one to
  1624.      define environment configurations that allow different
  1625.      environments for similar types of operating systems.  For
  1626.      example the same make script can be used for SYSV and BSD
  1627.      but with different macro definitions.
  1628.  
  1629.      To write a makefile that is portable between UNIX and MSDOS
  1630.      requires both features since in almost all cases you will
  1631.      need to define new recipes for making targets.  The recipes
  1632.      will probably be quite different since the capabilities of
  1633.      the tools on each machine are different.  Different macros
  1634.      will be needed to help handle the smaller differences in the
  1635.      two environments.
  1636.  
  1637. FILES
  1638.      Makefile, makefile, startup.mk (use dmake -V to tell you
  1639.      where the startup file is)
  1640.  
  1641. SEE ALSO
  1642.      sh(1), csh(1), touch(1), f77(1), pc(1), cc(1)
  1643.      S.I. Feldman  Make - A Program for Maintaining Computer Pro-
  1644.      grams
  1645.  
  1646. AUTHOR
  1647.      Dennis Vadura, CS Dept. University of Waterloo.
  1648.      dvadura@watdragon.uwaterloo.ca
  1649.      Many thanks to Carl Seger for his helpful suggestions, and
  1650.      to Trevor John Thompson for his many excellent ideas and
  1651.      informative bug reports.
  1652.  
  1653.  
  1654.  
  1655.  
  1656. Version 3.9 PL0                 UW                             54
  1657.  
  1658.  
  1659.  
  1660.  
  1661. DMAKE(p)             Unsupported Free Software            DMAKE(p)
  1662.  
  1663.  
  1664.  
  1665. BUGS
  1666.      Some system commands return non-zero status inappropriately.
  1667.      Use -i (`-' within the makefile) to overcome the difficulty.
  1668.  
  1669.      Some systems do not have easily accessible time stamps for
  1670.      library members (MSDOS, AMIGA, etc) for these dmake uses the
  1671.      time stamp of the library instead and prints a warning the
  1672.      first time it does so.  This is almost always ok, except
  1673.      when multiple makefiles update a single library file.  In
  1674.      these instances it is possible to miss an update if one is
  1675.      not careful.
  1676.  
  1677.      This man page is way too long.
  1678.  
  1679. WARNINGS
  1680.      Rules supported by make(1) may not work if transitive clo-
  1681.      sure is turned off (-T, .NOINFER).
  1682.  
  1683.      PWD from csh/ksh will cause problems if a cd operation is
  1684.      performed and -e or -E option is used.
  1685.  
  1686.      Using internal macros such as COMMAND, may wreak havoc if
  1687.      you don't understand their functionality.
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720. Version 3.9 PL0                 UW                             55
  1721.