1 .\" $NetBSD: tutorial.ms,v 1.9 2004/06/27 19:04:54 uwe Exp $
2 .\" Copyright (c) 1988, 1989, 1993
3 .\" The Regents of the University of California. All rights reserved.
5 .\" This code is derived from software contributed to Berkeley by
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" Copyright (c) 1988, 1989 by Adam de Boor
33 .\" Copyright (c) 1989 by Berkeley Softworks
35 .\" This code is derived from software contributed to Berkeley by
38 .\" Redistribution and use in source and binary forms, with or without
39 .\" modification, are permitted provided that the following conditions
41 .\" 1. Redistributions of source code must retain the above copyright
42 .\" notice, this list of conditions and the following disclaimer.
43 .\" 2. Redistributions in binary form must reproduce the above copyright
44 .\" notice, this list of conditions and the following disclaimer in the
45 .\" documentation and/or other materials provided with the distribution.
46 .\" 3. All advertising materials mentioning features or use of this software
47 .\" must display the following acknowledgement:
48 .\" This product includes software developed by the University of
49 .\" California, Berkeley and its contributors.
50 .\" 4. Neither the name of the University nor the names of its contributors
51 .\" may be used to endorse or promote products derived from this software
52 .\" without specific prior written permission.
54 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66 .\" @(#)tutorial.ms 8.1 (Berkeley) 8/18/93
68 .EH 'PSD:12-%''PMake \*- A Tutorial'
69 .OH 'PMake \*- A Tutorial''PSD:12-%'
70 .\" xH is a macro to provide numbered headers that are automatically stuffed
71 .\" into a table-of-contents, properly indented, etc. If the first argument
72 .\" is numeric, it is taken as the depth for numbering (as for .NH), else
73 .\" the default (1) is assumed.
75 .\" @P The initial paragraph distance.
76 .\" @Q The piece of section number to increment (or 0 if none given)
77 .\" @R Section header.
78 .\" @S Indent for toc entry
79 .\" @T Argument to NH (can't use @Q b/c giving 0 to NH resets the counter)
82 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
86 \\*(SN \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
90 .\" CW is used to place a string in fixed-width or switch to a
92 .\" C is a typewriter font for a laserwriter. Use something else if
93 .\" you don't have one...
96 .el \&\\$3\fC\\$1\fP\\$2
98 .\" Anything I put in a display I want to be in fixed-width
102 .\" The stuff in .No produces a little stop sign in the left margin
103 .\" that says NOTE in it. Unfortunately, it does cause a break, but
104 .\" hey. Can't have everything. In case you're wondering how I came
105 .\" up with such weird commands, they came from running grn on a
119 \h'50u'\D'l 71u 0u'\D'l 50u 50u'\D'l 0u 71u'\D'l -50u 50u'\D'l -71u 0u'\D'l -50u -50u'\D'l 0u -71u'\D'l 50u -50u'
124 \h'53u'\D'p 14 68u 0u 46u 46u 0u 68u -46u 46u -68u 0u -47u -46u 0u -68u 47u -46u'
131 \h'85u'\v'0.85n'\h
\a-\w
\a\\*(g9
\au/2u
\a\&\\*(g9
142 .ie !\\n(.$ .IP \(bu 2
152 2150 Shattuck Ave, Penthouse
157 Permission to use, copy, modify, and distribute this software and its
158 documentation for any purpose and without fee is hereby granted,
159 provided that the above copyright notice appears in all copies.
160 The University of California, Berkeley Softworks, and Adam de Boor make no
161 representations about the suitability of this software for any
162 purpose. It is provided "as is" without express or implied warranty.
167 PMake is a program for creating other programs, or anything else you
168 can think of for it to do. The basic idea behind PMake is that, for
169 any given system, be it a program or a document or whatever, there
170 will be some files that depend on the state of other files (on when
171 they were last modified). PMake takes these dependencies, which you
172 must specify, and uses them to build whatever it is you want it to
175 PMake is almost fully-compatible with Make, with which you may already
176 be familiar. PMake's most important feature is its ability to run
177 several different jobs at once, making the creation of systems
178 considerably faster. It also has a great deal more functionality than
179 Make. Throughout the text, whenever something is mentioned that is an
180 important difference between PMake and Make (i.e. something that will
181 cause a makefile to fail if you don't do something about it), or is
182 simply important, it will be flagged with a little sign in the left
186 This tutorial is divided into three main sections corresponding to basic,
187 intermediate and advanced PMake usage. If you already know Make well,
188 you will only need to skim chapter 2 (there are some aspects of
189 PMake that I consider basic to its use that didn't exist in Make).
190 Things in chapter 3 make life much easier, while those in chapter 4
191 are strictly for those who know what they are doing. Chapter 5 has
192 definitions for the jargon I use and chapter 6 contains possible
193 solutions to the problems presented throughout the tutorial.
194 .xH 1 The Basics of PMake
196 PMake takes as input a file that tells a) which files depend on which
197 other files to be complete and b) what to do about files that are
198 ``out-of-date.'' This file is known as a ``makefile'' and is usually
200 kept in the top-most directory of the system to be built. While you
201 can call the makefile anything you want, PMake will look for
205 (in that order) in the current directory if you don't tell it
207 .Ix 0 def makefile default
208 To specify a different makefile, use the
211 .CW "pmake -f program.mk" ''). ``
213 .Ix 0 ref makefile other
215 A makefile has four different types of lines in it:
218 File dependency specifications
224 Comments, include statements and conditional directives
227 Any line may be continued over multiple lines by ending it with a
229 .Ix 0 def "continuation line"
230 The backslash, following newline and any initial whitespace
231 on the following line are compressed into a single space before the
232 input line is examined by PMake.
233 .xH 2 Dependency Lines
235 As mentioned in the introduction, in any system, there are
236 dependencies between the files that make up the system. For instance,
237 in a program made up of several C source files and one header file,
238 the C files will need to be re-compiled should the header file be
239 changed. For a document of several chapters and one macro file, the
240 chapters will need to be reprocessed if any of the macros changes.
241 .Ix 0 def "dependency"
242 These are dependencies and are specified by means of dependency lines in
245 .Ix 0 def "dependency line"
246 On a dependency line, there are targets and sources, separated by a
247 one- or two-character operator.
248 The targets ``depend'' on the sources and are usually created from
253 Any number of targets and sources may be specified on a dependency line.
254 All the targets in the line are made to depend on all the sources.
255 Targets and sources need not be actual files, but every source must be
256 either an actual file or another target in the makefile.
257 If you run out of room, use a backslash at the end of the line to continue onto
260 Any file may be a target and any file may be a source, but the
261 relationship between the two (or however many) is determined by the
262 ``operator'' that separates them.
264 Three types of operators exist: one specifies that the datedness of a
265 target is determined by the state of its sources, while another
266 specifies other files (the sources) that need to be dealt with before
267 the target can be re-created. The third operator is very similar to
268 the first, with the additional condition that the target is
269 out-of-date if it has no sources. These operations are represented by
270 the colon, the exclamation point and the double-colon, respectively, and are
271 mutually exclusive. Their exact semantics are as follows:
273 .Ix 0 def operator colon
275 If a colon is used, a target on the line is considered to be
276 ``out-of-date'' (and in need of creation) if
279 any of the sources has been modified more recently than the target, or
281 the target doesn't exist.
283 .Ix 0 def out-of-date
285 Under this operation, steps will be taken to re-create the target only
286 if it is found to be out-of-date by using these two rules.
288 .Ix 0 def operator force
290 If an exclamation point is used, the target will always be re-created,
291 but this will not happen until all of its sources have been examined
292 and re-created, if necessary.
294 .Ix 0 def operator double-colon
296 If a double-colon is used, a target is out-of-date if:
299 any of the sources has been modified more recently than the target, or
301 the target doesn't exist, or
303 the target has no sources.
306 If the target is out-of-date according to these rules, it will be re-created.
307 This operator also does something else to the targets, but I'll go
308 into that in the next section (``Shell Commands'').
310 Enough words, now for an example. Take that C program I mentioned
311 earlier. Say there are three C files
319 The dependencies between the files could then be expressed as follows:
321 program : a.o b.o c.o
328 You may be wondering at this point, where
337 and the C files don't. The reason is quite simple:
339 cannot be made by linking together .c files \*- it must be
340 made from .o files. Likewise, if you change
342 it isn't the .c files that need to be re-created, it's the .o files.
343 If you think of dependencies in these terms \*- which files (targets)
344 need to be created from which files (sources) \*- you should have no problems.
346 An important thing to notice about the above example, is that all the
347 \&.o files appear as targets on more than one line. This is perfectly
348 all right: the target is made to depend on all the sources mentioned
349 on all the dependency lines. E.g.
358 The order of the dependency lines in the makefile is
359 important: the first target on the first dependency line in the
360 makefile will be the one that gets made if you don't say otherwise.
363 comes first in the example makefile, above.
365 Both targets and sources may contain the standard C-Shell wildcard
374 but the non-curly-brace ones may only appear in the final component
375 (the file portion) of the target or source. The characters mean the
378 These enclose a comma-separated list of options and cause the pattern
379 to be expanded once for each element of the list. Each expansion
380 contains a different element. For example,
381 .CW src/{whiffle,beep,fish}.c
382 expands to the three words
387 These braces may be nested and, unlike the other wildcard characters,
388 the resulting words need not be actual files. All other wildcard
389 characters are expanded using the files that exist when PMake is
392 This matches zero or more characters of any sort.
394 will expand to the same three words as above as long as
396 contains those three files (and no other files that end in
399 Matches any single character.
401 This is known as a character class and contains either a list of
402 single characters, or a series of character ranges
404 for example means all characters between a and z), or both. It matches
405 any single character contained in the list. E.g.
407 will match all letters, while
409 will match all numbers.
412 ``Isn't that nice,'' you say to yourself, ``but how are files
413 actually `re-created,' as he likes to spell it?''
414 The re-creation is accomplished by commands you place in the makefile.
415 These commands are passed to the Bourne shell (better known as
416 ``/bin/sh'') to be executed and are
418 .Ix 0 ref re-creation
420 expected to do what's necessary to update the target file (PMake
421 doesn't actually check to see if the target was created. It just
425 Shell commands in a makefile look a lot like shell commands you would
426 type at a terminal, with one important exception: each command in a
429 be preceded by at least one tab.
431 Each target has associated with it a shell script made up of
432 one or more of these shell commands. The creation script for a target
433 should immediately follow the dependency line for that target. While
434 any given target may appear on more than one dependency line, only one
435 of these dependency lines may be followed by a creation script, unless
436 the `::' operator was used on the dependency line.
437 .Ix 0 ref operator double-colon
441 If the double-colon was used, each dependency line for the target
442 may be followed by a shell script. That script will only be executed
443 if the target on the associated dependency line is out-of-date with
444 respect to the sources on that line, according to the rules I gave
446 I'll give you a good example of this later on.
448 To expand on the earlier makefile, you might add commands as follows:
450 program : a.o b.o c.o
451 cc a.o b.o c.o \-o program
461 Something you should remember when writing a makefile is, the
462 commands will be executed if the
464 on the dependency line is out-of-date, not the sources.
467 .Ix 0 ref out-of-date
468 In this example, the command
469 .CW "cc \-c a.c" '' ``
472 is out-of-date. Because of the `:' operator,
474 .Ix 0 ref operator colon
475 this means that should
479 have been modified more recently than
481 the command will be executed
483 will be considered out-of-date).
484 .Ix 0 ref out-of-date
486 Remember how I said the only difference between a makefile shell
487 command and a regular shell command was the leading tab? I lied. There
488 is another way in which makefile commands differ from regular ones.
489 The first two characters after the initial whitespace are treated
491 If they are any combination of `@' and `\-', they cause PMake to do
494 In most cases, shell commands are printed before they're
495 actually executed. This is to keep you informed of what's going on. If
496 an `@' appears, however, this echoing is suppressed. In the case of an
499 .CW "echo Linking index" ,'' ``
507 so PMake allows you to place an `@' before the command
508 .CW "@echo Linking index" '') (``
509 to prevent the command from being printed.
511 The other special character is the `\-'. In case you didn't know,
512 shell commands finish with a certain ``exit status.'' This status is
513 made available by the operating system to whatever program invoked the
514 command. Normally this status will be 0 if everything went ok and
515 non-zero if something went wrong. For this reason, PMake will consider
516 an error to have occurred if one of the shells it invokes returns a non-zero
517 status. When it detects an error, PMake's usual action is to abort
518 whatever it's doing and exit with a non-zero status itself (any other
519 targets that were being created will continue being made, but nothing
520 new will be started. PMake will exit after the last job finishes).
521 This behavior can be altered, however, by placing a `\-' at the front
523 .CW "\-mv index index.old" ''), (``
524 certain command-line arguments,
525 or doing other things, to be detailed later. In such
526 a case, the non-zero status is simply ignored and PMake keeps chugging
530 Because all the commands are given to a single shell to execute, such
531 things as setting shell variables, changing directories, etc., last
532 beyond the command in which they are found. This also allows shell
533 compound commands (like
535 loops) to be entered in a natural manner.
536 Since this could cause problems for some makefiles that depend on
537 each command being executed by a single shell, PMake has a
539 .Ix 0 ref compatibility
541 flag (it stands for backwards-compatible) that forces each command to
542 be given to a separate shell. It also does several other things, all
543 of which I discourage since they are now old-fashioned.\|.\|.\|.
546 A target's shell script is fed to the shell on its (the shell's) input stream.
547 This means that any commands, such as
549 that need to get input from the terminal won't work right \*- they'll
550 get the shell's input, something they probably won't find to their
551 liking. A simple way around this is to give a command like this:
553 ci $(SRCS) < /dev/tty
555 This would force the program's input to come from the terminal. If you
556 can't do this for some reason, your only other alternative is to use
557 PMake in its fullest compatibility mode. See
560 .Ix 0 ref compatibility
564 PMake, like Make before it, has the ability to save text in variables
565 to be recalled later at your convenience. Variables in PMake are used
566 much like variables in the shell and, by tradition, consist of
567 all upper-case letters (you don't
569 to use all upper-case letters.
570 In fact there's nothing to stop you from calling a variable
572 Just tradition). Variables are assigned-to using lines of the form
573 .Ix 0 def variable assignment
577 .Ix 0 def variable assignment
582 .Ix 0 def variable appending
583 .Ix 0 def variable assignment appended
585 conditionally assigned-to (if the variable isn't already defined) by
589 .Ix 0 def variable assignment conditional
591 and assigned-to with expansion (i.e. the value is expanded (see below)
592 before being assigned to the variable\*-useful for placing a value at
593 the beginning of a variable, or other things) by
597 .Ix 0 def variable assignment expanded
600 Any whitespace before
602 is stripped off. When appending, a space is placed between the old
603 value and the stuff being appended.
605 The final way a variable may be assigned to is using
607 VARIABLE != shell-command
609 .Ix 0 def variable assignment shell-output
613 has all its variables expanded (see below) and is passed off to a
614 shell to execute. The output of the shell is then placed in the
615 variable. Any newlines (other than the final one) are replaced by
616 spaces before the assignment is made. This is typically used to find
617 the current directory via a line like:
623 this is intended to be used to execute commands that produce small amounts
624 of output (e.g. ``pwd''). The implementation is less than intelligent and will
625 likely freeze if you execute something that produces thousands of
626 bytes of output (8 Kb is the limit on many UNIX systems).
628 The value of a variable may be retrieved by enclosing the variable
629 name in parentheses or curly braces and preceding the whole thing
632 For example, to set the variable CFLAGS to the string
633 .CW "\-I/sprite/src/lib/libc \-O" ,'' ``
634 you would place a line
636 CFLAGS = \-I/sprite/src/lib/libc \-O
638 in the makefile and use the word
640 wherever you would like the string
641 .CW "\-I/sprite/src/lib/libc \-O"
642 to appear. This is called variable expansion.
643 .Ix 0 def variable expansion
646 Unlike Make, PMake will not expand a variable unless it knows
647 the variable exists. E.g. if you have a
649 in a shell command and you have not assigned a value to the variable
651 (the empty string is considered a value, by the way), where Make would have
652 substituted the empty string, PMake will leave the
655 To keep PMake from substituting for a variable it knows, precede the
656 dollar sign with another dollar sign.
661 This causes PMake, in effect, to expand the
663 macro, which expands to a single
665 For compatibility, Make's style of variable expansion will be used
666 if you invoke PMake with any of the compatibility flags (\c
673 flag alters just the variable expansion).
677 .Ix 0 ref compatibility
679 .Ix 0 ref variable expansion
680 There are two different times at which variable expansion occurs:
681 When parsing a dependency line, the expansion occurs immediately
682 upon reading the line. If any variable used on a dependency line is
683 undefined, PMake will print a message and exit.
684 Variables in shell commands are expanded when the command is
686 Variables used inside another variable are expanded whenever the outer
687 variable is expanded (the expansion of an inner variable has no effect
688 on the outer variable. I.e. if the outer variable is used on a dependency
689 line and in a shell command, and the inner variable changes value
690 between when the dependency line is read and the shell command is
691 executed, two different values will be substituted for the outer
693 .Ix 0 def variable types
695 Variables come in four flavors, though they are all expanded the same
696 and all look about the same. They are (in order of expanding scope):
700 .Ix 0 ref variable local
702 Command-line variables.
703 .Ix 0 ref variable command-line
706 .Ix 0 ref variable global
708 Environment variables.
709 .Ix 0 ref variable environment
712 The classification of variables doesn't matter much, except that the
713 classes are searched from the top (local) to the bottom (environment)
714 when looking up a variable. The first one found wins.
715 .xH 3 Local Variables
717 .Ix 0 def variable local
718 Each target can have as many as seven local variables. These are
719 variables that are only ``visible'' within that target's shell script
720 and contain such things as the target's name, all of its sources (from
721 all its dependency lines), those sources that were out-of-date, etc.
722 Four local variables are defined for all targets. They are:
725 .Ix 0 def variable local .TARGET
727 The name of the target.
729 .Ix 0 def variable local .OODATE
731 The list of the sources for the target that were considered out-of-date.
732 The order in the list is not guaranteed to be the same as the order in
733 which the dependencies were given.
735 .Ix 0 def variable local .ALLSRC
737 The list of all sources for this target in the order in which they
740 .Ix 0 def variable local .PREFIX
742 The target without its suffix and without any leading path. E.g. for
744 .CW ../../lib/compat/fsRead.c ,
745 this variable would contain
749 Three other local variables are set only for certain targets under
750 special circumstances. These are the ``.IMPSRC,''
751 .Ix 0 ref variable local .IMPSRC
754 .Ix 0 ref variable local .ARCHIVE
757 .Ix 0 ref variable local .MEMBER
759 variables. When they are set and how they are used is described later.
761 Four of these variables may be used in sources as well as in shell
763 .Ix 0 def "dynamic source"
764 .Ix 0 def source dynamic
765 These are ``.TARGET'', ``.PREFIX'', ``.ARCHIVE'' and ``.MEMBER''. The
766 variables in the sources are expanded once for each target on the
767 dependency line, providing what is known as a ``dynamic source,''
769 allowing you to specify several dependency lines at once. For example,
771 $(OBJS) : $(.PREFIX).c
773 will create a dependency between each object file and its
774 corresponding C source file.
775 .xH 3 Command-line Variables
777 .Ix 0 def variable command-line
778 Command-line variables are set when PMake is first invoked by giving a
779 variable assignment as one of the arguments. For example,
781 pmake "CFLAGS = -I/sprite/src/lib/libc -O"
785 be a command-line variable with the given value. Any assignments to
787 in the makefile will have no effect, because once it
788 is set, there is (almost) nothing you can do to change a command-line
789 variable (the search order, you see). Command-line variables may be
790 set using any of the four assignment operators, though only
794 behave as you would expect them to, mostly because assignments to
795 command-line variables are performed before the makefile is read, thus
796 the values set in the makefile are unavailable at the time.
799 .Ix 0 ref variable assignment appended
802 because the old value of the variable is sought only in the scope in
803 which the assignment is taking place (for reasons of efficiency that I
804 won't get into here).
810 .Ix 0 ref variable assignment expanded
811 .Ix 0 ref variable assignment conditional
812 will work if the only variables used are in the environment.
814 is sort of pointless to use from the command line, since the same
815 effect can no doubt be accomplished using the shell's own command
816 substitution mechanisms (backquotes and all that).
817 .xH 3 Global Variables
819 .Ix 0 def variable global
820 Global variables are those set or appended-to in the makefile.
821 There are two classes of global variables: those you set and those PMake sets.
822 As I said before, the ones you set can have any name you want them to have,
823 except they may not contain a colon or an exclamation point.
824 The variables PMake sets (almost) always begin with a
825 period and always contain upper-case letters, only. The variables are
829 .Ix 0 def variable global .PMAKE
831 .Ix 0 def variable global MAKE
833 The name by which PMake was invoked is stored in this variable. For
834 compatibility, the name is also stored in the MAKE variable.
836 .Ix 0 def variable global .MAKEFLAGS
837 .Ix 0 def .MAKEFLAGS variable
838 .Ix 0 def variable global MFLAGS
840 All the relevant flags with which PMake was invoked. This does not
841 include such things as
843 or variable assignments. Again for compatibility, this value is stored
844 in the MFLAGS variable as well.
847 Two other variables, ``.INCLUDES'' and ``.LIBS,'' are covered in the
848 section on special targets in chapter 3.
849 .Ix 0 ref variable global .INCLUDES
850 .Ix 0 ref variable global .LIBS
852 Global variables may be deleted using lines of the form:
854 .Ix 0 def variable deletion
856 #undef \fIvariable\fP
860 must be the first character on the line. Note that this may only be
861 done on global variables.
862 .xH 3 Environment Variables
864 .Ix 0 def variable environment
865 Environment variables are passed by the shell that invoked PMake and
866 are given by PMake to each shell it invokes. They are expanded like
867 any other variable, but they cannot be altered in any way.
869 One special environment variable,
871 .Ix 0 def variable environment PMAKE
872 is examined by PMake for command-line flags, variable assignments,
873 etc., it should always use. This variable is examined before the
874 actual arguments to PMake are. In addition, all flags given to PMake,
877 variable or on the command line, are placed in this environment
878 variable and exported to each shell PMake executes. Thus recursive
879 invocations of PMake automatically receive the same flags as the
882 Using all these variables, you can compress the sample makefile even more:
886 cc $(.ALLSRC) \-o $(.TARGET)
895 .Ix 0 ref variable local .ALLSRC
897 .Ix 0 ref variable local .TARGET
903 Comments in a makefile start with a `#' character and extend to the
904 end of the line. They may appear
905 anywhere you want them, except in a shell command (though the shell
906 will treat it as a comment, too). If, for some reason, you need to use the `#'
907 in a variable or on a dependency line, put a backslash in front of it.
908 PMake will compress the two into a single `#' (Note: this isn't true
909 if PMake is operating in full-compatibility mode).
911 .Ix 0 ref compatibility
915 PMake was specifically designed to re-create several targets at once,
916 when possible. You do not have to do anything special to cause this to
917 happen (unless PMake was configured to not act in parallel, in which
918 case you will have to make use of the
925 but you do have to be careful at times.
927 There are several problems you are likely to encounter. One is
928 that some makefiles (and programs) are written in such a way that it is
929 impossible for two targets to be made at once. The program
932 always modifies the files
936 There is no way to change it. Thus you cannot run two of them at once
937 without something being trashed. Similarly, if you have commands
938 in the makefile that always send output to the same file, you will not
939 be able to make more than one target at once unless you change the
940 file you use. You can, for instance, add a
942 to the end of the file name to tack on the process ID of the shell
943 executing the command (each
947 thus giving you the shell variable
949 Since only one shell is used for all the
950 commands, you'll get the same file name for each command in the
953 The other problem comes from improperly-specified dependencies that
954 worked in Make because of its sequential, depth-first way of examining
955 them. While I don't want to go into depth on how PMake
956 works (look in chapter 4 if you're interested), I will warn you that
957 files in two different ``levels'' of the dependency tree may be
958 examined in a different order in PMake than they were in Make. For
959 example, given the makefile
964 PMake will examine the targets in the order
969 If the makefile's author expected PMake to abort before making
971 if an error occurred while making
975 needed to exist before
978 s/he will be sorely disappointed. The dependencies are
979 incomplete, since in both these cases,
985 Another problem you may face is that, while PMake is set up to handle the
986 output from multiple jobs in a graceful fashion, the same is not so for input.
987 It has no way to regulate input to different jobs,
988 so if you use the redirection from
990 I mentioned earlier, you must be careful not to run two of the jobs at once.
991 .xH 2 Writing and Debugging a Makefile
993 Now you know most of what's in a makefile, what do you do next? There
994 are two choices: (1) use one of the uncommonly-available makefile
995 generators or (2) write your own makefile (I leave out the third choice of
996 ignoring PMake and doing everything by hand as being beyond the bounds
999 When faced with the writing of a makefile, it is usually best to start
1000 from first principles: just what
1002 you trying to do? What do you want the makefile finally to produce?
1004 To begin with a somewhat traditional example, let's say you need to
1005 write a makefile to create a program,
1007 that takes standard infix expressions and converts them to prefix form (for
1008 no readily apparent reason). You've got three source files, in C, that
1009 make up the program:
1014 Harking back to my pithy advice about dependency lines, you write the
1015 first line of the file:
1017 expr : main.o parse.o output.o
1019 because you remember
1025 files. Similarly for the
1027 files you produce the lines:
1032 main.o parse.o output.o : defs.h
1035 Great. You've now got the dependencies specified. What you need now is
1036 commands. These commands, remember, must produce the target on the
1037 dependency line, usually by using the sources you've listed.
1038 You remember about local variables? Good, so it should come
1039 to you as no surprise when you write
1041 expr : main.o parse.o output.o
1042 cc -o $(.TARGET) $(.ALLSRC)
1044 Why use the variables? If your program grows to produce postfix
1045 expressions too (which, of course, requires a name change or two), it
1046 is one fewer place you have to change the file. You cannot do this for
1047 the object files, however, because they depend on their corresponding
1060 which is wrong. So you round out the makefile with these lines:
1070 The makefile is now complete and will, in fact, create the program you
1071 want it to without unnecessary compilations or excessive typing on
1072 your part. There are two things wrong with it, however (aside from it
1073 being altogether too long, something I'll address in chapter 3):
1076 .CW "main.o parse.o output.o" '' ``
1077 is repeated twice, necessitating two changes when you add postfix
1078 (you were planning on that, weren't you?). This is in direct violation
1079 of de Boor's First Rule of writing makefiles:
1082 Anything that needs to be written more than once
1083 should be placed in a variable.
1085 I cannot emphasize this enough as being very important to the
1086 maintenance of a makefile and its program.
1088 There is no way to alter the way compilations are performed short of
1089 editing the makefile and making the change in all places. This is evil
1090 and violates de Boor's Second Rule, which follows directly from the
1094 Any flags or programs used inside a makefile should be placed in a variable so
1095 they may be changed, temporarily or permanently, with the greatest ease.
1097 The makefile should more properly read:
1099 OBJS = main.o parse.o output.o
1101 $(CC) $(CFLAGS) -o $(.TARGET) $(.ALLSRC)
1103 $(CC) $(CFLAGS) -c main.c
1105 $(CC) $(CFLAGS) -c parse.c
1107 $(CC) $(CFLAGS) -c output.c
1110 Alternatively, if you like the idea of dynamic sources mentioned in
1114 .Ix 0 ref "dynamic source"
1115 .Ix 0 ref source dynamic
1116 you could write it like this:
1118 OBJS = main.o parse.o output.o
1120 $(CC) $(CFLAGS) -o $(.TARGET) $(.ALLSRC)
1121 $(OBJS) : $(.PREFIX).c defs.h
1122 $(CC) $(CFLAGS) -c $(.PREFIX).c
1124 These two rules and examples lead to de Boor's First Corollary:
1127 Variables are your friends.
1129 Once you've written the makefile comes the sometimes-difficult task of
1131 making sure the darn thing works. Your most helpful tool to make sure
1132 the makefile is at least syntactically correct is the
1135 flag, which allows you to see if PMake will choke on the makefile. The
1138 flag lets you do is see what PMake would do without it actually doing
1139 it, thus you can make sure the right commands would be executed were
1140 you to give PMake its head.
1142 When you find your makefile isn't behaving as you hoped, the first
1143 question that comes to mind (after ``What time is it, anyway?'') is
1144 ``Why not?'' In answering this, two flags will serve you well:
1150 The first causes PMake to tell you as it examines each target in the
1151 makefile and indicate why it is deciding whatever it is deciding. You
1152 can then use the information printed for other targets to see where
1155 flag makes PMake print out its internal state when it is done,
1156 allowing you to see that you forgot to make that one chapter depend on
1157 that file of macros you just got a new version of. The output from
1159 is intended to resemble closely a real makefile, but with additional
1160 information provided and with variables expanded in those commands
1161 PMake actually printed or executed.
1163 Something to be especially careful about is circular dependencies.
1164 .Ix 0 def dependency circular
1171 In this case, because of how PMake works,
1173 is the only thing PMake will examine, because
1177 will effectively fall off the edge of the universe, making it
1178 impossible to examine
1180 (or them, for that matter).
1181 PMake will tell you (if run in its normal mode) all the targets
1182 involved in any cycle it looked at (i.e. if you have two cycles in the
1183 graph (naughty, naughty), but only try to make a target in one of
1184 them, PMake will only tell you about that one. You'll have to try to
1185 make the other to find the second cycle). When run as Make, it will
1186 only print the first target in the cycle.
1187 .xH 2 Invoking PMake
1192 PMake comes with a wide variety of flags to choose from.
1193 They may appear in any order, interspersed with command-line variable
1194 assignments and targets to create.
1195 The flags are as follows:
1196 .IP "\fB\-d\fP \fIwhat\fP"
1199 This causes PMake to spew out debugging information that
1200 may prove useful to you. If you can't
1201 figure out why PMake is doing what it's doing, you might try using
1204 parameter is a string of single characters that tell PMake what
1205 aspects you are interested in. Most of what I describe will make
1206 little sense to you, unless you've dealt with Make before. Just
1207 remember where this table is and come back to it as you read on.
1208 The characters and the information they produce are as follows:
1211 Archive searching and caching.
1213 Conditional evaluation.
1215 The searching and caching of directories.
1217 Various snippets of information related to the running of the multiple
1218 shells. Not particularly interesting.
1220 The making of each target: what target is being examined; when it was
1221 last modified; whether it is out-of-date; etc.
1227 The application of suffix-transformation rules. (See chapter 3)
1229 The maintenance of the list of targets.
1231 Variable assignment.
1238 letters will be most useful to you.
1241 is the final argument or the argument from which it would get these
1242 key letters (see below for a note about which argument would be used)
1245 all of these debugging flags will be set, resulting in massive amounts
1247 .IP "\fB\-f\fP \fImakefile\fP"
1249 Specify a makefile to read different from the standard makefiles
1253 .Ix 0 ref makefile default
1254 .Ix 0 ref makefile other
1257 is ``\-'', PMake uses the standard input. This is useful for making
1258 quick and dirty makefiles.\|.\|.
1259 .Ix 0 ref makefile "quick and dirty"
1262 Prints out a summary of the various flags PMake accepts. It can also
1263 be used to find out what level of concurrency was compiled into the
1264 version of PMake you are using (look at
1268 and various other information on how PMake was configured.
1269 .Ix 0 ref configuration
1270 .Ix 0 ref makefile system
1273 If you give this flag, PMake will ignore non-zero status returned
1274 by any of its shells. It's like placing a `\-' before all the commands
1280 in that it allows PMake to continue when it sees an error, but unlike
1282 where PMake continues blithely as if nothing went wrong,
1284 causes it to recognize the error and only continue work on those
1285 things that don't depend on the target, either directly or indirectly (through
1286 depending on something that depends on it), whose creation returned the error.
1287 The `k' is for ``keep going''.\|.\|.
1291 PMake has the ability to lock a directory against other
1292 people executing it in the same directory (by means of a file called
1293 ``LOCK.make'' that it creates and checks for in the directory). This
1294 is a Good Thing because two people doing the same thing in the same place
1295 can be disastrous for the final product (too many cooks and all that).
1296 Whether this locking is the default is up to your system
1297 administrator. If locking is on,
1299 will turn it off, and vice versa. Note that this locking will not
1300 prevent \fIyou\fP from invoking PMake twice in the same place \*- if
1301 you own the lock file, PMake will warn you about it but continue to execute.
1302 .IP "\fB\-m\fP \fIdirectory\fP"
1304 Tells PMake another place to search for included makefiles via the <...>
1307 options can be given to form a search path. If this construct is used the
1308 default system makefile search path is completely overridden.
1309 To be explained in chapter 3, section 3.2.
1313 This flag tells PMake not to execute the commands needed to update the
1314 out-of-date targets in the makefile. Rather, PMake will simply print
1315 the commands it would have executed and exit. This is particularly
1316 useful for checking the correctness of a makefile. If PMake doesn't do
1317 what you expect it to, it's a good chance the makefile is wrong.
1318 .IP "\fB\-p\fP \fInumber\fP"
1321 This causes PMake to print its input in a reasonable form, though
1322 not necessarily one that would make immediate sense to anyone but me. The
1324 is a bitwise-or of 1 and 2 where 1 means it should print the input
1325 before doing any processing and 2 says it should print it after
1326 everything has been re-created. Thus
1328 would print it twice\*-once before processing and once after (you
1329 might find the difference between the two interesting). This is mostly
1330 useful to me, but you may find it informative in some bizarre circumstances.
1333 If you give PMake this flag, it will not try to re-create anything. It
1334 will just see if anything is out-of-date and exit non-zero if so.
1337 When PMake starts up, it reads a default makefile that tells it what
1338 sort of system it's on and gives it some idea of what to do if you
1339 don't tell it anything. I'll tell you about it in chapter 3. If you
1340 give this flag, PMake won't read the default makefile.
1343 This causes PMake to not print commands before they're executed. It
1344 is the equivalent of putting an `@' before every command in the
1348 Rather than try to re-create a target, PMake will simply ``touch'' it
1349 so as to make it appear up-to-date. If the target didn't exist before,
1350 it will when PMake finishes, but if the target did exist, it will
1351 appear to have been updated.
1354 This is a mixed-compatibility flag intended to mimic the System V
1355 version of Make. It is the same as giving
1359 as well as turning off directory locking. Targets can still be created
1360 in parallel, however. This is the mode PMake will enter if it is
1367 This tells PMake it's ok to export jobs to other machines, if they're
1368 available. It is used when running in Make mode, as exporting in this
1369 mode tends to make things run slower than if the commands were just
1372 .Ix 0 ref compatibility
1374 Forces PMake to be as backwards-compatible with Make as possible while
1379 Executing one shell per shell command
1381 Expanding anything that looks even vaguely like a variable, with the
1382 empty string replacing any variable PMake doesn't know.
1384 Refusing to allow you to escape a `#' with a backslash.
1386 Permitting undefined variables on dependency lines and conditionals
1387 (see below). Normally this causes PMake to abort.
1391 This nullifies any and all compatibility mode flags you may have given
1392 or implied up to the time the
1394 is encountered. It is useful mostly in a makefile that you wrote for PMake
1395 to avoid bad things happening when someone runs PMake as
1397 or has things set in the environment that tell it to be compatible.
1403 environment variable or the
1408 .Ix 0 ref variable environment PMAKE
1409 .Ix 0 ref variable global .MAKEFLAGS
1410 .Ix 0 ref variable global MFLAGS
1411 .Ix 0 ref .MAKEFLAGS variable
1413 .IP "\fB\-D\fP \fIvariable\fP"
1415 Allows you to define a variable to have
1417 as its value. The variable is a global variable, not a command-line
1418 variable. This is useful mostly for people who are used to the C
1419 compiler arguments and those using conditionals, which I'll get into
1422 .IP "\fB\-I\fP \fIdirectory\fP"
1424 Tells PMake another place to search for included makefiles. Yet
1425 another thing to be explained in chapter 3 (section 3.2, to be
1428 .IP "\fB\-J\fP \fInumber\fP"
1430 Gives the absolute maximum number of targets to create at once on both
1431 local and remote machines.
1432 .IP "\fB\-L\fP \fInumber\fP"
1434 This specifies the maximum number of targets to create on the local
1435 machine at once. This may be 0, though you should be wary of doing
1436 this, as PMake may hang until a remote machine becomes available, if
1437 one is not available when it is started.
1439 .Ix 0 ref compatibility
1441 This is the flag that provides absolute, complete, full compatibility
1442 with Make. It still allows you to use all but a few of the features of
1443 PMake, but it is non-parallel. This is the mode PMake enters if you
1448 .Ix 0 ref "output control"
1449 When creating targets in parallel, several shells are executing at
1450 once, each wanting to write its own two cent's-worth to the screen.
1451 This output must be captured by PMake in some way in order to prevent
1452 the screen from being filled with garbage even more indecipherable
1453 than you usually see. PMake has two ways of doing this, one of which
1454 provides for much cleaner output and a clear separation between the
1455 output of different jobs, the other of which provides a more immediate
1456 response so one can tell what is really happening. The former is done
1457 by notifying you when the creation of a target starts, capturing the
1458 output and transferring it to the screen all at once when the job
1459 finishes. The latter is done by catching the output of the shell (and
1460 its children) and buffering it until an entire line is received, then
1461 printing that line preceded by an indication of which job produced
1462 the output. Since I prefer this second method, it is the one used by
1463 default. The first method will be used if you give the
1468 As mentioned before, the
1470 flag tells PMake to use Make's style of expanding variables,
1471 substituting the empty string for any variable it doesn't know.
1474 There are several times when PMake will print a message at you that is
1475 only a warning, i.e. it can continue to work in spite of your having
1476 done something silly (such as forgotten a leading tab for a shell
1477 command). Sometimes you are well aware of silly things you have done
1478 and would like PMake to stop bothering you. This flag tells it to shut
1479 up about anything non-fatal.
1482 This flag causes PMake to not attempt to export any jobs to another
1485 Several flags may follow a single `\-'. Those flags that require
1486 arguments take them from successive parameters. E.g.
1488 pmake -fDnI server.mk DEBUG /chip2/X/server/include
1490 will cause PMake to read
1492 as the input makefile, define the variable
1494 as a global variable and look for included makefiles in the directory
1495 .CW /chip2/X/server/include .
1498 A makefile is made of four types of lines:
1505 Variable assignments
1507 Comments, include statements and conditional directives
1510 A dependency line is a list of one or more targets, an operator
1515 and a list of zero or more sources. Sources may contain wildcards and
1516 certain local variables.
1518 A creation command is a regular shell command preceded by a tab. In
1519 addition, if the first two characters after the tab (and other
1520 whitespace) are a combination of
1524 PMake will cause the command to not be printed (if the character is
1526 or errors from it to be ignored (if
1528 A blank line, dependency line or variable assignment terminates a
1529 creation script. There may be only one creation script for each target
1536 Variables are places to store text. They may be unconditionally
1537 assigned-to using the
1540 .Ix 0 ref variable assignment
1541 operator, appended-to using the
1544 .Ix 0 ref variable assignment appended
1545 operator, conditionally (if the variable is undefined) assigned-to
1549 .Ix 0 ref variable assignment conditional
1550 operator, and assigned-to with variable expansion with the
1553 .Ix 0 ref variable assignment expanded
1554 operator. The output of a shell command may be assigned to a variable
1558 .Ix 0 ref variable assignment shell-output
1559 operator. Variables may be expanded (their value inserted) by enclosing
1560 their name in parentheses or curly braces, preceded by a dollar sign.
1561 A dollar sign may be escaped with another dollar sign. Variables are
1562 not expanded if PMake doesn't know about them. There are seven local
1578 may be used to specify ``dynamic sources.''
1579 .Ix 0 ref "dynamic source"
1580 .Ix 0 ref source dynamic
1581 Variables are good. Know them. Love them. Live them.
1583 Debugging of makefiles is best accomplished using the
1592 .xH 1 Short-cuts and Other Nice Things
1594 Based on what I've told you so far, you may have gotten the impression
1595 that PMake is just a way of storing away commands and making sure you
1596 don't forget to compile something. Good. That's just what it is.
1597 However, the ways I've described have been inelegant, at best, and
1599 This chapter contains things that make the
1600 writing of makefiles easier and the makefiles themselves shorter and
1601 easier to modify (and, occasionally, simpler). In this chapter, I
1602 assume you are somewhat more
1603 familiar with Sprite (or UNIX, if that's what you're using) than I did
1604 in chapter 2, just so you're on your toes.
1605 So without further ado...
1606 .xH 2 Transformation Rules
1608 As you know, a file's name consists of two parts: a base name, which
1609 gives some hint as to the contents of the file, and a suffix, which
1610 usually indicates the format of the file.
1614 naming conventions, with regard to suffixes, have also developed that have
1615 become almost as incontrovertible as Law. E.g. a file ending in
1617 is assumed to contain C source code; one with a
1619 suffix is assumed to be a compiled, relocatable object file that may
1620 be linked into any program; a file with a
1622 suffix is usually a text file to be processed by Troff with the \-ms
1623 macro package, and so on.
1624 One of the best aspects of both Make and PMake comes from their
1625 understanding of how the suffix of a file pertains to its contents and
1626 their ability to do things with a file based solely on its suffix. This
1627 ability comes from something known as a transformation rule. A
1628 transformation rule specifies how to change a file with one suffix
1629 into a file with another suffix.
1631 A transformation rule looks much like a dependency line, except the
1632 target is made of two known suffixes stuck together. Suffixes are made
1633 known to PMake by placing them as sources on a dependency line whose
1634 target is the special target
1640 $(CC) $(CFLAGS) -c $(.IMPSRC)
1642 The creation script attached to the target is used to transform a file with
1643 the first suffix (in this case,
1645 into a file with the second suffix (here,
1647 In addition, the target inherits whatever attributes have been applied
1648 to the transformation rule.
1649 The simple rule given above says that to transform a C source file
1650 into an object file, you compile it using
1655 This rule is taken straight from the system makefile. Many
1656 transformation rules (and suffixes) are defined there, and I refer you
1657 to it for more examples (type
1658 .CW "pmake -h" '' ``
1659 to find out where it is).
1661 There are several things to note about the transformation rule given
1668 .Ix 0 def variable local .IMPSRC
1670 This variable is set to the ``implied source'' (the file from which
1671 the target is being created; the one with the first suffix), which, in this
1672 case, is the .c file.
1676 variable. Almost all of the transformation rules in the system
1677 makefile are set up using variables that you can alter in your
1678 makefile to tailor the rule to your needs. In this case, if you want
1679 all your C files to be compiled with the
1681 flag, to provide information for
1687 .CW "CFLAGS = -g" '') (``
1688 and PMake would take care of the rest.
1691 To give you a quick example, the makefile in 2.3.4
1693 could be changed to this:
1697 $(CC) -o $(.TARGET) $(.ALLSRC)
1700 The transformation rule I gave above takes the place of the 6 lines\**
1702 This is also somewhat cleaner, I think, than the dynamic source
1703 solution presented in 2.6
1715 Now you may be wondering about the dependency between the
1719 files \*- it's not mentioned anywhere in the new makefile. This is
1720 because it isn't needed: one of the effects of applying a
1721 transformation rule is the target comes to depend on the implied
1722 source. That's why it's called the implied
1725 For a more detailed example. Say you have a makefile like this:
1730 and a directory set up like this:
1733 -rw-rw-r-- 1 deboor 34 Sep 7 00:43 Makefile
1734 -rw-rw-r-- 1 deboor 119 Oct 3 19:39 a.c
1735 -rw-rw-r-- 1 deboor 201 Sep 7 00:43 a.o
1736 -rw-rw-r-- 1 deboor 69 Sep 7 00:43 b.c
1740 will do the right thing, it's much more informative to type
1741 .CW "pmake -d s" ''. ``
1742 This will show you what PMake is up to as it processes the files. In
1743 this case, PMake prints the following:
1745 Suff_FindDeps (a.out)
1746 using existing source a.o
1747 applying .o -> .out to "a.o"
1750 applying .c -> .o to "a.c"
1753 applying .c -> .o to "b.c"
1755 trying a.y...not there
1756 trying a.l...not there
1757 trying a.c,v...not there
1758 trying a.y,v...not there
1759 trying a.l,v...not there
1761 trying b.y...not there
1762 trying b.l...not there
1763 trying b.c,v...not there
1764 trying b.y,v...not there
1765 trying b.l,v...not there
1775 is the name of a function in PMake that is called to check for implied
1776 sources for a target using transformation rules.
1777 The transformations it tries are, naturally
1778 enough, limited to the ones that have been defined (a transformation
1779 may be defined multiple times, by the way, but only the most recent
1780 one will be used). You will notice, however, that there is a definite
1781 order to the suffixes that are tried. This order is set by the
1782 relative positions of the suffixes on the
1784 line \*- the earlier a suffix appears, the earlier it is checked as
1785 the source of a transformation. Once a suffix has been defined, the
1786 only way to change its position in the pecking order is to remove all
1787 the suffixes (by having a
1789 dependency line with no sources) and redefine them in the order you
1790 want. (Previously-defined transformation rules will be automatically
1791 redefined as the suffixes they involve are re-entered.)
1793 Another way to affect the search order is to make the dependency
1794 explicit. In the above example,
1800 Since a transformation exists from
1804 PMake uses that, as indicated by the
1805 .CW "using existing source a.o" '' ``
1808 The search for a transformation starts from the suffix of the target
1809 and continues through all the defined transformations, in the order
1810 dictated by the suffix ranking, until an existing file with the same
1811 base (the target name minus the suffix and any leading directories) is
1812 found. At that point, one or more transformation rules will have been
1813 found to change the one existing file into the target.
1815 For example, ignoring what's in the system makefile for now, say you
1816 have a makefile like this:
1818 \&.SUFFIXES : .out .o .c .y .l
1821 mv lex.yy.c $(.TARGET)
1824 mv y.tab.c $(.TARGET)
1828 cc -o $(.TARGET) $(.IMPSRC)
1833 .CW "pmake -rd ms jive.out" ,'' ``
1834 you would get the following output for
1837 Suff_FindDeps (jive.out)
1838 trying jive.o...not there
1839 trying jive.c...not there
1840 trying jive.y...not there
1841 trying jive.l...got it
1842 applying .l -> .c to "jive.l"
1843 applying .c -> .o to "jive.c"
1844 applying .o -> .out to "jive.o"
1846 and this is why: PMake starts with the target
1848 figures out its suffix
1850 and looks for things it can transform to a
1852 file. In this case, it only finds
1854 so it looks for the file
1856 It fails to find it, so it looks for transformations into a
1858 file. Again it has only one choice:
1862 and, as you know, fails to find it. At this point it has two choices:
1875 first, but can't find it, so it looks for
1877 and, lo and behold, there it is.
1878 At this point, it has defined a transformation path as follows:
1886 and applies the transformation rules accordingly. For completeness,
1887 and to give you a better idea of what PMake actually did with this
1888 three-step transformation, this is what PMake printed for the rest of
1891 Suff_FindDeps (jive.o)
1892 using existing source jive.c
1893 applying .c -> .o to "jive.c"
1894 Suff_FindDeps (jive.c)
1895 using existing source jive.l
1896 applying .l -> .c to "jive.l"
1897 Suff_FindDeps (jive.l)
1898 Examining jive.l...modified 17:16:01 Oct 4, 1987...up-to-date
1899 Examining jive.c...non-existent...out-of-date
1902 \&.\|.\|. meaningless lex output deleted .\|.\|.
1904 Examining jive.o...non-existent...out-of-date
1907 Examining jive.out...non-existent...out-of-date
1909 cc -o jive.out jive.o
1912 One final question remains: what does PMake do with targets that have
1913 no known suffix? PMake simply pretends it actually has a known suffix
1914 and searches for transformations accordingly.
1915 The suffix it chooses is the source for the
1918 target mentioned later. In the system makefile,
1920 is chosen as the ``null suffix''
1921 .Ix 0 def suffix null
1922 .Ix 0 def "null suffix"
1923 because most people use PMake to create programs. You are, however,
1924 free and welcome to change it to a suffix of your own choosing.
1925 The null suffix is ignored, however, when PMake is in compatibility
1926 mode (see chapter 4).
1927 .xH 2 Including Other Makefiles
1928 .Ix 0 def makefile inclusion
1931 Just as for programs, it is often useful to extract certain parts of a
1932 makefile into another file and just include it in other makefiles
1933 somehow. Many compilers allow you say something like
1937 to include the contents of
1939 in the source file. PMake allows you to do the same thing for
1940 makefiles, with the added ability to use variables in the filenames.
1941 An include directive in a makefile looks either like this:
1949 The difference between the two is where PMake searches for the file:
1950 the first way, PMake will look for
1951 the file only in the system makefile directory (or directories)
1952 (to find out what that directory is, give PMake the
1956 The system makefile directory search path can be overridden via the
1960 For files in double-quotes, the search is more complex:
1963 The directory of the makefile that's including the file.
1965 The current directory (the one in which you invoked PMake).
1967 The directories given by you using
1969 flags, in the order in which you gave them.
1971 Directories given by
1973 dependency lines (see chapter 4).
1975 The system makefile directory.
1980 You are free to use PMake variables in the filename\*-PMake will
1981 expand them before searching for the file. You must specify the
1982 searching method with either angle brackets or double-quotes
1984 of a variable expansion. I.e. the following
1986 SYSTEM = <command.mk>
1991 .xH 2 Saving Commands
1994 There may come a time when you will want to save certain commands to
1995 be executed when everything else is done. For instance: you're
1996 making several different libraries at one time and you want to create the
1997 members in parallel. Problem is,
1999 is another one of those programs that can't be run more than once in
2000 the same directory at the same time (each one creates a file called
2002 into which it stuffs information for the linker to use. Two of them
2003 running at once will overwrite each other's file and the result will
2004 be garbage for both parties). You might want a way to save the ranlib
2005 commands til the end so they can be run one after the other, thus
2006 keeping them from trashing each other's file. PMake allows you to do
2007 this by inserting an ellipsis (``.\|.\|.'') as a command between
2008 commands to be run at once and those to be run later.
2012 case above, you might do this:
2015 lib1.a : $(LIB1OBJS)
2017 ar cr $(.TARGET) $(.ALLSRC)
2021 lib2.a : $(LIB2OBJS)
2023 ar cr $(.TARGET) $(.ALLSRC)
2027 .Ix 0 ref variable local .TARGET
2028 .Ix 0 ref variable local .ALLSRC
2029 This would save both
2033 commands until the end, when they would run one after the other
2034 (using the correct value for the
2036 variable, of course).
2038 Commands saved in this manner are only executed if PMake manages to
2039 re-create everything without an error.
2040 .xH 2 Target Attributes
2042 PMake allows you to give attributes to targets by means of special
2043 sources. Like everything else PMake uses, these sources begin with a
2044 period and are made up of all upper-case letters. There are various
2045 reasons for using them, and I will try to give examples for most of
2046 them. Others you'll have to find uses for yourself. Think of it as ``an
2047 exercise for the reader.'' By placing one (or more) of these as a source on a
2048 dependency line, you are ``marking the target(s) with that
2049 attribute.'' That's just the way I phrase it, so you know.
2051 Any attributes given as sources for a transformation rule are applied
2052 to the target of the transformation rule when the rule is applied.
2053 .Ix 0 def attributes
2058 .Ix 0 def attributes .DONTCARE
2060 If a target is marked with this attribute and PMake can't figure out
2061 how to create it, it will ignore this fact and assume the file isn't
2062 really needed or actually exists and PMake just can't find it. This may prove
2063 wrong, but the error will be noted later on, not when PMake tries to create
2064 the target so marked. This attribute also prevents PMake from
2065 attempting to touch the target if it is given the
2070 .Ix 0 def attributes .EXEC
2072 This attribute causes its shell script to be executed while having no
2073 effect on targets that depend on it. This makes the target into a sort
2074 of subroutine. An example. Say you have some LISP files that need to
2075 be compiled and loaded into a LISP process. To do this, you echo LISP
2076 commands into a file and execute a LISP with this file as its input
2077 when everything's done. Say also that you have to load other files
2078 from another system before you can compile your files and further,
2079 that you don't want to go through the loading and dumping unless one
2082 files has changed. Your makefile might look a little bit
2083 like this (remember, this is an educational example, and don't worry
2086 rule, all will soon become clear, grasshopper):
2088 system : init a.fasl b.fasl c.fasl
2089 for i in $(.ALLSRC);
2091 echo -n '(load "' >> input
2092 echo -n ${i} >> input
2095 echo '(dump "$(.TARGET)")' >> input
2098 a.fasl : a.l init COMPILE
2099 b.fasl : b.l init COMPILE
2100 c.fasl : c.l init COMPILE
2102 echo '(compile "$(.ALLSRC)")' >> input
2104 echo '(load-system)' > input
2107 .Ix 0 ref attributes .USE
2108 .Ix 0 ref variable local .ALLSRC
2111 sources, don't appear in the local variables of targets that depend on
2112 them (nor are they touched if PMake is given the
2116 Note that all the rules, not just that for
2120 as a source. This is because none of the other targets can be made
2123 has been made, thus they depend on it.
2125 .Ix 0 def attributes .EXPORT
2127 This is used to mark those targets whose creation should be sent to
2128 another machine if at all possible. This may be used by some
2129 exportation schemes if the exportation is expensive. You should ask
2130 your system administrator if it is necessary.
2131 .IP .EXPORTSAME \n(pw
2132 .Ix 0 def attributes .EXPORTSAME
2133 .Ix 0 def .EXPORTSAME
2134 Tells the export system that the job should be exported to a machine
2135 of the same architecture as the current one. Certain operations (e.g.
2136 running text through
2138 can be performed the same on any architecture (CPU and
2139 operating system type), while others (e.g. compiling a program with
2141 must be performed on a machine with the same architecture. Not all
2142 export systems will support this attribute.
2144 .Ix 0 def attributes .IGNORE
2145 .Ix 0 def .IGNORE attribute
2148 attribute causes PMake to ignore errors from any of the target's commands, as
2149 if they all had `\-' before them.
2150 .IP .INVISIBLE \n(pw
2151 .Ix 0 def attributes .INVISIBLE
2152 .Ix 0 def .INVISIBLE
2153 This allows you to specify one target as a source for another without
2154 the one affecting the other's local variables. Useful if, say, you
2155 have a makefile that creates two programs, one of which is used to
2156 create the other, so it must exist before the other is created. You
2159 prog1 : $(PROG1OBJS) prog2 MAKEINSTALL
2160 prog2 : $(PROG2OBJS) .INVISIBLE MAKEINSTALL
2164 is some complex .USE rule (see below) that depends on the
2167 variable containing the right things. Without the
2173 rule couldn't be applied. This is not as useful as it should be, and
2174 the semantics may change (or the whole thing go away) in the
2175 not-too-distant future.
2177 .Ix 0 def attributes .JOIN
2179 This is another way to avoid performing some operations in parallel
2180 while permitting everything else to be done so. Specifically it
2181 forces the target's shell script to be executed only if one or more of the
2182 sources was out-of-date. In addition, the target's name,
2185 variable and all the local variables of any target that depends on it,
2186 is replaced by the value of its
2189 As an example, suppose you have a program that has four libraries that
2190 compile in the same directory along with, and at the same time as, the
2191 program. You again have the problem with
2193 that I mentioned earlier, only this time it's more severe: you
2194 can't just put the ranlib off to the end since the program
2195 will need those libraries before it can be re-created. You can do
2196 something like this:
2198 program : $(OBJS) libraries
2199 cc -o $(.TARGET) $(.ALLSRC)
2201 libraries : lib1.a lib2.a lib3.a lib4.a .JOIN
2204 .Ix 0 ref variable local .TARGET
2205 .Ix 0 ref variable local .ALLSRC
2206 .Ix 0 ref variable local .OODATE
2210 In this case, PMake will re-create the
2212 as necessary, along with
2218 It will then execute
2220 on any library that was changed and set
2223 variable to contain what's in
2226 .CW "lib1.a lib2.a lib3.a lib4.a" .'' ``
2227 In case you're wondering, it's called
2229 because it joins together different threads of the ``input graph'' at
2230 the target marked with the attribute.
2231 Another aspect of the .JOIN attribute is it keeps the target from
2232 being created if the
2237 .Ix 0 def attributes .MAKE
2241 attribute marks its target as being a recursive invocation of PMake.
2242 This forces PMake to execute the script associated with the target (if
2243 it's out-of-date) even if you gave the
2247 flag. By doing this, you can start at the top of a system and type
2251 and have it descend the directory tree (if your makefiles are set up
2252 correctly), printing what it would have executed if you hadn't
2257 .Ix 0 def attributes .NOEXPORT
2258 .Ix 0 def .NOEXPORT attribute
2259 If possible, PMake will attempt to export the creation of all targets to
2260 another machine (this depends on how PMake was configured). Sometimes,
2261 the creation is so simple, it is pointless to send it to another
2262 machine. If you give the target the
2264 attribute, it will be run locally, even if you've given PMake the
2268 .Ix 0 def attributes .NOTMAIN
2270 Normally, if you do not specify a target to make in any other way,
2271 PMake will take the first target on the first dependency line of a
2272 makefile as the target to create. That target is known as the ``Main
2273 Target'' and is labeled as such if you print the dependencies out
2278 Giving a target this attribute tells PMake that the target is
2282 This allows you to place targets in an included makefile and
2283 have PMake create something else by default.
2285 .Ix 0 def attributes .PRECIOUS
2286 .Ix 0 def .PRECIOUS attribute
2287 When PMake is interrupted (you type control-C at the keyboard), it
2288 will attempt to clean up after itself by removing any half-made
2289 targets. If a target has the
2291 attribute, however, PMake will leave it alone. An additional side
2292 effect of the `::' operator is to mark the targets as
2294 .Ix 0 ref operator double-colon
2297 .Ix 0 def attributes .SILENT
2298 .Ix 0 def .SILENT attribute
2299 Marking a target with this attribute keeps its commands from being
2300 printed when they're executed, just as if they had an `@' in front of them.
2302 .Ix 0 def attributes .USE
2304 By giving a target this attribute, you turn it into PMake's equivalent
2305 of a macro. When the target is used as a source for another target,
2306 the other target acquires the commands, sources and attributes (except
2309 If the target already has commands, the
2311 target's commands are added to the end. If more than one .USE-marked
2312 source is given to a target, the rules are applied sequentially.
2314 The typical .USE rule (as I call them) will use the sources of the
2315 target to which it is applied (as stored in the
2317 variable for the target) as its ``arguments,'' if you will.
2318 For example, you probably noticed that the commands for creating
2322 in the example in section 3.3
2324 were exactly the same. You can use the
2326 attribute to eliminate the repetition, like so:
2328 lib1.a : $(LIB1OBJS) MAKELIB
2329 lib2.a : $(LIB2OBJS) MAKELIB
2333 ar cr $(.TARGET) $(.ALLSRC)
2337 .Ix 0 ref variable local .TARGET
2338 .Ix 0 ref variable local .ALLSRC
2340 Several system makefiles (not to be confused with The System Makefile)
2341 make use of these .USE rules to make your
2342 life easier (they're in the default, system makefile directory...take a look).
2343 Note that the .USE rule source itself
2345 does not appear in any of the targets's local variables.
2346 There is no limit to the number of times I could use the
2348 rule. If there were more libraries, I could continue with
2349 .CW "lib3.a : $(LIB3OBJS) MAKELIB" '' ``
2350 and so on and so forth.
2351 .xH 2 Special Targets
2353 As there were in Make, so there are certain targets that have special
2354 meaning to PMake. When you use one on a dependency line, it is the
2355 only target that may appear on the left-hand-side of the operator.
2358 As for the attributes and variables, all the special targets
2359 begin with a period and consist of upper-case letters only.
2360 I won't describe them all in detail because some of them are rather
2361 complex and I'll describe them in more detail than you'll want in
2363 The targets are as follows:
2367 Any commands attached to this target are executed before anything else
2368 is done. You can use it for any initialization that needs doing.
2371 This is sort of a .USE rule for any target (that was used only as a
2372 source) that PMake can't figure out any other way to create. It's only
2373 ``sort of'' a .USE rule because only the shell script attached to the
2377 variable of a target that inherits
2379 commands is set to the target's own name.
2381 .Ix 0 ref variable local .IMPSRC
2384 This serves a function similar to
2386 in that commands attached to it are executed once everything has been
2387 re-created (so long as no errors occurred). It also serves the extra
2388 function of being a place on which PMake can hang commands you put off
2389 to the end. Thus the script for this target will be executed before
2390 any of the commands you save with the ``.\|.\|.''.
2393 The sources for this target are passed to the exportation system compiled
2394 into PMake. Some systems will use these sources to configure
2395 themselves. You should ask your system administrator about this.
2397 .Ix 0 def .IGNORE target
2398 .Ix 0 ref .IGNORE attribute
2399 .Ix 0 ref attributes .IGNORE
2400 This target marks each of its sources with the
2402 attribute. If you don't give it any sources, then it is like
2405 flag when you invoke PMake \*- errors are ignored for all commands.
2408 .Ix 0 def .INCLUDES target
2409 .Ix 0 def variable global .INCLUDES
2410 .Ix 0 def .INCLUDES variable
2411 The sources for this target are taken to be suffixes that indicate a
2412 file that can be included in a program source file.
2413 The suffix must have already been declared with
2416 Any suffix so marked will have the directories on its search path
2419 below) placed in the
2421 variable, each preceded by a
2423 flag. This variable can then be used as an argument for the compiler
2424 in the normal fashion. The
2426 suffix is already marked in this way in the system makefile.
2427 .Ix 0 ref makefile system
2430 \&.SUFFIXES : .bitmap
2431 \&.PATH.bitmap : /usr/local/X/lib/bitmaps
2432 \&.INCLUDES : .bitmap
2435 .CW "-I/usr/local/X/lib/bitmaps" '' ``
2438 variable and you can then say
2440 cc $(.INCLUDES) -c xprogram.c
2444 variable is not actually filled in until the entire makefile has been read.)
2445 .IP .INTERRUPT \n(pw
2446 .Ix 0 def .INTERRUPT
2447 When PMake is interrupted,
2448 it will execute the commands in the script for this target, if it
2451 .Ix 0 def .LIBS target
2452 .Ix 0 def .LIBS variable
2453 .Ix 0 def variable global .LIBS
2454 This does for libraries what
2456 does for include files, except the flag used is
2458 as required by those linkers that allow you to tell them where to find
2459 libraries. The variable used is
2461 Be forewarned that PMake may not have been compiled to do this if the
2462 linker on your system doesn't accept the
2466 variable will always be defined once the makefile has been read.
2469 If you didn't give a target (or targets) to create when you invoked
2470 PMake, it will take the sources of this target as the targets to
2472 .IP .MAKEFLAGS \n(pw
2473 .Ix 0 def .MAKEFLAGS target
2474 This target provides a way for you to always specify flags for PMake
2475 when the makefile is used. The flags are just as they would be typed
2476 to the shell (except you can't use shell variables unless they're in
2482 flags have no effect.
2485 .Ix 0 ref suffix null
2486 .Ix 0 ref "null suffix"
2487 This allows you to specify what suffix PMake should pretend a file has
2488 if, in fact, it has no known suffix. Only one suffix may be so
2489 designated. The last source on the dependency line is the suffix that
2490 is used (you should, however, only give one suffix.\|.\|.).
2493 If you give sources for this target, PMake will take them as
2494 directories in which to search for files it cannot find in the current
2495 directory. If you give no sources, it will clear out any directories
2496 added to the search path before. Since the effects of this all get
2497 very complex, I'll leave it til chapter four to give you a complete
2499 .IP .PATH\fIsuffix\fP \n(pw
2501 This does a similar thing to
2503 but it does it only for files with the given suffix. The suffix must
2504 have been defined already. Look at
2508 for more information.
2510 .Ix 0 def .PRECIOUS target
2511 .Ix 0 ref .PRECIOUS attribute
2512 .Ix 0 ref attributes .PRECIOUS
2517 attribute to each source on the dependency line, unless there are no
2518 sources, in which case the
2520 attribute is given to every target in the file.
2521 .IP .RECURSIVE \n(pw
2522 .Ix 0 def .RECURSIVE
2523 .Ix 0 ref attributes .MAKE
2525 This target applies the
2527 attribute to all its sources. It does nothing if you don't give it any sources.
2530 PMake is not constrained to only using the Bourne shell to execute
2531 the commands you put in the makefile. You can tell it some other shell
2532 to use with this target. Check out
2533 .B "A Shell is a Shell is a Shell"
2536 for more information.
2538 .Ix 0 def .SILENT target
2539 .Ix 0 ref .SILENT attribute
2540 .Ix 0 ref attributes .SILENT
2543 as a target, it applies the
2545 attribute to each of its sources. If there are no sources on the
2546 dependency line, then it is as if you gave PMake the
2548 flag and no commands will be echoed.
2551 This is used to give new file suffixes for PMake to handle. Each
2552 source is a suffix PMake should recognize. If you give a
2554 dependency line with no sources, PMake will forget about all the
2555 suffixes it knew (this also nukes the null suffix).
2556 For those targets that need to have suffixes defined, this is how you do it.
2558 In addition to these targets, a line of the form
2560 \fIattribute\fP : \fIsources\fP
2564 to all the targets listed as
2566 .xH 2 Modifying Variable Expansion
2568 .Ix 0 def variable expansion modified
2569 .Ix 0 ref variable expansion
2570 .Ix 0 def variable modifiers
2571 Variables need not always be expanded verbatim. PMake defines several
2572 modifiers that may be applied to a variable's value before it is
2573 expanded. You apply a modifier by placing it after the variable name
2574 with a colon between the two, like so:
2576 ${\fIVARIABLE\fP:\fImodifier\fP}
2578 Each modifier is a single character followed by something specific to
2579 the modifier itself.
2580 You may apply as many modifiers as you want \*- each one is applied to
2581 the result of the previous and is separated from the previous by
2584 There are seven ways to modify a variable's expansion, most of which
2585 come from the C shell variable modification characters:
2587 .IP "M\fIpattern\fP"
2589 .Ix 0 def modifier match
2590 This is used to select only those words (a word is a series of
2591 characters that are neither spaces nor tabs) that match the given
2593 The pattern is a wildcard pattern like that used by the shell, where
2595 means 0 or more characters of any sort;
2597 is any single character;
2599 matches any single character that is either `a', `b', `c' or `d'
2600 (there may be any number of characters between the brackets);
2602 matches any single character that is between `0' and `9' (i.e. any
2603 digit. This form may be freely mixed with the other bracket form), and
2604 `\\' is used to escape any of the characters `*', `?', `[' or `:',
2605 leaving them as regular characters to match themselves in a word.
2606 For example, the system makefile
2609 .CW "$(CFLAGS:M-[ID]*)" '' ``
2614 flags that would be passed to the C compiler. This allows it to
2615 properly locate include files and generate the correct dependencies.
2616 .IP "N\fIpattern\fP"
2618 .Ix 0 def modifier nomatch
2619 This is identical to
2621 except it substitutes all words that don't match the given pattern.
2622 .IP "S/\fIsearch-string\fP/\fIreplacement-string\fP/[g]"
2624 .Ix 0 def modifier substitute
2625 Causes the first occurrence of
2627 in the variable to be replaced by
2628 .I replacement-string ,
2631 flag is given at the end, in which case all occurrences of the string
2632 are replaced. The substitution is performed on each word in the
2633 variable in turn. If
2637 the string must match starting at the beginning of the word. If
2641 the string must match to the end of the word (these two may be
2642 combined to force an exact match). If a backslash precedes these two
2643 characters, however, they lose their special meaning. Variable
2644 expansion also occurs in the normal fashion inside both the
2647 .I replacement-string ,
2649 that a backslash is used to prevent the expansion of a
2651 not another dollar sign, as is usual.
2654 is just a string, not a pattern, so none of the usual
2655 regular-expression/wildcard characters have any special meaning save
2659 In the replacement string,
2662 character is replaced by the
2664 unless it is preceded by a backslash.
2665 You are allowed to use any character except
2666 colon or exclamation point to separate the two strings. This so-called
2667 delimiter character may be placed in either string by preceding it
2671 .Ix 0 def modifier tail
2672 Replaces each word in the variable expansion by its last
2673 component (its ``tail''). For example, given
2675 OBJS = ../lib/a.o b /usr/lib/libm.a
2681 .CW "a.o b libm.a" .'' ``
2684 .Ix 0 def modifier head
2687 except that every word is replaced by everything but the tail (the
2688 ``head''). Using the same definition of
2691 .CW "$(OBJS:H)" '' ``
2693 .CW "../lib /usr/lib" .'' ``
2694 Note that the final slash on the heads is removed and
2695 anything without a head is replaced by the empty string.
2698 .Ix 0 def modifier extension
2699 .Ix 0 def modifier suffix
2700 .Ix 0 ref suffix "variable modifier"
2702 replaces each word by its suffix (``extension''). So
2703 .CW "$(OBJS:E)" '' ``
2708 .Ix 0 def modifier root
2709 .Ix 0 def modifier base
2710 This replaces each word by everything but the suffix (the ``root'' of
2712 .CW "$(OBJS:R)" '' ``
2714 .CW "../lib/a b /usr/lib/libm" .''
2717 In addition, the System V style of substitution is also supported.
2720 $(\fIVARIABLE\fP:\fIsearch-string\fP=\fIreplacement\fP)
2722 It must be the last modifier in the chain. The search is anchored at
2723 the end of each word, so only suffixes or whole words may be replaced.
2724 .xH 2 More on Debugging
2725 .xH 2 More Exercises
2727 You've got a set programs, each of which is created from its own
2728 assembly-language source file (suffix
2730 Each program can be assembled into two versions, one with error-checking
2731 code assembled in and one without. You could assemble them into files
2732 with different suffixes
2736 for instance), but your linker only understands files that end in
2738 To top it all off, the final executables
2742 How can you still use transformation rules to make your life easier
2743 (Hint: assume the error-checking versions have
2745 tacked onto their prefix)?
2747 Assume, for a moment or two, you want to perform a sort of
2748 ``indirection'' by placing the name of a variable into another one,
2749 then you want to get the value of the first by expanding the second
2750 somehow. Unfortunately, PMake doesn't allow constructs like
2754 What do you do? Hint: no further variable expansion is performed after
2755 modifiers are applied, thus if you cause a $ to occur in the
2756 expansion, that's what will be in the result.
2757 .xH 1 PMake for Gods
2759 This chapter is devoted to those facilities in PMake that allow you to
2760 do a great deal in a makefile with very little work, as well as do
2761 some things you couldn't do in Make without a great deal of work (and
2762 perhaps the use of other programs). The problem with these features,
2763 is they must be handled with care, or you will end up with a mess.
2765 Once more, I assume a greater familiarity with
2767 or Sprite than I did in the previous two chapters.
2771 PMake supports the dispersal of files into multiple directories by
2772 allowing you to specify places to look for sources with
2774 targets in the makefile. The directories you give as sources for these
2775 targets make up a ``search path.'' Only those files used exclusively
2776 as sources are actually sought on a search path, the assumption being
2777 that anything listed as a target in the makefile can be created by the
2778 makefile and thus should be in the current directory.
2780 There are two types of search paths
2781 in PMake: one is used for all types of files (including included
2782 makefiles) and is specified with a plain
2785 .CW ".PATH : RCS" ''), ``
2786 while the other is specific to a certain type of file, as indicated by
2787 the file's suffix. A specific search path is indicated by immediately following
2790 with the suffix of the file. For instance
2792 \&.PATH.h : /sprite/lib/include /sprite/att/lib/include
2794 would tell PMake to look in the directories
2795 .CW /sprite/lib/include
2797 .CW /sprite/att/lib/include
2798 for any files whose suffix is
2801 The current directory is always consulted first to see if a file
2802 exists. Only if it cannot be found there are the directories in the
2803 specific search path, followed by those in the general search path,
2806 A search path is also used when expanding wildcard characters. If the
2807 pattern has a recognizable suffix on it, the path for that suffix will
2808 be used for the expansion. Otherwise the default search path is employed.
2810 When a file is found in some directory other than the current one, all
2811 local variables that would have contained the target's name
2815 will instead contain the path to the file, as found by PMake.
2816 Thus if you have a file
2822 $(CC) -o $(.TARGET) $(.ALLSRC)
2824 the command executed to create
2827 .CW "cc -o mumble ../lib/mumble.c" .'' ``
2828 (As an aside, the command in this case isn't strictly necessary, since
2829 it will be found using transformation rules if it isn't given. This is because
2831 is the null suffix by default and a transformation exists from
2835 Just thought I'd throw that in.)
2837 If a file exists in two directories on the same search path, the file
2838 in the first directory on the path will be the one PMake uses. So if
2839 you have a large system spread over many directories, it would behoove
2840 you to follow a naming convention that avoids such conflicts.
2842 Something you should know about the way search paths are implemented
2843 is that each directory is read, and its contents cached, exactly once
2844 \&\*- when it is first encountered \*- so any changes to the
2845 directories while PMake is running will not be noted when searching
2846 for implicit sources, nor will they be found when PMake attempts to
2847 discover when the file was last modified, unless the file was created in the
2848 current directory. While people have suggested that PMake should read
2849 the directories each time, my experience suggests that the caching seldom
2850 causes problems. In addition, not caching the directories slows things
2851 down enormously because of PMake's attempts to apply transformation
2852 rules through non-existent files \*- the number of extra file-system
2853 searches is truly staggering, especially if many files without
2854 suffixes are used and the null suffix isn't changed from
2856 .xH 2 Archives and Libraries
2859 and Sprite allow you to merge files into an archive using the
2861 command. Further, if the files are relocatable object files, you can
2864 on the archive and get yourself a library that you can link into any
2865 program you want. The main problem with archives is they double the
2866 space you need to store the archived files, since there's one copy in
2867 the archive and one copy out by itself. The problem with libraries is
2868 you usually think of them as
2872 and the linker thinks they're out-of-date if you so much as look at
2875 PMake solves the problem with archives by allowing you to tell it to
2876 examine the files in the archives (so you can remove the individual
2877 files without having to regenerate them later). To handle the problem
2878 with libraries, PMake adds an additional way of deciding if a library
2881 If the table of contents is older than the library, or is missing, the
2882 library is out-of-date.
2884 A library is any target that looks like
2886 or that ends in a suffix that was marked as a library using the
2890 is so marked in the system makefile.
2892 Members of an archive are specified as
2893 ``\fIarchive\fP(\fImember\fP[ \fImember\fP...])''.
2895 .CW libdix.a(window.o) '' ``'
2900 You may also use wildcards to specify the members of the archive. Just
2901 remember that most the wildcard characters will only find
2905 A file that is a member of an archive is treated specially. If the
2906 file doesn't exist, but it is in the archive, the modification time
2907 recorded in the archive is used for the file when determining if the
2908 file is out-of-date. When figuring out how to make an archived member target
2909 (not the file itself, but the file in the archive \*- the
2910 \fIarchive\fP(\fImember\fP) target), special care is
2911 taken with the transformation rules, as follows:
2913 \&\fIarchive\fP(\fImember\fP) is made to depend on \fImember\fP.
2915 The transformation from the \fImember\fP's suffix to the
2916 \fIarchive\fP's suffix is applied to the \fIarchive\fP(\fImember\fP) target.
2918 The \fIarchive\fP(\fImember\fP)'s
2920 variable is set to the name of the \fImember\fP if \fImember\fP is
2921 actually a target, or the path to the member file if \fImember\fP is
2926 variable for the \fIarchive\fP(\fImember\fP) target is set to the name
2927 of the \fIarchive\fP.
2928 .Ix 0 def variable local .ARCHIVE
2933 variable is set to the actual string inside the parentheses. In most
2934 cases, this will be the same as the
2937 .Ix 0 def variable local .MEMBER
2940 The \fIarchive\fP(\fImember\fP)'s place in the local variables of the
2941 targets that depend on it is taken by the value of its
2945 Thus, a program library could be created with the following makefile:
2950 OBJS = obj1.o obj2.o obj3.o
2951 libprog.a : libprog.a($(OBJS))
2952 ar cru $(.TARGET) $(.OODATE)
2955 This will cause the three object files to be compiled (if the
2956 corresponding source files were modified after the object file or, if
2957 that doesn't exist, the archived object file), the out-of-date ones
2960 a table of contents placed in the archive and the newly-archived
2961 object files to be removed.
2963 All this is used in the
2965 system makefile to create a single library with ease. This makefile
2970 # Rules for making libraries. The object files that make up the library
2971 # are removed once they are archived.
2973 # To make several libraries in parallel, you should define the variable
2974 # "many_libraries". This will serialize the invocations of ranlib.
2976 # To use, do something like this:
2978 # OBJECTS = <files in the library>
2980 # fish.a: fish.a($(OBJECTS)) MAKELIB
2996 # Re-archive the out-of-date members and recreate the library's table of
2997 # contents using ranlib. If many_libraries is defined, put the ranlib
2998 # off til the end so many libraries can be made at once.
3000 MAKELIB : .USE .PRECIOUS
3001 ar $(ARFLAGS) $(.TARGET) $(.OODATE)
3003 # ifdef many_libraries
3005 # endif /* many_libraries */
3007 #endif /* no_ranlib */
3009 #endif /* _MAKELIB_MK */
3011 .xH 2 On the Condition...
3014 Like the C compiler before it, PMake allows you to configure the makefile,
3015 based on the current environment, using conditional statements. A
3016 conditional looks like this:
3018 #if \fIboolean expression\fP
3020 #elif \fIanother boolean expression\fP
3023 \fIstill more lines\fP
3026 They may be nested to a maximum depth of 30 and may occur anywhere
3027 (except in a comment, of course). The
3029 must the very first character on the line.
3032 .I "boolean expression"
3033 is made up of terms that look like function calls, the standard C
3039 and the standard relational operators
3051 being overloaded to allow string comparisons as well.
3053 represents logical AND;
3057 is logical NOT. The arithmetic and string operators take precedence
3058 over all three of these operators, while NOT takes precedence over
3059 AND, which takes precedence over OR. This precedence may be
3060 overridden with parentheses, and an expression may be parenthesized to
3061 your heart's content. Each term looks like a call on one of four
3065 .Ix 0 def conditional make
3069 .CW make( \fItarget\fP\c
3073 is a target in the makefile. This is true if the given target was
3074 specified on the command line, or as the source for a
3076 target (note that the sources for
3078 are only used if no targets were given on the command line).
3081 .Ix 0 def conditional defined
3082 .Ix 0 def if defined
3084 .CW defined( \fIvariable\fP\c
3088 is defined. Certain variables are defined in the system makefile that
3089 identify the system on which PMake is being run.
3092 .Ix 0 def conditional exists
3095 .CW exists( \fIfile\fP\c
3097 and is true if the file can be found on the global search path
3098 (i.e. that defined by
3101 .CW .PATH \fIsuffix\fP
3105 .Ix 0 def conditional empty
3107 This syntax is much like the others, except the string inside the
3108 parentheses is of the same form as you would put between parentheses
3109 when expanding a variable, complete with modifiers and everything. The
3110 function returns true if the resulting string is empty (NOTE: an undefined
3111 variable in this context will cause at the very least a warning
3112 message about a malformed conditional, and at the worst will cause the
3113 process to stop once it has read the makefile. If you want to check
3114 for a variable being defined or empty, use the expression
3115 .CW !defined( \fIvar\fP\c ``
3116 .CW ") || empty(" \fIvar\fP\c
3118 as the definition of
3122 from being evaluated and causing an error, if the variable is
3123 undefined). This can be used to see if a variable contains a given
3126 #if !empty(\fIvar\fP:M\fIword\fP)
3129 The arithmetic and string operators may only be used to test the value
3130 of a variable. The lefthand side must contain the variable expansion,
3131 while the righthand side contains either a string, enclosed in
3132 double-quotes, or a number. The standard C numeric conventions (except
3133 for specifying an octal number) apply to both sides. E.g.
3137 #if $(MACHINE) == "sun3"
3139 #if $(LOAD_ADDR) < 0xc000
3141 are all valid conditionals. In addition, the numeric value of a
3142 variable can be tested as a boolean as follows:
3148 contains a non-zero value and
3154 contains a zero value.
3156 In addition to the bare
3158 there are other forms that apply one of the first two functions to each
3159 term. They are as follows:
3162 ifndef \fR!defined\fP
3166 There are also the ``else if'' forms:
3174 For instance, if you wish to create two versions of a program, one of which
3175 is optimized (the production version) and the other of which is for debugging
3176 (has symbols for dbx), you have two choices: you can create two
3177 makefiles, one of which uses the
3179 flag for the compilation, while the other uses the
3181 flag, or you can use another target (call it
3183 to create the debug version. The construct below will take care of
3184 this for you. I have also made it so defining the variable
3187 .CW "pmake -D DEBUG" )
3188 will also cause the debug version to be made.
3190 #if defined(DEBUG) || make(debug)
3196 There are, of course, problems with this approach. The most glaring
3197 annoyance is that if you want to go from making a debug version to
3198 making a production version, you have to remove all the object files,
3199 or you will get some optimized and some debug versions in the same
3200 program. Another annoyance is you have to be careful not to make two
3201 targets that ``conflict'' because of some conditionals in the
3202 makefile. For instance
3205 FORMATTER = ditroff -Plaser_printer
3208 FORMATTER = nroff -Pdot_matrix_printer
3211 would wreak havoc if you tried
3212 .CW "pmake draft print" '' ``
3213 since you would use the same formatter for each target. As I said,
3214 this all gets somewhat complicated.
3215 .xH 2 A Shell is a Shell is a Shell
3218 In normal operation, the Bourne Shell (better known as
3220 is used to execute the commands to re-create targets. PMake also allows you
3221 to specify a different shell for it to use when executing these
3222 commands. There are several things PMake must know about the shell you
3223 wish to use. These things are specified as the sources for the
3226 .Ix 0 ref target .SHELL
3227 target by keyword, as follows:
3228 .IP "\fBpath=\fP\fIpath\fP"
3229 PMake needs to know where the shell actually resides, so it can
3230 execute it. If you specify this and nothing else, PMake will use the
3231 last component of the path and look in its table of the shells it
3232 knows and use the specification it finds, if any. Use this if you just
3233 want to use a different version of the Bourne or C Shell (yes, PMake knows
3234 how to use the C Shell too).
3235 .IP "\fBname=\fP\fIname\fP"
3236 This is the name by which the shell is to be known. It is a single
3237 word and, if no other keywords are specified (other than
3239 it is the name by which PMake attempts to find a specification for
3240 it (as mentioned above). You can use this if you would just rather use
3241 the C Shell than the Bourne Shell
3242 .CW ".SHELL: name=csh" '' (``
3244 .IP "\fBquiet=\fP\fIecho-off command\fP"
3245 As mentioned before, PMake actually controls whether commands are
3246 printed by introducing commands into the shell's input stream. This
3247 keyword, and the next two, control what those commands are. The
3249 keyword is the command used to turn echoing off. Once it is turned
3250 off, echoing is expected to remain off until the echo-on command is given.
3251 .IP "\fBecho=\fP\fIecho-on command\fP"
3252 The command PMake should give to turn echoing back on again.
3253 .IP "\fBfilter=\fP\fIprinted echo-off command\fP"
3254 Many shells will echo the echo-off command when it is given. This
3255 keyword tells PMake in what format the shell actually prints the
3256 echo-off command. Wherever PMake sees this string in the shell's
3257 output, it will delete it and any following whitespace, up to and
3258 including the next newline. See the example at the end of this section
3260 .IP "\fBechoFlag=\fP\fIflag to turn echoing on\fP"
3261 Unless a target has been marked
3263 PMake wants to start the shell running with echoing on. To do this, it
3264 passes this flag to the shell as one of its arguments. If either this
3265 or the next flag begins with a `\-', the flags will be passed to the
3266 shell as separate arguments. Otherwise, the two will be concatenated
3267 (if they are used at the same time, of course).
3268 .IP "\fBerrFlag=\fP\fIflag to turn error checking on\fP"
3269 Likewise, unless a target is marked
3271 PMake wishes error-checking to be on from the very start. To this end,
3272 it will pass this flag to the shell as an argument. The same rules for
3273 an initial `\-' apply as for the
3275 .IP "\fBcheck=\fP\fIcommand to turn error checking on\fP"
3276 Just as for echo-control, error-control is achieved by inserting
3277 commands into the shell's input stream. This is the command to make
3278 the shell check for errors. It also serves another purpose if the
3279 shell doesn't have error-control as commands, but I'll get into that
3280 in a minute. Again, once error checking has been turned on, it is
3281 expected to remain on until it is turned off again.
3282 .IP "\fBignore=\fP\fIcommand to turn error checking off\fP"
3283 This is the command PMake uses to turn error checking off. It has
3284 another use if the shell doesn't do error-control, but I'll tell you
3285 about that.\|.\|.\|now.
3286 .IP "\fBhasErrCtl=\fP\fIyes or no\fP"
3287 This takes a value that is either
3291 Now you might think that the existence of the
3295 keywords would be enough to tell PMake if the shell can do
3296 error-control, but you'd be wrong. If
3300 PMake uses the check and ignore commands in a straight-forward manner.
3303 however, their use is rather different. In this case, the check
3304 command is used as a template, in which the string
3306 is replaced by the command that's about to be executed, to produce a
3307 command for the shell that will echo the command to be executed. The
3308 ignore command is also used as a template, again with
3310 replaced by the command to be executed, to produce a command that will
3311 execute the command to be executed and ignore any error it returns.
3312 When these strings are used as templates, you must provide newline(s)
3314 in the appropriate place(s).
3316 The strings that follow these keywords may be enclosed in single or
3317 double quotes (the quotes will be stripped off) and may contain the
3318 usual C backslash-characters (\en is newline, \er is return, \eb is
3319 backspace, \e' escapes a single-quote inside single-quotes, \e"
3320 escapes a double-quote inside double-quotes). Now for an example.
3322 This is actually the contents of the
3324 system makefile, and causes PMake to use the Bourne Shell in such a
3325 way that each command is printed as it is executed. That is, if more
3326 than one command is given on a line, each will be printed separately.
3327 Similarly, each time the body of a loop is executed, the commands
3328 within that loop will be printed, etc. The specification runs like
3332 # This is a shell specification to have the Bourne shell echo
3333 # the commands just before executing them, rather than when it reads
3334 # them. Useful if you want to see how variables are being expanded, etc.
3336 \&.SHELL : path=/bin/sh \e
3339 filter="+ set - " \e
3347 It tells PMake the following:
3349 The shell is located in the file
3351 It need not tell PMake that the name of the shell is
3353 as PMake can figure that out for itself (it's the last component of
3356 The command to stop echoing is
3359 The command to start echoing is
3362 When the echo off command is executed, the shell will print
3364 (The `+' comes from using the
3366 flag (rather than the
3368 flag PMake usually uses)). PMake will remove all occurrences of this
3369 string from the output, so you don't notice extra commands you didn't
3372 The flag the Bourne Shell will take to start echoing in this way is
3375 flag. The Bourne Shell will only take its flag arguments concatenated
3376 as its first argument, so neither this nor the
3378 specification begins with a \-.
3380 The flag to use to turn error-checking on from the start is
3383 The shell can turn error-checking on and off, and the commands to do
3390 I should note that this specification is for Bourne Shells that are
3391 not part of Berkeley
3393 as shells from Berkeley don't do error control. You can get a similar
3394 effect, however, by changing the last three lines to be:
3397 check="echo \e"+ %s\e"\en" \e
3398 ignore="sh -c '%s || exit 0\en"
3401 This will cause PMake to execute the two commands
3404 sh -c '\fIcmd\fP || true'
3406 for each command for which errors are to be ignored. (In case you are
3407 wondering, the thing for
3409 tells the shell to execute another shell without error checking on and
3410 always exit 0, since the
3414 to be executed only if the first command exited non-zero, and if the
3415 first command exited zero, the shell will also exit zero, since that's
3416 the last command it executed).
3418 .Ix 0 ref compatibility
3420 There are three (well, 3 \(12) levels of backwards-compatibility built
3421 into PMake. Most makefiles will need none at all. Some may need a
3422 little bit of work to operate correctly when run in parallel. Each
3423 level encompasses the previous levels (e.g.
3425 (one shell per command) implies
3427 The three levels are described in the following three sections.
3428 .xH 3 DEFCON 3 \*- Variable Expansion
3429 .Ix 0 ref compatibility
3431 As noted before, PMake will not expand a variable unless it knows of a
3432 value for it. This can cause problems for makefiles that expect to
3433 leave variables undefined except in special circumstances (e.g. if
3434 more flags need to be passed to the C compiler or the output from a
3435 text processor should be sent to a different printer). If the
3436 variables are enclosed in curly braces
3437 .CW ${PRINTER} ''), (``
3438 the shell will let them pass. If they are enclosed in parentheses,
3439 however, the shell will declare a syntax error and the make will come
3442 You have two choices: change the makefile to define the variables
3443 (their values can be overridden on the command line, since that's
3444 where they would have been set if you used Make, anyway) or always give the
3446 flag (this can be done with the
3448 target, if you want).
3449 .xH 3 DEFCON 2 \*- The Number of the Beast
3450 .Ix 0 ref compatibility
3452 Then there are the makefiles that expect certain commands, such as
3453 changing to a different directory, to not affect other commands in a
3454 target's creation script. You can solve this is either by going
3455 back to executing one shell per command (which is what the
3457 flag forces PMake to do), which slows the process down a good bit and
3458 requires you to use semicolons and escaped newlines for shell constructs, or
3459 by changing the makefile to execute the offending command(s) in a subshell
3460 (by placing the line inside parentheses), like so:
3463 (cd src; $(.PMAKE) install)
3464 (cd lib; $(.PMAKE) install)
3465 (cd man; $(.PMAKE) install)
3467 .Ix 0 ref operator double-colon
3468 .Ix 0 ref variable global .PMAKE
3471 .Ix 0 ref attribute .MAKE
3472 This will always execute the three makes (even if the
3474 flag was given) because of the combination of the ``::'' operator and
3477 attribute. Each command will change to the proper directory to perform
3478 the install, leaving the main shell in the directory in which it started.
3479 .xH 3 "DEFCON 1 \*- Imitation is the Not the Highest Form of Flattery"
3480 .Ix 0 ref compatibility
3482 The final category of makefile is the one where every command requires
3483 input, the dependencies are incompletely specified, or you simply
3484 cannot create more than one target at a time, as mentioned earlier. In
3485 addition, you may not have the time or desire to upgrade the makefile
3486 to run smoothly with PMake. If you are the conservative sort, this is
3487 the compatibility mode for you. It is entered either by giving PMake
3490 flag (for Make), or by executing PMake as
3492 In either case, PMake performs things exactly like Make (while still
3493 supporting most of the nice new features PMake provides). This
3496 No parallel execution.
3498 Targets are made in the exact order specified by the makefile. The
3499 sources for each target are made in strict left-to-right order, etc.
3501 A single Bourne shell is used to execute each command, thus the
3504 variable is useless, changing directories doesn't work across command
3507 If no special characters exist in a command line, PMake will break the
3508 command into words itself and execute the command directly, without
3509 executing a shell first. The characters that cause PMake to execute a
3532 You should notice that these are all the characters that are given
3533 special meaning by the shell (except
3537 which PMake deals with all by its lonesome).
3539 The use of the null suffix is turned off.
3540 .Ix 0 ref "null suffix"
3541 .Ix 0 ref suffix null
3542 .xH 2 The Way Things Work
3544 When PMake reads the makefile, it parses sources and targets into
3545 nodes in a graph. The graph is directed only in the sense that PMake
3546 knows which way is up. Each node contains not only links to all its
3547 parents and children (the nodes that depend on it and those on which
3548 it depends, respectively), but also a count of the number of its
3549 children that have already been processed.
3551 The most important thing to know about how PMake uses this graph is
3552 that the traversal is breadth-first and occurs in two passes.
3554 After PMake has parsed the makefile, it begins with the nodes the user
3555 has told it to make (either on the command line, or via a
3557 target, or by the target being the first in the file not labeled with
3560 attribute) placed in a queue. It continues to take the node off the
3561 front of the queue, mark it as something that needs to be made, pass
3564 (mentioned earlier) to find any implicit sources for the node, and
3565 place all the node's children that have yet to be marked at the end of
3566 the queue. If any of the children is a
3568 rule, its attributes are applied to the parent, then its commands are
3569 appended to the parent's list of commands and its children are linked
3570 to its parent. The parent's unmade children counter is then decremented
3573 node has been processed). You will note that this allows a
3575 node to have children that are
3577 nodes and the rules will be applied in sequence.
3578 If the node has no children, it is placed at the end of
3579 another queue to be examined in the second pass. This process
3580 continues until the first queue is empty.
3582 At this point, all the leaves of the graph are in the examination
3583 queue. PMake removes the node at the head of the queue and sees if it
3584 is out-of-date. If it is, it is passed to a function that will execute
3585 the commands for the node asynchronously. When the commands have
3586 completed, all the node's parents have their unmade children counter
3587 decremented and, if the counter is then 0, they are placed on the
3588 examination queue. Likewise, if the node is up-to-date. Only those
3589 parents that were marked on the downward pass are processed in this
3590 way. Thus PMake traverses the graph back up to the nodes the user
3591 instructed it to create. When the examination queue is empty and no
3592 shells are running to create a target, PMake is finished.
3594 Once all targets have been processed, PMake executes the commands
3597 target, either explicitly or through the use of an ellipsis in a shell
3598 script. If there were no errors during the entire process but there
3599 are still some targets unmade (PMake keeps a running count of how many
3600 targets are left to be made), there is a cycle in the graph. PMake does
3601 a depth-first traversal of the graph to find all the targets that
3602 weren't made and prints them out one by one.
3603 .xH 1 Answers to Exercises
3605 This is something of a trick question, for which I apologize. The
3606 trick comes from the UNIX definition of a suffix, which PMake doesn't
3607 necessarily share. You will have noticed that all the suffixes used in
3608 this tutorial (and in UNIX in general) begin with a period
3611 etc.). Now, PMake's idea of a suffix is more like English's: it's the
3612 characters at the end of a word. With this in mind, one possible
3614 solution to this problem goes as follows:
3616 \&.SUFFIXES : ec.exe .exe ec.obj .obj .asm
3617 ec.objec.exe .obj.exe :
3618 link -o $(.TARGET) $(.IMPSRC)
3620 asm -o $(.TARGET) -DDO_ERROR_CHECKING $(.IMPSRC)
3622 asm -o $(.TARGET) $(.IMPSRC)
3625 The trick to this one lies in the ``:='' variable-assignment operator
3626 and the ``:S'' variable-expansion modifier.
3627 .Ix 0 ref variable assignment expanded
3628 .Ix 0 ref variable expansion modified
3629 .Ix 0 ref modifier substitute
3632 Basically what you want is to take the pointer variable, so to speak,
3633 and transform it into an invocation of the variable at which it
3634 points. You might try something like
3636 $(PTR:S/^/\e$(/:S/$/))
3640 at the front of the variable name and
3642 at the end, thus transforming
3646 which is just what we want. Unfortunately (as you know if you've tried
3647 it), since, as it says in the hint, PMake does no further substitution
3648 on the result of a modified expansion, that's \fIall\fP you get. The
3649 solution is to make use of ``:='' to place that string into yet
3650 another variable, then invoke the other variable directly:
3652 *PTR := $(PTR:S/^/\e$(/:S/$/)/)
3656 to your heart's content.
3661 .xH 1 Glossary of Jargon
3663 A property given to a target that causes PMake to treat it differently.
3664 .Gp "command script"
3665 The lines immediately following a dependency line that specify
3666 commands to execute to create each of the targets on the dependency
3667 line. Each line in the command script must begin with a tab.
3668 .Gp "command-line variable"
3669 A variable defined in an argument when PMake is first executed.
3670 Overrides all assignments to the same variable name in the makefile.
3672 A construct much like that used in C that allows a makefile to be
3673 configured on the fly based on the local environment, or on what is being
3674 made by that invocation of PMake.
3675 .Gp "creation script"
3676 Commands used to create a target. See ``command script.''
3678 The relationship between a source and a target. This comes in three
3679 flavors, as indicated by the operator between the target and the
3680 source. `:' gives a straight time-wise dependency (if the target is
3681 older than the source, the target is out-of-date), while `!' provides
3682 simply an ordering and always considers the target out-of-date. `::'
3683 is much like `:', save it creates multiple instances of a target each
3684 of which depends on its own list of sources.
3685 .Gp "dynamic source"
3686 This refers to a source that has a local variable invocation in it. It
3687 allows a single dependency line to specify a different source for each
3689 .Gp "global variable"
3690 Any variable defined in a makefile. Takes precedence over variables
3691 defined in the environment, but not over command-line or local variables.
3693 What PMake constructs from a makefile. Consists of nodes made of the
3694 targets in the makefile, and the links between them (the
3695 dependencies). The links are directed (from source to target) and
3696 there may not be any cycles (loops) in the graph.
3697 .Gp "local variable"
3698 A variable defined by PMake visible only in a target's shell script.
3699 There are seven local variables, not all of which are defined for
3714 may be used on dependency lines to create ``dynamic sources.''
3716 A file that describes how a system is built. If you don't know what it
3717 is after reading this tutorial.\|.\|.\|.
3719 A letter, following a colon, used to alter how a variable is expanded.
3720 It has no effect on the variable itself.
3722 What separates a source from a target (on a dependency line) and specifies
3723 the relationship between the two. There are three:
3729 A list of directories in which a file should be sought. PMake's view
3730 of the contents of directories in a search path does not change once
3731 the makefile has been read. A file is sought on a search path only if
3732 it is exclusively a source.
3734 A program to which commands are passed in order to create targets.
3736 Anything to the right of an operator on a dependency line. Targets on
3737 the dependency line are usually created from the sources.
3738 .Gp "special target"
3739 A target that causes PMake to do special things when it's encountered.
3741 The tail end of a file name. Usually begins with a period,
3747 A word to the left of the operator on a dependency line. More
3748 generally, any file that PMake might create. A file may be (and often
3749 is) both a target and a source (what it is depends on how PMake is
3750 looking at it at the time \*- sort of like the wave/particle duality
3751 of light, you know).
3752 .Gp "transformation rule"
3753 A special construct in a makefile that specifies how to create a file
3754 of one type from a file of another, as indicated by their suffixes.
3755 .Gp "variable expansion"
3756 The process of substituting the value of a variable for a reference to
3757 it. Expansion may be altered by means of modifiers.
3759 A place in which to store text that may be retrieved later. Also used
3760 to define the local environment. Conditionals exist that test whether
3761 a variable is defined or not.
3763 .\" Output table of contents last, with an entry for the index, making
3764 .\" sure to save and restore the last real page number for the index...
3766 .\" We are not generating an index