home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-07-26 | 39.3 KB | 1,134 lines |
- Newsgroups: comp.sources.misc
- subject: v14i024: dmake version 3.5 part 14/21
- From: dvadura@watdragon.waterloo.edu (Dennis Vadura)
- Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 14, Issue 24
- Submitted-by: dvadura@watdragon.waterloo.edu (Dennis Vadura)
- Archive-name: dmake/part14
-
- #!/bin/sh
- # this is part 14 of a multipart archive
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file man/dmake.nc continued
- #
- CurArch=14
- if test ! -r s2_seq_.tmp
- then echo "Please unpack part 1 first!"
- exit 1; fi
- ( read Scheck
- if test "$Scheck" != $CurArch
- then echo "Please unpack part $Scheck next!"
- exit 1;
- else exit 0; fi
- ) < s2_seq_.tmp || exit 1
- echo "x - Continuing file man/dmake.nc"
- sed 's/^X//' << 'SHAR_EOF' >> man/dmake.nc
- X when that rule is bound to a target as the result of an
- X inference, the target's set of attributes is augmented by
- X the attributes from the above set that are specified in the
- X bound %-rule. Other attributes specified for %-meta rules
- X are not inherited by the target. The .SETDIR attribute is
- X treated in a special way. If the target already had a .SET-
- X DIR attribute set and the bound %-rule also specified a
- X .SETDIR attribute then the one originally specified with the
- X target prevails. During inference any .SETDIR attributes
- X for the inferred prerequisite are honored. The directories
- X must exist for a %-meta rule to be selected as a possible
- X inference path. If the directories do not exist no error
- X message is issued, instead the corresponding path in the
- X inference graph is simply rejected.
- X
- X dmake also supports the old format special target
- X .<suffix>.<suffix> by identifying any rules of this form and
- X mapping them to the appropriate %-rule. So for example if
- X an old makefile contains the construct:
- X
- X .c.o :; cc -c $< -o $@
- X
- X dmake maps this into the following %-rule:
- X
- X %.o : %.c; cc -c $< -o $@
- X
- X Furthermore, dmake understands several SYSV AUGMAKE special
- X targets and maps them into corresponding %-meta rules.
- X These transformation must be enabled by providing the -A
- X flag on the command line or by setting the value of AUGMAKE
- X to non NULL. The construct
- X
- X .suff :; recipe
- X
- X gets mapped into:
- X
- X
- X
- X
- XVersion 3.50 UW 31
- X
- X
- X
- X
- XDMAKE(p) Unsupported Software DMAKE(p)
- X
- X
- X
- X % : %.suff; recipe
- X
- X and the construct
- X
- X .c~.o :; recipe
- X
- X gets mapped into:
- X
- X %.o : s.%.c ; recipe
- X
- X In general, a special target of the form .<str>~ is replaced
- X by the %-rule construct s.%.<str>, thereby providing support
- X for the syntax used by SYSV AUGMAKE for providing SCCS sup-
- X port. When enabled, these mappings allow to processing of
- X existing SYSV makefiles without modifications.
- X
- X dmake bases all of it's inferences on the inference graph
- X constructed from the %-rules defined in the makefile. It
- X knows exactly which targets can be made from which prere-
- X quisites by making queries on the inference graph. For this
- X reason .SUFFIXES is not needed and is completely ignored.
- X
- X For a %-meta rule to be inferred as the rule whose recipe
- X will be used to make a target, the target's name must match
- X the %-target pattern, and any inferred %-prerequisite must
- X already exist or have an explicit recipe so that the prere-
- X quisite can be made. Without transitive closure on the
- X inference graph the above rule describes precisely when an
- X inference match terminates the search. If transitive clo-
- X sure is enabled (the usual case), and a prerequisite does
- X not exist or cannot be made, then dmake invokes the infer-
- X ence algorithm recursively on the prerequisite to see if
- X there is some way the prerequisite can be manufactured. For
- X if the prerequisite can be made then the current target can
- X also be made using the current %-meta rule. This means that
- X there is no longer a need to give a rule for making a .o
- X from a .y if you have already given a rule for making a .o
- X from a .c and a .c from a .y. In such cases dmake can infer
- X how to make the .o from the .y via the intermediary .c and
- X will remove the .c when the .o is made. Transitive closure
- X can be disabled by giving the -T switch on the command line.
- X
- X A word of caution. dmake bases its transitive closure on
- X the %-meta rule targets. When it performs transitive clo-
- X sure it infers how to make a target from a prerequisite by
- X performing a pattern match as if the potential prerequisite
- X were a new target. The set of rules:
- X
- X %.o : %.c :; rule for making .o from .c
- X %.c : %.y :; rule for making .c from .y
- X % : RCS/%,v :; check out of RCS file
- X
- X
- X
- X
- XVersion 3.50 UW 32
- X
- X
- X
- X
- XDMAKE(p) Unsupported Software DMAKE(p)
- X
- X
- X
- X will, by performing transitive closure, allow dmake to infer
- X how to make a .o from a .y using a .c as an intermediate
- X temporary file. Additionally it will be able to infer how
- X to make a .y from an RCS file, as long as that RCS file is
- X in the RCS directory and has a name which ends in .y,v. The
- X transitivity computation is performed dynamically for each
- X target that does not have a recipe. This has potential to
- X be very slow if the %-meta rules are not carefully speci-
- X fied. The .NOINFER attribute is used to mark a %-meta node
- X as being a final target during inference. Any node with
- X this attribute set will not be used for subsequent infer-
- X ences. As an example the node RCS/%,v is marked as a final
- X node since we know that if the RCS file does not exist there
- X likely is no other way to make it. Thus the standard
- X startup makefile contains the entry:
- X .NOINFER : RCS/%,v
- X Thereby indicating that the RCS file is the end of the
- X inference chain.
- X
- X dmake tries to remove intermediate files resulting from
- X transitive closure if the file is not marked as being PRE-
- X CIOUS, or the -u flag was not given on the command line, and
- X if the inferred intermediate did not previously exist.
- X Intermediate targets that existed prior to being made are
- X never removed. This is in keeping with the philosophy that
- X dmake should never remove things from the file system that
- X it did not add. If the special target .REMOVE is defined
- X and has a recipe then dmake constructs a list of the inter-
- X mediate files to be removed and makes them prerequisites of
- X .REMOVE. It then makes .REMOVE thereby removing the prere-
- X quisites if the recipe of .REMOVE says to. Typically
- X .REMOVE is defined in the startup file as:
- X
- X ".REMOVE :; $(RM) $<".
- X
- XMAKING TARGETS
- X In order to update a target dmake must execute a recipe.
- X When a recipe needs to be executed it is first expanded so
- X that any macros in the recipe text are expanded, and it is
- X then either executed directly or passed to a shell. dmake
- X supports two types of recipes. The regular recipes and
- X group recipes.
- X
- X When a regular recipe is invoked dmake executes each line of
- X the recipe separately using a new copy of a shell if a shell
- X is required. Thus effects of commands do not generally per-
- X sist across recipe lines. (e.g. cd requests in a recipe
- X line do not carry over to the next recipe line) The decision
- X on whether a shell is required to execute a command is based
- X on the value of the macro SHELLMETAS. If any character in
- X the value of SHELLMETAS is found in the expanded recipe
- X text-line then the command is executed using a shell,
- X
- X
- X
- XVersion 3.50 UW 33
- X
- X
- X
- X
- XDMAKE(p) Unsupported Software DMAKE(p)
- X
- X
- X
- X otherwise the command is executed directly. The shell that
- X is used for execution is given by the value of the macro
- X SHELL. The flags that are passed to the shell are given by
- X the value of SHELLFLAGS. Thus dmake constructs the command
- X line:
- X
- X $(SHELL) $(SHELLFLAGS) $(expanded_recipe_command)
- X
- X Normally dmake writes the command line that it is about to
- X invoke to standard output. If the .SILENT attribute is set
- X for the target or for the recipe line (via @), then the
- X recipe line is not echoed.
- X
- X Group recipe processing is similar to that of regular
- X recipes, except that a shell is always invoked. The shell
- X that is invoked is given by the value of the macro GROUP-
- X SHELL, and its flags are taken from the value of the macro
- X GROUPFLAGS. If a target has the .PROLOG attribute set then
- X dmake prepends to the shell script the recipe associated
- X with the special target .GROUPPROLOG, and if the attribute
- X .EPILOG is set as well, then the recipe associated with the
- X special target .GROUPEPILOG is appended to the script file.
- X This facility can be used to always prepend a common header
- X and common trailer to group recipes. Group recipes are
- X echoed to standard output just like standard recipes, but
- X are enclosed by lines beginning with [ and ].
- X
- XMAKING LIBRARIES
- X Libraries are easy to maintain using dmake. A library is a
- X file containing a collection of object files. Thus to make
- X a library you simply specify it as a target with the
- X .LIBRARY attribute set and specify its list of prere-
- X quisites. The prerequisites should be the object members
- X that are to go into the library. When dmake makes the
- X library target it uses the .LIBRARY attribute to pass to the
- X prerequisites the .LIBMEMBER attribute and the name of the
- X library. This enables the file binding mechanism to look
- X for the member in the library if an appropriate object file
- X cannot be found. A small example best illustrates this.
- X
- X mylib.a .LIBRARY : mem1.o mem2.o mem3.o
- X rules for making library...
- X # remember to remove .o's when lib is made
- X
- X # equivalent to: '%.o : %.c ; ...'
- X .c.o :; rules for making .o from .c say
- X
- X dmake will use the .c.o rule for making the library members
- X if appropriate .c files can be found using the search rules.
- X NOTE: this is not specific in any way to C programs, they
- X are simply used as an example.
- X
- X
- X
- X
- XVersion 3.50 UW 34
- X
- X
- X
- X
- XDMAKE(p) Unsupported Software DMAKE(p)
- X
- X
- X
- X dmake tries to handle the old library construct format in a
- X sensible way. The construct lib(member.o) is separated and
- X the lib portion is declared as a library target. The new
- X target is defined with the .LIBRARY attribute set and the
- X member.o portion of the construct is declared as a prere-
- X quisite of the lib target. If the construct lib(member.o)
- X appears as a prerequisite of a target in the makefile, that
- X target has the new name of the lib assigned as it's prere-
- X quisite. Thus the following example:
- X
- X a.out : ml.a(a.o) ml.a(b.o); $(CC) -o $@ $<
- X
- X .c.o :; $(CC) -c $(CFLAGS) -o $@ $<
- X %.a:
- X ar rv $@ $<
- X ranlib $@
- X rm -rf $<
- X
- X constructs the following dependency graph.
- X
- X a.out : ml.a; $(CC) -o $@ $<
- X ml.a .LIBRARY : a.o b.o
- X
- X %.o : %.c ; $(CC) -c $(CFLAGS) -o $@ $<
- X %.a :
- X ar rv $@ $<
- X ranlib $@
- X rm -rf $<
- X
- X and making a.out then works as expected.
- X
- X The same thing happens for any target of the form
- X lib((entry)). These targets have an additional feature in
- X that the entry target has the .SYMBOL attribute set automat-
- X ically.
- X
- X NOTE: If the notion of entry points is supported by the
- X archive and by dmake (currently not the case) then dmake
- X will search the archive for the entry point and return not
- X only the modification time of the member which defines the
- X entry but also the name of the member file. This name will
- X then replace entry and will be used for making the member
- X file. Once bound to an archive member the .SYMBOL attribute
- X is removed from the target. This feature is presently dis-
- X abled as there is little standardization among archive for-
- X mats, and we have yet to find a makefile utilizing this
- X feature (possibly due to the fact that it is unimplemented
- X in most versions of UNIX Make).
- X
- XMULTI PROCESSING
- X If the architecture supports it then dmake is capable of
- X making a target's prerequisites in parallel. dmake will
- X
- X
- X
- XVersion 3.50 UW 35
- X
- X
- X
- X
- XDMAKE(p) Unsupported Software DMAKE(p)
- X
- X
- X
- X make as much in parallel as it can and use a number of child
- X processes up to the maximum specified by MAXPROCESS or by
- X the value supplied to the -P command line flag. A parallel
- X make is enabled by setting the value of MAXPROCESS (either
- X directly or via -P option) to a value which is > 1. dmake
- X guarantees that all dependencies as specified in the
- X makefile are honored. A target will not be made until all
- X of its prerequisites have been made. If a parallel make is
- X being performed then the following restrictions on parallel-
- X ism are enforced.
- X
- X 1. Individual recipe lines in a non-group recipe are
- X performed sequentially in the order in which they
- X are specified within the makefile and in parallel
- X with the recipes of other targets.
- X
- X 2. If a target contains multiple recipe definitions
- X (cf. :: rules) then these are performed sequen-
- X tially in the order in which the :: rules are
- X specified within the makefile and in parallel with
- X the recipes of other targets.
- X
- X 3. If a target rule contains the `!' modifier, then
- X the recipe is performed sequentially for the list
- X of outdated prerequisites and in parallel with the
- X recipes of other targets.
- X
- X 4. If a target has the .SEQUENTIAL attribute set then
- X all of its prerequisites are made sequentially
- X relative to one another (as if MAXPROCESS=1), but
- X in parallel with other targets in the makefile.
- X
- X Note: If you specify a parallel make then the order of tar-
- X get update and the order in which the associated recipes are
- X invoked will not correspond to that displayed by the -n
- X flag.
- X
- XCONDITIONALS
- X dmake supports a makefile construct called a conditional.
- X It allows the user to conditionally select portions of
- X makefile text for input processing and to discard other por-
- X tions. This becomes useful for writing makefiles that are
- X intended to function for more than one target host and
- X environment. The conditional expression is specified as
- X follows:
- X
- X .IF expression
- X ... if text ...
- X .ELSE
- X ... else text ...
- X .END
- X
- X
- X
- X
- XVersion 3.50 UW 36
- X
- X
- X
- X
- XDMAKE(p) Unsupported Software DMAKE(p)
- X
- X
- X
- X The .ELSE portion is optional, and the conditionals may be
- X nested (ie. the text may contain another conditional).
- X .IF, .ELSE, and .END may appear anywhere in the makefile,
- X but a single conditional expression may not span multiple
- X makefiles.
- X
- X expression can be one of the following three forms:
- X
- X <text> | <text> == <text> | <text> != <text>
- X
- X where text is either text or a macro expression. In any
- X case, before the comparison is made, the expression is
- X expanded. The text portions are then selected and compared.
- X White space at the start and end of the text portion is dis-
- X carded before the comparison. This means that a macro that
- X evaluates to nothing but white space is considered a NULL
- X value for the purpose of the comparison. In the first case
- X the expression evaluates TRUE if the text is not NULL other-
- X wise it evaluates FALSE. The remaining two cases both
- X evaluate the expression on the basis of a string comparison.
- X If a macro expression needs to be equated to a NULL string
- X then compare it to the value of the macro $(NULL).
- X
- XEXAMPLES
- X # A simple example showing how to use make
- X #
- X prgm : a.o b.o
- X cc a.o b.o -o prgm
- X a.o : a.c g.h
- X cc a.c -o $@
- X b.o : b.c g.h
- X cc b.c -o $@
- X
- X In the previous example prgm is remade only if a.o and/or
- X b.o is out of date with respect to prgm. These dependencies
- X can be stated more concisely by using the inference rules
- X defined in the standard startup file. The default rule for
- X making .o's from .c's looks something like this:
- X
- X %.o : %.c; cc -c $(CFLAGS) -o $@ $<
- X
- X Since there exists a rule (defined in the startup file) for
- X making .o's from .c's dmake will use that rule for manufac-
- X turing a .o from a .c and we can specify our dependencies
- X more concisely.
- X
- X prgm : a.o b.o
- X cc -o prgm $<
- X a.o b.o : g.h
- X
- X A more general way to say the above using the new macro
- X expansions would be:
- X
- X
- X
- XVersion 3.50 UW 37
- X
- X
- X
- X
- XDMAKE(p) Unsupported Software DMAKE(p)
- X
- X
- X
- X SRC = a b
- X OBJ = {$(SRC)}.o
- X
- X prgm : $(OBJ)
- X cc -o $@ $<
- X
- X $(OBJ) : g.h
- X
- X If we want to keep the objects in a separate directory,
- X called objdir, then we would write something like this.
- X
- X SRC = a b
- X OBJ = {$(SRC)}.o
- X
- X prgm : $(OBJ)
- X cc $< -o $@
- X
- X $(OBJ) : g.h
- X %.o : %.c
- X $(CC) -c $(CFLAGS) -o $(@:f) $<
- X mv $(@:f) objdir
- X
- X .SOURCE.o : objdir # tell make to look here for .o's
- X
- X An example of building library members would go something
- X like this: (NOTE: The same rules as above will be used to
- X produce .o's from .c's)
- X
- X SRC = a b
- X LIB = lib
- X LIBm = { $(SRC) }.o
- X
- X prgm: $(LIB)
- X cc -o $@ $(LIB)
- X
- X $(LIB) .LIBRARY : $(LIBm)
- X ar rv $@ $<
- X rm $<
- X
- X Finally, suppose that each of the source files in the previ-
- X ous example had the `:' character in their target name.
- X Then we would write the above example as:
- X
- X SRC = f:a f:b
- X LIB = lib
- X LIBm = "{ $(SRC) }.o" # put quotes around each token
- X
- X prgm: $(LIB)
- X cc -o $@ $(LIB)
- X
- X $(LIB) .LIBRARY : $(LIBm)
- X ar rv $@ $<
- X
- X
- X
- XVersion 3.50 UW 38
- X
- X
- X
- X
- XDMAKE(p) Unsupported Software DMAKE(p)
- X
- X
- X
- X rm $<
- X
- XCOMPATIBILITY
- X There are two notable differences between dmake and the
- X standard version of BSD UNIX 4.2/4.3 Make.
- X
- X 1. BSD UNIX 4.2/4.3 Make supports wild card filename
- X expansion for prerequisite names. Thus if a direc-
- X tory contains a.h, b.h and c.h, then a line like
- X
- X target: *.h
- X
- X will cause UNIX make to expand the *.h into "a.h b.h
- X c.h". dmake does not support this type of filename
- X expansion.
- X
- X 2. Unlike UNIX make, touching a library member causes
- X dmake to search the library for the member name and
- X to update the library time stamp. This is only
- X implemented in the UNIX version. MSDOS and other
- X versions may not have librarians that keep file time
- X stamps, as a result dmake touches the library file
- X itself, and prints a warning.
- X
- X dmake is not compatible with GNU Make. In particular it
- X does not understand GNU Make's macro expansions that query
- X the file system.
- X
- X dmake is fully compatible with SYSV AUGMAKE, and supports
- X the following AUGMAKE features:
- X
- X 1. The word include appearing at the start of a line
- X can be used instead of the ".INCLUDE :" construct
- X understood by dmake.
- X
- X 2. The macro modifier expression $(macro:str=sub) is
- X understood and is equivalent to the expression
- X $(macro:s/str/sub), with the restriction that str
- X must match the following regular expression:
- X
- X str[ |\t][ |\t]*
- X
- X (ie. str only matches at the end of a token where
- X str is a suffix and is terminated by a space, a tab,
- X or end of line)
- X
- X 3. The macro % is defined to be $@ (ie. $% expands to
- X the same value as $@).
- X
- X 4. The AUGMAKE notion of libraries is handled
- X correctly.
- X
- X
- X
- X
- XVersion 3.50 UW 39
- X
- X
- X
- X
- XDMAKE(p) Unsupported Software DMAKE(p)
- X
- X
- X
- X 5. When defining special targets for the inference
- X rules and the AUGMAKE special target mapping is
- X enabled then the special target .X is equivalent to
- X the %-rule "% : %.X".
- X
- XLIMITS
- X In some environments the length of an argument string is
- X restricted. (e.g. MSDOS command line arguments cannot be
- X longer than 128 bytes if you are using the standard
- X command.com command interpreter as your shell, dmake text
- X diversions may help in these situations.)
- X
- XPORTABILITY
- X To write makefiles that can be moved from one environment to
- X another requires some forethought. In particular you must
- X define as macros all those things that may be different in
- X the new environment. dmake has two facilities that help to
- X support writing portable makefiles, recursive macros and
- X conditional expressions. The recursive macros, allow one to
- X define environment configurations that allow different
- X environments for similar types of operating systems. For
- X example the same make script can be used for SYSV and BSD
- X but with different macro definitions.
- X
- X To write a makefile that is portable between UNIX and MSDOS
- X requires both features since in almost all cases you will
- X need to define new recipes for making targets. The recipes
- X will probably be quite different since the capabilities of
- X the tools on each machine are different. Different macros
- X will be needed to help handle the smaller differences in the
- X two environments.
- X
- X NOTE: Unlike UNIX, MSDOS does maintain cd requests cross
- X single recipe lines. This is not portable, and your
- X makefiles will not work the same way if you depend on it.
- X Use the .IF ... .ELSE ... .END conditionals to supply dif-
- X ferent make scripts as necessary.
- X
- XFILES
- X Makefile, makefile, startup.mk (use dmake -V to tell you
- X where the startup file is)
- X
- XSEE ALSO
- X sh(1), csh(1), touch(1), f77(1), pc(1), cc(1)
- X S.I. Feldman Make - A Program for Maintaining Computer Pro-
- X grams
- X
- XAUTHOR
- X Dennis Vadura, CS Dept. University of Waterloo.
- X dvadura@watdragon.uwaterloo.ca
- X Many thanks to Carl Seger for his helpful suggestions, and
- X to Trevor John Thompson for his many excellent ideas and
- X
- X
- X
- XVersion 3.50 UW 40
- X
- X
- X
- X
- XDMAKE(p) Unsupported Software DMAKE(p)
- X
- X
- X
- X informative bug reports.
- X
- XBUGS
- X Some system commands return non-zero status inappropriately.
- X Use -i (`-' within the makefile) to overcome the difficulty.
- X
- X Some systems do not have easily accessible time stamps for
- X library members (MSDOS, AMIGA, etc) for these dmake uses the
- X time stamp of the library instead and prints a warning the
- X first time it does so. This is almost always ok, except
- X when multiple makefiles update a single library file. In
- X these instances it is possible to miss an update if one is
- X not careful.
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- XVersion 3.50 UW 41
- SHAR_EOF
- echo "File man/dmake.nc is complete"
- chmod 0640 man/dmake.nc || echo "restore of man/dmake.nc fails"
- echo "x - extracting makefile (Text)"
- sed 's/^X//' << 'SHAR_EOF' > makefile &&
- X# Default makefile for the various versions of dmake that we
- X# have available. This is a bootstrap version and uses /bin/sh to
- X# execute a script which compiles dmake.
- X#
- X# Note the DOS commands actually invoke command.com to run the .bat file
- X# to make the script.
- X
- Xall:
- X @echo "You must issue one of:"
- X @echo " make bsd43uw - Generic BSD 4.3 at U of Waterloo"
- X @echo " make bsd43 - Generic BSD 4.3"
- X @echo " make sysvr3 - Generic SysV R3 UNIX"
- X @echo " make dynix - Sequent DYNIX system"
- X @echo " make tccdos - DOS with tcc 2.0"
- X @echo " make 386ix - 386/ix (SysV R3) [NOTE: not tested]"
- X @echo " make mscdos - DOS with MSC 4.0 [NOTE: not tested]"
- X
- Xbsd43uw :; /bin/sh -x < unix/bsd43/uw/make.sh
- Xdynix :; /bin/sh -x < unix/bsd43/dynix/make.sh
- Xsysvr3 bsd43 386ix :; /bin/sh -x < unix/$@/make.sh
- X
- X# DOS with some form of make and sh
- X# Note if you do not have a 'make and/or sh' program under MSDOS then
- X# typing 'make' in the dmake distribution directory will invoke the make.bat
- X# batch file which will issue the appropriate instructions.
- Xmscdos tccdos :; make.bat $@
- SHAR_EOF
- chmod 0440 makefile || echo "restore of makefile fails"
- echo "x - extracting makefile.mk (Text)"
- sed 's/^X//' << 'SHAR_EOF' > makefile.mk &&
- X# //// Makefile for DMAKE. \\\\
- X# The target system is characterized by the following macros imported from
- X# the environment.
- X#
- X# OS - gives the class of operating system
- X# OSRELEASE - optionally gives the particular release of the OS above.
- X# OSENVIRONMENT - optionally gives the environment under which the above
- X# OS is in use.
- X#
- X# Valid values for the above macros are:
- X#
- X# OS - unix, msdos
- X# OSRELEASE - bsd43, sysvr3, 386ix
- X# - tccdos, mscdos (valid only of OS == msdos)
- X# OSENVIRONMENT - uw {valid for unix, bsd43 configuration only.}
- X# dynix (valid for unix, bsd43 configuration only.)
- X#
- X# See the config.mk file in the relevant subdirectories for additional
- X# comments describing when a setting is applicable.
- X
- X# First target in the makefile, do this so that targets declared in the
- X# included files are never marked as being the first *default* target.
- Xfirst : all ;
- X
- X# Pull in the configuration macros, from the environment. OS is required,
- X# OSRELEASE, and OSENVIRONMENT are optional.
- X.IMPORT : OS
- X.IMPORT .IGNORE : OSRELEASE OSENVIRONMENT TMPDIR
- X
- X# Define the source files
- XSRC =\
- X infer.c make.c stat.c expand.c string.c hash.c dag.c dmake.c\
- X path.c imacs.c sysintf.c parse.c getinp.c quit.c\
- X basename.c dump.c macparse.c rulparse.c percent.c
- X
- X# Common Include files.
- XHDR = dmake.h extern.h struct.h vextern.h patchlvl.h version.h
- X
- X# Define the TARGET we are making, and where the OBJECT files go.
- XOBJDIR := objects
- XTARGET = dmake$E
- XCFLAGS += -DHELP -I. -Icommon
- X
- X# Pull in the proper configuration file, based on the value of OS.
- X.INCLUDE : $(OS)/config.mk
- X
- X# Set the .SOURCE targets so that we look for things in the right place.
- X.SOURCE.c :^ .NULL
- X.SOURCE.h :^ .NULL
- X.SOURCE$O :^ $(OBJDIR)
- X.PRECIOUS : $(HDR)
- X
- X# Must come after the above INCLUDE so that it gets ALL objects.
- XOBJECTS := {$(SRC:b)}$O
- X
- X# The main target, make sure the objects directory exists first.
- X# LDARGS is defined in config.mk file of each OS/OSRELEASE combination.
- Xall : $(TARGET);
- X$(TARGET) : $(OBJDIR)
- X$(TARGET) : $(OBJECTS); $(LD) $(LDARGS)
- X
- X# Other obvious targets...
- X$(OBJDIR):;- mkdir $@
- X
- X# Meta rule for making .o's from .c's (give our own so we can move object
- X# to objects directory in a portable, compiler independent way)
- X%$O: %.c
- X $(CC) -c $(CFLAGS) $<
- X mv $(@:f) $(OBJDIR)
- X
- X# remaining dependencies should be automatically generated
- Xsysintf$O : $(OS)/sysintf.h
- X$(OBJECTS) : $(HDR)
- X.SOURCE.h : common
- X
- X# Define the macros for printing the source, and pull in the
- X# makefile portion.
- XPRINTEXCLUDE = $(OBJDIR) $(OBJDIR).dbg test RCS control man common
- X.INCLUDE : common/print.mk
- X
- Xclean:; $(RM) -rf dmake dbdmake objects*
- X
- X
- X#--------------------------------------------------------------------------
- X# Make the various archives for shipping the thing around.
- X#
- Xzoo : dmake.zoo ;
- Xshar : dmake.shar;
- Xtar : dmake.tar;
- Xunzoo : dmake.zoo ; zoo xO// dmake.zoo
- Xdmake.zoo .SILENT: src-list
- X[
- X echo "" >> $<
- X echo -n '$@ : $$(ALLSRC);@ zoo aI $$@ < ' >> $<
- X echo -n '<' >> $<
- X echo -n '+' >> $<
- X echo -n '$$(ALLSRC:t"\n")\n' >> $<
- X echo -n '+' >> $<
- X echo '>' >> $<
- X $(MAKECMD) -f $< $@
- X $(RM) -f $<
- X]
- X
- Xdmake.shar .SILENT : src-list-shar
- X[
- X echo '$@:$$(ALLSRC) ;xshar -vc -o$@ -l40 $$(ALLSRC)' >> $<
- X $(MAKECMD) -f $< $@
- X $(RM) -f $<
- X]
- X
- Xdmake.tar .SILENT : src-list
- X[
- X echo '$@:$$(ALLSRC) ;tar -cvf $@ $$(ALLSRC)' >> $<
- X $(MAKECMD) -f $< $@
- X $(RM) -f $<
- X]
- X
- Xsrc-list .SILENT: clean
- X echo 'ALLSRC = \' >$@
- X find . -type f -print |\
- X sed -e 's/RCS\///' -e 's/,v//' -e 's/$$/\\/' -e 's/^\.\// /'|\
- X sort -u |\
- X grep -v tst | grep -v $@ | grep -v LICENSE |\
- X grep -v '\.zoo' | grep -v '\.tar'| grep -v '\.shar' >> $@
- X echo ' LICENSE' >> $@
- X
- Xsrc-list-shar .SILENT: clean
- X echo 'ALLSRC = \' >$@
- X find . -print |\
- X sed -e 's/RCS\///' -e 's/,v//' -e 's/$$/\\/' -e 's/^\.\// /'|\
- X sort -ur |\
- X grep -v tst | grep -v $@ | grep -v LICENSE | grep -v RCS |\
- X grep -v '^\.\\$$' | grep -v '\.zoo' | grep -v '\.tar'|\
- X grep -v '\.shar' >> $@
- X echo ' LICENSE' >> $@
- X
- X
- X#--------------------------------------------------------------------------
- X# This section can be used to make the necessary script files so that dmake
- X# can be bootstrapped.
- X#
- X# dmake scripts -- makes all the script files at once.
- X#
- XSH = $(@:s,-,/,:s/scripts/${SCRIPTFILE})
- XMS = MAKESTARTUP=$(@:s,-,/,:s/scripts/startup.mk)
- X
- Xscripts: unix-scripts msdos-scripts
- X
- X# To add a new environment for UNIX, simply create the appropriate entry
- X# in the style below for the macro which contains the OS, OSRELEASE and
- X# OSENVIRONMENT flags. Then add the entry as a recipe line for the target
- X# unix-scripts.
- X#
- Xunix-bsd43-scripts-flags = OS=unix OSRELEASE=bsd43 OSENVIRONMENT=
- Xunix-sysvr3-scripts-flags = OS=unix OSRELEASE=sysvr3 OSENVIRONMENT=
- Xunix-386ix-scripts-flags = OS=unix OSRELEASE=386ix OSENVIRONMENT=
- Xunix-bsd43-uw-scripts-flags = OS=unix OSRELEASE=bsd43 OSENVIRONMENT=uw
- Xunix-bsd43-dynix-scripts-flags = OS=unix OSRELEASE=bsd43 OSENVIRONMENT=dynix
- X
- Xunix-scripts:
- X $(MAKE) SCRIPTFILE=make.sh unix-bsd43-scripts
- X $(MAKE) SCRIPTFILE=make.sh unix-bsd43-uw-scripts
- X $(MAKE) SCRIPTFILE=make.sh unix-bsd43-dynix-scripts
- X $(MAKE) SCRIPTFILE=make.sh unix-sysvr3-scripts
- X $(MAKE) SCRIPTFILE=make.sh unix-386ix-scripts
- X
- Xunix-%-scripts:; $(MAKECMD) -nus $(MS) $($@-flags) >$(SH)
- X
- X# We make the standard dos scripts here, but we have to go and fix up the
- X# make.bat file since it contains names of temporary files for the response
- X# files required by the linker. We need to also construct the response file
- X# contents. These two functions are performed by the fix-msdos-%-scripts
- X# meta-target.
- X#
- X# To add a new DOS environment just do what is described for adding a new
- X# unix environment, and then make certain that the fix-msdos-%-scripts target
- X# performs the correct function for the new environment.
- Xmsdos-tccdos-scripts-flags = OS=msdos OSRELEASE=tccdos OSENVIRONMENT=
- Xmsdos-mscdos-scripts-flags = OS=msdos OSRELEASE=mscdos OSENVIRONMENT=
- X
- Xmsdos-scripts:
- X $(MAKE) SCRIPTFILE=make.bat msdos-tccdos-scripts
- X $(MAKE) SCRIPTFILE=make.bat msdos-mscdos-scripts
- X
- Xmsdos-%-scripts:
- X $(MAKE) -nus $(MS) $($@-flags) >$(SH)
- X $(MAKE) -s $(MAKEMACROS) $(MS) $($@-flags) fix-msdos-$*-scripts
- X
- XOBJRSP = $(SH:s,fix/,,:s,${SCRIPTFILE},${*:s/dos/obj/}.rsp,)
- XLIBRSP = $(SH:s,fix/,,:s,${SCRIPTFILE},${*:s/dos/lib/}.rsp,)
- XDOSOBJ = $(CSTARTUP) $(OBJDIR)/{$(OBJECTS)}
- Xfix-msdos-%-scripts:
- X sed -e 's,/tmp/mkA..[0-9]*,$(SH:s,fix/,,:d)$(*:s/dos/obj).rsp,'\
- X -e 's,/tmp/mkB..[0-9]*,$(SH:s,fix/,,:d)$(*:s/dos/lib).rsp,'\
- X -e 's,/,\\,g' <$(SH:s,fix/,,) >tmp-out
- X mv -f tmp-out $(SH:s,fix/,,)
- X mv <+$(DOSOBJ:s,/,\\,:t"+\n")\n+> $(OBJRSP)
- X mv <+$(LDLIBS:s,/,\\,:t"+\n")\n+> $(LIBRSP)
- SHAR_EOF
- chmod 0640 makefile.mk || echo "restore of makefile.mk fails"
- echo "x - extracting make.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > make.c &&
- X/* RCS -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/make.c,v 1.1 90/07/20 16:53:12 dvadura Exp $
- X-- SYNOPSIS -- perform the update of all outdated targets.
- X--
- X-- DESCRIPTION
- X-- This is where we traverse the make graph looking for targets that
- X-- are out of date, and we try to infer how to make them if we can.
- X-- The usual make macros are understood, as well as some new ones:
- X--
- X-- $$ - expands to $
- X-- $@ - full target name
- X-- $* - target name with no suffix, same as $(@:db)
- X-- or, the value of % in % meta rule recipes
- X-- $? - list of out of date prerequisites
- X-- $< - all prerequisites associated with rules line
- X-- $& - all prerequisites associated with target
- X-- $> - library name for target (if any)
- X-- $^ - out of date prerequisites taken from value of $<
- X-- {{ - expands to {
- X-- }} - expands to }
- X-- \# - expands to #
- X--
- X-- AUTHOR
- X-- Dennis Vadura, dvadura@watdragon.uwaterloo.ca
- X-- CS DEPT, University of Waterloo, Waterloo, Ont., Canada
- X--
- X-- COPYRIGHT
- X-- Copyright (c) 1990 by Dennis Vadura. All rights reserved.
- X--
- X-- This program is free software; you can redistribute it and/or
- X-- modify it under the terms of the GNU General Public License
- X-- (version 1), as published by the Free Software Foundation, and
- X-- found in the file 'LICENSE' included with this distribution.
- X--
- X-- This program is distributed in the hope that it will be useful,
- X-- but WITHOUT ANY WARRANTY; without even the implied warrant of
- X-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X-- GNU General Public License for more details.
- X--
- X-- You should have received a copy of the GNU General Public License
- X-- along with this program; if not, write to the Free Software
- X-- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X--
- X-- LOG
- X-- $Log: make.c,v $
- X * Revision 1.1 90/07/20 16:53:12 dvadura
- X * Initial Revision of Version 3.5
- X *
- X*/
- X
- X#include "extern.h"
- X#include "alloc.h"
- X#include "db.h"
- X
- Xstatic int _exec_commands ANSI((CELLPTR, HOWPTR));
- Xstatic void _drop_mac ANSI((HASHPTR));
- Xstatic void _print_cmnd ANSI((char*, int, int));
- Xstatic void _set_recipe ANSI((char*, int));
- Xstatic void _set_tmd ANSI(());
- Xstatic void _append_line ANSI((char*, int, FILE*, char*, int));
- Xstatic void _append_file ANSI((STRINGPTR, FILE*, char*, int));
- Xstatic void _add_here ANSI((char*, FILE*, int));
- X
- X#define RP_GPPROLOG 0
- X#define RP_RECIPE 1
- X#define RP_GPEPILOG 2
- X#define NUM_RECIPES 3
- X
- Xstatic STRINGPTR _recipes[ NUM_RECIPES ];
- Xstatic CELLPTR Root; /* root cell for make graph */
- X
- X
- X
- Xint
- XMake_targets()/*
- X================
- X Actually go and make the targets on the target list */
- X{
- X LINKPTR lp;
- X int done = 0;
- X
- X DB_ENTER( "Make_targets" );
- X
- X /* Make sure the graph gets blown up for .SETDIR targets.
- X * Only required for architectures that support parallel
- X * makes. */
- X Explode_prq( Fringe_hd, NIL(CELL), FALSE );
- X
- X _set_recipe( ".GROUPPROLOG", RP_GPPROLOG );
- X _set_recipe( ".GROUPEPILOG", RP_GPEPILOG );
- X
- X while( !done ) {
- X done = F_MADE;
- X for( lp = Fringe_hd; lp != NIL(LINK); lp = lp->cl_next ) {
- X int rval = 0;
- X
- X Root = lp->cl_prq;
- X if( (rval |= Make(Root, Root->CE_HOW, NIL(CELL))) == -1 )
- X DB_RETURN(1);
- X else
- X done &= (Root->ce_flag & F_MADE);
- X
- X if( !rval && !done ) Wait_for_child( FALSE, -1 );
- X }
- X }
- X
- X for( lp = Fringe_hd; lp != NIL(LINK); lp = lp->cl_next ) {
- X Root = lp->cl_prq;
- X if( !(Root->ce_attr & A_UPDATED) )
- X printf( "`%s' is up to date\n", Root->CE_NAME );
- X }
- X
- X DB_RETURN( 0 );
- X}
- X
- X
- X
- Xint
- XMake( cp, how, setdirroot )/*
- X============================= Make a specified target */
- XCELLPTR cp;
- XHOWPTR how;
- XCELLPTR setdirroot;
- X{
- X register LINKPTR dp;
- X register CELLPTR tcp;
- X char *name, *lib;
- X HASHPTR m_at = NIL(HASH);
- X char *all = NIL(char);
- X char *inf = NIL(char);
- X char *outall = NIL(char);
- X char *imm = NIL(char);
- X int rval = 0;
- X int push = 0;
- X time_t otime = (time_t) 1L;
- X
- X DB_ENTER( "Make" );
- X DB_PRINT( "mem", ("%s:-> mem %ld", cp->CE_NAME, (long) coreleft()) );
- X
- X /* NOTE: The only time we are called with a NIL how pointer is for
- X * cells that are to be statted only or for cells that are destined
- X * to have a set of rules inferred for them. */
- X
- X if( how == NIL(HOW) ) {
- X TALLOC( cp->CE_HOW, 1, HOW );
- X how = cp->CE_HOW;
- X }
- X
- X /* Check to see if we have made the node already. If so then don't do
- X * it again, except if the cell's ce_setdir field is set to something other
- X * than the value of setdirroot. If they differ then, and we have made it
- X * already, then make it again and set the cell's stat bit to off so that
- X * we do it again. */
- X
- X if( how->hw_flag & F_VISITED ) {
- X /* we may return if we made it already from the same setdir location,
- X * or if it is not a library member whose lib field is non NULL. (if
- X * it is such a member then we have a line of the form:
- X * lib1 lib2 .LIBRARY : member_list...
- X * and we have to make sure all members are up to date in both libs. */
- X
- X if( cp->ce_setdir == setdirroot &&
- X !((cp->ce_attr & A_LIBRARYM) && (cp->ce_lib != NIL(char))) )
- X DB_RETURN( 0 );
- X
- X /* We check to make sure that we are comming from a truly different
- X * directory, ie. ".SETDIR=joe : a.c b.c d.c" are all assumed to come
- X * from the same directory, even though setdirroot is different when
- X * making dependents of each of these targets. */
- X
- X if( cp->ce_setdir != NIL(CELL) && setdirroot != NIL(CELL) &&
- X cp->ce_setdir->ce_dir == setdirroot->ce_dir )
- X DB_RETURN( 0 );
- X
- X cp->ce_flag &= ~(F_STAT|F_VISITED|F_MADE);
- X how->hw_flag &= ~(F_VISITED|F_MADE);
- X }
- X
- X if( how->hw_next != NIL(HOW))
- X if( (rval = Make(cp, how->hw_next, setdirroot)) == -1 ||
- X !(how->hw_next->hw_flag & F_MADE) )
- X goto stop_making_it;
- X
- X /* If we are supposed to change directories for this target then do so.
- X * If we do change dir, then modify the setdirroot variable to reflect
- SHAR_EOF
- echo "End of part 14"
- echo "File make.c is continued in part 15"
- echo "15" > s2_seq_.tmp
- exit 0
-
-