v20i079: dmake - dmake version 3.7, Patch02d/12

Dennis Vadura dvadura at watdragon.waterloo.edu
Sun Jun 30 08:25:48 AEST 1991


Submitted-by: Dennis Vadura <dvadura at watdragon.waterloo.edu>
Posting-number: Volume 20, Issue 79
Archive-name: dmake/patch02d
Patch-To: dmake: Volume 19, Issue 22-58

#!/bin/sh
# this is dp2.03 (part 3 of a multipart archive)
# do not concatenate these parts, unpack them in order with /bin/sh
# file dm37p2 continued
#
if test ! -r _shar_seq_.tmp; then
	echo 'Please unpack part 1 first!'
	exit 1
fi
(read Scheck
 if test "$Scheck" != 3; then
	echo Please unpack part "$Scheck" next!
	exit 1
 else
	exit 0
 fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
	echo 'x - still skipping dm37p2'
else
echo 'x - continuing file dm37p2'
sed 's/^X//' << 'SHAR_EOF' >> 'dm37p2' &&
XX     ddmmaakkee defines a number of special macros.  They are divided
XX     into three classes: control macros, run-time macros, and
XX     function macros.  The control macros are used by ddmmaakkee to
XX     configure its actions, and are the preferred method of doing
XX     so.  In the case when a control macro has the same function
XX     as a special target or attribute they share the same name as
XX     the special target or attribute.  The run-time macros are
XX     defined when ddmmaakkee makes targets and may be used by the user
XX     inside recipes.  The function macros provide higher level
XX     functions dealing with macro expansion and diversion file
XX     processing.
XX
XCCOONNTTRROOLL MMAACCRROOSS
XX     To use the control macros simply assign them a value just
XX     like any other macro.  The control macros are divided into
XX     three groups: string valued macros, character valued macros,
XX     and boolean valued macros.
XX
XX     The following are all of the string valued macros.  This
XX     list is divided into two groups.  The first group gives the
XX     string valued macros that are defined internally and cannot
XX     be directly set by the user.
XX
XX     DDIIRRBBRRKKSSTTRR     Contains the string of chars used to terminate
XX                   the name of a directory in a pathname.  Under
XX                   UNIX its value is "/", under MSDOS its value
XX                   is "/\:".
XX
XX     IINNCCDDEEPPTTHH      This macro's value is a string of digits
XX                   representing the current depth of makefile
XX                   inclusion.  In the first makefile level this
XX                   value is zero.
XX
XX     MMFFLLAAGGSS        Is the list of flags that were given on the
XX                   command line including a leading switch char-
XX                   acter.  The -f flag is not included in this
XX                   list.
XX
XX     MMAAKKEECCMMDD       Is the name with which ddmmaakkee was invoked.
XX
XX     MMAAKKEEDDIIRR       Is the full path to the initial directory in
XX                   which ddmmaakkee was invoked.
XX
XX     MMAAKKEEFFIILLEE      Contains the string "-f _m_a_k_e_f_i_l_e" where,
XX                   _m_a_k_e_f_i_l_e is the name of initial user makefile
XX                   that was first read.
XX
XX
XX
XVersion 3.70                    UW                             25
XX
XX
XX
XX
XDMAKE(p)             Unsupported Free Software            DMAKE(p)
XX
XX
XX
XX     MMAAKKEEFFLLAAGGSS     Is the same as $(MFLAGS) but has no leading
XX                   switch character. (ie. MFLAGS = -$(MAKEFLAGS))
XX
XX     MMAAKKEEMMAACCRROOSS    Contains the complete list of macro expres-
XX                   sions that were specified on the command line.
XX
XX     MMAAKKEETTAARRGGEETTSS   Contains the name(s) of the target(s), if any,
XX                   that were specified on the command line.
XX
XX     MMAAXXPPRROOCCEESSSSLLIIMMIITT
XX                   Is a numeric string representing the maximum
XX                   number of processes that ddmmaakkee can use when
XX                   making targets using parallel mode.
XX
XX     NNUULLLL          Is permanently defined to be the NULL string.
XX                   This is useful when comparing a conditional
XX                   expression to an NULL value.
XX
XX     PPWWDD           Is the full path to the current directory in
XX                   which make is executing.
XX
XX     TTMMPPFFIILLEE       Is set to the name of the most recent tem-
XX                   porary file opened by ddmmaakkee.  Temporary files
XX                   are used for text diversions and for group
XX                   recipe processing.
XX
XX     TTMMDD           Stands for "To Make Dir", and is the path from
XX                   the present directory (value of $(PWD)) to the
XX                   directory that ddmmaakkee was started up in (value
XX                   of $(MAKEDIR)).  This macro is modified when
XX                   .SETDIR attributes are processed.
XX
XX     UUSSEESSHHEELLLL      The value of this macro is set to "yes" if the
XX                   current recipe is forced to use a shell for
XX                   its execution via the .USESHELL or '+' direc-
XX                   tives, its value is "no" otherwise.
XX
XX
XX     The second group of string valued macros control ddmmaakkee
XX     behavior and may be set by the user.
XX
XX     ..NNOOTTAABBSS         When set to non-NULL enables the use of
XX                     spaces as well as <tabs> to begin recipe
XX                     lines.  By default a non-group recipe is
XX                     terminated by a line without any leading
XX                     white-space or by a line not beggining with
XX                     a <tab> character.  Enabling this mode modi-
XX                     fies the first condition of the above termi-
XX                     nation rule to terminate a non-group recipe
XX                     with a line that contains only white-space.
XX                     This mode does not effect the parsing of
XX                     group recipes bracketed by [].
XX
XX
XX
XVersion 3.70                    UW                             26
XX
XX
XX
XX
XDMAKE(p)             Unsupported Free Software            DMAKE(p)
XX
XX
XX
XX     ..SSEETTDDIIRR         If this macro is assigned a value then ddmmaakkee
XX                     will change to the directory given by that
XX                     value before making any targets.
XX
XX     AAUUGGMMAAKKEE         If set to a non NULL value will enable the
XX                     transformation of special meta targets to
XX                     support special AUGMAKE inferences (See the
XX                     COMPATIBILITY section).
XX
XX     DDIIRRSSEEPPSSTTRR       Contains the string that is used to separate
XX                     directory components when path names are
XX                     constructed.  It is defined with a default
XX                     value at startup.
XX
XX     DDIIVVFFIILLEE         Is defined in the startup file and gives the
XX                     name that should be returned for the diver-
XX                     sion file name when used in $(mktmp ...)
XX                     expansions, see the TEXT DIVERSION section
XX                     for details.
XX
XX     ..KKEEEEPP__SSTTAATTEE     Assigning this macro a value tells ddmmaakkee the
XX                     name of the state file to use and turns on
XX                     the keeping of state information for any
XX                     targets that are brought up to date by the
XX                     make.
XX
XX     GGRROOUUPPFFLLAAGGSS      This macro gives the set of flags to pass to
XX                     the shell when invoking it to execute a
XX                     group recipe.  The value of the macro is the
XX                     list of flags with a leading switch indica-
XX                     tor.  (ie. `-' under UNIX)
XX
XX     GGRROOUUPPSSHHEELLLL      This macro defines the full path to the exe-
XX                     cutable image to be used as the shell when
XX                     processing group recipes.  This macro must
XX                     be defined if group recipes are used.  It is
XX                     assigned a default value in the startup
XX                     makefile.  Under UNIX this value is /bin/sh.
XX
XX     GGRROOUUPPSSUUFFFFIIXX     If defined, this macro gives the string to
XX                     use as a suffix when creating group recipe
XX                     files to be handed to the command inter-
XX                     preter.  For example, if it is defined as
XX                     .sh, then all temporary files created by
XX                     ddmmaakkee will end in the suffix .sh.  Under
XX                     MSDOS if you are using command.com as your
XX                     GROUPSHELL, then this suffix must be set to
XX                     .bat in order for group recipes to function
XX                     correctly.  The setting of GROUPSUFFIX and
XX                     GROUPSHELL is done automatically for
XX                     command.com in the startup.mk files.
XX
XX
XX
XX
XVersion 3.70                    UW                             27
XX
XX
XX
XX
XDMAKE(p)             Unsupported Free Software            DMAKE(p)
XX
XX
XX
XX     MMAAKKEE            Is defined in the startup file by default.
XX                     The string $(MAKE) is recognized when using
XX                     the -n option for single line recipes.  Ini-
XX                     tially this macro is defined to have the
XX                     value "$(MAKECMD) $(MFLAGS)".
XX
XX     MMAAKKEESSTTAARRTTUUPP     This macro defines the full path to the ini-
XX                     tial startup makefile.  Use the --VV command
XX                     line option to discover its initial value.
XX
XX     MMAAXXLLIINNEELLEENNGGTTHH   This macro defines the maximum size of a
XX                     single line of makefile input text.  The
XX                     size is specified as a number, the default
XX                     value is defined internally and is shown via
XX                     the --VV option.  A buffer of this size plus 2
XX                     is allocated for reading makefile text.  The
XX                     buffer is freed before any targets are made,
XX                     thereby allowing files containing long input
XX                     lines to be processed without consuming
XX                     memory during the actual make.
XX
XX     MMAAXXPPRROOCCEESSSS      Specify the maximum number of child
XX                     processes to use when making targets.  The
XX                     default value of this macro is "1" and its
XX                     value cannot exceed the value of the macro
XX                     MAXPROCESSLIMIT.  Setting the value of MAX-
XX                     PROCESS on the command line or in the
XX                     makefile is equivalent to supplying a
XX                     corresponding value to the -P flag on the
XX                     command line.
XX
XX     PPRREEPP            This macro defines the number of iterations
XX                     to be expanded automatically when processing
XX                     % rule definitions of the form:
XX
XX                     % : %.suff
XX
XX                     See the sections on PERCENT(%) RULES for
XX                     details on how PREP is used.
XX
XX     SSHHEELLLL           This macro defines the full path to the exe-
XX                     cutable image to be used as the shell when
XX                     processing single line recipes.  This macro
XX                     must be defined if recipes requiring the
XX                     shell for execution are to be used.  It is
XX                     assigned a default value in the startup
XX                     makefile.  Under UNIX this value is /bin/sh.
XX
XX     SSHHEELLLLFFLLAAGGSS      This macro gives the set of flags to pass to
XX                     the shell when invoking it to execute a sin-
XX                     gle line recipe.  The value of the macro is
XX                     the list of flags with a leading switch
XX
XX
XX
XVersion 3.70                    UW                             28
XX
XX
XX
XX
XDMAKE(p)             Unsupported Free Software            DMAKE(p)
XX
XX
XX
XX                     indicator.  (ie. `-' under UNIX)
XX
XX     SSHHEELLLLMMEETTAASS      Each time ddmmaakkee executes a single recipe
XX                     line (not a group recipe) the line is
XX                     searched for any occurrence of a character
XX                     defined in the value of SHELLMETAS.  If such
XX                     a character is found the recipe line is
XX                     defined to require a shell to ensure its
XX                     correct execution.  In such instances a
XX                     shell is used to invoke the recipe line.  If
XX                     no match is found the recipe line is exe-
XX                     cuted without the use of a shell.
XX
XX
XX     There is only one character valued macro defined by ddmmaakkee:
XX     SSWWIITTCCHHAARR contains the switch character used to introduce
XX     options on command lines.  For UNIX its value is `-', and
XX     for MSDOS its value may be `/' or `-'.  The macro is inter-
XX     nally defined and is not user setable.  The MSDOS version of
XX     ddmmaakkee attempts to first extract SWITCHAR from an environment
XX     variable of the same name.  If that fails it then attempts
XX     to use the undocumented getswitchar system call, and returns
XX     the result of that.  Under MSDOS version 4.0 you must set
XX     the value of the environment macro SWITCHAR to '/' to obtain
XX     predictable behavior.
XX
XX     All boolean macros currently understood by ddmmaakkee correspond
XX     directly to the previously defined attributes.  These macros
XX     provide a second way to apply global attributes, and
XX     represent the preferred method of doing so.  They are used
XX     by assigning them a value.  If the value is not a NULL
XX     string then the boolean condition is set to on.  If the
XX     value is a NULL string then the condition is set to off.
XX     There are five conditions defined and they correspond
XX     directly to the attributes of the same name.  Their meanings
XX     are defined in the ATTRIBUTES section above.  The macros
XX     are: ..EEPPIILLOOGG, ..IIGGNNOORREE, ..MMKKSSAARRGGSS, ..NNOOIINNFFEERR, ..PPRREECCIIOOUUSS, ..PPRROO----
XX     LLOOGG, ..SSEEQQUUEENNTTIIAALL, ..SSIILLEENNTT, ..SSWWAAPP, and ..UUSSEESSHHEELLLL.  Assigning
XX     any of these a non NULL value will globally set the
XX     corresponding attribute to on.
XX
XRRUUNN__TTIIMMEE MMAACCRROOSS
XX     These macros are defined when ddmmaakkee is making targets, and
XX     may take on different values for each target.  $$@@ is defined
XX     to be the full target name, $$?? is the list of all out of
XX     date prerequisites, $$&& is the list of all prerequisites, $$>>
XX     is the name of the library if the current target is a
XX     library member, and $$<< is the list of prerequisites speci-
XX     fied in the current rule.  If the current target had a
XX     recipe inferred then $$<< is the name of the inferred prere-
XX     quisite even if the target had a list of prerequisites sup-
XX     plied using an explicit rule that did not provide a recipe.
XX
XX
XX
XVersion 3.70                    UW                             29
XX
XX
XX
XX
XDMAKE(p)             Unsupported Free Software            DMAKE(p)
XX
XX
XX
XX     In such situations $$&& gives the full list of prerequisites.
XX
XX     $$** is defined as $$((@@::ddbb)) when making targets with explicit
XX     recipes and is defined as the value of % when making targets
XX     whose recipe is the result of an inference.  In the first
XX     case $$** is the target name with no suffix, and in the second
XX     case, is the value of the matched % pattern from the associ-
XX     ated %-rule.  $$^^ expands to the set of out of date prere-
XX     quisites taken from the current value of $$<<.  In addition to
XX     these, $$$$ expands to $, {{{{ expands to {, }}}} expands to },
XX     and the strings <<++ and ++>> are recognized as respectively
XX     starting and terminating a text diversion when they appear
XX     literally together in the same input line.
XX
XX     The difference between $? and $^ can best be illustrated by
XX     an example, consider:
XX
XX          fred.out : joe amy hello
XX               rules for making fred
XX
XX          fred.out : my.c your.h his.h her.h   # more prerequisites
XX
XX     Assume joe, amy, and my.c are newer then fred.out.  When
XX     ddmmaakkee executes the recipe for making fred.out the values of
XX     the following macros will be:
XX
XX          $@ --> fred.out
XX          $* --> fred
XX          $? --> joe amy my.c  # note the difference between $? and $^
XX          $^ --> joe amy
XX          $< --> joe amy hello
XX          $& --> joe amy hello my.c your.h his.h her.h
XX
XX
XFFUUNNCCTTIIOONN MMAACCRROOSS
XX     ddmmaakkee supports a full set of functional macros.  One of
XX     these, the $(mktmp ...) macro, is discussed in detail in the
XX     TEXT DIVERSION section and is not covered here.
XX
XX
XX          $(nnuullll,_t_e_x_t ttrruuee ffaallssee)
XX               expands the value of _t_e_x_t_. If it is NULL then the
XX               macro returns the value of the expansion of ttrruuee
XX               and the expansion of ffaallssee otherwise.  The terms
XX               ttrruuee, and ffaallssee must be strings containing no
XX               white-space.
XX
XX          $(!!nnuullll,_t_e_x_t ttrruuee ffaallssee)
XX               Behaves identically to the previous macro except
XX               that the ttrruuee string is chosen if the expansion of
XX               _t_e_x_t is not NULL.
XX
XX
XX
XX
XVersion 3.70                    UW                             30
XX
XX
XX
XX
XDMAKE(p)             Unsupported Free Software            DMAKE(p)
XX
XX
XX
XX          $(eeqq,_t_e_x_t___a,_t_e_x_t___b ttrruuee ffaallssee)
XX               expands _t_e_x_t___a and _t_e_x_t___b and compares their
XX               results.  If equal it returns the result of the
XX               expansion of the ttrruuee term, otherwise it returns
XX               the expansion of the ffaallssee term.
XX
XX          $(!!eeqq,_t_e_x_t___a,_t_e_x_t___b ttrruuee ffaallssee)
XX               Behaves identically to the previous macro except
XX               that the ttrruuee string is chosen if the expansions
XX               of the two strings are not equal
XX
XX          $(sshheellll ccoommmmaanndd)
XX               Runs _c_o_m_m_a_n_d as if it were part of a recipe and
XX               returns, separated by a single space, all the
XX               non-white space terms written to stdout by the
XX               command.  For example:
XX
XX                    $(shell ls *.c)
XX
XX               will return _"_a_._c _b_._c _c_._c _d_._c_" if the files exist
XX               in the current directory.  The recipe modification
XX               flags [[++@@%%--]] are honored if they appear as the
XX               first characters in the command.  For example:
XX
XX                    $(shell +ls *.c)
XX
XX               will run the command using the current shell.
XX
XX          $(ssoorrtt lliisstt)
XX               Will take all white-space separated tokens in _l_i_s_t
XX               and will return their sorted equivalent list.
XX
XX          $(ssttrriipp ddaattaa)
XX               Will replace all strings of white-space in data by
XX               a single space.
XX
XX          $(ssuubbsstt,_p_a_t,_r_e_p_l_a_c_e_m_e_n_t ddaattaa)
XX               Will search for _p_a_t in ddaattaa and will replace any
XX               occurrence of _p_a_t with the _r_e_p_l_a_c_e_m_e_n_t string.
XX               The expansion
XX
XX                    $(subst,.o,.c $(OBJECTS))
XX
XX               is equivalent to:
XX
XX                    $(OBJECTS:s/.o/.c/)
XX
XX
XDDYYNNAAMMIICC PPRREERREEQQUUIISSIITTEESS
XX     ddmmaakkee looks for prerequisites whose names contain macro
XX     expansions during target processing.  Any such prerequisites
XX     are expanded and the result of the expansion is used as the
XX
XX
XX
XVersion 3.70                    UW                             31
XX
XX
XX
XX
XDMAKE(p)             Unsupported Free Software            DMAKE(p)
XX
XX
XX
XX     prerequisite name.  As an example the line:
XX
XX          fred : $$@.c
XX
XX     causes the $$@ to be expanded when ddmmaakkee is making fred, and
XX     it resolves to the target _f_r_e_d.  This enables dynamic prere-
XX     quisites to be generated.  The value of @ may be modified by
XX     any of the valid macro modifiers.  So you can say for exam-
XX     ple:
XX
XX          fred.out : $$(@:b).c
XX
XX     where the $$(@:b) expands to _f_r_e_d.  Note the use of $$
XX     instead of $ to indicate the dynamic expansion, this is due
XX     to the fact that the rule line is expanded when it is ini-
XX     tially parsed, and $$ then returns $ which later triggers
XX     the dynamic prerequisite expansion.  If you really want a $
XX     to be part of a prerequisite name you must use $$$$.
XX     Dynamic macro expansion is performed in all user defined
XX     rules, and the special targets .SOURCE*, and .INCLUDEDIRS.
XX
XBBIINNDDIINNGG TTAARRGGEETTSS
XX     This operation takes a target name and binds it to an exist-
XX     ing file, if possible.  ddmmaakkee makes a distinction between
XX     the internal target name of a target and its associated
XX     external file name.  Thus it is possible for a target's
XX     internal name and its external file name to differ.  To per-
XX     form the binding, the following set of rules is used.
XX     Assume that we are trying to bind a target whose name is of
XX     the form _X_._s_u_f_f, where _._s_u_f_f is the suffix and _X is the stem
XX     portion (ie. that part which contains the directory and the
XX     basename).  ddmmaakkee takes this target name and performs a
XX     series of search operations that try to find a suitably
XX     named file in the external file system.  The search opera-
XX     tion is user controlled via the settings of the various
XX     .SOURCE targets.
XX
XX          1.   If target has the .SYMBOL attribute set then look
XX               for it in the library.  If found, replace the tar-
XX               get name with the library member name and continue
XX               with step 2.  If the name is not found then
XX               return.
XX
XX          2.   Extract the suffix portion (that following the
XX               `.') of the target name.  If the suffix is not
XX               null, look up the special target .SOURCE.<suff>
XX               (<suff> is the suffix). If the special target
XX               exists then search each directory given in the
XX               .SOURCE.<suff> prerequisite list for the target.
XX               If the target's suffix was null (ie. _._s_u_f_f was
XX               empty) then perform the above search but use the
XX               special target .SOURCE.NULL instead.  If at any
XX
XX
XX
XVersion 3.70                    UW                             32
XX
XX
XX
XX
XDMAKE(p)             Unsupported Free Software            DMAKE(p)
XX
XX
XX
XX               point a match is found then terminate the search.
XX               If a directory in the prerequisite list is the
XX               special name `.NULL ' perform a search for the
XX               full target name without prepending any directory
XX               portion (ie. prepend the NULL directory).  (a
XX               default target of '.SOURCE : .NULL' is defined by
XX               ddmmaakkee at startup, and is user redefinable)
XX
XX          3.   The search in step 2. failed.  Repeat the same
XX               search but this time use the special target
XX               .SOURCE.
XX
XX          4.   The search in step 3. failed.  If the target has
XX               the library member attribute (.LIBMEMBER) set then
XX               try to find the target in the library which was
XX               passed along with the .LIBMEMBER attribute (see
XX               the MAKING LIBRARIES section).  The bound file
XX               name assigned to a target which is successfully
XX               located in a library is the same name that would
XX               be assigned had the search failed (see 5.).
XX
XX          5.   The search failed.  Either the target was not
XX               found in any of the search directories or no
XX               applicable .SOURCE special targets exist.  If
XX               applicable .SOURCE special targets exist, but the
XX               target was not found, then ddmmaakkee assigns the first
XX               name searched as the bound file name.  If no
XX               applicable .SOURCE special targets exist, then the
XX               full original target name becomes the bound file
XX               name.
XX
XX     There is potential here for a lot of search operations.  The
XX     trick is to define .SOURCE.x special targets with short
XX     search lists and leave .SOURCE as short as possible.  The
XX     search algorithm has the following useful side effect.  When
XX     a target having the .LIBMEMBER (library member) attribute is
XX     searched for, it is first searched for as an ordinary file.
XX     When a number of library members require updating it is
XX     desirable to compile all of them first and to update the
XX     library at the end in a single operation.  If one of the
XX     members does not compile and ddmmaakkee stops, then the user may
XX     fix the error and make again.  ddmmaakkee will not remake any of
XX     the targets whose object files have already been generated
XX     as long as none of their prerequisite files have been modi-
XX     fied as a result of the fix.
XX
XX     When defining .SOURCE and .SOURCE.x targets the construct
XX
XX          .SOURCE :
XX          .SOURCE : fred gery
XX
XX     is equivalent to
XX
XX
XX
XVersion 3.70                    UW                             33
XX
XX
XX
XX
XDMAKE(p)             Unsupported Free Software            DMAKE(p)
XX
XX
XX
XX          .SOURCE :- fred gery
XX
XX     ddmmaakkee correctly handles the UNIX Make variable VPATH.  By
XX     definition VPATH contains a list of ':' separated direc-
XX     tories to search when looking for a target.  ddmmaakkee maps
XX     VPATH to the following special rule:
XX
XX          .SOURCE :^ $(VPATH:s/:/ /)
XX
XX     Which takes the value of VPATH and sets .SOURCE to the same
XX     set of directories as specified in VPATH.
XX
XPPEERRCCEENNTT((%%)) RRUULLEESS AANNDD MMAAKKIINNGG IINNFFEERREENNCCEESS
XX     When ddmmaakkee makes a target, the target's set of prerequisites
XX     (if any) must exist and the target must have a recipe which
XX     ddmmaakkee can use to make it.  If the makefile does not specify
XX     an explicit recipe for the target then ddmmaakkee uses special
XX     rules to try to infer a recipe which it can use to make the
XX     target.  Previous versions of Make perform this task by
XX     using rules that are defined by targets of the form
XX     .<suffix>.<suffix> and by using the .SUFFIXES list of suf-
XX     fixes.  The exact workings of this mechanism were sometimes
XX     difficult to understand and often limiting in their useful-
XX     ness.  Instead, ddmmaakkee supports the concept of _%_-_m_e_t_a rules.
XX     The syntax and semantics of these rules differ from standard
XX     rule lines as follows:
XX
XX          _<_%_-_t_a_r_g_e_t_> [_<_a_t_t_r_i_b_u_t_e_s_>] _<_r_u_l_e_o_p_> [_<_%_-_p_r_e_r_e_q_u_i_s_i_t_e_s_>] [;_<_r_e_c_i_p_e_>]
XX
XX     where _%_-_t_a_r_g_e_t is a target containing exactly a single `%'
XX     sign, _a_t_t_r_i_b_u_t_e_s is a list (possibly empty) of attributes,
XX     _r_u_l_e_o_p is the standard set of rule operators, _%_-_p_r_e_r_e_-
XX     _q_u_i_s_i_t_e_s , if present, is a list of prerequisites containing
XX     zero or more `%' signs, and _r_e_c_i_p_e_, if present, is the first
XX     line of the recipe.
XX
XX     The _%_-_t_a_r_g_e_t defines a pattern against which a target whose
XX     recipe is being inferred gets matched.  The pattern match
XX     goes as follows:  all chars are matched exactly from left to
XX     right up to but not including the % sign in the pattern, %
XX     then matches the longest string from the actual target name
XX     not ending in the suffix given after the % sign in the pat-
XX     tern.  Consider the following examples:
XX
XX          %.c       matches fred.c but not joe.c.Z
XX          dir/%.c   matches dir/fred.c but not dd/fred.c
XX          fred/%    matches fred/joe.c but not f/joe.c
XX          %         matches anything
XX
XX     In each case the part of the target name that matched the %
XX     sign is retained and is substituted for any % signs in the
XX     prerequisite list of the %-meta rule when the rule is
XX
XX
XX
XVersion 3.70                    UW                             34
XX
XX
XX
XX
XDMAKE(p)             Unsupported Free Software            DMAKE(p)
XX
XX
XX
XX     selected during inference and ddmmaakkee constructs the new
XX     dependency.  As an example the following %-meta rules
XX     describe the following:
XX
XX          %.c : %.y ; recipe...
XX
XX     describes how to make any file ending in .c if a correspond-
XX     ing file ending in .y can be found.
XX
XX          foo%.o : fee%.k ; recipe...
XX
XX     is used to describe how to make fooxxxx.o from feexxxx.k.
XX
XX          %.a :; recipe...
XX
XX     describes how to make a file whose suffix is .a without
XX     inferring any prerequisites.
XX
XX          %.c : %.y yaccsrc/%.y ; recipe...
XX
XX     is a short form for the construct:
XX
XX          %.c : %.y ; recipe...
XX          %.c : yaccsrc/%.y ; recipe...
XX
XX     ie. It is possible to specify the same recipe for two
XX     %-rules by giving more than one prerequisite in the prere-
XX     quisite list.  A more interesting example is:
XX
XX          % : RCS/%,v ; co $@
XX
XX     which describes how to take any target and check it out of
XX     the RCS directory if the corresponding file exists in the
XX     RCS directory.  The equivalent SCCS rule would be:
XX
XX          % : s.% ; get $@
XX
XX
XX     The previous RCS example defines an infinite rule, because
XX     it says how to make _a_n_y_t_h_i_n_g from RCS/%,v, and _a_n_y_t_h_i_n_g also
XX     includes RCS/fred.c,v.  To limit the size of the graph that
XX     results from such rules ddmmaakkee uses the macro variable PREP
XX     (stands for % repetition).  By default the value of this
XX     variable is 0, which says that no repetitions of a %-rule
XX     are to be generated.  If it is set to something greater than
XX     0, then that many repetitions of any infinite %-rule are
XX     allowed.  If in the above example PREP was set to 1, then
XX     ddmmaakkee would generate the dependency graph:
XX
XX          % --> RCS/%,v --> RCS/RCS/%,v,v
XX
XX     Where each link is assigned the same recipe as the first
XX
XX
XX
XVersion 3.70                    UW                             35
XX
XX
XX
XX
XDMAKE(p)             Unsupported Free Software            DMAKE(p)
XX
XX
XX
XX     link.  PREP should be used only in special cases, since it
XX     may result in a large increase in the number of possible
XX     prerequisites tested.  ddmmaakkee further assumes that any target
XX     that has no suffix can be made from a prerequisite that has
XX     at least one suffix.
XX
XX     ddmmaakkee supports dynamic prerequisite generation for prere-
XX     quisites of %-meta rules.  This is best illustrated by an
XX     example.  The RCS rule shown above can infer how to check
XX     out a file from a corresponding RCS file only if the target
XX     is a simple file name with no directory information.  That
XX     is, the above rule can infer how to find _R_C_S_/_f_r_e_d_._c_,_v from
XX     the target _f_r_e_d_._c, but cannot infer how to find
XX     _s_r_c_d_i_r_/_R_C_S_/_f_r_e_d_._c_,_v from _s_r_c_d_i_r_/_f_r_e_d_._c because the above
XX     rule will cause ddmmaakkee to look for RCS/srcdir/fred.c,v; which
XX     does not exist (assume that srcdir has its own RCS directory
XX     as is the common case).
XX
XX     A more versatile formulation of the above RCS check out rule
XX     is the following:
XX
XX          % :  $$(@:d)RCS/$$(@:f),v : co $@
XX
XX     This rule uses the dynamic macro $@ to specify the prere-
XX     quisite to try to infer.  During inference of this rule the
XX     macro $@ is set to the value of the target of the %-meta
XX     rule and the appropriate prerequisite is generated by
XX     extracting the directory portion of the target name (if
XX     any), appending the string _R_C_S_/ to it, and appending the
XX     target file name with a trailing _,_v attached to the previous
XX     result.
XX
XX     ddmmaakkee can also infer indirect prerequisites.  An inferred
XX     target can have a list of prerequisites added that will not
XX     show up in the value of $< but will show up in the value of
XX     $? and $&.  Indirect prerequisites are specified in an
XX     inference rule by quoting the prerequisite with single
XX     quotes.  For example, if you had the explicit dependency:
XX
XX          fred.o : fred.c ; rule to make fred.o
XX          fred.o : local.h
XX
XX     then this can be inferred for fred.o from the following
XX     inference rule:
XX
XX          %.o : %.c 'local.h' ; rule to make a .o from a .c
XX
XX     You may infer indirect prerequisites that are a function of
XX     the value of '%' in the current rule.  The meta-rule:
XX
XX          %.o : %.c '$(INC)/%.h' ; rule to make a .o from a .c
XX
XX
XX
XX
XVersion 3.70                    UW                             36
XX
XX
XX
XX
XDMAKE(p)             Unsupported Free Software            DMAKE(p)
XX
XX
XX
XX     infers an indirect prerequisite found in the INC directory
XX     whose name is the same as the expansion of $(INC), and the
XX     prerequisite name depends on the base name of the current
XX     target.  The set of indirect prerequisites is attached to
XX     the meta rule in which they are specified and are inferred
XX     only if the rule is used to infer a recipe for a target.
XX     They do not play an active role in driving the inference
XX     algorithm.  The construct:
XX
XX          %.o : %.c %.f 'local.h'; recipe
XX
XX     is equivalent to:
XX
XX          %.o : %.c 'local.h' : recipe
XX          %.o : %.f 'local.h' : recipe
XX
XX
XX     If any of the attributes .SETDIR, .EPILOG, .PROLOG, .SILENT,
XX     .USESHELL, .SWAP, .PRECIOUS, .LIBRARY, .NOSTATE and .IGNORE
XX     are given for a %-rule then when that rule is bound to a
XX     target as the result of an inference, the target's set of
XX     attributes is augmented by the attributes from the above set
XX     that are specified in the bound %-rule.  Other attributes
XX     specified for %-meta rules are not inherited by the target.
XX     The .SETDIR attribute is treated in a special way.  If the
XX     target already had a .SETDIR attribute set then ddmmaakkee
XX     changes to that directory prior to performing the inference.
XX     During inference any .SETDIR attributes for the inferred
XX     prerequisite are honored.  The directories must exist for a
XX     %-meta rule to be selected as a possible inference path.  If
XX     the directories do not exist no error message is issued,
XX     instead the corresponding path in the inference graph is
XX     rejected.
XX
XX     ddmmaakkee also supports the old format special target
XX     .<suffix>.<suffix> by identifying any rules of this form and
XX     mapping them to the appropriate %-rule.  So for example if
XX     an old makefile contains the construct:
XX
XX          .c.o :; cc -c $< -o $@
XX
XX     ddmmaakkee maps this into the following %-rule:
XX
XX          %.o : %.c; cc -c $< -o $@
XX
XX     Furthermore, ddmmaakkee understands several SYSV AUGMAKE special
XX     targets and maps them into corresponding %-meta rules.
XX     These transformation must be enabled by providing the -A
XX     flag on the command line or by setting the value of AUGMAKE
XX     to non-NULL.  The construct
XX
XX          .suff :; recipe
XX
XX
XX
XVersion 3.70                    UW                             37
XX
XX
XX
XX
XDMAKE(p)             Unsupported Free Software            DMAKE(p)
XX
XX
XX
XX     gets mapped into:
XX
XX          % : %.suff; recipe
XX
XX     and the construct
XX
XX          .c~.o :; recipe
XX
XX     gets mapped into:
XX
XX          %.o : s.%.c ; recipe
XX
XX     In general, a special target of the form .<str>~ is replaced
XX     by the %-rule construct s.%.<str>, thereby providing support
XX     for the syntax used by SYSV AUGMAKE for providing SCCS sup-
XX     port.  When enabled, these mappings allow processing of
XX     existing SYSV makefiles without modifications.
XX
XX     ddmmaakkee bases all of its inferences on the inference graph
XX     constructed from the %-rules defined in the makefile.  It
XX     knows exactly which targets can be made from which prere-
XX     quisites by making queries on the inference graph.  For this
XX     reason .SUFFIXES is not needed and is completely ignored.
XX
XX     For a %-meta rule to be inferred as the rule whose recipe
XX     will be used to make a target, the target's name must match
XX     the %-target pattern, and any inferred %-prerequisite must
XX     already exist or have an explicit recipe so that the prere-
SHAR_EOF
true || echo 'restore of dm37p2 failed'
fi
echo 'End of  part 3'
echo 'File dm37p2 is continued in part 4'
echo 4 > _shar_seq_.tmp
exit 0

exit 0 # Just in case...
-- 
Kent Landfield                   INTERNET: kent at sparky.IMD.Sterling.COM
Sterling Software, IMD           UUCP:     uunet!sparky!kent
Phone:    (402) 291-8300         FAX:      (402) 291-4362
Please send comp.sources.misc-related mail to kent at uunet.uu.net.



More information about the Comp.sources.misc mailing list