3.5. Special Targets

As there were in Make, so there are certain targets that have special meaning to PMake. When you use one on a dependency line, it is the only target that may appear on the left-hand-side of the operator. As for the attributes and variables, all the special targets begin with a period and consist of upper-case letters only. I will not describe them all in detail because some of them are rather complex and I will describe them in more detail than you will want in Chapter 4, PMake for Gods. The targets are as follows:

.BEGINAny commands attached to this target are executed before anything else is done. You can use it for any initialization that needs doing.
.DEFAULTThis is sort of a .USE rule for any target (that was used only as a source) that PMake can not figure out any other way to create. It is only sort of a .USE rule because only the shell script attached to the .DEFAULT target is used. The .IMPSRC variable of a target that inherits .DEFAULT's commands is set to the target's own name.
.ENDThis serves a function similar to .BEGIN, in that commands attached to it are executed once everything has been re-created (so long as no errors occurred). It also serves the extra function of being a place on which PMake can hang commands you put off to the end. Thus the script for this target will be executed before any of the commands you save with the ....
.EXPORTThe sources for this target are passed to the exportation system compiled into PMake. Some systems will use these sources to configure themselves. You should ask your system administrator about this.
.IGNOREThis target marks each of its sources with the .IGNORE attribute. If you do not give it any sources, then it is like giving the -i flag when you invoke PMake – errors are ignored for all commands.

The sources for this target are taken to be suffixes that indicate a file that can be included in a program source file. The suffix must have already been declared with .SUFFIXES (see below). Any suffix so marked will have the directories on its search path (see .PATH, below) placed in the .INCLUDES variable, each preceded by a -I flag. This variable can then be used as an argument for the compiler in the normal fashion. The .h suffix is already marked in this way in the system makefile. E.g. if you have

.SUFFIXES       : .bitmap
.PATH.bitmap    : /usr/local/X/lib/bitmaps
.INCLUDES       : .bitmap

PMake will place -I/usr/local/X/lib/bitmaps in the .INCLUDES variable and you can then say

cc $(.INCLUDES) -c xprogram.c

(Note: the .INCLUDES variable is not actually filled in until the entire makefile has been read.)

.INTERRUPTWhen PMake is interrupted, it will execute the commands in the script for this target, if it exists.
.LIBSThis does for libraries what .INCLUDES does for include files, except the flag used is -L, as required by those linkers that allow you to tell them where to find libraries. The variable used is .LIBS. Be forewarned that PMake may not have been compiled to do this if the linker on your system does not accept the -L flag, though the .LIBS variable will always be defined once the makefile has been read.
.MAINIf you did not give a target (or targets) to create when you invoked PMake, it will take the sources of this target as the targets to create.
.MAKEFLAGSThis target provides a way for you to always specify flags for PMake when the makefile is used. The flags are just as they would be typed to the shell (except you can not use shell variables unless they are in the environment), though the -f and -r flags have no effect.
.NULLThis allows you to specify what suffix PMake should pretend a file has if, in fact, it has no known suffix. Only one suffix may be so designated. The last source on the dependency line is the suffix that is used (you should, however, only give one suffix...).
.PATHIf you give sources for this target, PMake will take them as directories in which to search for files it cannot find in the current directory. If you give no sources, it will clear out any directories added to the search path before. Since the effects of this all get very complex, we will leave it till Chapter 4, PMake for Gods to give you a complete explanation.
.PATHsuffixThis does a similar thing to .PATH, but it does it only for files with the given suffix. The suffix must have been defined already. Look at Search Paths (Section 4.1, “Search Paths”) for more information.
.PRECIOUSSimilar to .IGNORE, this gives the .PRECIOUS attribute to each source on the dependency line, unless there are no sources, in which case the .PRECIOUS attribute is given to every target in the file.
.RECURSIVEThis target applies the .MAKE attribute to all its sources. It does nothing if you do not give it any sources.
.SHELLPMake is not constrained to only using the Bourne shell to execute the commands you put in the makefile. You can tell it some other shell to use with this target. Check out A Shell is a Shell is a Shell (Section 4.4, “A Shell is a Shell is a Shell”) for more information.
.SILENTWhen you use .SILENT as a target, it applies the .SILENT attribute to each of its sources. If there are no sources on the dependency line, then it is as if you gave PMake the -s flag and no commands will be echoed.
.SUFFIXESThis is used to give new file suffixes for PMake to handle. Each source is a suffix PMake should recognize. If you give a .SUFFIXES dependency line with no sources, PMake will forget about all the suffixes it knew (this also nukes the null suffix). For those targets that need to have suffixes defined, this is how you do it.

In addition to these targets, a line of the form:

attribute : sources

applies the attribute to all the targets listed as sources.

All FreeBSD documents are available for download at https://download.freebsd.org/ftp/doc/

Questions that are not answered by the documentation may be sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.