xref: /386bsd/usr/share/man/cat1/make.0 (revision a2142627)
1MAKE(1)                     386BSD Reference Manual                    MAKE(1)
2
3NNAAMMEE
4     mmaakkee - maintain program dependencies
5
6SSYYNNOOPPSSIISS
7     mmaakkee [--eeiikknnqqrrssttvv] [--DD _v_a_r_i_a_b_l_e] [--dd _f_l_a_g_s] [--ff _m_a_k_e_f_i_l_e] [--II _d_i_r_e_c_t_o_r_y]
8          [--jj _m_a_x__j_o_b_s] [_v_a_r_i_a_b_l_e=_v_a_l_u_e] [_t_a_r_g_e_t ...]
9
10DDEESSCCRRIIPPTTIIOONN
11     MMaakkee is a program designed to simplify the maintenance of other programs.
12     Its input is a list of specifications as to the files upon which programs
13     and other files depend.  If the file `_m_a_k_e_f_i_l_e' exists, it is read for
14     this list of specifications.  If it does not exist, the file `_M_a_k_e_f_i_l_e'
15     is read.  If the file `._d_e_p_e_n_d' exists, it is read (see mkdep(1)).
16
17     This manual page is intended as a reference document only.  For a more
18     thorough description of mmaakkee and makefiles, please refer to _M_a_k_e - _A
19     _T_u_t_o_r_i_a_l.
20
21     The options are as follows:
22
23     --DD _v_a_r_i_a_b_l_e
24             Define variable to be 1, in the global context.
25
26     --dd _f_l_a_g_s
27             Turn on debugging, and specify which portions of mmaakkee are to
28             print debugging information.  _F_l_a_g_s is one or more of the
29             following:
30
31             _A       Print all possible debugging information; equivalent to
32                     specifying all of the debugging flags.
33
34             _a       Print debugging information about archive searching and
35                     caching.
36
37             _c       Print debugging information about conditional evaluation.
38
39             _d       Print debugging information about directory searching and
40                     caching.
41
42             _g_1      Print the input graph before making anything.
43
44             _g_2      Print the input graph after making everything, or before
45                     exiting on error.
46
47             _j       Print debugging information about running multiple
48                     shells.
49
50             _m       Print debugging information about making targets,
51                     including modification dates.
52
53             _s       Print debugging information about suffix-transformation
54                     rules.
55
56             _t       Print debugging information about target list
57                     maintenance.
58
59             _v       Print debugging information about variable assignment.
60
61     --ee      Specify that environmental variables override macro assignments
62             within makefiles.
63
64     --ff _m_a_k_e_f_i_l_e
65             Specify a makefile to read instead of the default `_m_a_k_e_f_i_l_e' and
66             `_M_a_k_e_f_i_l_e'. If _m_a_k_e_f_i_l_e is `--', standard input is read.  Multiple
67             makefile's may be specified, and are read in the order specified.
68
69     --II _d_i_r_e_c_t_o_r_y
70             Specify a directory in which to search for makefiles and included
71             makefiles.  The system makefile directory is automatically
72             included as part of this list.
73
74     --ii      Ignore non-zero exit of shell commands in the makefile.
75             Equivalent to specifying `--' before each command line in the
76             makefile.
77
78     --jj _m_a_x__j_o_b_s
79             Specify the maximum number of jobs that mmaakkee may have running at
80             any one time.
81
82     --kk      Continue processing after errors are encountered, but only on
83             those targets that do not depend on the target whose creation
84             caused the error.
85
86     --nn      Display the commands that would have been executed, but do not
87             actually execute them.
88
89     --qq      Do not execute any commands, but exit 0 if the specified targets
90             are up-to-date and 1, otherwise.
91
92     --rr      Do not use the built-in rules specified in the system makefile.
93
94     --ss      Do not echo any commands as they are executed.  Equivalent to
95             specifying `@@' before each command line in the makefile.
96
97     --tt      Rather than re-building a target as specified in the makefile,
98             create it or update its modification time to make it appear up-
99             to-date.
100
101     _v_a_r_i_a_b_l_e=_v_a_l_u_e
102             Set the value of the variable _v_a_r_i_a_b_l_e to _v_a_l_u_e.
103
104     There are six different types of lines in a makefile: file dependency
105     specifications, shell commands, variable assignments, include statements,
106     conditional directives, and comments.
107
108     In general, lines may be continued from one line to the next by ending
109     them with a backslash (`\'). The trailing newline character and initial
110     whitespace on the following line are compressed into a single space.
111
112FFIILLEE DDEEPPEENNDDEENNCCYY SSPPEECCIIFFIICCAATTIIOONNSS
113     Dependency lines consist of one or more targets, an operator, and zero or
114     more sources.  This creates a relationship where the targets ``depend''
115     on the sources and are usually created from them.  The exact relationship
116     between the target and the source is determined by the operator that
117     separates them.  The three operators are as follows:
118
119     ::     A target is considered out-of-date if its modification time is less
120           than those of any of its sources.  Sources for a target accumulate
121           over dependency lines when this operator is used.  The target is
122           removed if mmaakkee is interrupted.
123
124     !!     Targets are always re-created, but not until all sources have been
125           examined and re-created as necessary.  Sources for a target
126           accumulate over dependency lines when this operator is used.  The
127           target is removed if mmaakkee is interrupted.
128
129     ::::    If no sources are specified, the target is always re-created.
130           Otherwise, a target is considered out-of-date if any of its sources
131           has been modified more recently than the target.  Sources for a
132           target do not accumulate over dependency lines when this operator
133           is used.  The target will not be removed if mmaakkee is interrupted.
134
135     Targets and sources may contain the shell wildcard values `?', `*', `[]'
136     and `{}'. The values `?', `*' and `[]' may only be used as part of the
137     final component of the target or source, and must be used to describe
138     existing files.  The value `{}' need not necessarily be used to describe
139     existing files.  Expansion is in directory order, not alphabetically as
140     done in the shell.
141
142SSHHEELLLL CCOOMMMMAANNDDSS
143     Each target may have associated with it a series of shell commands,
144     normally used to create the target.  Each of the commands in this script
145     _m_u_s_t be preceded by a tab.  While any target may appear on a dependency
146     line, only one of these dependencies may be followed by a creation
147     script, unless the `::::' operator is used.
148
149     If the first or first two characters of the command line are `@@' and/or
150     `--', the command is treated specially.  A `@@' causes the command not to
151     be echoed before it is executed.  A `--' causes any non-zero exit status
152     of the command line to be ignored.
153
154VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
155     Variables in make are much like variables in the shell, and, by
156     tradition, consist of all upper-case letters.  The five operators that
157     can be used to assign values to variables are as follows:
158
159     ==       Assign the value to the variable.  Any previous value is
160             overridden.
161
162     ++==      Append the value to the current value of the variable.
163
164     ??==      Assign the value to the variable if it is not already defined.
165
166     ::==      Assign with expansion, i.e. expand the value before assigning it
167             to the variable.  Normally, expansion is not done until the
168             variable is referenced.
169
170     !!==      Expand the value and pass it to the shell for execution and
171             assign the result to the variable.  Any newlines in the result
172             are replaced with spaces.
173
174     Any white-space before the assigned _v_a_l_u_e is removed; if the value is
175     being appended, a single space is inserted between the previous contents
176     of the variable and the appended value.
177
178     Variables are expanded by surrounding the variable name with either curly
179     braces (`{}') or parenthesis (`()') and preceding it with a dollar sign
180     (`$'). If the variable name contains only a single letter, the
181     surrounding braces or parenthesis are not required.  This shorter form is
182     not recommended.
183
184     Variable substitution occurs at two distinct times, depending on where
185     the variable is being used.  Variables in dependency lines are expanded
186     as the line is read.  Variables in shell commands are expanded when the
187     shell command is executed.
188
189     The four different classes of variables (in order of increasing
190     precedence) are:
191
192     Environment variables
193             Variables defined as part of mmaakkee's environment.
194
195     Global variables
196
197
198             Variables defined in the makefile or in included makefiles.
199
200     Command line variables
201             Variables defined as part of the command line.
202
203     Local variables
204             Variables that are defined specific to a certain target.  The
205             seven local variables are as follows:
206
207             ._A_L_L_S_R_C   The list of all sources for this target; also known as
208                       `>'.
209
210             ._A_R_C_H_I_V_E  The name of the archive file.
211
212             ._I_M_P_S_R_C   The name/path of the source from which the target is to
213                       be transformed (the ``implied'' source); also known as
214                       `<'.
215
216             ._M_E_M_B_E_R   The name of the archive member.
217
218             ._O_O_D_A_T_E   The list of sources for this target that were deemed
219                       out-of-date; also known as `?'.
220
221             ._P_R_E_F_I_X   The file prefix of the file, containing only the file
222                       portion, no suffix or preceding directory components;
223                       also known as `*'.
224
225             ._T_A_R_G_E_T   The name of the target; also known as `@'.
226
227             The shorter forms `@', `?', `>' and `*' are permitted for
228             backward compatibility with historical makefiles and are not
229             recommended.  The six variables `@_F', `@_D', `<_F', `<_D', `*_F' and
230             `*_D' are permitted for compatibility with AT&T System V UNIX
231             makefiles and are not recommended.
232
233             Four of the local variables may be used in sources on dependency
234             lines because they expand to the proper value for each target on
235             the line.  These variables are `._T_A_R_G_E_T', `._P_R_E_F_I_X', `._A_R_C_H_I_V_E',
236             and `._M_E_M_B_E_R'.
237
238             In addition, mmaakkee sets or knows about the following variables:
239
240             $          A single dollar sign `$', i.e.  `$$' expands to a
241                        single dollar sign.
242
243             ._M_A_K_E      The name that mmaakkee was executed with (_a_r_g_v [0])
244
245             ._C_U_R_D_I_R    A path to the directory where mmaakkee was executed.
246
247             MAKEFLAGS  The environment variable `MAKEFLAGS' may contain
248                        anything that may be specified on mmaakkee's command line.
249                        Anything specified on mmaakkee's command line is appended
250                        to the `MAKEFLAGS' variable which is then entered into
251                        the environment for all programs which mmaakkee executes.
252
253             Variable expansion may be modified to select or modify each word
254             of the variable (where a ``word'' is white-space delimited
255             sequence of characters).  The general format of a variable
256             expansion is as follows:
257
258                   {variable[:modifier[:...]]}
259
260             Each modifier begins with a colon and one of the following
261             special characters.  The colon may be escaped with a backslash
262
263
264             (`\').
265
266             EE           Replaces each word in the variable with its suffix.
267
268             HH           Replaces each word in the variable with everything
269                         but the last component.
270
271             MM_p_a_t_t_e_r_n    Select only those words that match the rest of the
272                         modifier.  The standard shell wildcard characters
273                         (`*', `?', and `[]') may be used.  The wildcard
274                         characters may be escaped with a backslash (`\').
275
276             NN_p_a_t_t_e_r_n    This is identical to `MM', but selects all words which
277                         do not match the rest of the modifier.
278
279             RR           Replaces each word in the variable with everything
280                         but its suffix.
281
282             SS/_o_l_d__p_a_t_t_e_r_n/_n_e_w__p_a_t_t_e_r_n/[gg]
283                         Modify the first occurrence of _o_l_d__p_a_t_t_e_r_n in each
284                         word to be replaced with _n_e_w__p_a_t_t_e_r_n. If a `g' is
285                         appended to the last slash of the pattern, all
286                         occurrences in each word are replaced.  If
287                         _o_l_d__p_a_t_t_e_r_n begins with a carat (`^'), _o_l_d__p_a_t_t_e_r_n is
288                         anchored at the beginning of each word.  If
289                         _o_l_d__p_a_t_t_e_r_n ends with a dollar sign (`$'), it is
290                         anchored at the end of each word.  Inside _n_e_w__s_t_r_i_n_g,
291                         an ampersand (`&') is replaced by _o_l_d__p_a_t_t_e_r_n. Any
292                         character may be used as a delimiter for the parts of
293                         the modifier string.  The anchoring, ampersand and
294                         delimiter characters may be escaped with a backslash
295                         (`\').
296
297                         Variable expansion occurs in the normal fashion
298                         inside both _o_l_d__s_t_r_i_n_g and _n_e_w__s_t_r_i_n_g with the single
299                         exception that a backslash is used to prevent the
300                         expansion of a dollar sign (`$') not a preceding
301                         dollar sign as is usual.
302
303             TT           Replaces each word in the variable with its last
304                         component.
305
306             _o_l_d__s_t_r_i_n_g=_n_e_w__s_t_r_i_n_g
307                         This is the AT&T System V UNIX style variable
308                         substitution.  It must be the last modifier
309                         specified.  _O_l_d__s_t_r_i_n_g is anchored at the end of each
310                         word, so only suffixes or entire words may be
311                         replaced.
312
313IINNCCLLUUDDEE SSTTAATTEEMMEENNTTSS AANNDD CCOONNDDIITTIIOONNAALLSS
314     Makefile inclusion and conditional structures reminiscent of the C
315     programming language are provided in mmaakkee. All such structures are
316     identified by a line beginning with a single dot (`.') character.  Files
317     are included with either `.include <file>' or `.include "file"'.
318     Variables between the angle brackets or double quotes are expanded to
319     form the file name.  If angle brackets are used, the included makefile is
320     expected to be in the system makefile directory.  If double quotes are
321     used, the including makefile's directory and any directories specified
322     using the --II option are searched before the system makefile directory.
323
324     Conditional expressions are also preceded by a single dot as the first
325     chraracter of a line.  The possible conditionals are as follows:
326
327     ..uunnddeeff _v_a_r_i_a_b_l_e
328             Un-define the specified global variable.  Only global variables
329
330             may be un-defined.
331
332     ..iiff [!]_e_x_p_r_e_s_s_i_o_n [_o_p_e_r_a_t_o_r _e_x_p_r_e_s_s_i_o_n ...]
333             Test the value of an expression.
334
335     ..iiffddeeff [!]_v_a_r_i_a_b_l_e [_o_p_e_r_a_t_o_r _v_a_r_i_a_b_l_e ...]
336             Test the value of an variable.
337
338     ..iiffnnddeeff [!]_v_a_r_i_a_b_l_e [_o_p_e_r_a_t_o_r _v_a_r_i_a_b_l_e ...]
339             Test the value of an variable.
340
341     ..iiffmmaakkee [!]_t_a_r_g_e_t [_o_p_e_r_a_t_o_r _t_a_r_g_e_t ...]
342             Test the the target being built.
343
344     ..iiffnnmmaakkee [!]_t_a_r_g_e_t [_o_p_e_r_a_t_o_r _t_a_r_g_e_t ...]
345             Test the target being built.
346
347     ..eellssee   Reverse the sense of the last conditional.
348
349     ..eelliiff [!]_e_x_p_r_e_s_s_i_o_n [_o_p_e_r_a_t_o_r _e_x_p_r_e_s_s_i_o_n ...]
350             A combination of `..eellssee' followed by `..iiff'.
351
352     ..eelliiffddeeff [!]_v_a_r_i_a_b_l_e [_o_p_e_r_a_t_o_r _v_a_r_i_a_b_l_e ...]
353             A combination of `..eellssee' followed by `..iiffddeeff'.
354
355     ..eelliiffnnddeeff [!]_v_a_r_i_a_b_l_e [_o_p_e_r_a_t_o_r _v_a_r_i_a_b_l_e ...]
356             A combination of `..eellssee' followed by `..iiffnnddeeff'.
357
358     ..eelliiffmmaakkee [!]_t_a_r_g_e_t [_o_p_e_r_a_t_o_r _t_a_r_g_e_t ...]
359             A combination of `..eellssee' followed by `..iiffmmaakkee'.
360
361     ..eelliiffnnmmaakkee [!]_t_a_r_g_e_t [_o_p_e_r_a_t_o_r _t_a_r_g_e_t ...]
362             A combination of `..eellssee' followed by `..iiffnnmmaakkee'.
363
364     ..eennddiiff  End the body of the conditional.
365
366     The _o_p_e_r_a_t_o_r may be any one of the following:
367
368     ||||     logical OR
369
370     &&&&     Logical AND; of higher precedence than ``''.
371
372     As in C, mmaakkee will only evaluate a conditional as far as is necessary to
373     determine its value.  Parenthesis may be used to change the order of
374     evaluation.  The boolean operator `!!' may be used to logically negate an
375     entire conditional.  It is of higher precendence than `&&&&'.
376
377     The value of _e_x_p_r_e_s_s_i_o_n may be any of the following:
378
379     ddeeffiinneedd     Takes a variable name as an argument and evaluates to true if
380                 the variable has been defined.
381
382     mmaakkee        Takes a target name as an argument and evaluates to true if
383                 the target was specified as part of mmaakkee's command line or
384                 was declared the default target (either implicitly or
385                 explicitly, see ._M_A_I_N) before the line containing the
386                 conditional.
387
388     eemmppttyy       Takes a variable, with possible modifiers, and evalutes to
389                 true if the expansion of the variable would result in an
390                 empty string.
391
392     eexxiissttss      Takes a file name as an argument and evaluates to true if the
393                 file exists.  The file is searched for on the system search
394
395
396                 path (see ._P_A_T_H).
397
398     ttaarrggeett      Takes a target name as an argument and evaluates to true if
399                 the target has been defined.
400
401     _E_x_p_r_e_s_s_i_o_n may also be an arithmetic or string comparison, with the left-
402     hand side being a variable expansion.  The standard C relational
403     operators are all supported, and the usual number/base conversion is
404     performed.  Note, octal numbers are not supported.  If the righthand
405     value of a `====' or `!!==' operator begins with a quotation mark (`"') a
406     string comparison is done between the expanded variable and the text
407     between the quotation marks.  If no relational operator is given, it is
408     assumed that the expanded variable is being compared against 0.
409
410     When mmaakkee is evaluating one of these conditional expression, and it
411     encounters a word it doesn't recognize, either the ``make'' or
412     ``defined'' expression is applied to it, depending on the form of the
413     conditional.  If the form is `..iiffddeeff' or `..iiffnnddeeff', the ``defined''
414     expression is applied.  Similarly, if the form is `..iiffmmaakkee' or `..iiffnnmmaakkee,
415     tthhee ````mmaakkee''''' expression is applied.
416
417     If the conditional evaluates to true the parsing of the makefile
418     continues as before.  If it evaluates to false, the following lines are
419     skipped.  In both cases this continues until a `..eellssee' or `..eennddiiff' is
420     found.
421
422CCOOMMMMEENNTTSS
423     Comments begin with a hash (`#') character, anywhere but in a shell
424     command line, and continue to the end of the line.
425
426SSPPEECCIIAALL SSOOUURRCCEESS
427     ..IIGGNNOORREE     Ignore any errors from the commands associated with this
428                 target, exactly as if they all were preceded by a dash (`-').
429
430     ..MMAAKKEE       Execute the commands associated with this target even if the
431                 --nn or --tt options were specified.  Normally used to mark
432                 recursive mmaakkee's.
433
434     ..NNOOTTMMAAIINN    Normally mmaakkee selects the first target it encounters as the
435                 default target to be built if no target was specified.  This
436                 source prevents this target from being selected.
437
438     ..OOPPTTIIOONNAALL   If a target is marked with this attribute and mmaakkee can't
439                 figure out how to create it, it will ignore this fact and
440                 assume the file isn't needed or already exists.
441
442     ..PPRREECCIIOOUUSS   When mmaakkee is interrupted, it removes any partially made
443                 targets.  This source prevents the target from being removed.
444
445     ..SSIILLEENNTT     Do not echo any of the commands associated with this target,
446                 exactly as if they all were preceded by an at sign (`@').
447
448     ..UUSSEE        Turn the target into mmaakkee's. version of a macro.  When the
449                 target is used as a source for another target, the other
450                 target acquires the commands, sources, and attributes (except
451                 for ..UUSSEE) of the source.  If the target already has commands,
452                 the ..UUSSEE target's commands are appended to them.
453
454SSPPEECCIIAALL TTAARRGGEETTSS
455     Special targets may not be included with other targets, i.e. they must be
456     the only target specified.
457
458     ..BBEEGGIINN      Any command lines attached to this target are executed before
459                 anything else is done.
460
461     ..DDEEFFAAUULLTT    This is sort of a ..UUSSEE rule for any target (that was used
462                 only as a source) that mmaakkee can't figure out any other way to
463                 create.  Only the shell script is used.  The ..IIMMPPSSRRCC variable
464                 of a target that inherits ..DDEEFFAAUULLTT's commands is set to the
465                 target's own name.
466
467     ..EENNDD        Any command lines attached to this target are executed after
468                 everything else is done.
469
470     ..IIGGNNOORREE     Mark each of the sources with the ..IIGGNNOORREE attribute.  If no
471                 sources are specified, this is the equivalent of specifying
472                 the --ii option.
473
474     ..IINNTTEERRRRUUPPTT  If mmaakkee is interrupted, the commands for this target will be
475                 executed.
476
477     ..MMAAIINN       If no target is specified when mmaakkee is invoked, this target
478                 will be built.
479
480     ..MMAAKKEEFFLLAAGGSS  This target provides a way to specify flags for mmaakkee when the
481                 makefile is used.  The flags are as if typed to the shell,
482                 though the --ff option will have no effect.
483
484     ..PPAATTHH       The sources are directories which are to be searched for
485                 files not found in the current directory.  If no sources are
486                 specified, any previously specified directories are deleted.
487
488     ..PPRREECCIIOOUUSS   Apply the ..PPRREECCIIOOUUSS attribute to any specified sources.  If
489                 no sources are specified, the ..PPRREECCIIOOUUSS attribute is applied
490                 to every target in the file.
491
492     ..SSIILLEENNTT     Apply the ..SSIILLEENNTT attribute to any specified sources.  If no
493                 sources are specified, the ..SSIILLEENNTT attribute is applied to
494                 every command in the file.
495
496     ..SSUUFFFFIIXXEESS   Each source specifies a suffix to mmaakkee. If no sources are
497                 specified, any previous specifies suffices are deleted.
498
499EENNVVIIRROONNMMEENNTT
500     MMaakkee utilizes the following environment variables, if they exist: MAKE,
501     MAKEFLAGS and MAKEOBJDIR.
502
503FFIILLEESS
504     .depend        list of dependencies
505     Makefile       list of dependencies
506     makefile       list of dependencies
507     sys.mk         system makefile
508     /usr/share/mk  system makefile directory
509
510SSEEEE AALLSSOO
511     mkdep(1)
512
513HHIISSTTOORRYY
514     A MMaakkee command appeared in Version 7 AT&T UNIX.
515
516BSD Experimental                 July 24, 1991                               8
517
518
519
520
521
522
523
524
525
526
527
528
529