1MAKE(1) General Commands Manual MAKE(1)
2
3
4
6 make - maintain program groups
7
9 make [ -f makefile ] [ option ] ... file ...
10
12 Make executes commands in makefile to update one or more target names.
13 Name is typically a program. If no -f option is present, `makefile'
14 and `Makefile' are tried in order. If makefile is `-', the standard
15 input is taken. More than one -f option may appear
16
17 Make updates a target if it depends on prerequisite files that have
18 been modified since the target was last modified, or if the target does
19 not exist.
20
21 Makefile contains a sequence of entries that specify dependencies. The
22 first line of an entry is a blank-separated list of targets, then a
23 colon, then a list of prerequisite files. Text following a semicolon,
24 and all following lines that begin with a tab, are shell commands to be
25 executed to update the target.
26
27 Sharp and newline surround comments.
28
29 The following makefile says that `pgm' depends on two files `a.o' and
30 `b.o', and that they in turn depend on `.c' files and a common file
31 `incl'.
32
33
34 pgm: a.o b.o
35 cc a.o b.o -lm -o pgm
36 a.o: incl a.c
37 cc -c a.c
38 b.o: incl b.c
39 cc -c b.c
40
41 Makefile entries of the form
42
43 string1 = string2
44
45 are macro definitions. Subsequent appearances of $(string1) are
46 replaced by string2. If string1 is a single character, the parentheses
47 are optional.
48
49 Make infers prerequisites for files for which makefile gives no con‐
50 struction commands. For example, a `.c' file may be inferred as pre‐
51 requisite for a `.o' file and be compiled to produce the `.o' file.
52 Thus the preceding example can be done more briefly:
53
54
55 pgm: a.o b.o
56 cc a.o b.o -lm -o pgm
57 a.o b.o: incl
58
59 Prerequisites are inferred according to selected suffixes listed as the
60 `prerequisites' for the special name `.SUFFIXES'; multiple lists accu‐
61 mulate; an empty list clears what came before. Order is significant;
62 the first possible name for which both a file and a rule as described
63 in the next paragraph exist is inferred. The default list is
64
65 .SUFFIXES: .out .o .c .e .r .f .y .l .s
66
67 The rule to create a file with suffix s2 that depends on a similarly
68 named file with suffix s1 is specified as an entry for the `target'
69 s1s2. In such an entry, the special macro $* stands for the target
70 name with suffix deleted, $@ for the full target name, $< for the com‐
71 plete list of prerequisites, and $? for the list of prerequisites that
72 are out of date. For example, a rule for making optimized `.o' files
73 from `.c' files is
74
75 .c.o: ; cc -c -O -o $@ $*.c
76
77 Certain macros are used by the default inference rules to communicate
78 optional arguments to any resulting compilations. In particular,
79 `CFLAGS' is used for cc and f77(1) options, `LFLAGS' and `YFLAGS' for
80 lex and yacc(1) options.
81
82 Command lines are executed one at a time, each by its own shell. A
83 line is printed when it is executed unless the special target `.SILENT'
84 is in makefile, or the first character of the command is `@'.
85
86 Commands returning nonzero status (see intro(1)) cause make to termi‐
87 nate unless the special target `.IGNORE' is in makefile or the command
88 begins with <tab><hyphen>.
89
90 Interrupt and quit cause the target to be deleted unless the target
91 depends on the special name `.PRECIOUS'.
92
93 Other options:
94
95 -i Equivalent to the special entry `.IGNORE:'.
96
97 -k When a command returns nonzero status, abandon work on the cur‐
98 rent entry, but continue on branches that do not depend on the
99 current entry.
100
101 -n Trace and print, but do not execute the commands needed to
102 update the targets.
103
104 -t Touch, i.e. update the modified date of targets, without execut‐
105 ing any commands.
106
107 -r Equivalent to an initial special entry `.SUFFIXES:' with no
108 list.
109
110 -s Equivalent to the special entry `.SILENT:'.
111
113 makefile, Makefile
114
116 sh(1), touch(1)
117 S. I. Feldman Make - A Program for Maintaining Computer Programs
118
120 Some commands return nonzero status inappropriately. Use -i to over‐
121 come the difficulty.
122 Commands that are directly executed by the shell, notably cd(1), are
123 ineffectual across newlines in make.
124
125
126
127 MAKE(1)