make(1)
_________________________________________________________________
make Command
maintain, update, and regenerate groups of programs
_________________________________________________________________
SYNTAX
make [ -f makefile ] [ -beiknpqrst ] [ macro=definition ... ] [
target ... ]
DESCRIPTION
Make follows a set of rules to update one or more targets.
Target is typically the name of an executable file. The rules
are taken from the makefile and from make's built-in list of
rules. Macros defined on the command line override those defined
in the makefile.
OPTIONS
-f makefile Makefile is taken to be the makefile. "-" represents
the standard input. If several -f makefile options
are given, the makefile input is read from each of
the named files in succession.
If no -f makefile option is given, make looks for
files named makefile or Makefile, or SCCS archives
named s.makefile or s.Makefile, in that order, and
reads the makefile from the first one it finds. If
none of those are present, make uses only its built-
in rules.
-b Assumes the makefiles are in an old format in which
blank lines after a rule end it even if the rule had
no commands.
-e Causes macro definitions read from the environment
(see below) to override macro definitions in the
makefiles.
-i Non-zero error codes returned by invoked commands are
ignored.
-k If a command fails, make stops working on the current
entry, but continues on other branches that do not
depend on that entry.
-n "No execute" mode. In this mode, make prints every
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
make(1)
command that it would normally execute, including
those it would not normally print; but it executes
none of them except for $(MAKE) commands (see below).
-p Make prints the explicit and default rules and the
macro definitions.
-q "Question" mode. Causes make to execute no commands,
but rather to return a zero status code if the
targets are up to date and a non-zero status code if
they are not.
-r Do not use the built-in rules.
-s "Silent" mode -- do not print command lines before
executing them.
-t Rather than executing the commands for a target that
is out of date, make will "touch" the target (see
touch(1)) to change its modification time. Use this
option with caution -- it makes it impossible for
make to determine later what targets are out of date.
Makefiles
Makefiles may contain any of the following:
* rules
* macros
* definitions
* comments
* include commands
A rule lists the ancestors a target depends on and the commands
required to rebuild the target if any of the ancestors are newer
than it is. There are two kinds of rules: explicit rules, which
apply only to specified files, and inference rules, which apply
to any file with the correct suffix.
Explicit rules have the following form:
target [ ... ] :[:] [ ancestor ... ] [ ; commands ]
[ commands ]
More than one target may be listed in a single rule if each one
depends on the same ancestors and is rebuilt by the same
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)
make(1)
commands.
If no ancestors are listed for a rule, the targets for that rule
are considered always out of date.
The commands may either follow a semicolon after the ancestors,
or (more commonly) may follow on successive lines, each beginning
with a tab character. Each commands line is given to a separate
invocation of sh(1), so cd in a commands line only affects the
line it is on.
Commands may begin with "@", "-", "@-", or "-@". Make removes
these characters before executing the command. If the command
begins with an "at" sign @, make does not print the command
before executing it. If the command begins with a dash -, make
does not stop if the command fails and returns a non-zero status.
Inference rules have the following form:
.suffix1[~][.suffix2[~]] :[:] [ ; command ]
[ command ]
An inference rule applies to any target whose suffix is suffix2;
the ancestor is the file whose name is the same as the target's
but with the suffix changed to suffix1. suffix2 may be empty, in
which case the rule applies to any target with no suffix.
Commands for inference rules usually use internal macros (see
below) to refer to file names. The set of possible suffixes is
defined using the special target .SUFFIXES (see below).
The tilde character ~ after suffix1 or suffix2 restricts the
target or ancestor respectively to begin with "s." like an SCCS
archive file (see sccs(1)).
Rules of either type may have either a single colon : or a double
colon ::.
* Make combines single-colon rules for the same target,
including inference rules, so that the target is considered
to depend on all the ancestors in all the single-colon rules
for that target.
Not counting any inference rules, at most one of the
single-colon rules for the target may have a command. If
any ancestor from any of the rules is newer than the target,
that command is executed. If the inference rule is the only
one with a command, its command is used.
* Double-colon rules for the same target are not combined. If
an ancestor in a double-colon rule is newer than the target,
only that rule's commands are executed.
DG/UX 4.00 Page 3
Licensed material--property of copyright holder(s)
make(1)
Macro definitions are lines in the following form:
name = [ definition ]
Macro calls can appear in rules and macro definitions. They have
two forms.
$(name)
is replaced by definition. If name is one character long, $name
may be used in place of $(name).
$(name:subst1=subst2)
is replaced by definition, with any occurrences of subst1 at the
end of words in definition replaced by subst2. Subst2 can be
empty.
Comments begin with # and continue until the end of the line.
Include commands are lines of the form:
include file
These include commands cause make to read from file at that
point. If file does not exist, make will try to get it from an
SCCS archive named s.file.
Any line in a makefile that is too long may be broken by escaping
the newline with a backslash character (\\). After the
backslash, blanks, tabs, and further newlines are ignored until
some other character is encountered.
Special Targets
These targets have special meanings. All but .DEFAULT are used
syntactically like targets, but have an entirely different
function. The special targets are as follows:
.DEFAULT This target matches anything that matches no other
rule.
.IGNORE If this appears as a target, the effect is as if the -i
option has been given.
.PRECIOUS Dependents of this target are not removed when quit or
interrupt are hit.
.SILENT If this appears as a target, the effect is as if the -s
option has been given.
DG/UX 4.00 Page 4
Licensed material--property of copyright holder(s)
make(1)
.SUFFIXES The ancestors of this target are appended to the list
of suffixes that can be used in inference rules. An
empty list of ancestors clears the list of suffixes.
The order of the suffixes is significant: an inference
rule will only be used if the suffix of the file it
would make precedes the suffix of the file it would
depend on in the suffix list.
The default suffix list is:
.o .c .y .l .s
Library Members as Targets
Normally a target or ancestor is a name of a file. However,
make has a special form by which a member of a library may be
referred to. The modification date of such a target or ancestor
is the modification date of the member in the archive, not the
date of the archive file. The form by which a library member is
referred to is:
lib(member)
The suffix of such a target or ancestor is assumed to be the
special suffix ".a", and an inference rule for ".a" may apply.
Make restricts library members to depend only on files whose
suffix is not the same as that of the member. For example,
"file.o" cannot be an ancestor of "lib(member.o)".
Internal Macros
Make has internal macros whose values depend on the target and
ancestors of the current rule.
$* Stands for current target's filename with the suffix
deleted.
$@ Stands for the current target's filename, or, if the target
is a library member of the form "lib(file.o)," for the
library name (in this case "lib").
$< Stands for the current target's list of ancestors.
$? Stands for the list of all the current target's ancestors
that are newer than the target is.
$% Stands for the target's member name, if the target is of the
DG/UX 4.00 Page 5
Licensed material--property of copyright holder(s)
make(1)
form "lib(member.o)"; in this case $% stands for "member.o".
The $* macro is only defined for targets for which an inference
rule applies, and the $< macro is only defined for targets for
which an inference rule or the .DEFAULT rule applies.
Each internal macro has a D (directory) and an F (file) form,
which stand for the directory and file parts of the macro's
normal value. For example, if $@ is "dir/file", $(@D) is "dir"
and $(@F) is "file". If the macro's normal value has no
directory part, "." is used.
If $@ is used in a rule as an ancestor, it must have a doubled
dollar sign, thus: $$@.
Built-in Rules and Macros
Make has a set of built-in rules. The following sh(1) command
will display them (along with a list of macro definitions and
suffixes):
make -pf /dev/null 2>/dev/null
The built-in rules are mostly inference rules for the most common
cases. They use macros that may be redefined to add options for
the commands for these rules:
AR Name of the ar command.
ARFLAGS Options for the ar command.
CC Name of the cc command.
CFLAGS Options for the cc command.
F77 Name of the f77 command.
F77FLAGS Options for the f77 command.
GET Name of the get command.
GFLAGS Options for the get command.
LDFLAGS Additional options for the cc or f77 commands if they
are linking an executable.
LEX Name of the lex command.
LFLAGS Options for the lex command.
DG/UX 4.00 Page 6
Licensed material--property of copyright holder(s)
make(1)
MAKE Name of the make command.
MAKEFLAGS Options for the make command (see below).
YACC Name of the yacc command.
YFLAGS Options for the yacc command.
There are built-in single-colon inference rules for the following
cases:
C source: .c .c~ .c.o .c~.o
F77 source: .f .f~ .f.o .f~.o
Lex source: .l.o .l~.o .l.c .l~.c
Yacc source: .y.o .y~.o .y.c .y~.c
Shell scripts: .sh .sh~
Archives: .c.a .c~.a .s~.a .f~.a .f.a
SCCS: .c~.c .f~.f .h~.h .l~.l .y~.y .sh~.sh .s~.s
Environment Variables
Make reads its environment variables (see sh(1), csh(1), and
environ(5)). Each environment variable and its value (except for
MAKEFLAGS) are treated like a macro name and its definition.
Macro definitions in the makefile override those from the
environment.
Make examines the MAKEFLAGS environment variable for further
command line options. Each character of the value of MAKEFLAGS
must be an option letter; the "-" that precedes options on the
command line is not allowed, nor are spaces or any other
character that is not an option. The -f option has no effect in
MAKEFLAGS.
Make adds MAKEFLAGS to the environment for each command it
executes. The value it gives to MAKEFLAGS in these environments
is a string containing each option letter other than -f that is
in force.
EXAMPLE
The following makefile indicates that:
* pgm depends on two files one.o and two.o
* one.o and two.o in turn depend on their corresponding source
files (one.c and two.c) and a common file incl.h:
* one.c and two.c in turn depend on their SCCS archives
DG/UX 4.00 Page 7
Licensed material--property of copyright holder(s)
make(1)
s.one.c and s.two.c.
# Definition of macro OFILES.
#
# The definition was continued across several lines
# by ending all but the last one with a backslash.
OFILES = \ one.o \ two.o \
# Explicit rule for making 'pgm' from 'one.o' and 'two.o'.
pgm: $(OFILES)
cc $(OFILES) -o pgm
# These single colon rules are combined with the inference
# rule for making .o files from .c files, and cause 'one.o'
# and 'two.o' to be recompiled if 'incl.h' is newer.
one.o: incl.h
two.o: incl.h
# Inference rules for making a .o file from a .c file,
# and for making a .c file from an SCCS archive containing
# a .c file -- for example, "one.c" and "s.one.c".
#
# (Make has built-in rules that already do this --
# these rules are for the purpose of illustration only)
.c.o:
cc -c $<
.c~.c:
get $<
FILES
[Mm]akefile
s.[Mm]akefile
SEE ALSO
cc(1), cd(1), lex(1), sh(1), yacc(1).
environ(5), printf(3S), sccsfile(4) in the Programmer's Reference
for the DG/UX System.
BUGS
Some commands return non-zero status inappropriately; begin
these commands with - or use -i to overcome the difficulty.
Filenames with the characters = : @ will not work.
Commands that are directly executed by the shell, notably cd(1),
DG/UX 4.00 Page 8
Licensed material--property of copyright holder(s)
make(1)
are ineffectual across Newlines in make.
The syntax (lib(file1.o file2.o file3.o) is illegal.
You cannot build lib(file.0) from file.o.
The macro $(a:.o=.c~) does not work.
WARNING
Under NFS, all files referenced by make should reside on the same
machine so that their timestamps are consistent, thereby avoiding
clock skew.
DG/UX 4.00 Page 9
Licensed material--property of copyright holder(s)