The information that tells make how to recompile a system comes from
reading a data base called the makefile.
Makefiles contain five kinds of things: explicit rules, implicit rules, variable definitions, directives, and comments. Rules, variables, and directives are described at length in later chapters.
objects
as a list of all object files (see Variables
Make Makefiles Simpler).
make to do something
special while reading the makefile. These include:
#, escape it with a backslash (e.g., \#). Comments may
appear on any line in the makefile, although they are treated
specially in certain situations.
You cannot use comments within variable references or function calls:
any instance of # will be treated literally (rather than as the
start of a comment) inside a variable reference or function call.
Comments within a recipe are passed to the shell, just as with any other recipe text. The shell decides how to interpret it: whether or not this is a comment is up to the shell.
Within a define directive, comments are not ignored during the
definition of the variable, but rather kept intact in the value of the
variable. When the variable is expanded they will either be treated
as make comments or as recipe text, depending on the context in
which the variable is evaluated.
Makefiles use a “line-based” syntax in which the newline character
is special and marks the end of a statement. GNU make has no
limit on the length of a statement line, up to the amount of memory in
your computer.
However, it is difficult to read lines which are too long to display
without wrapping or scrolling. So, you can format your makefiles for
readability by adding newlines into the middle of a statement: you do
this by escaping the internal newlines with a backslash (\)
character. Where we need to make a distinction we will refer to
“physical lines” as a single line ending with a newline (regardless
of whether it is escaped) and a “logical line” being a complete
statement including all escaped newlines up to the first non-escaped
newline.
The way in which backslash/newline combinations are handled depends on whether the statement is a recipe line or a non-recipe line. Handling of backslash/newline in a recipe line is discussed later (see Splitting Recipe Lines).
Outside of recipe lines, backslash/newlines are converted into a single space character. Once that is done, all whitespace around the backslash/newline is condensed into a single space: this includes all whitespace preceding the backslash, all whitespace at the beginning of the line after the backslash/newline, and any consecutive backslash/newline combinations.
If the .POSIX special target is defined then backslash/newline
handling is modified slightly to conform to POSIX.2: first, whitespace
preceding a backslash is not removed and second, consecutive
backslash/newlines are not condensed.
If you need to split a line but do not want any whitespace added, you can utilize a subtle trick: replace your backslash/newline pairs with the three characters dollar sign, backslash, and newline:
var := one$\
word
After make removes the backslash/newline and condenses the
following line into a single space, this is equivalent to:
var := one$ word
Then make will perform variable expansion. The variable
reference ‘$ ’ refers to a variable with the one-character name
“ ” (space) which does not exist, and so expands to the empty
string, giving a final assignment which is the equivalent of:
var := oneword