1sysV-make(1)                     User Commands                    sysV-make(1)
2
3
4

NAME

6       sysV-make - maintain, update, and regenerate groups of programs
7

SYNOPSIS

9       /usr/lib/svr4.make [-f makefile] [-eiknpqrst] [names]
10
11

DESCRIPTION

13       This  is the vanilla System V version of make. If the environment vari‐
14       able USE_SVR4_MAKE is set, then the command make will invoke this  ver‐
15       sion of  make. (See also the ENVIRONMENT section.)
16
17
18       make  allows  the programmer to maintain, update, and regenerate groups
19       of computer programs. make executes commands in makefile to update  one
20       or  more  target names (names are typically programs). If the -f option
21       is not present, then makefile, Makefile, and the  Source  Code  Control
22       System  (SCCS)  files  s.makefile and s.Makefile are tried in order. If
23       makefile is `' the standard input is taken. More than one -f  makefile
24       argument pair may appear.
25
26
27       make updates a target only if its dependents are newer than the target.
28       All prerequisite files of a target are added recursively to the list of
29       targets. Missing files are deemed to be outdated.
30
31
32       The  following  list  of four directives can be included in makefile to
33       extend the options provided by make. They are used in  makefile  as  if
34       they were targets:
35
36       .DEFAULT:       If  a  file must be made but there are no explicit com‐
37                       mands or relevant built-in rules, the commands  associ‐
38                       ated with the name .DEFAULT are used if it exists.
39
40
41       .IGNORE:        Same effect as the -i option.
42
43
44       .PRECIOUS:      Dependents  of  the .PRECIOUS entry will not be removed
45                       when quit or interrupt are hit.
46
47
48       .SILENT:        Same effect as the -s option.
49
50
51   Options
52       The options for make are listed below:
53
54       -e             Environment variables override assignments within  make‐
55                      files.
56
57
58       -f makefile    Description filename (makefile is assumed to be the name
59                      of a description file).
60
61
62       -i             Ignore error codes returned by invoked commands.
63
64
65       -k             Abandon work on the current entry if it fails, but  con‐
66                      tinue  on  other  branches  that  do  not depend on that
67                      entry.
68
69
70       -n             No execute mode. Print  commands,  but  do  not  execute
71                      them.  Even  command  lines  beginning  with  an `@' are
72                      printed.
73
74
75       -p             Print out the complete set of macro definitions and tar‐
76                      get descriptions.
77
78
79       -q             Question.  make  returns  a zero or non-zero status code
80                      depending on whether or not the  target  file  has  been
81                      updated.
82
83
84       -r             Do not use the built-in rules.
85
86
87       -s             Silent  mode.  Do not print command lines before execut‐
88                      ing.
89
90
91       -t             Touch the target files  (causing  them  to  be  updated)
92                      rather than issue the usual commands.
93
94
95   Creating the makefile
96       The  makefile invoked with the -f option is a carefully structured file
97       of explicit instructions for updating and  regenerating  programs,  and
98       contains  a  sequence  of entries that specify dependencies.  The first
99       line of an entry is a blank-separated, non-null list of targets, then a
100       `:', then a (possibly null) list of prerequisite files or dependencies.
101       Text following a `;' and all following lines that begin with a tab  are
102       shell commands to be executed to update the target. The first non-empty
103       line that does not begin with a tab or `#' begins a new  dependency  or
104       macro  definition.  Shell commands may be continued across lines with a
105       backslash-new-line (\-NEWLINE) sequence.  Everything  printed  by  make
106       (except the initial TAB) is passed directly to the shell as is. Thus,
107
108         echo a\
109         b
110
111
112
113
114       will produce
115
116
117       ab
118
119
120       exactly the same as the shell would.
121
122
123       Number-sign  (#)  and  NEWLINE  surround  comments  including contained
124       `\−NEWLINE' sequences.
125
126
127       The following makefile says that pgm depends on two files a.o and  b.o,
128       and  that  they in turn depend on their corresponding source files (a.c
129       and b.c) and a common file incl.h:
130
131         pgm: a.o b.o
132                 cc a.o b.o -o pgm
133         a.o: incl.h a.c
134                 cc -c a.c
135         b.o: incl.h b.c
136                 cc -c b.c
137
138
139
140
141       Command lines are executed one at a time, each by its  own  shell.  The
142       SHELL  environment  variable  can  be  used to specify which shell make
143       should use to execute commands. The default is /usr/bin/sh.  The  first
144       one  or  two  characters  in  a command can be the following: `@', `',
145       `@−', or `−@'. If `@' is present,  printing  of  the  command  is  sup‐
146       pressed.  If  `'  is present, make ignores an error. A line is printed
147       when it is executed unless the -s  option  is  present,  or  the  entry
148       .SILENT:  is  included  in  makefile,  or  unless the initial character
149       sequence contains a @. The -n option specifies printing without  execu‐
150       tion;  however,  if  the command line has the string $(MAKE) in it, the
151       line is always executed (see the discussion of the MAKEFLAGS  macro  in
152       the  make Environment sub-section below). The -t (touch) option updates
153       the modified date of a file without executing any commands.
154
155
156       Commands returning non-zero status normally terminate make. If  the  -i
157       option is present, if the entry .IGNORE: is included in makefile, or if
158       the initial character sequence of the command contains `',  the  error
159       is  ignored. If the -k option is present, work is abandoned on the cur‐
160       rent entry, but continues on other branches that do not depend on  that
161       entry.
162
163
164       Interrupt  and quit cause the target to be deleted unless the target is
165       a dependent of the directive .PRECIOUS.
166
167   make Environment
168       The environment is read by make. All variables are assumed to be  macro
169       definitions  and  are  processed as such. The environment variables are
170       processed before any makefile and after the internal rules; thus, macro
171       assignments in a makefile override environment variables. The -e option
172       causes the environment to override the macro assignments in a makefile.
173       Suffixes  and  their associated rules in the makefile will override any
174       identical suffixes in the built-in rules.
175
176
177       The MAKEFLAGS environment variable is processed by make  as  containing
178       any legal input option (except -f and -p) defined for the command line.
179       Further, upon invocation, make "invents" the variable if it is  not  in
180       the  environment, puts the current options into it, and passes it on to
181       invocations of commands. Thus, MAKEFLAGS always  contains  the  current
182       input  options.  This  feature proves very useful for "super-makes". In
183       fact, as noted above, when the -n option is used, the  command  $(MAKE)
184       is  executed  anyway; hence, one can perform a make -n recursively on a
185       whole software system to see what would have been executed. This result
186       is  possible  because  the -n is put in MAKEFLAGS and passed to further
187       invocations of $(MAKE). This usage is one way of debugging all  of  the
188       makefiles for a software project without actually doing anything.
189
190   Include Files
191       If the string include appears as the first seven letters of a line in a
192       makefile, and is followed by a blank or a tab, the rest of the line  is
193       assumed  to  be a filename and will be read by  the current invocation,
194       after substituting for any macros.
195
196   Macros
197       Entries of the form string1 = string2 are macro definitions. string2 is
198       defined  as  all  characters  up to a comment character or an unescaped
199       NEWLINE. Subsequent  appearances  of  $(string1[:subst1=[subst2]])  are
200       replaced by string2. The parentheses are optional if a single-character
201       macro name is used and there is no substitute  sequence.  The  optional
202       :subst1=subst2  is  a substitute sequence. If it is specified, all non-
203       overlapping occurrences of subst1 in the named macro  are  replaced  by
204       subst2.  Strings  (for  the  purposes of this type of substitution) are
205       delimited by BLANKs, TABs, NEWLINE characters, and beginnings of lines.
206       An  example  of  the  use  of  the  substitute sequence is shown in the
207       Libraries sub-section below.
208
209   Internal Macros
210       There are five internally maintained macros that are useful for writing
211       rules for building targets.
212
213       $*    The  macro  $* stands for the filename part of the current depen‐
214             dent with the suffix deleted. It is evaluated only for  inference
215             rules.
216
217
218       $@    The  $@ macro stands for the full target name of the current tar‐
219             get. It is evaluated only for explicitly named dependencies.
220
221
222       $<    The $< macro  is  only  evaluated  for  inference  rules  or  the
223             .DEFAULT  rule. It is the module that is outdated with respect to
224             the target (the "manufactured" dependent file name). Thus, in the
225             .c.o rule, the $< macro would evaluate to the .c file. An example
226             for making optimized .o files from .c files is:
227
228               .c.o:
229                       cc c O $*.c
230
231
232             or:
233
234               .c.o:
235                       cc c O $<
236
237
238
239
240       $?    The $? macro is evaluated when explicit rules from  the  makefile
241             are  evaluated. It is the list of prerequisites that are outdated
242             with respect to the target, and essentially  those  modules  that
243             must be rebuilt.
244
245
246       $%    The  $%  macro  is  only  evaluated when the target is an archive
247             library member of the form lib(file.o). In this case,  $@  evalu‐
248             ates to lib and $% evaluates to the library member, file.o.
249
250
251
252       Four  of the five macros can have alternative forms. When an upper case
253       D or F is appended to any of the four macros, the meaning is changed to
254       "directory part" for D and "file part" for F. Thus, $(@D) refers to the
255       directory part of the string $@. If there is no directory part,  ./  is
256       generated. The only macro excluded from this alternative form is $?.
257
258   Suffixes
259       Certain  names (for instance, those ending with .o) have inferable pre‐
260       requisites such as .c, .s, etc. If no update commands for such  a  file
261       appear  in makefile, and if an inferable prerequisite exists, that pre‐
262       requisite is compiled to make the target. In this case, make has infer‐
263       ence  rules that allow building files from other files by examining the
264       suffixes and determining an appropriate inference rule to use. The cur‐
265       rent default inference rules are:
266
267
268
269
270       .c      .c~       .f       .f~     .s       .s~     .sh      .sh~    .C       .C~
271       .c.a    .c.o      .c~.a    .c~.c   .c~.o    .f.a    .f.o     .f~.a   .f~.f    .f~.o
272       .h~.h   .l.c      .l.o     .l~.c   .l~.l    .l~.o   .s.a     .s.o    .s~.a    .s~.o
273       .s~.s   .sh~.sh   .y.c     .y.o    .y~.c    .y~.o   .y~.y    .C.a    .C.o     .C~.a
274       .C~.C   .C~.o     .L.C     .L.o    .L~.C    .L~.L   .L~.o    .Y.C    .Y.o     .Y~.C
275       .Y~.o   .Y~.Y
276
277
278
279       The internal rules for make are contained in the source file make.rules
280       for the make program. These rules can be locally modified. To print out
281       the  rules compiled into the make on any machine in a form suitable for
282       re-compilation, the following command is used:
283
284         make -pf −2>/dev/null < /dev/null
285
286
287
288
289       A tilde in the above rules refers to an SCCS  file  (see  sccsfile(4)).
290       Thus,  the  rule  .c~.o  would  transform an SCCS C source file into an
291       object file (.o). Because the s. of the SCCS files is a prefix,  it  is
292       incompatible  with the make suffix point of view. Hence, the tilde is a
293       way of changing any file reference into an SCCS file reference.
294
295
296       A rule with only one suffix (for example, .c:) is the definition of how
297       to  build x from x.c. In effect, the other suffix is null. This feature
298       is useful for building targets from only one source file, for  example,
299       shell procedures and simple C programs.
300
301
302       Additional  suffixes  are  given  as the dependency list for .SUFFIXES.
303       Order is significant: the first possible name for which both a file and
304       a rule exist is inferred as a prerequisite. The default list is:
305
306
307       .SUFFIXES: .o .c .c~ .y .y~ .l .l~ .s .s~ .sh .sh~ .h .h~ .f .f~ .C .C~
308       .Y .Y~ .L .L~
309
310
311       Here again, the above command for printing the internal rules will dis‐
312       play  the list of suffixes implemented on the current machine. Multiple
313       suffix lists accumulate; .SUFFIXES: with  no  dependencies  clears  the
314       list of suffixes.
315
316   Inference Rules
317       The first example can be done more briefly.
318
319         pgm: a.o b.o
320             cc a.o b.o o pgm
321         a.o b.o: incl.h
322
323
324
325
326       This  abbreviation is possible because make has a set of internal rules
327       for building files. The user may add  rules  to  this  list  by  simply
328       putting them in the makefile.
329
330
331       Certain  macros  are  used by the default inference rules to permit the
332       inclusion of optional matter in any resulting commands. Again, the pre‐
333       vious method for examining the current rules is recommended.
334
335
336       The  inference of prerequisites can be controlled. The rule to create a
337       file with suffix .o from a file with suffix .c is specified as an entry
338       with  .c.o:  as the target and no dependents. Shell commands associated
339       with the target define the rule for making a .o file from  a  .c  file.
340       Any  target  that has no slashes in it and starts with a dot is identi‐
341       fied as a rule and not a true target.
342
343   Libraries
344       If a target or dependency name contains parentheses, it is  assumed  to
345       be  an  archive  library,  the string within parentheses referring to a
346       member within the library. Thus, lib(file.o)  and  $(LIB)(file.o)  both
347       refer to an archive library that contains file.o. (This example assumes
348       the  LIB  macro  has  been   previously   defined.)    The   expression
349       $(LIB)(file1.o  file2.o)  is  not  legal.  Rules  pertaining to archive
350       libraries have the form .XX.a where the XX  is the  suffix  from  which
351       the archive member is to be made. An unfortunate by-product of the cur‐
352       rent implementation requires the XX  to be different from the suffix of
353       the  archive  member.  Thus,  one  cannot  have lib(file.o) depend upon
354       file.o explicitly. The most common use of the  archive  interface  fol‐
355       lows. Here, we assume the source files are all C type source:
356
357         lib: lib(file1.o) lib(file2.o) lib(file3.o)
358              @echo lib is now up-to-date
359         .c.a:
360                 $(CC) -c $(CFLAGS) $<
361              $(AR) $(ARFLAGS) $@ $*.o
362                 rm -f $*.o
363
364
365
366
367       In  fact, the .c.a rule listed above is built into make and is unneces‐
368       sary in this example. A more interesting, but more limited  example  of
369       an archive library maintenance construction follows:
370
371         lib: lib(file1.o) lib(file2.o) lib(file3.o)
372                 $(CC) -c $(CFLAGS) $(?:.o=.c)
373              $(AR) $(ARFLAGS) lib $?
374              rm $?
375              @echo lib is now up-to-date
376         .c.a:;
377
378
379
380
381       Here the substitution mode of the macro expansions is used. The $? list
382       is defined to be the set of  object  filenames  (inside  lib)  whose  C
383       source  files  are outdated. The substitution mode translates the .o to
384       .c. (Unfortunately, one cannot as yet transform to .c~;  however,  this
385       transformation  may become possible in the future.)  Also note the dis‐
386       abling of the .c.a: rule, which would have created  each  object  file,
387       one by one. This particular construct speeds up archive library mainte‐
388       nance considerably. This type of construct becomes very  cumbersome  if
389       the archive library contains a mix of assembly programs and C programs.
390

