Just as for programs, it is often useful to extract certain parts of a makefile into another file and just include it in other makefiles somehow. Many compilers allow you say something like:
#include "defs.h"
to include the contents of defs.h
in the source file. PMake
allows you to do the same thing for makefiles, with the
added ability to use variables in the filenames. An include
directive in a makefile looks either like this:
#include <file>
or this:
#include "file"
The difference between the two is where
PMake searches for the file: the first way,
PMake will look for the file only in the
system makefile directory (or directories) (to find out what that
directory is, give PMake the
-h
flag).
The system makefile directory search path can be overridden via the
-m
option. For files in double-quotes, the search
is more complex:
The directory of the makefile that's including the file.
The current directory (the one in which you invoked PMake).
The directories given by you using
-I
flags, in the order in which you
gave them.
Directories given by
.PATH
dependency lines (see
Chapter 4, PMake for Gods).
The system makefile directory.
in that order.
You are free to use PMake variables in the filename – PMake will expand them before searching for the file. You must specify the searching method with either angle brackets or double-quotes outside of a variable expansion. I.e. the following:
SYSTEM = <command.mk> #include $(SYSTEM)
will not work.
All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/
Questions that are not answered by the
documentation may be
sent to <[email protected]>.
Send questions about this document to <[email protected]>.