summaryrefslogtreecommitdiffstats
path: root/man-pages-posix-2013/man1p/make.1p
blob: 44f900fa7925f3554418aa9b6d079b59fad88854 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
'\" et
.TH MAKE "1P" 2013 "IEEE/The Open Group" "POSIX Programmer's Manual"
.SH PROLOG
This manual page is part of the POSIX Programmer's Manual.
The Linux implementation of this interface may differ (consult
the corresponding Linux manual page for details of Linux behavior),
or the interface may not be implemented on Linux.

.SH NAME
make
\(em maintain, update, and regenerate groups of programs
(\fBDEVELOPMENT\fP)
.SH SYNOPSIS
.LP
.nf
make \fB[\fR\(mieinpqrst\fB] [\fR\(mif \fImakefile\fB]\fR... \fB[\fR\(mik|\(miS\fB] [\fImacro\fR=\fIvalue\fR...\fB]
    \fB[\fItarget_name\fR...\fB]\fR
.fi
.SH DESCRIPTION
The
.IR make
utility shall update files that are derived from other files. A typical
case is one where object files are derived from the corresponding
source files. The
.IR make
utility examines time relationships and shall update those derived files
(called targets) that have modified times earlier than the modified
times of the files (called prerequisites) from which they are derived.
A description file (makefile) contains a description of the
relationships between files, and the commands that need to be executed
to update the targets to reflect changes in their prerequisites. Each
specification, or rule, shall consist of a target, optional
prerequisites, and optional commands to be executed when a prerequisite
is newer than the target. There are two types of rule:
.IP " 1." 4
\fIInference rules\fP,
which have one target name with at least one
<period>
(\c
.BR '.' )
and no
<slash>
(\c
.BR '/' )
.IP " 2." 4
\fITarget rules\fP,
which can have more than one target name
.P
In addition,
.IR make
shall have a collection of built-in macros and inference rules that
infer prerequisite relationships to simplify maintenance of programs.
.P
To receive exactly the behavior described in this section, the
user shall ensure that a portable makefile shall:
.IP " *" 4
Include the special target
.BR .POSIX
.IP " *" 4
Omit any special target reserved for implementations (a leading period
followed by uppercase letters) that has not been specified by this
section
.P
The behavior of
.IR make
is unspecified if either or both of these conditions are not met.
.SH OPTIONS
The
.IR make
utility shall conform to the Base Definitions volume of POSIX.1\(hy2008,
.IR "Section 12.2" ", " "Utility Syntax Guidelines",
except for Guideline 9.
.P
The following options shall be supported:
.IP "\fB\(mie\fP" 10
Cause environment variables, including those with null values, to
override macro assignments within makefiles.
.IP "\fB\(mif\ \fImakefile\fR" 10
Specify a different makefile. The argument
.IR makefile
is a pathname of a description file, which is also referred to as the
.IR makefile .
A pathname of
.BR '\(mi' 
shall denote the standard input. There can be multiple instances of
this option, and they shall be processed in the order specified. The
effect of specifying the same option-argument more than once is
unspecified.
.IP "\fB\(mii\fP" 10
Ignore error codes returned by invoked commands. This mode is the same
as if the special target
.BR .IGNORE
were specified without prerequisites.
.IP "\fB\(mik\fP" 10
Continue to update other targets that do not depend on the current
target if a non-ignored error occurs while executing the commands to
bring a target up-to-date.
.IP "\fB\(min\fP" 10
Write commands that would be executed on standard output, but do not
execute them. However, lines with a
<plus-sign>
(\c
.BR '\(pl' )
prefix shall be executed. In this mode, lines with an at-sign (\c
.BR '@' )
character prefix shall be written to standard output.
.IP "\fB\(mip\fP" 10
Write to standard output the complete set of macro definitions and
target descriptions. The output format is unspecified.
.IP "\fB\(miq\fP" 10
Return a zero exit value if the target file is up-to-date; otherwise,
return an exit value of 1. Targets shall not be updated if this option
is specified. However, a makefile command line (associated with the
targets) with a
<plus-sign>
(\c
.BR '\(pl' )
prefix shall be executed.
.IP "\fB\(mir\fP" 10
Clear the suffix list and do not use the built-in rules.
.IP "\fB\(miS\fP" 10
Terminate
.IR make
if an error occurs while executing the commands to bring a target
up-to-date. This shall be the default and the opposite of
.BR \(mik .
.IP "\fB\(mis\fP" 10
Do not write makefile command lines or touch messages (see
.BR \(mit )
to standard output before executing. This mode shall be the same as if
the special target
.BR .SILENT
were specified without prerequisites.
.IP "\fB\(mit\fP" 10
Update the modification time of each target as though a
.IR touch
.IR target
had been executed. Targets that have prerequisites but no commands (see
.IR "Target Rules"),
or that are already up-to-date, shall not be touched in this manner.
Write messages to standard output for each target file indicating the
name of the file and that it was touched. Normally, the
.IR makefile
command lines associated with each target are not executed. However, a
command line with a
<plus-sign>
(\c
.BR '\(pl' )
prefix shall be executed.
.P
Any options specified in the
.IR MAKEFLAGS
environment variable shall be evaluated before any options specified on
the
.IR make
utility command line. If the
.BR \(mik
and
.BR \(miS
options are both specified on the
.IR make
utility command line or by the
.IR MAKEFLAGS
environment variable, the last option specified shall take precedence.
If the
.BR \(mif
or
.BR \(mip
options appear in the
.IR MAKEFLAGS
environment variable, the result is undefined.
.SH OPERANDS
The following operands shall be supported:
.IP "\fItarget_name\fR" 10
Target names, as defined in the EXTENDED DESCRIPTION section. If no
target is specified, while
.IR make
is processing the makefiles, the first target that
.IR make
encounters that is not a special target or an inference rule shall be
used.
.IP "\fImacro\fR=\fIvalue\fR" 10
Macro definitions, as defined in
.IR "Macros".
.P
If the
.IR target_name
and
.IR macro =\c
.IR value
operands are intermixed on the
.IR make
utility command line, the results are unspecified.
.SH STDIN
The standard input shall be used only if the
.IR makefile
option-argument is
.BR '\(mi' .
See the INPUT FILES section.
.SH "INPUT FILES"
The input file, otherwise known as the makefile, is a text file
containing rules, macro definitions, and comments. See the
EXTENDED DESCRIPTION section.
.SH "ENVIRONMENT VARIABLES"
The following environment variables shall affect the execution of
.IR make :
.IP "\fILANG\fP" 10
Provide a default value for the internationalization variables that are
unset or null. (See the Base Definitions volume of POSIX.1\(hy2008,
.IR "Section 8.2" ", " "Internationalization Variables"
for the precedence of internationalization variables used to determine
the values of locale categories.)
.IP "\fILC_ALL\fP" 10
If set to a non-empty string value, override the values of all the
other internationalization variables.
.IP "\fILC_CTYPE\fP" 10
Determine the locale for the interpretation of sequences of bytes of
text data as characters (for example, single-byte as opposed to
multi-byte characters in arguments and input files).
.IP "\fILC_MESSAGES\fP" 10
.br
Determine the locale that should be used to affect the format and
contents of diagnostic messages written to standard error.
.IP "\fIMAKEFLAGS\fP" 10
.br
This variable shall be interpreted as a character string representing a
series of option characters to be used as the default options. The
implementation shall accept both of the following formats (but need not
accept them when intermixed):
.RS 10 
.IP " *" 4
The characters are option letters without the leading
<hyphen>
characters or
<blank>
separation used on a
.IR make
utility command line.
.IP " *" 4
The characters are formatted in a manner similar to a portion of the
.IR make
utility command line: options are preceded by
<hyphen>
characters and
<blank>-separated
as described in the Base Definitions volume of POSIX.1\(hy2008,
.IR "Section 12.2" ", " "Utility Syntax Guidelines".
The
.IR macro =\c
.IR value
macro definition operands can also be included. The difference between
the contents of
.IR MAKEFLAGS
and the
.IR make
utility command line is that the contents of the variable shall not be
subjected to the word expansions (see
.IR "Section 2.6" ", " "Word Expansions")
associated with parsing the command line values.
.RE
.IP "\fINLSPATH\fP" 10
Determine the location of message catalogs for the processing of
.IR LC_MESSAGES .
.IP "\fIPROJECTDIR\fP" 10
.br
Provide a directory to be used to search for SCCS files not found in
the current directory. In all of the following cases, the search for
SCCS files is made in the directory
.BR SCCS
in the identified directory. If the value of
.IR PROJECTDIR
begins with a
<slash>,
it shall be considered an absolute pathname; otherwise, the value of
.IR PROJECTDIR
is treated as a user name and that user's initial working directory
shall be examined for a subdirectory
.BR src
or
.BR source .
If such a directory is found, it shall be used. Otherwise, the value
is used as a relative pathname.
.RS 10 
.P
If
.IR PROJECTDIR
is not set or has a null value, the search for SCCS files shall be made
in the directory
.BR SCCS
in the current directory.
.P
The setting of
.IR PROJECTDIR
affects all files listed in the remainder of this utility description
for files with a component named
.BR SCCS .
.RE
.P
The value of the
.IR SHELL
environment variable shall not be used as a macro and shall not be
modified by defining the
.BR SHELL
macro in a makefile or on the command line. All other environment
variables, including those with null values, shall be used as macros,
as defined in
.IR "Macros".
.SH "ASYNCHRONOUS EVENTS"
If not already ignored,
.IR make
shall trap SIGHUP, SIGTERM, SIGINT, and SIGQUIT and remove the current
target unless the target is a directory or the target is a prerequisite
of the special target
.BR .PRECIOUS
or unless one of the
.BR \(min ,
.BR \(mip ,
or
.BR \(miq
options was specified. Any targets removed in this manner shall be
reported in diagnostic messages of unspecified format, written to
standard error. After this cleanup process, if any,
.IR make
shall take the standard action for all other signals.
.SH STDOUT
The
.IR make
utility shall write all commands to be executed to standard output
unless the
.BR \(mis
option was specified, the command is prefixed with an at-sign, or the
special target
.BR .SILENT
has either the current target as a prerequisite or has no
prerequisites. If
.IR make
is invoked without any work needing to be done, it shall write a
message to standard output indicating that no action was taken. If the
.BR \(mit
option is present and a file is touched,
.IR make
shall write to standard output a message of unspecified format
indicating that the file was touched, including the filename of the
file.
.SH STDERR
The standard error shall be used only for diagnostic messages.
.SH "OUTPUT FILES"
Files can be created when the
.BR \(mit
option is present. Additional files can also be created by the
utilities invoked by
.IR make .
.SH "EXTENDED DESCRIPTION"
The
.IR make
utility attempts to perform the actions required to ensure that the
specified targets are up-to-date. A target is considered out-of-date
if it is older than any of its prerequisites or if it does not exist.
The
.IR make
utility shall treat all prerequisites as targets themselves and
recursively ensure that they are up-to-date, processing them in the
order in which they appear in the rule. The
.IR make
utility shall use the modification times of files to determine whether
the corresponding targets are out-of-date.
.P
After
.IR make
has ensured that all of the prerequisites of a target are up-to-date
and if the target is out-of-date, the commands associated with the
target entry shall be executed. If there are no commands listed for
the target, the target shall be treated as up-to-date.
.SS "Makefile Syntax"
.P
A makefile can contain rules, macro definitions (see
.IR "Macros"),
include lines, and comments. There are two kinds of rules:
.IR "inference rules"
and
.IR "target rules" .
The
.IR make
utility shall contain a set of built-in inference rules. If the
.BR \(mir
option is present, the built-in rules shall not be used and the suffix
list shall be cleared. Additional rules of both types can be specified
in a makefile. If a rule is defined more than once, the value of the
rule shall be that of the last one specified. Macros can also be
defined more than once, and the value of the macro is specified in
.IR "Macros".
Comments start with a
<number-sign>
(\c
.BR '#' )
and continue until an unescaped
<newline>
is reached.
.P
By default, the following files shall be tried in sequence:
.BR ./makefile
and
.BR ./Makefile .
If neither
.BR ./makefile
or
.BR ./Makefile
are found, other implementation-defined files may also be tried.
On XSI-conformant systems, the additional files
.BR ./s.makefile ,
.BR SCCS/s.makefile ,
.BR ./s.Makefile ,
and
.BR SCCS/s.Makefile
shall also be tried.
.P
The
.BR \(mif
option shall direct
.IR make
to ignore any of these default files and use the specified argument as
a makefile instead. If the
.BR '\(mi' 
argument is specified, standard input shall be used.
.P
The term
.IR makefile
is used to refer to any rules provided by the user, whether in
.BR ./makefile
or its variants, or specified by the
.BR \(mif
option.
.P
The rules in makefiles shall consist of the following types of lines:
target rules, including special targets (see
.IR "Target Rules"),
inference rules (see
.IR "Inference Rules"),
macro definitions (see
.IR "Macros"),
empty lines, and comments.
.P
Target and Inference Rules may contain
.IR "command lines" .
Command lines can have a prefix that shall be removed before
execution (see
.IR "Makefile Execution").
.P
When an escaped
<newline>
(one preceded by a
<backslash>)
is found anywhere in the makefile except in a command line, an include
line, or a line immediately preceding an include line, it shall be
replaced, along with any leading white space on the following line,
with a single
<space>.
When an escaped
<newline>
is found in a command line in a makefile, the command line shall
contain the
<backslash>,
the
<newline>,
and the next line, except that the first character of the next line
shall not be included if it is a
<tab>.
When an escaped
<newline>
is found in an include line or in a line immediately preceding an
include line, the behavior is unspecified.
.SS "Include Lines"
.P
If the word
.BR include
appears at the beginning of a line and is followed by one or more
<blank>
characters, the string formed by the remainder of the line shall be
processed as follows to produce a pathname:
.IP " *" 4
The trailing
<newline>
and any comment shall be discarded. If the resulting string contains
any double-quote characters (\c
.BR '\&"' )
the behavior is unspecified.
.IP " *" 4
The resulting string shall be processed for macro expansion (see
.IR "Macros".
.IP " *" 4
Any
<blank>
characters that appear after the first non-\c
<blank>
shall be used as separators to divide the macro-expanded string into
fields. It is unspecified whether any other white-space characters
are also used as separators. It is unspecified whether pathname
expansion (see
.IR "Section 2.13" ", " "Pattern Matching Notation")
is also performed.
.IP " *" 4
If the processing of separators and optional pathname expansion
results in either zero or two or more non-empty fields, the
behavior is unspecified. If it results in one non-empty field,
that field is taken as the pathname.
.P
If the pathname does not begin with a
.BR '/' 
it shall be treated as relative to the current working directory
of the process, not relative to the directory containing the makefile.
If the file does not exist in this location, it is unspecified whether
additional directories are searched.
.P
The contents of the file specified by the pathname shall be read
and processed as if they appeared in the makefile in place of the
include line. If the file ends with an escaped
<newline>
the behavior is unspecified.
.P
The file may itself contain further include lines. Implementations
shall support nesting of include files up to a depth of at least 16.
.SS "Makefile Execution"
.P
Makefile command lines shall be processed one at a time.
.P
Makefile command lines can have one or more of the following prefixes: a
<hyphen>
(\c
.BR '-' ),
an at-sign (\c
.BR '@' ),
or a
<plus-sign>
(\c
.BR '+' ).
These shall modify the way in which
.IR make
processes the command.
.IP "\fR\(mi\fR" 6
If the command prefix contains a
<hyphen>,
or the
.BR \(mii
option is present, or the special target
.BR .IGNORE
has either the current target as a prerequisite or has no prerequisites,
any error found while executing the command shall be ignored.
.IP "\fR@\fR" 6
If the command prefix contains an at-sign and the
.IR make
utility command line
.BR \(min
option is not specified, or the
.BR \(mis
option is present, or the special target
.BR .SILENT
has either the current target as a prerequisite or has no prerequisites,
the command shall not be written to standard output before it is executed.
.IP "\fR+\fR" 6
If the command prefix contains a
<plus-sign>,
this indicates a makefile command line that shall be executed even if
.BR \(min ,
.BR \(miq ,
or
.BR \(mit
is specified.
.P
An
.IR "execution line"
is built from the command line by removing any prefix characters. Except
as described under the at-sign prefix, the execution line shall be
written to the standard output, optionally preceded by a
<tab>.
The execution line shall then be executed by a shell as if it were passed
as the argument to the
\fIsystem\fR()
interface, except that if errors are not being ignored then the shell
.BR \(mie
option shall also be in effect. If errors are being ignored for the
command (as a result of the
.BR \(mii
option, a
.BR '\(mi' 
command prefix, or a
.BR .IGNORE
special target), the shell
.BR \(mie
option shall not be in effect. The environment for the command being
executed shall contain all of the variables in the environment of
.IR make .
.P
By default, when
.IR make
receives a non-zero status from the execution of a command, it shall
terminate with an error message to standard error.
.SS "Target Rules"
.P
Target rules are formatted as follows:
.sp
.RS 4
.nf
\fB
\fItarget \fB[\fItarget\fR...\fB]\fR: \fB[\fIprerequisite\fR...\fB][;\fIcommand\fB]
[\fR<tab>\fIcommand\fR
<tab>\fIcommand\fR
\&...\fB]\fR
.P
\fIline that does not begin with \fR<tab>
.fi \fR
.P
.RE
.P
Target entries are specified by a
<blank>-separated,
non-null list of targets, then a
<colon>,
then a
<blank>-separated,
possibly empty list of prerequisites. Text following a
<semicolon>,
if any, and all following lines that begin with a
<tab>,
are makefile command lines to be executed to update the target. The
first non-empty line that does not begin with a
<tab>
or
.BR '#' 
shall begin a new entry. An empty or blank line, or a line beginning
with
.BR '#' ,
may begin a new entry.
.P
Applications shall select target names from the set of characters
consisting solely of periods, underscores, digits, and alphabetics from
the portable character set (see the Base Definitions volume of POSIX.1\(hy2008,
.IR "Section 6.1" ", " "Portable Character Set").
Implementations may allow other characters in target names as
extensions. The interpretation of targets containing the characters
.BR '%' 
and
.BR '\&"' 
is implementation-defined.
.P
A target that has prerequisites, but does not have any commands, can be
used to add to the prerequisite list for that target. Only one target
rule for any given target can contain commands.
.P
Lines that begin with one of the following are called
.IR "special targets"
and control the operation of
.IR make :
.IP "\&\fB.DEFAULT\fR" 10
If the makefile uses this special target, the application shall ensure
that it is specified with commands, but without prerequisites. The
commands shall be used by
.IR make
if there are no other rules available to build a target.
.IP "\&\fB.IGNORE\fR" 10
Prerequisites of this special target are targets themselves; this shall
cause errors from commands associated with them to be ignored in the
same manner as specified by the
.BR \(mii
option. Subsequent occurrences of
.BR .IGNORE
shall add to the list of targets ignoring command errors. If no
prerequisites are specified,
.IR make
shall behave as if the
.BR \(mii
option had been specified and errors from all commands associated with
all targets shall be ignored.
.IP "\&\fB.POSIX\fR" 10
The application shall ensure that this special target is specified
without prerequisites or commands. If it appears as the first
non-comment line in the makefile,
.IR make
shall process the makefile as specified by this section; otherwise, the
behavior of
.IR make
is unspecified.
.IP "\&\fB.PRECIOUS\fR" 10
Prerequisites of this special target shall not be removed if
.IR make
receives one of the asynchronous events explicitly described in the
ASYNCHRONOUS EVENTS section. Subsequent occurrences of
.BR .PRECIOUS
shall add to the list of precious files. If no prerequisites are
specified, all targets in the makefile shall be treated as if specified
with
.BR .PRECIOUS .
.IP "\fB.SCCS_GET\fR" 10
The application shall ensure that this special target is specified
without prerequisites. If this special target is included in a
makefile, the commands specified with this target shall replace the
default commands associated with this special target (see
.IR "Default Rules").
The commands specified with this target are used to get all SCCS files
that are not found in the current directory.
.RS 10 
.P
When source files are named in a dependency list,
.IR make
shall treat them just like any other target. Because the source file is
presumed to be present in the directory, there is no need to add an
entry for it to the makefile. When a target has no dependencies, but is
present in the directory,
.IR make
shall assume that that file is up-to-date. If, however, an SCCS file
named
.BR SCCS/s. \c
.IR source_file
is found for a target
.IR source_file ,
.IR make
compares the timestamp of the target file with that of the
.BR SCCS/s.source_file
to ensure the target is up-to-date. If the target is missing, or if the
SCCS file is newer,
.IR make
shall automatically issue the commands specified for the
.BR .SCCS_GET
special target to retrieve the most recent version. However, if the
target is writable by anyone,
.IR make
shall not retrieve a new version.
.RE
.IP "\&\fB.SILENT\fR" 10
Prerequisites of this special target are targets themselves; this shall
cause commands associated with them not to be written to the standard
output before they are executed. Subsequent occurrences of
.BR .SILENT
shall add to the list of targets with silent commands. If no
prerequisites are specified,
.IR make
shall behave as if the
.BR \(mis
option had been specified and no commands or touch messages associated
with any target shall be written to standard output.
.IP "\&\fB.SUFFIXES\fR" 10
Prerequisites of
.BR .SUFFIXES
shall be appended to the list of known suffixes and are used in
conjunction with the inference rules (see
.IR "Inference Rules").
If
.BR .SUFFIXES
does not have any prerequisites, the list of known suffixes shall be
cleared.
.P
The special targets
.BR .IGNORE ,
.BR .POSIX ,
.BR .PRECIOUS ,
.BR .SILENT ,
and
.BR .SUFFIXES
shall be specified without commands.
.P
Targets with names consisting of a leading
<period>
followed by the uppercase letters
.BR \(dqPOSIX\(dq 
and then any other characters are reserved for future standardization.
Targets with names consisting of a leading
<period>
followed by one or more uppercase letters are reserved for implementation
extensions.
.SS "Macros"
.P
Macro definitions are in the form:
.sp
.RS 4
.nf
\fB
\fIstring1\fR = \fB[\fIstring2\fB]\fR
.fi \fR
.P
.RE
.P
The macro named
.IR string1
is defined as having the value of
.IR string2 ,
where
.IR string2
is defined as all characters, if any, after the
<equals-sign>,
up to a comment character (\c
.BR '#' )
or an unescaped
<newline>.
Any
<blank>
characters immediately before or after the
<equals-sign>
shall be ignored.
.P
Applications shall select macro names from the set of characters
consisting solely of periods, underscores, digits, and alphabetics from
the portable character set (see the Base Definitions volume of POSIX.1\(hy2008,
.IR "Section 6.1" ", " "Portable Character Set").
A macro name shall not contain an
<equals-sign>.
Implementations may allow other characters in macro names as extensions.
.P
Macros can appear anywhere in the makefile. Macro expansions using
the forms $(\c
.IR string1 )
or ${\c
.IR string1 }
shall be replaced by
.IR string2 ,
as follows:
.IP " *" 4
Macros in target lines shall be evaluated when the target line is read.
.IP " *" 4
Macros in makefile command lines shall be evaluated when the command is
executed.
.IP " *" 4
Macros in the string before the
<equals-sign>
in a macro definition shall be evaluated when the macro assignment
is made.
.IP " *" 4
Macros after the
<equals-sign>
in a macro definition shall not be evaluated until the defined macro
is used in a rule or command, or before the
<equals-sign>
in a macro definition.
.P
The parentheses or braces are optional if
.IR string1
is a single character. The macro $$ shall be replaced by the single
character
.BR '$' .
If
.IR string1
in a macro expansion contains a macro expansion, the results are
unspecified.
.P
Macro expansions using the forms $(\c
.IR string1 \c
.BR [: \c
.IR subst1 \c
.BR =[ \c
.IR subst2 \c
.BR ]] )
or ${\c
.IR string1 \c
.BR [: \c
.IR subst1 \c
.BR =[ \c
.IR subst2 \c
.BR ]] }
can be used to replace all occurrences of
.IR subst1
with
.IR subst2
when the macro substitution is performed. The
.IR subst1
to be replaced shall be recognized when it is a suffix at the end of a
word in
.IR string1
(where a
.IR word ,
in this context, is defined to be a string delimited by the beginning
of the line, a
<blank>,
or a
<newline>).
If
.IR string1
in a macro expansion contains a macro expansion, the results are
unspecified.
.P
Macro expansions in
.IR string1
of macro definition lines shall be evaluated when read. Macro
expansions in
.IR string2
of macro definition lines shall be performed when the macro identified
by
.IR string1
is expanded in a rule or command.
.P
Macro definitions shall be taken from the following sources, in the
following logical order, before the makefile(s) are read.
.IP " 1." 4
Macros specified on the
.IR make
utility command line, in the order specified on the command line. It is
unspecified whether the internal macros defined in
.IR "Internal Macros"
are accepted from this source.
.IP " 2." 4
Macros defined by the
.IR MAKEFLAGS
environment variable, in the order specified in the environment
variable. It is unspecified whether the internal macros defined in
.IR "Internal Macros"
are accepted from this source.
.IP " 3." 4
The contents of the environment, excluding the
.IR MAKEFLAGS
and
.IR SHELL
variables and including the variables with null values.
.IP " 4." 4
Macros defined in the inference rules built into
.IR make .
.P
Macro definitions from these sources shall not override macro
definitions from a lower-numbered source. Macro definitions from a
single source (for example, the
.IR make
utility command line, the
.IR MAKEFLAGS
environment variable, or the other environment variables) shall
override previous macro definitions from the same source.
.P
Macros defined in the makefile(s) shall override macro definitions that
occur before them in the makefile(s) and macro definitions from source
4. If the
.BR \(mie
option is not specified, macros defined in the makefile(s) shall
override macro definitions from source 3. Macros defined in the
makefile(s) shall not override macro definitions from source 1 or
source 2.
.P
Before the makefile(s) are read, all of the
.IR make
utility command line options (except
.BR \(mif
and
.BR \(mip )
and
.IR make
utility command line macro definitions (except any for the
.IR MAKEFLAGS
macro), not already included in the
.IR MAKEFLAGS
macro, shall be added to the
.IR MAKEFLAGS
macro, quoted in an implementation-defined manner such that when
.IR MAKEFLAGS
is read by another instance of the
.IR make
command, the original macro's value is recovered. Other
implementation-defined options and macros may also be added to the
.IR MAKEFLAGS
macro. If this modifies the value of the
.IR MAKEFLAGS
macro, or, if the
.IR MAKEFLAGS
macro is modified at any subsequent time, the
.IR MAKEFLAGS
environment variable shall be modified to match the new value of the
.IR MAKEFLAGS
macro. The result of setting
.IR MAKEFLAGS
in the Makefile is unspecified.
.P
Before the makefile(s) are read, all of the
.IR make
utility command line macro definitions (except the
.IR MAKEFLAGS
macro or the
.IR SHELL
macro) shall be added to the environment of
.IR make .
Other implementation-defined variables may also be added to the
environment of
.IR make .
.P
The
.BR SHELL
macro shall be treated specially. It shall be provided by
.IR make
and set to the pathname of the shell command language interpreter (see
.IR "\fIsh\fR\^").
The
.IR SHELL
environment variable shall not affect the value of the
.BR SHELL
macro. If
.BR SHELL
is defined in the makefile or is specified on the command line, it
shall replace the original value of the
.BR SHELL
macro, but shall not affect the
.IR SHELL
environment variable. Other effects of defining
.BR SHELL
in the makefile or on the command line are implementation-defined.
.SS "Inference Rules"
.P
Inference rules are formatted as follows:
.sp
.RS 4
.nf
\fB
\fItarget\fR:
<tab>\fIcommand
\fB[\fR<tab>\fIcommand\fB]\fR
\&...
.P
\fIline that does not begin with \fR<tab>\fI or \fR#
.fi \fR
.P
.RE
.P
The application shall ensure that the
.IR target
portion is a valid target name (see
.IR "Target Rules")
of the form
.BR .s2
or
.BR .s1.s2
(where
.BR .s1
and
.BR .s2
are suffixes that have been given as prerequisites of the
.BR .SUFFIXES
special target and
.IR s1
and
.IR s2
do not contain any
<slash>
or
<period>
characters.) If there is only one
<period>
in the target, it is a single-suffix inference rule. Targets with two
periods are double-suffix inference rules. Inference rules can have
only one target before the
<colon>.
.P
The application shall ensure that the makefile does not specify
prerequisites for inference rules; no characters other than white space
shall follow the
<colon>
in the first line, except when creating the
.IR "empty rule,"
described below. Prerequisites are inferred, as described below.
.P
Inference rules can be redefined. A target that matches an existing
inference rule shall overwrite the old inference rule. An empty rule
can be created with a command consisting of simply a
<semicolon>
(that is, the rule still exists and is found during inference rule search,
but since it is empty, execution has no effect). The empty rule can also
be formatted as follows:
.sp
.RS 4
.nf
\fB
\fIrule\fR: ;
.fi \fR
.P
.RE
.P
where zero or more
<blank>
characters separate the
<colon>
and
<semicolon>.
.P
The
.IR make
utility uses the suffixes of targets and their prerequisites to infer
how a target can be made up-to-date. A list of inference rules defines
the commands to be executed. By default,
.IR make
contains a built-in set of inference rules. Additional rules can be
specified in the makefile.
.P
The special target
.BR .SUFFIXES
contains as its prerequisites a list of suffixes that shall be used by
the inference rules. The order in which the suffixes are specified
defines the order in which the inference rules for the suffixes are
used. New suffixes shall be appended to the current list by specifying
a
.BR .SUFFIXES
special target in the makefile. A
.BR .SUFFIXES
target with no prerequisites shall clear the list of suffixes. An
empty
.BR .SUFFIXES
target followed by a new
.BR .SUFFIXES
list is required to change the order of the suffixes.
.P
Normally, the user would provide an inference rule for each suffix.
The inference rule to update a target with a suffix
.BR .s1
from a prerequisite with a suffix
.BR .s2
is specified as a target
.BR .s2.s1 .
The internal macros provide the means to specify general inference
rules (see
.IR "Internal Macros").
.P
When no target rule is found to update a target, the inference rules
shall be checked. The suffix of the target (\c
.BR .s1 )
to be built is compared to the list of suffixes specified by the
.BR .SUFFIXES
special targets. If the
.BR .s1
suffix is found in
.BR .SUFFIXES ,
the inference rules shall be searched in the order defined for the
first
.BR .s2.s1
rule whose prerequisite file (\c
.BR $*.s2 )
exists. If the target is out-of-date with respect to this
prerequisite, the commands for that inference rule shall be executed.
.P
If the target to be built does not contain a suffix and there is no
rule for the target, the single suffix inference rules shall be
checked. The single-suffix inference rules define how to build a
target if a file is found with a name that matches the target name with
one of the single suffixes appended. A rule with one suffix
.BR .s2
is the definition of how to build
.IR target
from
.BR target.s2 .
The other suffix (\c
.BR .s1 )
is treated as null.
.P
A
<tilde>
(\c
.BR '~' )
in the above rules refers to an SCCS file in the current directory.
Thus, the rule
.BR .c~.o
would transform an SCCS C-language source file into an object file (\c
.BR .o ).
Because the
.BR s.
of the SCCS files is a prefix, it is incompatible with
.IR make 's
suffix point of view. Hence, the
.BR '~' 
is a way of changing any file reference into an SCCS file reference.
.SS "Libraries"
.P
If a target or prerequisite contains parentheses, it shall be treated
as a member of an archive library. For the
.IR lib (\c
.IR member \c
.BR .o )
expression
.IR lib
refers to the name of the archive library and
.IR member \c
.BR .o
to the member name. The application shall ensure that the member is an
object file with the
.BR .o
suffix. The modification time of the expression is the modification
time for the member as kept in the archive library; see
.IR "\fIar\fR\^".
The
.BR .a
suffix shall refer to an archive library. The
.BR .s2.a
rule shall be used to update a member in the library from a file
with a suffix
.BR .s2 .
.SS "Internal Macros"
.P
The
.IR make
utility shall maintain five internal macros that can be used in target
and inference rules. In order to clearly define the meaning of these
macros, some clarification of the terms
.IR "target rule" ,
.IR "inference rule" ,
.IR target ,
and
.IR prerequisite
is necessary.
.P
Target rules are specified by the user in a makefile for a particular
target. Inference rules are user-specified or
.IR make -specified
rules for a particular class of target name. Explicit prerequisites
are those prerequisites specified in a makefile on target lines.
Implicit prerequisites are those prerequisites that are generated when
inference rules are used. Inference rules are applied to implicit
prerequisites or to explicit prerequisites that do not have target
rules defined for them in the makefile. Target rules are applied to
targets specified in the makefile.
.P
Before any target in the makefile is updated, each of its prerequisites
(both explicit and implicit) shall be updated. This shall be
accomplished by recursively processing each prerequisite. Upon
recursion, each prerequisite shall become a target itself. Its
prerequisites in turn shall be processed recursively until a target is
found that has no prerequisites, at which point the recursion stops.
The recursion shall then back up, updating each target as it goes.
.P
In the definitions that follow, the word
.IR target
refers to one of:
.IP " *" 4
A target specified in the makefile
.IP " *" 4
An explicit prerequisite specified in the makefile that becomes the
target when
.IR make
processes it during recursion
.IP " *" 4
An implicit prerequisite that becomes a target when
.IR make
processes it during recursion
.P
In the definitions that follow, the word
.IR prerequisite
refers to one of the following:
.IP " *" 4
An explicit prerequisite specified in the makefile for a particular
target
.IP " *" 4
An implicit prerequisite generated as a result of locating an
appropriate inference rule and corresponding file that matches the
suffix of the target
.P
The five internal macros are:
.IP $@ 8
The $@ shall evaluate to the full target name of the current target, or
the archive filename part of a library archive target. It shall be
evaluated for both target and inference rules.
.RS 8 
.P
For example, in the
.BR .c.a
inference rule, $@ represents the out-of-date
.BR .a
file to be built. Similarly, in a makefile target rule to build
.BR lib.a
from
.BR file.c ,
$@ represents the out-of-date
.BR lib.a .
.RE
.IP $% 8
The $% macro shall be evaluated only when the current target is an
archive library member of the form
.IR libname (\c
.IR member \c
.BR .o ).
In these cases, $@ shall evaluate to
.IR libname
and $% shall evaluate to
.IR member \c
.BR .o .
The $% macro shall be evaluated for both target and inference rules.
.RS 8 
.P
For example, in a makefile target rule to build
.BR lib.a (\c
.BR file.o ),
$% represents
.BR file.o ,
as opposed to $@, which represents
.BR lib.a .
.RE
.IP $? 8
The $? macro shall evaluate to the list of prerequisites that are
newer than the current target. It shall be evaluated for both target
and inference rules.
.RS 8 
.P
For example, in a makefile target rule to build
.IR prog
from
.BR file1.o ,
.BR file2.o ,
and
.BR file3.o ,
and where
.IR prog
is not out-of-date with respect to
.BR file1.o ,
but is out-of-date with respect to
.BR file2.o
and
.BR file3.o ,
$? represents
.BR file2.o
and
.BR file3.o .
.RE
.IP $< 8
In an inference rule, the $< macro shall evaluate to the filename
whose existence allowed the inference rule to be chosen for the target.
In the
.BR .DEFAULT
rule, the $< macro shall evaluate to the current target name. The
meaning of the $< macro shall be otherwise unspecified.
.RS 8 
.P
For example, in the
.BR .c.a
inference rule, $< represents the prerequisite
.BR .c
file.
.RE
.IP $* 8
The $* macro shall evaluate to the current target name with its suffix
deleted. It shall be evaluated at least for inference rules.
.RS 8 
.P
For example, in the
.BR .c.a
inference rule, $*.o represents the out-of-date
.BR .o
file that corresponds to the prerequisite
.BR .c
file.
.RE
.P
Each of the internal macros has an alternative form. When an uppercase
.BR 'D' 
or
.BR 'F' 
is appended to any of the macros, the meaning shall be changed to the
.IR "directory part"
for
.BR 'D' 
and
.IR "filename part"
for
.BR 'F' .
The directory part is the path prefix of the file without a trailing
<slash>;
for the current directory, the directory part is
.BR '.' .
When the $? macro contains more than one prerequisite filename, the
$(?D) and $(?F) (or ${?D} and ${?F}) macros expand to a list of
directory name parts and filename parts respectively.
.P
For the target
.IR lib (\c
.IR member \c
.BR .o )
and the
.BR s2.a
rule, the internal macros shall be defined as:
.IP $< 8
.IR member \c
.BR .s2
.IP $* 8
.IR member
.IP $@ 8
.IR lib
.IP $? 8
.IR member \c
.BR .s2
.IP $% 8
.IR member \c
.BR .o
.SS "Default Rules"
.P
The default rules for
.IR make
shall achieve results that are the same as if the following were used.
Implementations that do not support the C-Language Development
Utilities option may omit
.BR CC ,
.BR CFLAGS ,
.BR YACC ,
.BR YFLAGS ,
.BR LEX ,
.BR LFLAGS ,
.BR LDFLAGS ,
and the
.BR .c ,
.BR .y ,
and
.BR .l
inference rules. Implementations that do not support FORTRAN may omit
.BR FC ,
.BR FFLAGS ,
and the
.BR .f
inference rules. Implementations may provide additional macros and
rules.
.sp
.RS 4
.nf
\fB
\fISPECIAL TARGETS\fP
.P
\&.SCCS_GET: sccs $(SCCSFLAGS) get $(SCCSGETFLAGS) $@
.P
\&.SUFFIXES: .o .c .y .l .a .sh .f .c~ .y~ .l~ .sh~ .f~
.P
.IR MACROS
.P
MAKE=make
AR=ar
ARFLAGS=\(mirv
YACC=yacc
YFLAGS=
LEX=lex
LFLAGS=
LDFLAGS=
CC=c99
CFLAGS=\(miO
FC=fort77
FFLAGS=\(miO 1
GET=get
GFLAGS=
SCCSFLAGS=
SCCSGETFLAGS=\(mis
.P
\fISINGLE SUFFIX RULES\fP
.P
\&.c:
    $(CC) $(CFLAGS) $(LDFLAGS) \(mio $@ $<
.P
\&.f:
    $(FC) $(FFLAGS) $(LDFLAGS) \(mio $@ $<
.P
\&.sh:
    cp $< $@
    chmod a+x $@
.P
\&.c~:
    $(GET) $(GFLAGS) \(mip $< > $*.c
    $(CC) $(CFLAGS) $(LDFLAGS) \(mio $@ $*.c
.P
\&.f~:
    $(GET) $(GFLAGS) \(mip $< > $*.f
    $(FC) $(FFLAGS) $(LDFLAGS) \(mio $@ $*.f
.P
\&.sh~:
    $(GET) $(GFLAGS) \(mip $< > $*.sh
    cp $*.sh $@
    chmod a+x $@
.P
\fIDOUBLE SUFFIX RULES\fP
.P
\&.c.o:
    $(CC) $(CFLAGS) \(mic $<
.P
\&.f.o:
    $(FC) $(FFLAGS) \(mic $<
.P
\&.y.o:
    $(YACC) $(YFLAGS) $<
    $(CC) $(CFLAGS) \(mic y.tab.c
    rm \(mif y.tab.c
    mv y.tab.o $@
.P
\&.l.o:
    $(LEX) $(LFLAGS) $<
    $(CC) $(CFLAGS) \(mic lex.yy.c
    rm \(mif lex.yy.c
    mv lex.yy.o $@
.P
\&.y.c:
    $(YACC) $(YFLAGS) $<
    mv y.tab.c $@
.P
\&.l.c:
    $(LEX) $(LFLAGS) $<
    mv lex.yy.c $@
.P
\&.c~.o:
    $(GET) $(GFLAGS) \(mip $< > $*.c
    $(CC) $(CFLAGS) \(mic $*.c
.P
\&.f~.o:
    $(GET) $(GFLAGS) \(mip $< > $*.f
    $(FC) $(FFLAGS) \(mic $*.f
.P
\&.y~.o:
    $(GET) $(GFLAGS) \(mip $< > $*.y
    $(YACC) $(YFLAGS) $*.y
    $(CC) $(CFLAGS) \(mic y.tab.c
    rm \(mif y.tab.c
    mv y.tab.o $@
.P
\&.l~.o:
    $(GET) $(GFLAGS) \(mip $< > $*.l
    $(LEX) $(LFLAGS) $*.l
    $(CC) $(CFLAGS) \(mic lex.yy.c
    rm \(mif lex.yy.c
    mv lex.yy.o $@
.P
\&.y~.c:
    $(GET) $(GFLAGS) \(mip $< > $*.y
    $(YACC) $(YFLAGS) $*.y
    mv y.tab.c $@
.P
\&.l~.c:
    $(GET) $(GFLAGS) \(mip $< > $*.l
    $(LEX) $(LFLAGS) $*.l
    mv lex.yy.c $@
.P
\&.c.a:
    $(CC) \(mic $(CFLAGS) $<
    $(AR) $(ARFLAGS) $@ $*.o
    rm \(mif $*.o
.P
\&.f.a:
    $(FC) \(mic $(FFLAGS) $<
    $(AR) $(ARFLAGS) $@ $*.o
    rm \(mif $*.o
.fi \fR
.P
.RE
.SH "EXIT STATUS"
When the
.BR \(miq
option is specified, the
.IR make
utility shall exit with one of the following values:
.IP "\00" 6
Successful completion.
.IP "\01" 6
The target was not up-to-date.
.IP >1 6
An error occurred.
.P
When the
.BR \(miq
option is not specified, the
.IR make
utility shall exit with one of the following values:
.IP "\00" 6
Successful completion.
.IP >0 6
An error occurred.
.SH "CONSEQUENCES OF ERRORS"
Default.
.LP
.IR "The following sections are informative."
.SH "APPLICATION USAGE"
If there is a source file (such as
.BR ./source.c )
and there are two SCCS files corresponding to it (\c
.BR ./s.source.c
and
.BR ./SCCS/s.source.c ),
on XSI-conformant systems
.IR make
uses the SCCS file in the current directory. However, users are
advised to use the underlying SCCS utilities (\c
.IR admin ,
.IR delta ,
.IR get ,
and so on) or the
.IR sccs
utility for all source files in a given directory. If both forms are
used for a given source file, future developers are very likely to be
confused.
.P
It is incumbent upon portable makefiles to specify the
.BR .POSIX
special target in order to guarantee that they are not affected by
local extensions.
.P
The
.BR \(mik
and
.BR \(miS
options are both present so that the relationship between the command
line, the
.IR MAKEFLAGS
variable, and the makefile can be controlled precisely. If the
.BR k
flag is passed in
.IR MAKEFLAGS
and a command is of the form:
.sp
.RS 4
.nf
\fB
$(MAKE) \(miS foo
.fi \fR
.P
.RE
.P
then the default behavior is restored for the child
.IR make .
.P
When the
.BR \(min
option is specified, it is always added to
.IR MAKEFLAGS .
This allows a recursive
.IR make
.BR \(min
.IR target
to be used to see all of the action that would be taken to update
.IR target .
.P
Because of widespread historical practice, interpreting a
<number-sign>
(\c
.BR '#' )
inside a variable as the start of a comment has the unfortunate
side-effect of making it impossible to place a
<number-sign>
in a variable, thus forbidding something like:
.sp
.RS 4
.nf
\fB
CFLAGS = "\(miD COMMENT_CHAR='#'"
.fi \fR
.P
.RE
.P
Many historical
.IR make
utilities stop chaining together inference rules when an intermediate
target is nonexistent. For example, it might be possible for a
.IR make
to determine that both
.BR .y.c
and
.BR .c.o
could be used to convert a
.BR .y
to a
.BR .o .
Instead, in this case,
.IR make
requires the use of a
.BR .y.o
rule.
.P
The best way to provide portable makefiles is to include all of the
rules needed in the makefile itself. The rules provided use only
features provided by other parts of this volume of POSIX.1\(hy2008. The default rules include
rules for optional commands in this volume of POSIX.1\(hy2008. Only rules pertaining to commands
that are provided are needed in an implementation's default set.
.P
Macros used within other macros are evaluated when the new macro is
used rather than when the new macro is defined. Therefore:
.sp
.RS 4
.nf
\fB
MACRO = \fIvalue1\fP
NEW   = $(MACRO)
MACRO = \fIvalue2\fP
.P
target:
    echo $(NEW)
.fi \fR
.P
.RE
.P
would produce
.IR value2
and not
.IR value1
since
.BR NEW
was not expanded until it was needed in the
.IR echo
command line.
.P
Some historical applications have been known to intermix
.IR target_name
and
.IR macro=name
operands on the command line, expecting that all of the macros are
processed before any of the targets are dealt with. Conforming
applications do not do this, although some backwards-compatibility
support may be included in some implementations.
.P
The following characters in filenames may give trouble:
.BR '=' ,
.BR ':' ,
.BR '`' ,
single-quote, and
.BR '@' .
In include filenames, pattern matching characters and
.BR '\&"' 
should also be avoided, as they may be treated as special by some
implementations.
.P
For inference rules, the description of $< and $? seem similar. However,
an example shows the minor difference. In a makefile containing:
.sp
.RS 4
.nf
\fB
foo.o: foo.h
.fi \fR
.P
.RE
.P
if
.BR foo.h
is newer than
.BR foo.o ,
yet
.BR foo.c
is older than
.BR foo.o ,
the built-in rule to make
.BR foo.o
from
.BR foo.c
is used, with $< equal to
.BR foo.c
and $? equal to
.BR foo.h .
If
.BR foo.c
is also newer than
.BR foo.o ,
$< is equal to
.BR foo.c
and $? is equal to
.BR "foo.h foo.c" .
.SH EXAMPLES
.IP " 1." 4
The following command:
.RS 4 
.sp
.RS 4
.nf
\fB
make
.fi \fR
.P
.RE
.P
makes the first target found in the makefile.
.RE
.IP " 2." 4
The following command:
.RS 4 
.sp
.RS 4
.nf
\fB
make junk
.fi \fR
.P
.RE
.P
makes the target
.BR junk .
.RE
.IP " 3." 4
The following makefile says that
.BR pgm
depends on two files,
.BR a.o
and
.BR b.o ,
and that they in turn depend on their corresponding source files (\c
.BR a.c
and
.BR b.c ),
and a common file
.BR incl.h :
.RS 4 
.sp
.RS 4
.nf
\fB
pgm: a.o b.o
    c99 a.o b.o \(mio pgm
a.o: incl.h a.c
    c99 \(mic a.c
b.o: incl.h b.c
    c99 \(mic b.c
.fi \fR
.P
.RE
.RE
.IP " 4." 4
An example for making optimized
.BR .o
files from
.BR .c
files is:
.RS 4 
.sp
.RS 4
.nf
\fB
\&.c.o:
    c99 \(mic \(miO $*.c
.fi \fR
.P
.RE
.P
or:
.sp
.RS 4
.nf
\fB
\&.c.o:
    c99 \(mic \(miO $<
.fi \fR
.P
.RE
.RE
.IP " 5." 4
The most common use of the archive interface follows. Here, it is
assumed that the source files are all C-language source:
.RS 4 
.sp
.RS 4
.nf
\fB
lib: lib(file1.o) lib(file2.o) lib(file3.o)
    @echo lib is now up-to-date
.fi \fR
.P
.RE
.P
The
.BR .c.a
rule is used to make
.BR file1.o ,
.BR file2.o ,
and
.BR file3.o
and insert them into
.BR lib .
.P
The treatment of escaped
<newline>
characters throughout the makefile is historical practice. For example,
the inference rule:
.sp
.RS 4
.nf
\fB
\&.c.o\e
:
.fi \fR
.P
.RE
.P
works, and the macro:
.sp
.RS 4
.nf
\fB
f=  bar baz\e
    biz
a:
    echo ==$f==
.fi \fR
.P
.RE
.P
echoes
.BR \(dq==bar\ baz\ biz==\(dq .
.P
If $? were:
.sp
.RS 4
.nf
\fB
/usr/include/stdio.h /usr/include/unistd.h foo.h
.fi \fR
.P
.RE
.P
then $(?D) would be:
.sp
.RS 4
.nf
\fB
/usr/include /usr/include .
.fi \fR
.P
.RE
.P
and $(?F) would be:
.sp
.RS 4
.nf
\fB
stdio.h unistd.h foo.h
.fi \fR
.P
.RE
.RE
.IP " 6." 4
The contents of the built-in rules can be viewed by running:
.RS 4 
.sp
.RS 4
.nf
\fB
make \(mip \(mif /dev/null 2>/dev/null
.fi \fR
.P
.RE
.RE
.SH RATIONALE
The
.IR make
utility described in this volume of POSIX.1\(hy2008 is intended to provide the means for
changing portable source code into executables that can be run on an
POSIX.1\(hy2008-conforming system. It reflects the most common features present
in System V and BSD
.IR make s.
.P
Historically, the
.IR make
utility has been an especially fertile ground for vendor and research
organization-specific syntax modifications and extensions. Examples
include:
.IP " *" 4
Syntax supporting parallel execution (such as from various
multi-processor vendors, GNU, and others)
.IP " *" 4
Additional ``operators'' separating targets and their prerequisites
(System V, BSD, and others)
.IP " *" 4
Specifying that command lines containing the strings
.BR \(dq${MAKE}\(dq 
and
.BR \(dq$(MAKE)\(dq 
are executed when the
.BR \(min
option is specified (GNU and System V)
.IP " *" 4
Modifications of the meaning of internal macros when referencing
libraries (BSD and others)
.IP " *" 4
Using a single instance of the shell for all of the command lines of
the target (BSD and others)
.IP " *" 4
Allowing
<space>
characters as well as
<tab>
characters to delimit command lines (BSD)
.IP " *" 4
Adding C preprocessor-style ``include'' and ``ifdef'' constructs
(System V, GNU, BSD, and others)
.IP " *" 4
Remote execution of command lines (Sprite and others)
.IP " *" 4
Specifying additional special targets (BSD, System V, and most others)
.P
Additionally, many vendors and research organizations have rethought
the basic concepts of
.IR make ,
creating vastly extended, as well as completely new, syntaxes. Each of
these versions of
.IR make
fulfills the needs of a different community of users; it is
unreasonable for this volume of POSIX.1\(hy2008 to require behavior that would be incompatible
(and probably inferior) to historical practice for such a community.
.P
In similar circumstances, when the industry has enough sufficiently
incompatible formats as to make them irreconcilable, this volume of POSIX.1\(hy2008 has followed
one or both of two courses of action. Commands have been renamed (\c
.IR cksum ,
.IR echo ,
and
.IR pax )
and/or command line options have been provided to select the desired
behavior (\c
.IR grep ,
.IR od ,
and
.IR pax ).
.P
Because the syntax specified for the
.IR make
utility is, by and large, a subset of the syntaxes accepted by almost
all versions of
.IR make ,
it was decided that it would be counter-productive to change the name.
And since the makefile itself is a basic unit of portability, it would
not be completely effective to reserve a new option letter, such as
.IR make
.BR \(miP ,
to achieve the portable behavior. Therefore, the special target
.BR .POSIX
was added to the makefile, allowing users to specify ``standard''
behavior. This special target does not preclude extensions in the
.IR make
utility, nor does it preclude such extensions being used by the
makefile specifying the target; it does, however, preclude any
extensions from being applied that could alter the behavior of
previously valid syntax; such extensions must be controlled via
command line options or new special targets. It is incumbent upon
portable makefiles to specify the
.BR .POSIX
special target in order to guarantee that they are not affected by
local extensions.
.P
The portable version of
.IR make
described in this reference page is not intended to be the
state-of-the-art software generation tool and, as such, some newer and
more leading-edge features have not been included. An attempt has been
made to describe the portable makefile in a manner that does not
preclude such extensions as long as they do not disturb the portable
behavior described here.
.P
When the
.BR \(min
option is specified, it is always added to
.IR MAKEFLAGS .
This allows a recursive
.IR make
.BR \(min
.IR target
to be used to see all of the action that would be taken to update
.IR target .
.P
The definition of
.IR MAKEFLAGS
allows both the System V letter string and the BSD command line
formats. The two formats are sufficiently different to allow
implementations to support both without ambiguity.
.P
Early proposals stated that an ``unquoted''
<number-sign>
was treated as the start of a comment. The
.IR make
utility does not pay any attention to quotes. A
<number-sign>
starts a comment regardless of its surroundings.
.P
The text about ``other implementation-defined pathnames may also be
tried'' in addition to
.BR ./makefile
and
.BR ./Makefile
is to allow such extensions as
.BR SCCS/s.Makefile
and other variations. It was made an implementation-defined
requirement (as opposed to unspecified behavior) to highlight
surprising implementations that might select something unexpected like
.BR /etc/Makefile .
XSI-conformant systems also try
.BR ./s.makefile ,
.BR SCCS/s.makefile ,
.BR ./s.Makefile ,
and
.BR SCCS/s.Makefile .
.P
Early proposals contained the macro
.BR NPROC
as a means of specifying that
.IR make
should use
.IR n
processes to do the work required. While this feature is a valuable
extension for many systems, it is not common usage and could require
other non-trivial extensions to makefile syntax. This extension is not
required by this volume of POSIX.1\(hy2008, but could be provided as a compatible extension. The
macro
.BR PARALLEL
is used by some historical systems with essentially the same meaning
(but without using a name that is a common system limit value). It is
suggested that implementors recognize the existing use of
.BR NPROC
and/or
.BR PARALLEL
as extensions to
.IR make .
.P
The default rules are based on System V. The default
.BR CC=
value is
.IR c99
instead of
.IR cc
because this volume of POSIX.1\(hy2008 does not standardize the utility named
.IR cc .
Thus, every conforming application would be required to define
.BR CC= \c
.IR c99
to expect to run. There is no advantage conferred by the hope that the
makefile might hit the ``preferred'' compiler because this cannot be
guaranteed to work. Also, since the portable makescript can only use
the
.IR c99
options, no advantage is conferred in terms of what the script can do.
It is a quality-of-implementation issue as to whether
.IR c99
is as valuable as
.IR cc .
.P
The
.BR \(mid
option to
.IR make
is frequently used to produce debugging information, but is too
implementation-defined to add to this volume of POSIX.1\(hy2008.
.P
The
.BR \(mip
option is not passed in
.IR MAKEFLAGS
on most historical implementations and to change this would cause many
implementations to break without sufficiently increased portability.
.P
Commands that begin with a
<plus-sign>
(\c
.BR '\(pl' )
are executed even if the
.BR \(min
option is present. Based on the GNU version of
.IR make ,
the behavior of
.BR \(min
when the
<plus-sign>
prefix is encountered has been extended to apply to
.BR \(miq
and
.BR \(mit
as well. However, the System V convention of forcing command execution
with
.BR \(min
when the command line of a target contains either of the strings
.BR \(dq$(MAKE)\(dq 
or
.BR \(dq${MAKE}\(dq 
has not been adopted. This functionality appeared in early proposals,
but the danger of this approach was pointed out with the following
example of a portion of a makefile:
.sp
.RS 4
.nf
\fB
subdir:
    cd subdir; rm all_the_files; $(MAKE)
.fi \fR
.P
.RE
.P
The loss of the System V behavior in this case is well-balanced by the
safety afforded to other makefiles that were not aware of this
situation. In any event, the command line
<plus-sign>
prefix can provide the desired functionality.
.P
The double
<colon>
in the target rule format is supported in BSD systems to allow more
than one target line containing the same target name to have commands
associated with it. Since this is not functionality described in the
SVID or XPG3 it has been allowed as an extension, but not mandated.
.P
The default rules are provided with text specifying that the built-in
rules shall be the same as if the listed set were used. The intent is
that implementations should be able to use the rules without change,
but will be allowed to alter them in ways that do not affect the
primary behavior.
.P
The best way to provide portable makefiles is to include all of the
rules needed in the makefile itself. The rules provided use only
features provided by other portions of this volume of POSIX.1\(hy2008. The default rules include
rules for optional commands in this volume of POSIX.1\(hy2008. Only rules pertaining to commands
that are provided are needed in the default set of an implementation.
.P
One point of discussion was whether to drop the default rules list from
\&this volume of POSIX.1\(hy2008. They provide convenience, but do not enhance portability of
applications. The prime benefit is in portability of users who wish to
type
.IR make
.IR command
and have the command build from a
.BR command.c
file.
.P
The historical
.IR MAKESHELL
feature was omitted. In some implementations it is used to let a user
override the shell to be used to run
.IR make
commands. This was confusing; for a portable
.IR make ,
the shell should be chosen by the makefile writer or specified on the
.IR make
command line and not by a user running
.IR make .
.P
The
.IR make
utilities in most historical implementations process the prerequisites
of a target in left-to-right order, and the makefile format
requires this. It supports the standard idiom used in many makefiles
that produce
.IR yacc
programs; for example:
.sp
.RS 4
.nf
\fB
foo: y.tab.o lex.o main.o
    $(CC) $(CFLAGS) \(mio $\fR@\fP t.tab.o lex.o main.o
.fi \fR
.P
.RE
.P
In this example, if
.IR make
chose any arbitrary order, the
.BR lex.o
might not be made with the correct
.BR y.tab.h .
Although there may be better ways to express this relationship, it is
widely used historically. Implementations that desire to update
prerequisites in parallel should require an explicit extension to
.IR make
or the makefile format to accomplish it, as described previously.
.P
The algorithm for determining a new entry for target rules is partially
unspecified. Some historical
.IR make s
allow blank, empty, or comment lines within the collection of commands
marked by leading
<tab>
characters. A conforming makefile must ensure that each command starts
with a
<tab>,
but implementations are free to ignore blank, empty, and comment lines
without triggering the start of a new entry.
.P
The ASYNCHRONOUS EVENTS section includes having SIGTERM and SIGHUP,
along with the more traditional SIGINT and SIGQUIT, remove the current
target unless directed not to do so. SIGTERM and SIGHUP were added to
parallel other utilities that have historically cleaned up their work
as a result of these signals. When
.IR make
receives any signal other than SIGQUIT, it is required to resend itself
the signal it received so that it exits with a status that reflects the
signal. The results from SIGQUIT are partially unspecified because, on
systems that create
.BR core
files upon receipt of SIGQUIT, the
.BR core
from
.IR make
would conflict with a
.BR core
file from the command that was running when the SIGQUIT arrived. The
main concern was to prevent damaged files from appearing up-to-date when
.IR make
is rerun.
.P
The
.BR .PRECIOUS
special target was extended to affect all targets globally (by
specifying no prerequisites). The
.BR .IGNORE
and
.BR .SILENT
special targets were extended to allow prerequisites; it was judged to
be more useful in some cases to be able to turn off errors or echoing
for a list of targets than for the entire makefile. These extensions
to
.IR make
in System V were made to match historical practice from the BSD
.IR make .
.P
Macros are not exported to the environment of commands to be run. This
was never the case in any historical
.IR make
and would have serious consequences. The environment is the same as
the environment to
.IR make
except that
.IR MAKEFLAGS
and macros defined on the
.IR make
command line are added.
.P
Some implementations do not use
\fIsystem\fR()
for all command lines, as required by the portable makefile
format; as a performance enhancement, they select lines without shell
metacharacters for direct execution by
\fIexecve\fR().
There is no requirement that
\fIsystem\fR()
be used specifically, but merely that the same results be achieved.
The metacharacters typically used to bypass the direct
\fIexecve\fR()
execution have been any of:
.sp
.RS 4
.nf
\fB
=  |  ^  (  )  ;  &  <  >  *  ?  [  ]  :  $  `  '  "  \e  \en
.fi \fR
.P
.RE
.P
The default in some advanced versions of
.IR make
is to group all the command lines for a target and execute them using a
single shell invocation; the System V method is to pass each line
individually to a separate shell. The single-shell method has the
advantages in performance and the lack of a requirement for many
continued lines. However, converting to this newer method has caused
portability problems with many historical makefiles, so the behavior
with the POSIX makefile is specified to be the same as that of System
V. It is suggested that the special target
.BR .ONESHELL
be used as an implementation extension to achieve the single-shell
grouping for a target or group of targets.
.P
Novice users of
.IR make
have had difficulty with the historical need to start commands with a
<tab>.
Since it is often difficult to discern differences between
<tab>
and
<space>
characters on terminals or printed listings, confusing bugs can arise. In
early proposals, an attempt was made to correct this problem by allowing
leading
<blank>
characters instead of
<tab>
characters. However, implementors reported many makefiles that failed
in subtle ways following this change, and it is difficult to implement a
.IR make
that unambiguously can differentiate between macro and command lines.
There is extensive historical practice of allowing leading
<space>
characters before macro definitions. Forcing macro lines into column 1
would be a significant backwards-compatibility problem for some makefiles.
Therefore, historical practice was restored.
.P
There is substantial variation in the handling of include lines by
different implementations. However, there is enough commonality for the
standard to be able to specify a minimum set of requirements that allow
the feature to be used portably. Known variations have been explicitly
called out as unspecified behavior in the description.
.P
The System V dynamic dependency feature was not included. It would
support:
.sp
.RS 4
.nf
\fB
cat: $$@.c
.fi \fR
.P
.RE
.P
that would expand to;
.sp
.RS 4
.nf
\fB
cat: cat.c
.fi \fR
.P
.RE
.P
This feature exists only in the new version of System V
.IR make
and, while useful, is not in wide usage. This means that macros are
expanded twice for prerequisites: once at makefile parse time and once
at target update time.
.P
Consideration was given to adding metarules to the POSIX
.IR make .
This would make
.BR "%.o:\ %.c"
the same as
.BR .c.o: .
This is quite useful and available from some vendors, but it would
cause too many changes to this
.IR make
to support. It would have introduced rule chaining and new substitution
rules. However, the rules for target names have been set to reserve the
.BR '%' 
and
.BR '\&"' 
characters. These are traditionally used to implement metarules and
quoting of target names, respectively. Implementors are strongly
encouraged to use these characters only for these purposes.
.P
A request was made to extend the suffix delimiter character from a
<period>
to any character. The metarules feature in newer
.IR make s
solves this problem in a more general way. This volume of POSIX.1\(hy2008 is staying with the
more conservative historical definition.
.P
The standard output format for the
.BR \(mip
option is not described because it is primarily a debugging option and
because the format is not generally useful to programs. In historical
implementations the output is not suitable for use in generating
makefiles. The
.BR \(mip
format has been variable across historical implementations. Therefore,
the definition of
.BR \(mip
was only to provide a consistently named option for obtaining
.IR make
script debugging information.
.P
Some historical implementations have not cleared the suffix list with
.BR \(mir .
.P
Implementations should be aware that some historical applications have
intermixed
.IR target_name
and
.IR macro =\c
.IR value
operands on the command line, expecting that all of the macros are
processed before any of the targets are dealt with. Conforming
applications do not do this, but some backwards-compatibility support
may be warranted.
.P
Empty inference rules are specified with a
<semicolon>
command rather than omitting all commands, as described in an early
proposal. The latter case has no traditional meaning and is reserved
for implementation extensions, such as in GNU
.IR make .
.SH "FUTURE DIRECTIONS"
None.
.SH "SEE ALSO"
.IR "Chapter 2" ", " "Shell Command Language",
.IR "\fIar\fR\^",
.IR "\fIc99\fR\^",
.IR "\fIget\fR\^",
.IR "\fIlex\fR\^",
.IR "\fIsccs\fR\^",
.IR "\fIsh\fR\^",
.IR "\fIyacc\fR\^"
.P
The Base Definitions volume of POSIX.1\(hy2008,
.IR "Section 6.1" ", " "Portable Character Set",
.IR "Chapter 8" ", " "Environment Variables",
.IR "Section 12.2" ", " "Utility Syntax Guidelines"
.P
The System Interfaces volume of POSIX.1\(hy2008,
.IR "\fIexec\fR\^",
.IR "\fIsystem\fR\^(\|)"
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 7, Copyright (C) 2013 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group.
(This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.unix.org/online.html .

Any typographical or formatting errors that appear
in this page are most likely
to have been introduced during the conversion of the source files to
man page format. To report such errors, see
https://www.kernel.org/doc/man-pages/reporting_bugs.html .