ENVIRONMENT VARIABLES

392       USE_SVR4_MAKE    If  this  environment  variable  is set, then the make
393                        command will invoke this System V version of  make. If
394                        this  variable is not set, then the default version of
395                        make(1S) is invoked.
396
397                        USE_SVR4_MAKE can be set as follows (Bourne shell):
398
399                        $ USE_SVR4_MAKE=``''; export USE_SVR4_MAKE
400
401                        or (C shell):
402
403                        % setenv USE_SVR4_MAKE
404
405

FILES

407       [Mm]akefile
408       s.[Mm]akefile
409
410           default makefiles
411
412
413       /usr/bin/sh
414
415           default shell for make
416
417
418       /usr/share/lib/make/make.rules
419
420           default rules for make
421
422

ATTRIBUTES

424       See attributes(5) for descriptions of the following attributes:
425
426
427
428
429       ┌─────────────────────────────┬─────────────────────────────┐
430       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
431       ├─────────────────────────────┼─────────────────────────────┤
432       │Availability                 │SUNWsprot                    │
433       └─────────────────────────────┴─────────────────────────────┘
434

SEE ALSO

436       cd(1), make(1S), sh(1), printf(3C), sccsfile(4), attributes(5)
437

NOTES

439       Some commands return non-zero status inappropriately; use -i or the `-'
440       command line prefix to overcome the difficulty.
441
442
443       Filenames  containing  the characters =, :, and @ do not work. Commands
444       that are directly executed by the shell, notably cd(1), are ineffectual
445       across  NEWLINEs  in  make.  The syntax lib(file1.o file2.o file3.o) is
446       illegal. You cannot build lib(file.o) from file.o.
447
448
449
450SunOS 5.11                        24 Aug 2009                     sysV-make(1)
Impressum