File: cons.html

package info (click to toggle)
cons 2.2.0-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 600 kB
  • ctags: 304
  • sloc: perl: 2,307; makefile: 29
file content (2201 lines) | stat: -rw-r--r-- 113,490 bytes parent folder | download | duplicates (4)
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
<HTML>
<HEAD>
<TITLE>Cons - Software Construction System</TITLE>
<LINK REV="made" HREF="mailto:prospector@porky.devel.redhat.com">
</HEAD>

<BODY>

<A NAME="__index__"></A>
<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#name">NAME</A></LI>
	<LI><A HREF="#description">DESCRIPTION</A></LI>
	<LI><A HREF="#introduction">Introduction</A></LI>
	<LI><A HREF="#why cons why not make">Why Cons? Why not Make?</A></LI>
	<UL>

		<LI><A HREF="#build complexity">Build complexity</A></LI>
		<LI><A HREF="#build reproducibility">Build reproducibility</A></LI>
		<LI><A HREF="#variant builds">Variant builds</A></LI>
		<LI><A HREF="#repositories">Repositories</A></LI>
	</UL>

	<LI><A HREF="#keeping it simple">Keeping it simple</A></LI>
	<UL>

		<LI><A HREF="#perl scripts">Perl scripts</A></LI>
		<LI><A HREF="#hello, world!">Hello, World!</A></LI>
		<LI><A HREF="#construction environments">Construction environments</A></LI>
		<LI><A HREF="#automatic and complete dependency analysis">Automatic and complete dependency analysis</A></LI>
		<LI><A HREF="#automatic global build sequencing">Automatic global build sequencing</A></LI>
	</UL>

	<LI><A HREF="#building large treesstill just as simple">Building large trees-still just as simple</A></LI>
	<UL>

		<LI><A HREF="#a hierarchy of build scripts">A hierarchy of build scripts</A></LI>
		<LI><A HREF="#the build command">The Build command</A></LI>
		<LI><A HREF="#relative, toprelative, and absolute file names">Relative, top-relative, and absolute file names</A></LI>
		<LI><A HREF="#using modules in build scripts">Using modules in build scripts</A></LI>
		<LI><A HREF="#scope of variables">Scope of variables</A></LI>
		<LI><A HREF="#the export command">The Export command</A></LI>
		<LI><A HREF="#the import command">The Import command</A></LI>
		<LI><A HREF="#build script evaluation order">Build script evaluation order</A></LI>
	</UL>

	<LI><A HREF="#a model for sharing files">A Model for sharing files</A></LI>
	<UL>

		<LI><A HREF="#some simple conventions">Some simple conventions</A></LI>
		<LI><A HREF="#clean, understandable, locationindependent scripts">Clean, understandable, location-independent scripts</A></LI>
	</UL>

	<LI><A HREF="#separating source and build trees">Separating source and build trees</A></LI>
	<UL>

		<LI><A HREF="#separating build and source directories using the link command">Separating build and source directories using the Link command</A></LI>
	</UL>

	<LI><A HREF="#variant builds">Variant builds</A></LI>
	<UL>

		<LI><A HREF="#hello, world! for banana and peach os's">Hello, World! for baNaNa and peAcH OS's</A></LI>
		<LI><A HREF="#variations on a theme">Variations on a theme</A></LI>
	</UL>

	<LI><A HREF="#signatures">Signatures</A></LI>
	<UL>

		<LI><A HREF="#md5 cryptographic signatures">MD5 cryptographic signatures</A></LI>
	</UL>

	<LI><A HREF="#code repositories">Code Repositories</A></LI>
	<UL>

		<LI><A HREF="#repository">Repository</A></LI>
		<LI><A HREF="#finding the construct file in a repository">Finding the Construct file in a Repository</A></LI>
		<LI><A HREF="#repository source files">Repository source files</A></LI>
		<LI><A HREF="#repository derived files">Repository derived files</A></LI>
		<LI><A HREF="#local copies of files">Local copies of files</A></LI>
		<LI><A HREF="#repository dependency analysis">Repository dependency analysis</A></LI>
		<LI><A HREF="#repository_list">Repository_List</A></LI>
		<LI><A HREF="#repository interaction with other cons features">Repository interaction with other Cons features</A></LI>
	</UL>

	<LI><A HREF="#default targets">Default targets</A></LI>
	<LI><A HREF="#selective builds">Selective builds</A></LI>
	<UL>

		<LI><A HREF="#selective targeting">Selective targeting</A></LI>
		<LI><A HREF="#no ``special'' targets">No ``special'' targets</A></LI>
	</UL>

	<LI><A HREF="#build pruning">Build Pruning</A></LI>
	<LI><A HREF="#temporary overrides">Temporary overrides</A></LI>
	<UL>

		<LI><A HREF="#overriding environment variables">Overriding environment variables</A></LI>
		<LI><A HREF="#the override command">The Override command</A></LI>
	</UL>

	<LI><A HREF="#more on construction environments">More on construction environments</A></LI>
	<UL>

		<LI><A HREF="#default construction variables">Default construction variables</A></LI>
		<LI><A HREF="#interpolating construction variables">Interpolating construction variables</A></LI>
	</UL>

	<LI><A HREF="#default construction methods">Default construction methods</A></LI>
	<UL>

		<LI><A HREF="#the new constructor">The <CODE>new</CODE> constructor</A></LI>
		<LI><A HREF="#the clone method">The <CODE>clone</CODE> method</A></LI>
		<LI><A HREF="#the copy method">The <CODE>copy</CODE> method</A></LI>
		<LI><A HREF="#the install method">The <CODE>Install</CODE> method</A></LI>
		<LI><A HREF="#the installas method">The <CODE>InstallAs</CODE> method</A></LI>
		<LI><A HREF="#the precious method">The <CODE>Precious</CODE> method</A></LI>
		<LI><A HREF="#the command method">The <CODE>Command</CODE> method</A></LI>
		<LI><A HREF="#the objects method">The <CODE>Objects</CODE> method</A></LI>
		<LI><A HREF="#the program method">The <CODE>Program</CODE> method</A></LI>
		<LI><A HREF="#the library method">The <CODE>Library</CODE> method</A></LI>
		<LI><A HREF="#the module method">The <CODE>Module</CODE> method</A></LI>
		<LI><A HREF="#the depends method">The <CODE>Depends</CODE> method</A></LI>
		<LI><A HREF="#the ignore method">The <CODE>Ignore</CODE> method</A></LI>
		<LI><A HREF="#the salt method">The <CODE>Salt</CODE> method</A></LI>
		<LI><A HREF="#the usecache method">The <CODE>UseCache</CODE> method</A></LI>
		<LI><A HREF="#the sourcepath method">The <CODE>SourcePath</CODE> method</A></LI>
		<LI><A HREF="#the conspath method">The <CODE>ConsPath</CODE> method</A></LI>
		<LI><A HREF="#the splitpath method">The <CODE>SplitPath</CODE> method</A></LI>
		<LI><A HREF="#the dirpath method">The <CODE>DirPath</CODE> method</A></LI>
		<LI><A HREF="#the filepath method">The <CODE>FilePath</CODE> method</A></LI>
		<LI><A HREF="#the help method">The <CODE>Help</CODE> method</A></LI>
	</UL>

	<LI><A HREF="#extending cons">Extending Cons</A></LI>
	<UL>

		<LI><A HREF="#overriding construction variables">Overriding construction variables</A></LI>
		<LI><A HREF="#adding new methods">Adding new methods</A></LI>
		<LI><A HREF="#overriding methods">Overriding methods</A></LI>
	</UL>

	<LI><A HREF="#invoking cons">Invoking Cons</A></LI>
	<LI><A HREF="#using and writing dependency scanners">Using and writing dependency scanners</A></LI>
	<LI><A HREF="#support and suggestions">SUPPORT AND SUGGESTIONS</A></LI>
	<LI><A HREF="#bugs">BUGS</A></LI>
	<LI><A HREF="#information about cons">INFORMATION ABOUT CONS</A></LI>
	<LI><A HREF="#authors">AUTHORS</A></LI>
</UL>
<!-- INDEX END -->

<HR>
<P>
<H1><A NAME="name">NAME</A></H1>
<P>Cons - A Software Construction System</P>
<P>
<HR>
<H1><A NAME="description">DESCRIPTION</A></H1>
<P>A guide and reference for version 2.2.0</P>
<P>Copyright (c) 1996-2000 Free Software Foundation, Inc.</P>
<P>This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.</P>
<P>This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.</P>
<P>You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.  If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.</P>
<P>
<HR>
<H1><A NAME="introduction">Introduction</A></H1>
<P><STRONG>Cons</STRONG> is a system for constructing, primarily, software, but is quite
different from previous software construction systems. Cons was designed
from the ground up to deal easily with the construction of software spread
over multiple source directories. Cons makes it easy to create build scripts
that are simple, understandable and maintainable. Cons ensures that complex
software is easily and accurately reproducible.</P>
<P>Cons uses a number of techniques to accomplish all of this. Construction
scripts are just Perl scripts, making them both easy to comprehend and very
flexible. Global scoping of variables is replaced with an import/export
mechanism for sharing information between scripts, significantly improving
the readability and maintainability of each script. <STRONG>Construction
environments</STRONG> are introduced: these are Perl objects that capture the
information required for controlling the build process. Multiple
environments are used when different semantics are required for generating
products in the build tree. Cons implements automatic dependency analysis
and uses this to globally sequence the entire build. Variant builds are
easily produced from a single source tree. Intelligent build subsetting is
possible, when working on localized changes. Overrides can be setup to
easily override build instructions without modifying any scripts. MD5
cryptographic <STRONG>signatures</STRONG> are associated with derived files, and are used
to accurately determine whether a given file needs to be rebuilt.</P>
<P>While offering all of the above, and more, Cons remains simple and easy to
use. This will, hopefully, become clear as you read the remainder of this
document.</P>
<P>
<HR>
<H1><A NAME="why cons why not make">Why Cons? Why not Make?</A></H1>
<P>Cons is a <STRONG>make</STRONG> replacement. In the following paragraphs, we look at a few
of the undesirable characteristics of make--and typical build environments
based on make--that motivated the development of Cons.</P>
<P>
<H2><A NAME="build complexity">Build complexity</A></H2>
<P>Traditional make-based systems of any size tend to become quite complex. The
original make utility and its derivatives have contributed to this tendency
in a number of ways. Make is not good at dealing with systems that are
spread over multiple directories. Various work-arounds are used to overcome
this difficulty; the usual choice is for make to invoke itself recursively
for each sub-directory of a build. This leads to complicated code, in which
it is often unclear how a variable is set, or what effect the setting of a
variable will have on the build as a whole. The make scripting language has
gradually been extended to provide more possibilities, but these have
largely served to clutter an already overextended language. Often, builds
are done in multiple passes in order to provide appropriate products from
one directory to another directory. This represents a further increase in
build complexity.</P>
<P>
<H2><A NAME="build reproducibility">Build reproducibility</A></H2>
<P>The bane of all makes has always been the correct handling of
dependencies. Most often, an attempt is made to do a reasonable job of
dependencies within a single directory, but no serious attempt is made to do
the job between directories. Even when dependencies are working correctly,
make's reliance on a simple time stamp comparison to determine whether a
file is out of date with respect to its dependents is not, in general,
adequate for determining when a file should be rederived. If an external
library, for example, is rebuilt and then ``snapped'' into place, the
timestamps on its newly created files may well be earlier than the last
local build, since it was built before it became visible.</P>
<P>
<H2><A NAME="variant builds">Variant builds</A></H2>
<P>Make provides only limited facilities for handling variant builds. With the
proliferation of hardware platforms and the need for debuggable
vs. optimized code, the ability to easily create these variants is
essential. More importantly, if variants are created, it is important to
either be able to separate the variants or to be able to reproduce the
original or variant at will. With make it is very difficult to separate the
builds into multiple build directories, separate from the source. And if
this technique isn't used, it's also virtually impossible to guarantee at
any given time which variant is present in the tree, without resorting to a
complete rebuild.</P>
<P>
<H2><A NAME="repositories">Repositories</A></H2>
<P>Make provides only limited support for building software from code that
exists in a central repository directory structure.  The VPATH feature of
GNU make (and some other make implementations) is intended to provide this,
but doesn't work as expected: it changes the path of target file to the
VPATH name too early in its analysis, and therefore searches for all
dependencies in the VPATH directory.  To ensure correct development builds,
it is important to be able to create a file in a local build directory and
have any files in a code repository (a VPATH directory, in make terms) that
depend on the local file get rebuilt properly.  This isn't possible with
VPATH, without coding a lot of complex repository knowledge directly into
the makefiles.</P>
<P>
<HR>
<H1><A NAME="keeping it simple">Keeping it simple</A></H1>
<P>A few of the difficulties with make have been cited above. In this and
subsequent sections, we shall introduce Cons and show how these issues are
addressed.</P>
<P>
<H2><A NAME="perl scripts">Perl scripts</A></H2>
<P>Cons is Perl-based. That is, Cons scripts--<EM>Conscript</EM> and <EM>Construct</EM>
files, the equivalent to <EM>Makefile</EM> or <EM>makefile</EM>--are all written in
Perl. This provides an immediate benefit: the language for writing scripts
is a familiar one. Even if you don't happen to be a Perl programmer, it
helps to know that Perl is basically just a simple declarative language,
with a well-defined flow of control, and familiar semantics. It has
variables that behave basically the way you would expect them to,
subroutines, flow of control, and so on. There is no special syntax
introduced for Cons. The use of Perl as a scripting language simplifies
the task of expressing the appropriate solution to the often complex
requirements of a build.</P>
<P>
<H2><A NAME="hello, world!">Hello, World!</A></H2>
<P>To ground the following discussion, here's how you could build the <STRONG>Hello,
World!</STRONG> C application with Cons:</P>
<PRE>
  $env = new cons();
  Program $env 'hello', 'hello.c';</PRE>
<P>If you install this script in a directory, naming the script <EM>Construct</EM>,
and create the <EM>hello.c</EM> source file in the same directory, then you can
type <CODE>cons hello</CODE> to build the application:</P>
<PRE>
  % cons hello
  cc -c hello.c -o hello.o
  cc -o hello hello.o</PRE>
<P>
<H2><A NAME="construction environments">Construction environments</A></H2>
<P>A key simplification of Cons is the idea of a <STRONG>construction environment</STRONG>. A
construction environment is an <STRONG>object</STRONG> characterized by a set of key/value
pairs and a set of <STRONG>methods. </STRONG>In order to tell Cons how to build something,
you invoke the appropriate method via an appropriate construction
environment. Consider the following example:</P>
<PRE>
  $env = new cons(
        CC      =&gt;      'gcc',
        LIBS    =&gt;      'libworld.a'
  );</PRE>
<PRE>
  Program $env 'hello', 'hello.c';</PRE>
<P>In this case, rather than using the default construction environment, as is,
we have overridden the value of <CODE>CC</CODE> so that the GNU C Compiler equivalent
is used, instead. Since this version of <STRONG>Hello, World!</STRONG> requires a library,
<EM>libworld.a</EM>, we have specified that any program linked in this environment
should be linked with that library. If the library exists already, well and
good, but if not, then we'll also have to include the statement:</P>
<PRE>
  Library $env 'libworld', 'world.c';</PRE>
<P>Now if you type <CODE>cons hello</CODE>, the library will be built before the program
is linked, and, of course, <CODE>gcc</CODE> will be used to compile both modules:</P>
<PRE>
  % cons hello
  gcc -c hello.c -o hello.o
  gcc -c world.c -o world.o
  ar r libworld.a world.o
  ar: creating libworld.a
  ranlib libworld.a
  gcc -o hello hello.o libworld.a</PRE>
<P>
<H2><A NAME="automatic and complete dependency analysis">Automatic and complete dependency analysis</A></H2>
<P>With Cons, dependencies are handled automatically. Continuing the previous
example, note that when we modify <EM>world.c</EM>, <EM>world.o</EM> is recompiled,
<EM>libworld.a</EM> recreated, and <EM>hello</EM> relinked:</P>
<PRE>
  % vi world.c
    [EDIT]
  % cons hello
  gcc -c world.c -o world.o
  ar r libworld.a world.o
  ar: creating libworld.a
  ranlib libworld.a
  gcc -o hello hello.o libworld.a</PRE>
<P>This is a relatively simple example: Cons ``knows'' <EM>world.o</EM> depends upon
<EM>world.c</EM>, because the dependency is explicitly set up by the <CODE>Library</CODE>
method. It also knows that <EM>libworld.a</EM> depends upon <EM>world.o</EM> and that
<EM>hello</EM> depends upon <EM>libworld.a</EM>, all for similar reasons.</P>
<P>Now it turns out that <EM>hello.c</EM> also includes the interface definition
file, <EM>world.h</EM>:</P>
<PRE>
  % emacs world.h
    [EDIT]
  % cons hello
  gcc -c hello.c -o hello.o
  gcc -o hello hello.o libworld.a</PRE>
<P>How does Cons know that <EM>hello.c</EM> includes <EM>world.h</EM>, and that <EM>hello.o</EM>
must therefore be recompiled? For now, suffice it to say that when
considering whether or not <EM>hello.o</EM> is up-to-date, Cons invokes a scanner
for its dependency, <EM>hello.c</EM>. This scanner enumerates the files included
by <EM>hello.c</EM> to come up with a list of further dependencies, beyond those
made explicit by the Cons script. This process is recursive: any files
included by included files will also be scanned.</P>
<P>Isn't this expensive? The answer is--it depends. If you do a full build of a
large system, the scanning time is insignificant. If you do a rebuild of a
large system, then Cons will spend a fair amount of time thinking about it
before it decides that nothing has to be done (although not necessarily more
time than make!). The good news is that Cons makes it very easy to
intelligently subset your build, when you are working on localized changes.</P>
<P>
<H2><A NAME="automatic global build sequencing">Automatic global build sequencing</A></H2>
<P>Because Cons does full and accurate dependency analysis, and does this
globally, for the entire build, Cons is able to use this information to take
full control of the <STRONG>sequencing</STRONG> of the build. This sequencing is evident
in the above examples, and is equivalent to what you would expect for make,
given a full set of dependencies. With Cons, this extends trivially to
larger, multi-directory builds. As a result, all of the complexity involved
in making sure that a build is organized correctly--including multi-pass
hierarchical builds--is eliminated. We'll discuss this further in the next
sections.</P>
<P>
<HR>
<H1><A NAME="building large treesstill just as simple">Building large trees--still just as simple</A></H1>
<P>
<H2><A NAME="a hierarchy of build scripts">A hierarchy of build scripts</A></H2>
<P>A larger build, in Cons, is organized by creating a hierarchy of <STRONG>build
scripts</STRONG>. At the top of the tree is a script called <EM>Construct</EM>. The rest
of the scripts, by convention, are each called <EM>Conscript</EM>. These scripts
are connected together, very simply, by the <CODE>Build</CODE>, <CODE>Export</CODE>, and
<CODE>Import</CODE> commands.</P>
<P>
<H2><A NAME="the build command">The Build command</A></H2>
<P>The <CODE>Build</CODE> command takes a list of <EM>Conscript</EM> file names, and arranges
for them to be included in the build. For example:</P>
<PRE>
  Build qw(
        drivers/display/Conscript
        drivers/mouse/Conscript
        parser/Conscript
        utilities/Conscript
  );</PRE>
<P>This is a simple two-level hierarchy of build scripts: all the subsidiary
<EM>Conscript</EM> files are mentioned in the top-level <EM>Construct</EM> file. Notice
that not all directories in the tree necessarily have build scripts
associated with them.</P>
<P>This could also be written as a multi-level script. For example, the
<EM>Construct</EM> file might contain this command:</P>
<PRE>
  Build qw(
        parser/Conscript
        drivers/Conscript
        utilities/Conscript
  );</PRE>
<P>and the <EM>Conscript</EM> file in the <EM>drivers</EM> directory might contain this:</P>
<PRE>
  Build qw(
        display/Conscript
        mouse/Conscript
  );</PRE>
<P>Experience has shown that the former model is a little easier to understand,
since the whole construction tree is laid out in front of you, at the
top-level. Hybrid schemes are also possible. A separately maintained
component that needs to be incorporated into a build tree, for example,
might hook into the build tree in one place, but define its own construction
hierarchy.</P>
<P>By default, Cons does not change its working directory to the directory
containing a subsidiary <EM>Conscript</EM> file it is including.  This behavior
can be enabled for a build by specifying, in the top-level <EM>Construct</EM>
file:</P>
<PRE>
  Conscript_chdir 1;</PRE>
<P>When enabled, Cons will change to the subsidiary <EM>Conscript</EM> file's
containing directory while reading in that file, and then change back
to the top-level directory once the file has been processed.</P>
<P>It is expected that this behavior will become the default in some future
version of Cons.  To prepare for this transition, builds that expect
Cons to remain at the top of the build while it reads in a subsidiary
<EM>Conscript</EM> file should explicitly disable this feature as follows:</P>
<PRE>
  Conscript_chdir 0;</PRE>
<P>
<H2><A NAME="relative, toprelative, and absolute file names">Relative, top-relative, and absolute file names</A></H2>
<P>You may have noticed that the file names specified to the Build command are
relative to the location of the script it is invoked from. This is generally
true for other filename arguments to other commands, too, although we might
as well mention here that if you begin a file name with a hash mark, ``#'',
then that file is interpreted relative to the top-level directory (where the
<EM>Construct</EM> file resides). And, not surprisingly, if you begin it with ``/'',
then it is considered to be an absolute pathname. This is true even on
systems which use a back slash rather than a forward slash to name absolute
paths.</P>
<P>
<H2><A NAME="using modules in build scripts">Using modules in build scripts</A></H2>
<P>You may pull modules into each <EM>Conscript</EM> file using the normal Perl
<CODE>use</CODE> or <CODE>require</CODE> statements:</P>
<PRE>
  use English;
  require My::Module;</PRE>
<P>Each <CODE>use</CODE> or <CODE>require</CODE> only affects the one <EM>Conscript</EM> file in which
it appears.  To use a module in multiple <EM>Conscript</EM> files, you must
put a <CODE>use</CODE> or <CODE>require</CODE> statement in each one that needs the module.</P>
<P>
<H2><A NAME="scope of variables">Scope of variables</A></H2>
<P>The top-level <EM>Construct</EM> file and all <EM>Conscript</EM> files begin life in
a common, separate Perl package.  <STRONG>Cons</STRONG> controls the symbol table for
the package so that, the symbol table for each script is empty, except
for the <EM>Construct</EM> file, which gets some of the command line arguments.
All of the variables that are set or used, therefore, are set by the
script itself--not by some external script.</P>
<P>Variables can be explicitly <STRONG>imported</STRONG> by a script from its parent
script. To import a variable, it must have been <STRONG>exported</STRONG> by the parent
and initialized (otherwise an error will occur).</P>
<P>
<H2><A NAME="the export command">The Export command</A></H2>
<P>The <CODE>Export</CODE> command is used as in the following example:</P>
<PRE>
  $env = new cons();
  $INCLUDE = &quot;#export/include&quot;;
  $LIB = &quot;#export/lib&quot;;
  Export qw( env INCLUDE LIB );
  Build qw( util/Conscript );</PRE>
<P>The values of the simple variables mentioned in the <CODE>Export</CODE> list will be
squirreled away by any subsequent <CODE>Build</CODE> commands. The <CODE>Export</CODE> command
will only export Perl <STRONG>scalar</STRONG> variables, that is, variables whose name
begins with <CODE>$</CODE>. Other variables, objects, etc. can be exported by
reference--but all scripts will refer to the same object, and this object
should be considered to be read-only by the subsidiary scripts and by the
original exporting script. It's acceptable, however, to assign a new value
to the exported scalar variable--that won't change the underlying variable
referenced. This sequence, for example, is OK:</P>
<PRE>
  $env = new cons();
  Export qw( env INCLUDE LIB );
  Build qw( util/Conscript );
  $env = new cons(CFLAGS =&gt; '-O');
  Build qw( other/Conscript );</PRE>
<P>It doesn't matter whether the variable is set before or after the <CODE>Export</CODE>
command. The important thing is the value of the variable at the time the
<CODE>Build</CODE> command is executed. This is what gets squirreled away. Any
subsequent <CODE>Export</CODE> commands, by the way, invalidate the first: you must
mention all the variables you wish to export on each <CODE>Export</CODE> command.</P>
<P>
<H2><A NAME="the import command">The Import command</A></H2>
<P>Variables exported by the <CODE>Export</CODE> command can be imported into subsidiary
scripts by the <CODE>Import</CODE> command. The subsidiary script always imports
variables directly from the superior script. Consider this example:</P>
<PRE>
  Import qw( env INCLUDE );</PRE>
<P>This is only legal if the parent script exported both <CODE>$env</CODE> and
<CODE>$INCLUDE</CODE>. It also must have given each of these variables values. It is
OK for the subsidiary script to only import a subset of the exported
variables (in this example, <CODE>$LIB</CODE>, which was exported by the previous
example, is not imported).</P>
<P>All the imported variables are automatically re-exported, so the sequence:</P>
<PRE>
  Import qw ( env INCLUDE );
  Build qw ( beneath-me/Conscript );</PRE>
<P>will supply both <CODE>$env</CODE> and <CODE>$INCLUDE</CODE> to the subsidiary file. If only
<CODE>$env</CODE> is to be exported, then the following will suffice:</P>
<PRE>
  Import qw ( env INCLUDE );
  Export qw ( env );
  Build qw ( beneath-me/Conscript );</PRE>
<P>Needless to say, the variables may be modified locally before invoking
<CODE>Build</CODE> on the subsidiary script.</P>
<P>
<H2><A NAME="build script evaluation order">Build script evaluation order</A></H2>
<P>The only constraint on the ordering of build scripts is that superior
scripts are evaluated before their inferior scripts. The top-level
<EM>Construct</EM> file, for instance, is evaluated first, followed by any
inferior scripts. This is all you really need to know about the evaluation
order, since order is generally irrelevant. Consider the following <CODE>Build</CODE>
command:</P>
<PRE>
  Build qw(
        drivers/display/Conscript
        drivers/mouse/Conscript
        parser/Conscript
        utilities/Conscript
  );</PRE>
<P>We've chosen to put the script names in alphabetical order, simply because
that's the most convenient for maintenance purposes. Changing the order will
make no difference to the build.</P>
<P>
<HR>
<H1><A NAME="a model for sharing files">A Model for sharing files</A></H1>
<P>
<H2><A NAME="some simple conventions">Some simple conventions</A></H2>
<P>In any complex software system, a method for sharing build products needs to
be established. We propose a simple set of conventions which are trivial to
implement with Cons, but very effective.</P>
<P>The basic rule is to require that all build products which need to be shared
between directories are shared via an intermediate directory. We have
typically called this <EM>export</EM>, and, in a C environment, provided
conventional sub-directories of this directory, such as <EM>include</EM>, <EM>lib</EM>,
<EM>bin</EM>, etc.</P>
<P>These directories are defined by the top-level <EM>Construct</EM> file. A simple
<EM>Construct</EM> file for a <STRONG>Hello, World!</STRONG> application, organized using
multiple directories, might look like this:</P>
<PRE>
  # Construct file for Hello, World!</PRE>
<PRE>
  # Where to put all our shared products.
  $EXPORT = '#export';</PRE>
<PRE>
  Export qw( CONS INCLUDE LIB BIN );</PRE>
<PRE>
  # Standard directories for sharing products.
  $INCLUDE = &quot;$EXPORT/include&quot;;
  $LIB = &quot;$EXPORT/lib&quot;;
  $BIN = &quot;$EXPORT/bin&quot;;</PRE>
<PRE>
  # A standard construction environment.
  $CONS = new cons (
        CPPPATH =&gt; $INCLUDE,    # Include path for C Compilations
        LIBPATH =&gt; $LIB,        # Library path for linking programs
        LIBS =&gt; '-lworld',      # List of standard libraries
  );</PRE>
<PRE>
  Build qw(
        hello/Conscript
        world/Conscript
  );</PRE>
<P>The <EM>world</EM> directory's <EM>Conscript</EM> file looks like this:</P>
<PRE>
  # Conscript file for directory world
  Import qw( CONS INCLUDE LIB );</PRE>
<PRE>
  # Install the products of this directory
  Install $CONS $LIB, 'libworld.a';
  Install $CONS $INCLUDE, 'world.h';</PRE>
<PRE>
  # Internal products
  Library $CONS 'libworld.a', 'world.c';</PRE>
<P>and the <EM>hello</EM> directory's <EM>Conscript</EM> file looks like this:</P>
<PRE>
  # Conscript file for directory hello
  Import qw( CONS BIN );</PRE>
<PRE>
  # Exported products
  Install $CONS $BIN, 'hello';</PRE>
<PRE>
  # Internal products
  Program $CONS 'hello', 'hello.c';</PRE>
<P>To construct a <STRONG>Hello, World!</STRONG> program with this directory structure, go to
the top-level directory, and invoke <CODE>cons</CODE> with the appropriate
arguments. In the following example, we tell Cons to build the directory
<EM>export</EM>. To build a directory, Cons recursively builds all known products
within that directory (only if they need rebuilding, of course). If any of
those products depend upon other products in other directories, then those
will be built, too.</P>
<PRE>
  % cons export
  Install world/world.h as export/include/world.h
  cc -Iexport/include -c hello/hello.c -o hello/hello.o
  cc -Iexport/include -c world/world.c -o world/world.o
  ar r world/libworld.a world/world.o
  ar: creating world/libworld.a
  ranlib world/libworld.a
  Install world/libworld.a as export/lib/libworld.a
  cc -o hello/hello hello/hello.o -Lexport/lib -lworld
  Install hello/hello as export/bin/hello</PRE>
<P>
<H2><A NAME="clean, understandable, locationindependent scripts">Clean, understandable, location-independent scripts</A></H2>
<P>You'll note that the two <EM>Conscript</EM> files are very clean and
to-the-point. They simply specify products of the directory and how to build
those products. The build instructions are minimal: they specify which
construction environment to use, the name of the product, and the name of
the inputs. Note also that the scripts are location-independent: if you wish
to reorganize your source tree, you are free to do so: you only have to
change the <EM>Construct</EM> file (in this example), to specify the new locations
of the <EM>Conscript</EM> files. The use of an export tree makes this goal easy.</P>
<P>Note, too, how Cons takes care of little details for you. All the <EM>export</EM>
directories, for example, were made automatically. And the installed files
were really hard-linked into the respective export directories, to save
space and time. This attention to detail saves considerable work, and makes
it even easier to produce simple, maintainable scripts.</P>
<P>
<HR>
<H1><A NAME="separating source and build trees">Separating source and build trees</A></H1>
<P>It's often desirable to keep any derived files from the build completely
separate from the source files. This makes it much easier to keep track of
just what is a source file, and also makes it simpler to handle <STRONG>variant</STRONG>
builds, especially if you want the variant builds to co-exist.</P>
<P>
<H2><A NAME="separating build and source directories using the link command">Separating build and source directories using the Link command</A></H2>
<P>Cons provides a simple mechanism that handles all of these requirements. The
<CODE>Link</CODE> command is invoked as in this example:</P>
<PRE>
  Link 'build' =&gt; 'src';</PRE>
<P>The specified directories are ``linked'' to the specified source
directory. Let's suppose that you setup a source directory, <EM>src</EM>, with the
sub-directories <EM>world</EM> and <EM>hello</EM> below it, as in the previous
example. You could then substitute for the original build lines the
following:</P>
<PRE>
  Build qw(
        build/world/Conscript
        build/hello/Conscript
  );</PRE>
<P>Notice that you treat the <EM>Conscript</EM> file as if it existed in the build
directory. Now if you type the same command as before, you will get the
following results:</P>
<PRE>
  % cons export
  Install build/world/world.h as export/include/world.h
  cc -Iexport/include -c build/hello/hello.c -o build/hello/hello.o
  cc -Iexport/include -c build/world/world.c -o build/world/world.o
  ar r build/world/libworld.a build/world/world.o
  ar: creating build/world/libworld.a
  ranlib build/world/libworld.a
  Install build/world/libworld.a as export/lib/libworld.a
  cc -o build/hello/hello build/hello/hello.o -Lexport/lib -lworld
  Install build/hello/hello as export/bin/hello</PRE>
<P>Again, Cons has taken care of the details for you. In particular, you will
notice that all the builds are done using source files and object files from
the build directory. For example, <EM>build/world/world.o</EM> is compiled from
<EM>build/world/world.c</EM>, and <EM>export/include/world.h</EM> is installed from
<EM>build/world/world.h</EM>. This is accomplished on most systems by the simple
expedient of ``hard'' linking the required files from each source directory
into the appropriate build directory.</P>
<P>The links are maintained correctly by Cons, no matter what you do to the
source directory. If you modify a source file, your editor may do this ``in
place'' or it may rename it first and create a new file. In the latter case,
any hard link will be lost. Cons will detect this condition the next time
the source file is needed, and will relink it appropriately.</P>
<P>You'll also notice, by the way, that <STRONG>no</STRONG> changes were required to the
underlying <EM>Conscript</EM> files. And we can go further, as we shall see in the
next section.</P>
<P>
<HR>
<H1><A NAME="variant builds">Variant builds</A></H1>
<P>
<H2><A NAME="hello, world! for banana and peach os's">Hello, World! for baNaNa and peAcH OS's</A></H2>
<P>Variant builds require just another simple extension. Let's take as an
example a requirement to allow builds for both the baNaNa and peAcH
operating systems. In this case, we are using a distributed file system,
such as NFS to access the particular system, and only one or the other of
the systems has to be compiled for any given invocation of <CODE>cons</CODE>. Here's
one way we could set up the <EM>Construct</EM> file for our <STRONG>Hello, World!</STRONG>
application:</P>
<PRE>
  # Construct file for Hello, World!</PRE>
<PRE>
  die qq(OS must be specified) unless $OS = $ARG{OS};
  die qq(OS must be &quot;peach&quot; or &quot;banana&quot;)
        if $OS ne &quot;peach&quot; &amp;&amp; $OS ne &quot;banana&quot;;</PRE>
<PRE>
  # Where to put all our shared products.
  $EXPORT = &quot;#export/$OS&quot;;</PRE>
<PRE>
  Export qw( CONS INCLUDE LIB BIN );</PRE>
<PRE>
  # Standard directories for sharing products.
  $INCLUDE = &quot;$EXPORT/include&quot;;
  $LIB = &quot;$EXPORT/lib&quot;;
  $BIN = &quot;$EXPORT/bin&quot;;</PRE>
<PRE>
  # A standard construction environment.
  $CONS = new cons (
        CPPPATH =&gt; $INCLUDE,    # Include path for C Compilations
        LIBPATH =&gt; $LIB,        # Library path for linking programs
        LIBS =&gt; '-lworld',      # List of standard libraries
  );</PRE>
<PRE>
  # $BUILD is where we will derive everything.
  $BUILD = &quot;#build/$OS&quot;;</PRE>
<PRE>
  # Tell cons where the source files for $BUILD are.
  Link $BUILD =&gt; 'src';</PRE>
<PRE>
  Build (
        &quot;$BUILD/hello/Conscript&quot;,
        &quot;$BUILD/world/Conscript&quot;,
  );</PRE>
<P>Now if we login to a peAcH system, we can build our <STRONG>Hello, World!</STRONG>
application for that platform:</P>
<PRE>
  % cons export OS=peach
  Install build/peach/world/world.h as export/peach/include/world.h
  cc -Iexport/peach/include -c build/peach/hello/hello.c -o build/peach/hello/hello.o
  cc -Iexport/peach/include -c build/peach/world/world.c -o build/peach/world/world.o
  ar r build/peach/world/libworld.a build/peach/world/world.o
  ar: creating build/peach/world/libworld.a
  ranlib build/peach/world/libworld.a
  Install build/peach/world/libworld.a as export/peach/lib/libworld.a
  cc -o build/peach/hello/hello build/peach/hello/hello.o -Lexport/peach/lib -lworld
  Install build/peach/hello/hello as export/peach/bin/hello</PRE>
<P>
<H2><A NAME="variations on a theme">Variations on a theme</A></H2>
<P>Other variations of this model are possible. For example, you might decide
that you want to separate out your include files into platform dependent and
platform independent files. In this case, you'd have to define an
alternative to <CODE>$INCLUDE</CODE> for platform-dependent files. Most <EM>Conscript</EM>
files, generating purely platform-independent include files, would not have
to change.</P>
<P>You might also want to be able to compile your whole system with debugging
or profiling, for example, enabled. You could do this with appropriate
command line options, such as <CODE>DEBUG=on</CODE>. This would then be translated
into the appropriate platform-specific requirements to enable debugging
(this might include turning off optimization, for example). You could
optionally vary the name space for these different types of systems, but, as
we'll see in the next section, it's not <STRONG>essential</STRONG> to do this, since Cons
is pretty smart about rebuilding things when you change options.</P>
<P>
<HR>
<H1><A NAME="signatures">Signatures</A></H1>
<P>
<H2><A NAME="md5 cryptographic signatures">MD5 cryptographic signatures</A></H2>
<P>Whenever Cons creates a derived file, it stores a <STRONG>signature</STRONG> for that
file. The signature is stored in a separate file, one per directory. After
the previous example was compiled, the <EM>.consign</EM> file in the
<EM>build/peach/world</EM> directory looked like this:</P>
<PRE>
  world.o:834179303 23844c0b102ecdc0b4548d1cd1cbd8c6
  libworld.a:834179304 9bf6587fa06ec49d864811a105222c00</PRE>
<P>The first number is a timestamp--for a UNIX systems, this is typically the
number of seconds since January 1st, 1970. The second value is an MD5
checksum. The <STRONG>Message Digest Algorithm</STRONG> is an algorithm that, given an
input string, computes a strong cryptographic signature for that string. The
MD5 checksum stored in the <EM>.consign</EM> file is, in effect, a digest of all
the dependency information for the specified file. So, for example, for the
<EM>world.o</EM> file, this includes at least the <EM>world.c</EM> file, and also any
header files that Cons knows about that are included, directly or indirectly
by <EM>world.c</EM>. Not only that, but the actual command line that was used to
generate <EM>world.o</EM> is also fed into the computation of the
signature. Similarly, <EM>libworld.a</EM> gets a signature which ``includes'' all
the signatures of its constituents (and hence, transitively, the signatures
of <STRONG>their</STRONG> constituents), as well as the command line that created the
file.</P>
<P>The signature of a non-derived file is computed, by default, by taking the
current modification time of the file and the file's entry name (unless
there happens to be a current <EM>.consign</EM> entry for that file, in which case
that signature is used).</P>
<P>Notice that there is no need for a derived file to depend upon any
particular <EM>Construct</EM> or <EM>Conscript</EM> file--if changes to these files
affect the file in question, then this will be automatically reflected in
its signature, since relevant parts of the command line are included in the
signature. Unrelated changes will have no effect.</P>
<P>When Cons considers whether to derive a particular file, then, it first
computes the expected signature of the file. It then compares the file's
last modification time with the time recorded in the <EM>.consign</EM> entry, if
one exists. If these times match, then the signature stored in the
<EM>.consign</EM> file is considered to be accurate. If the file's previous
signature does not match the new, expected signature, then the file must be
rederived.</P>
<P>Notice that a file will be rederived whenever anything about a dependent
file changes. In particular, notice that <STRONG>any</STRONG> change to the modification
time of a dependent (forward or backwards in time) will force recompilation
of the derived file.</P>
<P>The use of these signatures is an extremely simple, efficient, and effective
method of improving--dramatically--the reproducibility of a system.</P>
<P>We'll demonstrate this with a simple example:</P>
<PRE>
  # Simple &quot;Hello, World!&quot; Construct file
  $CFLAGS = '-g' if $ARG{DEBUG} eq 'on';
  $CONS = new cons(CFLAGS =&gt; $CFLAGS);
  Program $CONS 'hello', 'hello.c';</PRE>
<P>Notice how Cons recompiles at the appropriate times:</P>
<PRE>
  % cons hello
  cc -c hello.c -o hello.o
  cc -o hello hello.o
  % cons hello
  cons: &quot;hello&quot; is up-to-date.
  % cons DEBUG=on hello
  cc -g -c hello.c -o hello.o
  cc -o hello hello.o
  % cons DEBUG=on hello
  cons: &quot;hello&quot; is up-to-date.
  % cons hello
  cc -c hello.c -o hello.o
  cc -o hello hello.o</PRE>
<P>
<HR>
<H1><A NAME="code repositories">Code Repositories</A></H1>
<P>Many software development organizations will have one or more central
repository directory trees containing the current source code for one or
more projects, as well as the derived object files, libraries, and
executables.  In order to reduce unnecessary recompilation, it is useful to
use files from the repository to build development software--assuming, of
course, that no newer dependency file exists in the local build tree.</P>
<P>
<H2><A NAME="repository">Repository</A></H2>
<P>Cons provides a mechanism to specify a list of code repositories that will
be searched, in-order, for source files and derived files not found in the
local build directory tree.</P>
<P>The following lines in a <EM>Construct</EM> file will instruct Cons to look first
under the <EM>/usr/experiment/repository</EM> directory and then under the
<EM>/usr/product/repository</EM> directory:</P>
<PRE>
  Repository qw (
        /usr/experiment/repository
        /usr/product/repository
  );</PRE>
<P>The repository directories specified may contain source files, derived files
(objects, libraries and executables), or both.  If there is no local file
(source or derived) under the directory in which Cons is executed, then the
first copy of a same-named file found under a repository directory will be
used to build any local derived files.</P>
<P>Cons maintains one global list of repositories directories.  Cons will
eliminate the current directory, and any non-existent directories, from the
list.</P>
<P>
<H2><A NAME="finding the construct file in a repository">Finding the Construct file in a Repository</A></H2>
<P>Cons will also search for <EM>Construct</EM> and <EM>Conscript</EM> files in the
repository tree or trees.  This leads to a chicken-and-egg situation,
though: how do you look in a repository tree for a <EM>Construct</EM> file if the
<EM>Construct</EM> file tells you where the repository is?  To get around this,
repositories may be specified via <CODE>-R</CODE> options on the command line:</P>
<PRE>
  % cons -R /usr/experiment/repository -R /usr/product/repository .</PRE>
<P>Any repository directories specified in the <EM>Construct</EM> or <EM>Conscript</EM>
files will be appended to the repository directories specified by
command-line <CODE>-R</CODE> options.</P>
<P>
<H2><A NAME="repository source files">Repository source files</A></H2>
<P>If the source code (include the <EM>Conscript</EM> file) for the library version
of the <EM>Hello, World!</EM> C application is in a repository (with no derived
files), Cons will use the repository source files to create the local object
files and executable file:</P>
<PRE>
  % cons -R /usr/src_only/repository hello
  gcc -c /usr/src_only/repository/hello.c -o hello.o
  gcc -c /usr/src_only/repository/world.c -o world.o
  ar r libworld.a world.o
  ar: creating libworld.a
  ranlib libworld.a
  gcc -o hello hello.o libworld.a</PRE>
<P>Creating a local source file will cause Cons to rebuild the appropriate
derived file or files:</P>
<PRE>
  % pico world.c
    [EDIT]
  % cons -R /usr/src_only/repository hello
  gcc -c world.c -o world.o
  ar r libworld.a world.o
  ar: creating libworld.a
  ranlib libworld.a
  gcc -o hello hello.o libworld.a</PRE>
<P>And removing the local source file will cause Cons to revert back to
building the derived files from the repository source:</P>
<PRE>
  % rm world.c
  % cons -R /usr/src_only/repository hello
  gcc -c /usr/src_only/repository/world.c -o world.o
  ar r libworld.a world.o
  ar: creating libworld.a
  ranlib libworld.a
  gcc -o hello hello.o libworld.a</PRE>
<P>
<H2><A NAME="repository derived files">Repository derived files</A></H2>
<P>If a repository tree contains derived files (usually object files,
libraries, or executables), Cons will perform its normal signature
calculation to decide whether the repository file is up-to-date or a derived
file must be built locally.  This means that, in order to ensure correct
signature calculation, a repository tree must also contain the <EM>.consign</EM>
files that were created by Cons when generating the derived files.</P>
<P>This would usually be accomplished by building the software in the
repository (or, alternatively, in a build directory, and then copying the
result to the repository):</P>
<PRE>
  % cd /usr/all/repository
  % cons hello
  gcc -c hello.c -o hello.o
  gcc -c world.c -o world.o
  ar r libworld.a world.o
  ar: creating libworld.a
  ranlib libworld.a
  gcc -o hello hello.o libworld.a</PRE>
<P>(This is safe even if the <EM>Construct</EM> file lists the <EM>/usr/all/repository</EM>
directory in a <CODE>Repository</CODE> command because Cons will remove the current
directory from the repository list.)</P>
<P>Now if we want to build a copy of the application with our own <EM>hello.c</EM>
file, we only need to create the one necessary source file, and use the
<CODE>-R</CODE> option to have Cons use other files from the repository:</P>
<PRE>
  % mkdir $HOME/build1
  % cd $HOME/build1
  % ed hello.c
    [EDIT]
  % cons -R /usr/all/repository hello
  gcc -c hello.c -o hello.o
  gcc -o hello hello.o /usr/all/repository/libworld.a</PRE>
<P>Notice that Cons has not bothered to recreate a local <EM>libworld.a</EM> library
(or recompile the <EM>world.o</EM> module), but instead uses the already-compiled
version from the repository.</P>
<P>Because the MD5 signatures that Cons puts in the <EM>.consign</EM> file contain
timestamps for the derived files, the signature timestamps must match the
file timestamps for a signature to be considered valid.</P>
<P>Some software systems may alter the timestamps on repository files (by
copying them, e.g.), in which case Cons will, by default, assume the
repository signatures are invalid and rebuild files unnecessarily.  This
behavior may be altered by specifying:</P>
<PRE>
  Repository_Sig_Times_OK 0;</PRE>
<P>This tells Cons to ignore timestamps when deciding whether a signature is
valid.  (Note that avoiding this sanity check means there must be proper
control over the repository tree to ensure that the derived files cannot be
modified without updating the <EM>.consign</EM> signature.)</P>
<P>
<H2><A NAME="local copies of files">Local copies of files</A></H2>
<P>If the repository tree contains the complete results of a build, and we try
to build from the repository without any files in our local tree, something
moderately surprising happens:</P>
<PRE>
  % mkdir $HOME/build2
  % cd $HOME/build2
  % cons -R /usr/all/repository hello
  cons: &quot;hello&quot; is up-to-date.</PRE>
<P>Why does Cons say that the <EM>hello</EM> program is up-to-date when there is no
<EM>hello</EM> program in the local build directory?  Because the repository (not
the local directory) contains the up-to-date <EM>hello</EM> program, and Cons
correctly determines that nothing needs to be done to rebuild this
up-to-date copy of the file.</P>
<P>There are, however, many times in which it is appropriate to ensure that a
local copy of a file always exists.  A packaging or testing script, for
example, may assume that certain generated files exist locally.  Instead of
making these subsidiary scripts aware of the repository directory, the
<CODE>Local</CODE> command may be added to a <EM>Construct</EM> or <EM>Conscript</EM> file to
specify that a certain file or files must appear in the local build
directory:</P>
<PRE>
  Local qw(
        hello
  );</PRE>
<P>Then, if we re-run the same command, Cons will make a local copy of the
program from the repository copy (telling you that it is doing so):</P>
<PRE>
  % cons -R /usr/all/repository hello
  Local copy of hello from /usr/all/repository/hello
  cons: &quot;hello&quot; is up-to-date.</PRE>
<P>Notice that, because the act of making the local copy is not considered a
``build'' of the <EM>hello</EM> file, Cons still reports that it is up-to-date.</P>
<P>Creating local copies is most useful for files that are being installed into
an intermediate directory (for sharing with other directories) via the
<CODE>Install</CODE> command.  Accompanying the <CODE>Install</CODE> command for a file with a
companion <CODE>Local</CODE> command is so common that Cons provides a
<CODE>Install_Local</CODE> command as a convenient way to do both:</P>
<PRE>
  Install_Local $env, '#export', 'hello';</PRE>
<P>is exactly equivalent to:</P>
<PRE>
  Install $env '#export', 'hello';
  Local '#export/hello';</PRE>
<P>Both the <CODE>Local</CODE> and <CODE>Install_Local</CODE> commands update the local <EM>.consign</EM>
file with the appropriate file signatures, so that future builds are
performed correctly.</P>
<P>
<H2><A NAME="repository dependency analysis">Repository dependency analysis</A></H2>
<P>Due to its built-in scanning, Cons will search the specified repository
trees for included <EM>.h</EM> files.  Unless the compiler also knows about the
repository trees, though, it will be unable to find <EM>.h</EM> files that only
exist in a repository.  If, for example, the <EM>hello.c</EM> file includes the
<EM>hello.h</EM> file in its current directory:</P>
<PRE>
  % cons -R /usr/all/repository hello
  gcc -c /usr/all/repository/hello.c -o hello.o
  /usr/all/repository/hello.c:1: hello.h: No such file or directory</PRE>
<P>Solving this problem forces some requirements onto the way construction
environments are defined and onto the way the C <CODE>#include</CODE> preprocessor
directive is used to include files.</P>
<P>In order to inform the compiler about the repository trees, Cons will add
appropriate <CODE>-I</CODE> flags to the compilation commands.  This means that the
<CODE>CPPPATH</CODE> variable in the construct environment must explicitly specify all
subdirectories which are to be searched for included files, including the
current directory.  Consequently, we can fix the above example by changing
the environment creation in the <EM>Construct</EM> file as follows:</P>
<PRE>
  $env = new cons(
        CC      =&gt; 'gcc',
        CPPPATH =&gt; '.',
        LIBS    =&gt; 'libworld.a',
  );</PRE>
<P>Due to the definition of the <CODE>CPPPATH</CODE> variable, this yields, when we
re-execute the command:</P>
<PRE>
  % cons -R /usr/all/repository hello
  gcc -c -I. -I/usr/all/repository /usr/all/repository/hello.c -o hello.o
  gcc -o hello hello.o /usr/all/repository/libworld.a</PRE>
<P>The order of the <CODE>-I</CODE> flags replicates, for the C preprocessor, the same
repository-directory search path that Cons uses for its own dependency
analysis.  If there are multiple repositories and multiple <CODE>CPPPATH</CODE>
directories, Cons will append the repository directories to the beginning of
each <CODE>CPPPATH</CODE> directory, rapidly multiplying the number of <CODE>-I</CODE> flags.
As an extreme example, a <EM>Construct</EM> file containing:</P>
<PRE>
  Repository qw(
        /u1
        /u2
  );</PRE>
<PRE>
  $env = new cons(
        CPPPATH =&gt; 'a:b:c',
  );</PRE>
<P>Would yield a compilation command of:</P>
<PRE>
  cc -Ia -I/u1/a -I/u2/a -Ib -I/u1/b -I/u2/b -Ic -I/u1/c -I/u2/c -c hello.c -o hello.o</PRE>
<P>Because Cons relies on the compiler's <CODE>-I</CODE> flags to communicate the order
in which repository directories must be searched, Cons' handling of
repository directories is fundamentally incompatible with using
double-quotes on the <CODE>#include</CODE> directives in your C source code:</P>
<PRE>
  #include &quot;file.h&quot;     /* DON'T USE DOUBLE-QUOTES LIKE THIS */</PRE>
<P>This is because most C preprocessors, when faced with such a directive, will
always first search the directory containing the source file.  This
undermines the elaborate <CODE>-I</CODE> options that Cons constructs to make the
preprocessor conform to its preferred search path.</P>
<P>Consequently, when using repository trees in Cons,
<STRONG>always</STRONG> use angle-brackets for included files:</P>
<PRE>
  #include &lt;file.h&gt;     /* USE ANGLE-BRACKETS INSTEAD */</PRE>
<P>
<H2><A NAME="repository_list">Repository_List</A></H2>
<P>Cons provides a <CODE>Repository_List</CODE> command to return a list of all
repository directories in their current search order.  This can be used for
debugging, or to do more complex Perl stuff:</P>
<PRE>
  @list = Repository_List;
  print join(' ', @list), &quot;\n&quot;;</PRE>
<P>
<H2><A NAME="repository interaction with other cons features">Repository interaction with other Cons features</A></H2>
<P>Cons' handling of repository trees interacts correctly with other Cons
features--which is to say, it generally does what you would expect.</P>
<P>Most notably, repository trees interact correctly, and rather powerfully,
with the 'Link' command.  A repository tree may contain one or more
subdirectories for version builds established via <CODE>Link</CODE> to a source
subdirectory.  Cons will search for derived files in the appropriate build
subdirectories under the repository tree.</P>
<P>
<HR>
<H1><A NAME="default targets">Default targets</A></H1>
<P>Until now, we've demonstrated invoking Cons with an explicit target
to build:</P>
<PRE>
  % cons hello</PRE>
<P>Normally, Cons does not build anything unless a target is specified,
but specifying '.' (the current directory) will build everything:</P>
<PRE>
  % cons                # does not build anything</PRE>
<PRE>
  % cons .              # builds everything under the top-level directory</PRE>
<P>Adding the <CODE>Default</CODE> method to any <EM>Construct</EM> or <EM>Conscript</EM> file will add
the specified targets to a list of default targets.  Cons will build
these defaults if there are no targets specified on the command line.
So adding the following line to the top-level <EM>Construct</EM> file will mimic
Make's typical behavior of building everything by default:</P>
<PRE>
  Default '.';</PRE>
<P>The following would add the <EM>hello</EM> and <EM>goodbye</EM> commands (in the
same directory as the <EM>Construct</EM> or <EM>Conscript</EM> file) to the default list:</P>
<PRE>
  Default qw(
        hello
        goodbye
  );</PRE>
<P>The <CODE>Default</CODE> method may be used more than once to add targets to the
default list.</P>
<P>
<HR>
<H1><A NAME="selective builds">Selective builds</A></H1>
<P>Cons provides two methods for reducing the size of given build. The first is
by specifying targets on the command line, and the second is a method for
pruning the build tree. We'll consider target specification first.</P>
<P>
<H2><A NAME="selective targeting">Selective targeting</A></H2>
<P>Like make, Cons allows the specification of ``targets'' on the command
line. Cons targets may be either files or directories. When a directory is
specified, this is simply a short-hand notation for every derivable
product--that Cons knows about--in the specified directory and below. For
example:</P>
<PRE>
  % cons build/hello/hello.o</PRE>
<P>means build <EM>hello.o</EM> and everything that <EM>hello.o</EM> might need. This is
from a previous version of the <STRONG>Hello, World!</STRONG> program in which <EM>hello.o</EM>
depended upon <EM>export/include/world.h</EM>. If that file is not up-to-date
(because someone modified <EM>src/world/world.h)</EM>, then it will be rebuilt,
even though it is in a directory remote from <EM>build/hello</EM>.</P>
<P>In this example:</P>
<PRE>
  % cons build</PRE>
<P>Everything in the <EM>build</EM> directory is built, if necessary. Again, this may
cause more files to be built. In particular, both <EM>export/include/world.h</EM>
and <EM>export/lib/libworld.a</EM> are required by the <EM>build/hello</EM> directory,
and so they will be built if they are out-of-date.</P>
<P>If we do, instead:</P>
<PRE>
  % cons export</PRE>
<P>then only the files that should be installed in the export directory will be
rebuilt, if necessary, and then installed there. Note that <CODE>cons build</CODE>
might build files that <CODE>cons export</CODE> doesn't build, and vice-versa.</P>
<P>
<H2><A NAME="no ``special'' targets">No ``special'' targets</A></H2>
<P>With Cons, make-style ``special'' targets are not required. The simplest
analog with Cons is to use special <EM>export</EM> directories, instead. Let's
suppose, for example, that you have a whole series of unit tests that are
associated with your code. The tests live in the source directory near the
code. Normally, however, you don't want to build these tests. One solution
is to provide all the build instructions for creating the tests, and then to
install the tests into a separate part of the tree. If we install the tests
in a top-level directory called <EM>tests</EM>, then:</P>
<PRE>
  % cons tests</PRE>
<P>will build all the tests.</P>
<PRE>
  % cons export</PRE>
<P>will build the production version of the system (but not the tests), and:</P>
<PRE>
  % cons build</PRE>
<P>should probably be avoided (since it will compile tests unecessarily).</P>
<P>If you want to build just a single test, then you could explicitly name the
test (in either the <EM>tests</EM> directory or the <EM>build</EM> directory). You could
also aggregate the tests into a convenient hierarchy within the tests
directory. This hierarchy need not necessarily match the source hierarchy,
in much the same manner that the include hierarchy probably doesn't match
the source hierarchy (the include hierarchy is unlikely to be more than two
levels deep, for C programs).</P>
<P>If you want to build absolutely everything in the tree (subject to whatever
options you select), you can use:</P>
<PRE>
  % cons .</PRE>
<P>This is not particularly efficient, since it will redundantly walk all the
trees, including the source tree. The source tree, of course, may have
buildable objects in it--nothing stops you from doing this, even if you
normally build in a separate build tree.</P>
<P>
<HR>
<H1><A NAME="build pruning">Build Pruning</A></H1>
<P>In conjunction with target selection, <STRONG>build pruning</STRONG> can be used to reduce
the scope of the build. In the previous peAcH and baNaNa example, we have
already seen how script-driven build pruning can be used to make only half
of the potential build available for any given invocation of <CODE>cons</CODE>. Cons
also provides, as a convenience, a command line convention that allows you
to specify which <EM>Conscript</EM> files actually get ``built''--that is,
incorporated into the build tree. For example:</P>
<PRE>
  % cons build +world</PRE>
<P>The <CODE>+</CODE> argument introduces a Perl regular expression. This must, of
course, be quoted at the shell level if there are any shell meta-characters
within the expression. The expression is matched against each <EM>Conscript</EM>
file which has been mentioned in a <CODE>Build</CODE> statement, and only those
scripts with matching names are actually incorporated into the build
tree. Multiple such arguments are allowed, in which case a match against any
of them is sufficient to cause a script to be included.</P>
<P>In the example, above, the <EM>hello</EM> program will not be built, since Cons
will have no knowledge of the script <EM>hello/Conscript</EM>. The <EM>libworld.a</EM>
archive will be built, however, if need be.</P>
<P>There are a couple of uses for build pruning via the command line. Perhaps
the most useful is the ability to make local changes, and then, with
sufficient knowledge of the consequences of those changes, restrict the size
of the build tree in order to speed up the rebuild time. A second use for
build pruning is to actively prevent the recompilation of certain files that
you know will recompile due to, for example, a modified header file. You may
know that either the changes to the header file are immaterial, or that the
changes may be safely ignored for most of the tree, for testing
purposes.With Cons, the view is that it is pragmatic to admit this type of
behavior, with the understanding that on the next full build everything that
needs to be rebuilt will be. There is no equivalent to a ``make touch''
command, to mark files as permanently up-to-date. So any risk that is
incurred by build pruning is mitigated. For release quality work, obviously,
we recommend that you do not use build pruning (it's perfectly OK to use
during integration, however, for checking compilation, etc. Just be sure to
do an unconstrained build before committing the integration).</P>
<P>
<HR>
<H1><A NAME="temporary overrides">Temporary overrides</A></H1>
<P>Cons provides a very simple mechanism for overriding aspects of a build. The
essence is that you write an override file containing one or more
<CODE>Override</CODE> commands, and you specify this on the command line, when you run
<CODE>cons</CODE>:</P>
<PRE>
  % cons -o over export</PRE>
<P>will build the <EM>export</EM> directory, with all derived files subject to the
overrides present in the <EM>over</EM> file. If you leave out the <CODE>-o</CODE> option,
then everything necessary to remove all overrides will be rebuilt.</P>
<P>
<H2><A NAME="overriding environment variables">Overriding environment variables</A></H2>
<P>The override file can contain two types of overrides. The first is incoming
environment variables. These are normally accessible by the <EM>Construct</EM>
file from the <CODE>%ENV</CODE> hash variable. These can trivially be overridden in
the override file by setting the appropriate elements of <CODE>%ENV</CODE> (these
could also be overridden in the user's environment, of course).</P>
<P>
<H2><A NAME="the override command">The Override command</A></H2>
<P>The second type of override is accomplished with the <CODE>Override</CODE> command,
which looks like this:</P>
<PRE>
  Override &lt;regexp&gt;, &lt;var1&gt; =&gt; &lt;value1&gt;, &lt;var2&gt; =&gt; &lt;value2&gt;, ...;</PRE>
<P>The regular expression <EM>regexp</EM> is matched against every derived file that
is a candidate for the build. If the derived file matches, then the
variable/value pairs are used to override the values in the construction
environment associated with the derived file.</P>
<P>Let's suppose that we have a construction environment like this:</P>
<PRE>
  $CONS = new cons(
        COPT =&gt; '',
        CDBG =&gt; '-g',
        CFLAGS =&gt; '%COPT %CDBG',
  );</PRE>
<P>Then if we have an override file <EM>over</EM> containing this command:</P>
<PRE>
  Override '\.o$', COPT =&gt; '-O', CDBG =&gt; '';</PRE>
<P>then any <CODE>cons</CODE> invocation with <CODE>-o over</CODE> that creates <EM>.o</EM> files via
this environment will cause them to be compiled with <CODE>-O </CODE>and no <CODE>-g</CODE>. The
override could, of course, be restricted to a single directory by the
appropriate selection of a regular expression.</P>
<P>Here's the original version of the Hello, World! program, built with this
environment. Note that Cons rebuilds the appropriate pieces when the
override is applied or removed:</P>
<PRE>
  % cons hello
  cc -g -c hello.c -o hello.o
  cc -o hello hello.o
  % cons -o over hello
  cc -O -c hello.c -o hello.o
  cc -o hello hello.o
  % cons -o over hello
  cons: &quot;hello&quot; is up-to-date.
  % cons hello
  cc -g -c hello.c -o hello.o
  cc -o hello hello.o</PRE>
<P>It's important that the <CODE>Override</CODE> command only be used for temporary,
on-the-fly overrides necessary for development because the overrides are not
platform independent and because they rely too much on intimate knowledge of
the workings of the scripts. For temporary use, however, they are exactly
what you want.</P>
<P>Note that it is still useful to provide, say, the ability to create a fully
optimized version of a system for production use--from the <EM>Construct</EM> and
<EM>Conscript</EM> files. This way you can tailor the optimized system to the
platform. Where optimizer trade-offs need to be made (particular files may
not be compiled with full optimization, for example), then these can be
recorded for posterity (and reproducibility) directly in the scripts.</P>
<P>
<HR>
<H1><A NAME="more on construction environments">More on construction environments</A></H1>
<P>
<H2><A NAME="default construction variables">Default construction variables</A></H2>
<P>We have mentioned, and used, the concept of a <STRONG>construction environment</STRONG>,
many times in the preceding pages. Now it's time to make this a little more
concrete. With the following statement:</P>
<PRE>
  $env = new cons();</PRE>
<P>a reference to a new, default construction environment is created. This
contains a number of construction variables and some methods. At the present
writing, the default list of construction variables is defined as follows:</P>
<PRE>
  CC            =&gt; 'cc',
  CFLAGS        =&gt; '',
  CCCOM         =&gt; '%CC %CFLAGS %_IFLAGS -c %&lt; -o %&gt;',
  INCDIRPREFIX  =&gt; '-I',
  CXX           =&gt; '%CC',
  CXXFLAGS      =&gt; '%CFLAGS',
  CXXCOM        =&gt; '%CXX %CXXFLAGS %_IFLAGS -c %&lt; -o %&gt;',
  LINK          =&gt; '%CXX',
  LINKCOM       =&gt; '%LINK %LDFLAGS -o %&gt; %&lt; %_LDIRS %LIBS',
  LINKMODULECOM =&gt; '%LD -r -o %&gt; %&lt;',
  LIBDIRPREFIX  =&gt; '-L',
  AR            =&gt; 'ar',
  ARFLAGS       =&gt; 'r',
  ARCOM         =&gt; &quot;%AR %ARFLAGS %&gt; %&lt;\n%RANLIB %&gt;&quot;,
  RANLIB        =&gt; 'ranlib',
  AS            =&gt; 'as',
  ASFLAGS       =&gt; '',
  ASCOM         =&gt; '%AS %ASFLAGS %&lt; -o %&gt;',
  LD            =&gt; 'ld',
  LDFLAGS       =&gt; '',
  PREFLIB       =&gt; 'lib',
  SUFLIB        =&gt; '.a',
  SUFLIBS       =&gt; '.so:.a',
  SUFOBJ        =&gt; '.o',
  ENV           =&gt; { 'PATH' =&gt; '/bin:/usr/bin' },</PRE>
<P>On Win32 systems (Windows NT), the following construction variables
are overridden in the default:</P>
<PRE>
  CC            =&gt; 'cl',
  CFLAGS        =&gt; '/nologo',
  CCCOM         =&gt; '%CC %CFLAGS %_IFLAGS /c %&lt; /Fo%&gt;',
  CXXCOM        =&gt; '%CXX %CXXFLAGS %_IFLAGS /c %&lt; /Fo%&gt;',
  INCDIRPREFIX  =&gt; '/I',
  LINK          =&gt; 'link',
  LINKCOM       =&gt; '%LINK %LDFLAGS /out:%&gt; %&lt; %_LDIRS %LIBS',
  LINKMODULECOM =&gt; '%LD /r /o %&gt; %&lt;',
  LIBDIRPREFIX  =&gt; '/LIBPATH:',
  AR            =&gt; 'lib',
  ARFLAGS       =&gt; '/nologo ',
  ARCOM         =&gt; &quot;%AR %ARFLAGS /out:%&gt; %&lt;&quot;,
  RANLIB        =&gt; '',
  LD            =&gt; 'link',
  LDFLAGS       =&gt; '/nologo ',
  PREFLIB       =&gt; '',
  SUFEXE        =&gt; '.exe',
  SUFLIB        =&gt; '.lib',
  SUFLIBS       =&gt; '.dll:.lib',
  SUFOBJ        =&gt; '.obj',</PRE>
<P>These variables are used by the various methods associated with the
environment, in particular any method that ultimately invokes an external
command will substitute these variables into the final command, as
appropriate. For example, the <CODE>Objects</CODE> method takes a number of source
files and arranges to derive, if necessary, the corresponding object
files. For example:</P>
<PRE>
  Objects $env 'foo.c', 'bar.c';</PRE>
<P>This will arrange to produce, if necessary, <EM>foo.o</EM> and <EM>bar.o</EM>. The
command invoked is simply <CODE>%CCCOM</CODE>, which expands through substitution, to
the appropriate external command required to build each object. We will
explore the substitution rules further under the <CODE>Command</CODE> method, below.</P>
<P>The construction variables are also used for other purposes. For example,
<CODE>CPPPATH</CODE> is used to specify a colon-separated path of include
directories. These are intended to be passed to the C preprocessor and are
also used by the C-file scanning machinery to determine the dependencies
involved in a C Compilation. Variables beginning with underscore, are
created by various methods, and should normally be considered ``internal''
variables. For example, when a method is called which calls for the creation
of an object from a C source, the variable <CODE>_IFLAGS</CODE> is created: this
corresponds to the <CODE>-I</CODE> switches required by the C compiler to represent
the directories specified by <CODE>CPPPATH</CODE>.</P>
<P>Note that, for any particular environment, the value of a variable is set
once, and then never reset (to change a variable, you must create a new
environment. Methods are provided for copying existing environments for this
purpose). Some internal variables, such as <CODE>_IFLAGS</CODE> are created on demand,
but once set, they remain fixed for the life of the environment.</P>
<P>The <CODE>CFLAGS</CODE>, <CODE>LDFLAGS</CODE>, and <CODE>ARFLAGS</CODE> variables all supply a place
for passing options to the compiler, loader, and archiver, respectively.
Less obviously, the <CODE>INCDIRPREFIX</CODE> variable specifies the option string
to be appended to the beginning of each include directory so that the
compiler knows where to find <EM>.h</EM> files.  Similarly, the <CODE>LIBDIRPREFIX</CODE>
variable specifies the option string to be appended to the beginning of
each directory that the linker should search for libraries.</P>
<P>Another variable, <CODE>ENV</CODE>, is used to determine the system environment during
the execution of an external command. By default, the only environment
variable that is set is <CODE>PATH</CODE>, which is the execution path for a UNIX
command. For the utmost reproducibility, you should really arrange to set
your own execution path, in your top-level <EM>Construct</EM> file (or perhaps by
importing an appropriate construction package with the Perl <CODE>use</CODE>
command). The default variables are intended to get you off the ground.</P>
<P>
<H2><A NAME="interpolating construction variables">Interpolating construction variables</A></H2>
<P>Construction environment variables may be interpolated in the source and
target file names by prefixing the construction variable name with <CODE>%</CODE>.</P>
<PRE>
  $env = new cons(
        DESTDIR =&gt;      'programs',
        SRCDIR  =&gt;      'src',
  );
  Program $env '%DESTDIR/hello', '%SRCDIR/hello.c';</PRE>
<P>Expansion of construction variables is recursive--that is, the file
<CODE>name(s)</CODE> will be re-expanded until no more substitutions can be made. If
a construction variable is not defined in the environment, then the null
string will be substituted.</P>
<P>
<HR>
<H1><A NAME="default construction methods">Default construction methods</A></H1>
<P>The list of default construction methods includes the following:</P>
<P>
<H2><A NAME="the new constructor">The <CODE>new</CODE> constructor</A></H2>
<P>The <CODE>new</CODE> method is a Perl object constructor. That is, it is not invoked
via a reference to an existing construction environment <STRONG>reference</STRONG>, but,
rather statically, using the name of the Perl <STRONG>package</STRONG> where the
constructor is defined. The method is invoked like this:</P>
<PRE>
  $env = new cons(&lt;overrides&gt;);</PRE>
<P>The environment you get back is blessed into the package <CODE>cons</CODE>, which
means that it will have associated with it the default methods described
below. Individual construction variables can be overridden by providing
name/value pairs in an override list. Note that to override any command
environment variable (i.e. anything under <CODE>ENV</CODE>), you will have to override
all of them. You can get around this difficulty by using the <CODE>copy</CODE> method
on an existing construction environment.</P>
<P>
<H2><A NAME="the clone method">The <CODE>clone</CODE> method</A></H2>
<P>The <CODE>clone</CODE> method creates a clone of an existing construction environment,
and can be called as in the following example:</P>
<PRE>
  $env2 = $env1-&gt;clone(&lt;overrides&gt;);</PRE>
<P>You can provide overrides in the usual manner to create a different
environment from the original. If you just want a new name for the same
environment (which may be helpful when exporting environments to existing
components), you can just use simple assignment.</P>
<P>
<H2><A NAME="the copy method">The <CODE>copy</CODE> method</A></H2>
<P>The <CODE>copy</CODE> method extracts the externally defined construction variables
from an environment and returns them as a list of name/value
pairs. Overrides can also be provided, in which case, the overridden values
will be returned, as appropriate. The returned list can be assigned to a
hash, as shown in the prototype, below, but it can also be manipulated in
other ways:</P>
<PRE>
  %env = $env1-&gt;copy(&lt;overrides&gt;);</PRE>
<P>The value of <CODE>ENV</CODE>, which is itself a hash, is also copied to a new hash,
so this may be changed without fear of affecting the original
environment. So, for example, if you really want to override just the
<CODE>PATH</CODE> variable in the default environment, you could do the following:</P>
<PRE>
  %cons = new cons()-&gt;copy();
  $cons{ENV}{PATH} = &quot;&lt;your path here&gt;&quot;;
  $cons = new cons(%cons);</PRE>
<P>This will leave anything else that might be in the default execution
environment undisturbed.</P>
<P>
<H2><A NAME="the install method">The <CODE>Install</CODE> method</A></H2>
<P>The <CODE>Install</CODE> method arranges for the specified files to be installed in
the specified directory. The installation is optimized: the file is not
copied if it can be linked. If this is not the desired behavior, you will
need to use a different method to install the file. It is called as follows:</P>
<PRE>
  Install $env &lt;directory&gt;, &lt;names&gt;;</PRE>
<P>Note that, while the files to be installed may be arbitrarily named,
only the last component of each name is used for the installed target
name. So, for example, if you arrange to install <EM>foo/bar</EM> in <EM>baz</EM>,
this will create a <EM>bar</EM> file in the <EM>baz</EM> directory (not <EM>foo/bar</EM>).</P>
<P>
<H2><A NAME="the installas method">The <CODE>InstallAs</CODE> method</A></H2>
<P>The <CODE>InstallAs</CODE> method arranges for the specified source <CODE>file(s)</CODE> to be
installed as the specified target file(s). Multiple files should be
specified as a file list. The installation is optimized: the file is not
copied if it can be linked. If this is not the desired behavior, you will
need to use a different method to install the file. It is called as follows:</P>
<P><CODE>InstallAs</CODE> works in two ways:</P>
<P>Single file install:</P>
<PRE>
  InstallAs $env TgtFile, SrcFile;</PRE>
<P>Multiple file install:</P>
<PRE>
  InstallAs $env ['tgt1', 'tgt2'], ['src1', 'src2'];</PRE>
<P>Or, even as:</P>
<PRE>
  @srcs = qw(src1 src2 src3);
  @tgts = qw(tgt1 tgt2 tgt3);
  InstallAs $env [@tgts], [@srcs];</PRE>
<P>Both the target and the sources lists should be of the same length.</P>
<P>
<H2><A NAME="the precious method">The <CODE>Precious</CODE> method</A></H2>
<P>The <CODE>Precious</CODE> method asks cons not to delete the specified file or
list of files before building them again.  It is invoked as:</P>
<PRE>
  Precious &lt;files&gt;;</PRE>
<P>This is especially useful for allowing incremental updates to libraries
or debug information files which are updated rather than rebuilt anew each
time.  Cons will still delete the files when the <A HREF="#item_%2Dr"><CODE>-r</CODE></A> flag is specified.</P>
<P>
<H2><A NAME="the command method">The <CODE>Command</CODE> method</A></H2>
<P>The <CODE>Command</CODE> method is a catchall method which can be used to arrange for
any external command to be called to update the target. For this command, a
target file and list of inputs is provided. In addition a construction
command line, or lines, is provided as a string (this string may have
multiple commands embedded within it, separated by new lines). <CODE>Command</CODE> is
called as follows:</P>
<PRE>
  Command $env &lt;target&gt;, &lt;inputs&gt;, &lt;construction command&gt;;</PRE>
<P>The target is made dependent upon the list of input files specified, and the
inputs must be built successfully or Cons will not attempt to build the
target.</P>
<P>Within the construction command, any variable from the construction
environment may be introduced by prefixing the name of the construction
variable with <CODE>%</CODE>. This is recursive: the command is expanded until no more
substitutions can be made. If a construction variable is not defined in the
environment, then the null string will be substituted.  A doubled <CODE>%%</CODE>
will be replaced by a single <CODE>%</CODE> in the construction command.</P>
<P>There are several pseudo variables which will also be expanded:</P>
<DL>
<DT><STRONG><A NAME="item_%>">%&gt;</A></STRONG><BR>
<DD>
The target file name (in a multi-target command, this is always the first
target mentioned).
<P></P>
<DT><STRONG><A NAME="item_%0">%0</A></STRONG><BR>
<DD>
Same as <A HREF="#item_%>"><CODE>%&gt;</CODE></A>.
<P></P>
<DT><STRONG><A NAME="item_%1,">%1, %2, ..., %9</A></STRONG><BR>
<DD>
These refer to the first through ninth input file, respectively.
<P></P>
<DT><STRONG><A NAME="item_%<">%&lt;</A></STRONG><BR>
<DD>
The full set of inputs. If any of these have been used anywhere else in the
current command line (via <CODE>%1</CODE>, <CODE>%2</CODE>, etc.), then those will be deleted
from the list provided by <A HREF="#item_%<"><CODE>%&lt;</CODE></A>. Consider the following command found in a
<EM>Conscript</EM> file in the <EM>test</EM> directory:
<PRE>
  Command $env 'tgt', qw(foo bar baz), qq(
        echo %&lt; -i %1 &gt; %&gt;
        echo %&lt; -i %2 &gt;&gt; %&gt;
        echo %&lt; -i %3 &gt;&gt; %&gt;
  );</PRE>
<P>If <EM>tgt</EM> needed to be updated, then this would result in the execution of
the following commands, assuming that no remapping has been established for
the <EM>test</EM> directory:</P>
<PRE>
  echo test/bar test/baz -i test/foo &gt; test/tgt
  echo test/foo test/baz -i test/bar &gt;&gt; test/tgt
  echo test/foo test/bar -i test/baz &gt;&gt; test/tgt</PRE>
<P></P></DL>
<P>Any of the above pseudo variables may be followed immediately by one of
the following suffixes to select a portion of the expanded path name:</P>
<PRE>
  :a    the absolute path to the file name
  :b    the directory plus the file name stripped of any suffix
  :d    the directory
  :f    the file name
  :s    the file name suffix
  :F    the file name stripped of any suffix</PRE>
<P>Continuing with the above example, <CODE>%&lt;:f</CODE> would expand to <CODE>foo bar baz</CODE>,
and <CODE>%</CODE>:d&gt; would expand to <CODE>test</CODE>.</P>
<P>It is possible to programmatically rewrite part of the command by
enclosing part of it between <CODE>%[</CODE> and <CODE>%]</CODE>.  This will call the
construction variable named as the first word enclosed in the brackets
as a Perl code reference; the results of this call will be used to
replace the contents of the brackets in the command line.  For example,
given an existing input file named <EM>tgt.in</EM>:</P>
<PRE>
  @keywords = qw(foo bar baz);
  $env = new cons(X_COMMA =&gt; sub { join(&quot;,&quot;, @_) });
  Command $env 'tgt', 'tgt.in', qq(
        echo '# Keywords: %[X_COMMA @keywords %]' &gt; %&gt;
        cat %&lt; &gt;&gt; %&gt;
  );</PRE>
<P>This will execute:</P>
<PRE>
  echo '# Keywords: foo,bar,baz' &gt; tgt
  cat tgt.in &gt;&gt; tgt</PRE>
<P>After substitution occurs, strings of white space are converted into single
blanks, and leading and trailing white space is eliminated. It is therefore
not possible to introduce variable length white space in strings passed into
a command, without resorting to some sort of shell quoting.</P>
<P>If a multi-line command string is provided, the commands are executed
sequentially. If any of the commands fails, then none of the rest are
executed, and the target is not marked as updated, i.e. a new signature is
not stored for the target.</P>
<P>Normally, if all the commands succeed, and return a zero status (or whatever
platform-specific indication of success is required), then a new signature
is stored for the target. If a command erroneously reports success even
after a failure, then Cons will assume that the target file created by that
command is accurate and up-to-date.</P>
<P>The first word of each command string, after expansion, is assumed to be an
executable command looked up on the <CODE>PATH</CODE> environment variable (which is,
in turn, specified by the <CODE>ENV</CODE> construction variable). If this command is
found on the path, then the target will depend upon it: the command will
therefore be automatically built, as necessary. It's possible to write
multi-part commands to some shells, separated by semi-colons. Only the first
command word will be depended upon, however, so if you write your command
strings this way, you must either explicitly set up a dependency (with the
<CODE>Depends</CODE> method), or be sure that the command you are using is a system
command which is expected to be available. If it isn't available, you will,
of course, get an error.</P>
<P>If any command (even one within a multi-line command) begins with
<CODE>[perl]</CODE>, the remainder of that command line will be evaluated by the
running Perl instead of being forked by the shell.  If an error occurs
in parsing the Perl or if the Perl expression returns 0 or undef, the
command will be considered to have failed.  For example, here is a simple
command which creates a file <CODE>foo</CODE> directly from Perl:</P>
<PRE>
  $env = new cons();
  Command $env 'foo',
    qq([perl] open(FOO,'&gt;foo');print FOO &quot;hi\\n&quot;; close(FOO); 1);</PRE>
<P>Note that when the command is executed, you are in the same package as
when the <EM>Construct</EM> or <EM>Conscript</EM> file was read, so you can call
Perl functions you've defined in the same <EM>Construct</EM> or <EM>Conscript</EM>
file in which the <CODE>Command</CODE> appears:</P>
<PRE>
  $env = new cons();
  sub create_file {
        my $file = shift;
        open(FILE, &quot;&gt;$file&quot;);
        print FILE &quot;hi\n&quot;;
        close(FILE);
        return 1;
  }
  Command $env 'foo', &quot;[perl] &amp;create_file('%&gt;')&quot;;</PRE>
<P>The Perl string will be used to generate the signature for the derived
file, so if you change the string, the file will be rebuilt.  The contents
of any subroutines you call, however, are not part of the signature,
so if you modify a called subroutine such as <CODE>create_file</CODE> above,
the target will <EM>not</EM> be rebuilt.  Caveat user.</P>
<P>Cons normally prints a command before executing it.  This behavior is
suppressed if the first character of the command is <CODE>@</CODE>.  Note that
you may need to separate the <CODE>@</CODE> from the command name or escape it to
prevent <CODE>@cmd</CODE> from looking like an array to Perl quote operators that
perform interpolation:</P>
<PRE>
  # The first command line is incorrect,
  # because &quot;@cp&quot; looks like an array
  # to the Perl qq// function.
  # Use the second form instead.
  Command $env 'foo', 'foo.in', qq(
        @cp %&lt; tempfile
        @ cp tempfile %&gt;
  );</PRE>
<P>If there are shell meta characters anywhere in the expanded command line,
such as <CODE>&lt;</CODE>, <CODE>&gt;</CODE>, quotes, or semi-colon, then the command
will actually be executed by invoking a shell. This means that a command
such as:</P>
<PRE>
  cd foo</PRE>
<P>alone will typically fail, since there is no command <CODE>cd</CODE> on the path. But
the command string:</P>
<PRE>
  cd $&lt;:d; tar cf $&gt;:f $&lt;:f</PRE>
<P>when expanded will still contain the shell meta character semi-colon, and a
shell will be invoked to interpret the command. Since <CODE>cd</CODE> is interpreted
by this sub-shell, the command will execute as expected.</P>
<P>To specify a command with multiple targets, you can specify a reference to a
list of targets. In Perl, a list reference can be created by enclosing a
list in square brackets. Hence the following command:</P>
<PRE>
  Command $env ['foo.h', 'foo.c'], 'foo.template', q(
        gen %1
  );</PRE>
<P>could be used in a case where the command <CODE>gen</CODE> creates two files, both
<EM>foo.h</EM> and <EM>foo.c</EM>.</P>
<P>
<H2><A NAME="the objects method">The <CODE>Objects</CODE> method</A></H2>
<P>The <CODE>Objects</CODE> method arranges to create the object files that correspond to
the specified source files. It is invoked as shown below:</P>
<PRE>
  @files = Objects $env &lt;source or object files&gt;;</PRE>
<P>Under Unix, source files ending in <EM>.s</EM> and <EM>.c</EM> are currently
supported, and will be compiled into a name of the same file ending
in <EM>.o</EM>. By default, all files are created by invoking the external
command which results from expanding the <CODE>CCCOM</CODE> construction
variable, with <A HREF="#item_%<"><CODE>%&lt;</CODE></A> and <A HREF="#item_%>"><CODE>%&gt;</CODE></A> set to the source and object
files, respectively (see the <CODE>Command</CODE> method for expansion details).
The variable <CODE>CPPPATH</CODE> is also used when scanning source files for
dependencies. This is a colon separated list of pathnames, and is also
used to create the construction variable <CODE>_IFLAGS,</CODE> which will contain
the appropriate list of -<CODE>I</CODE> options for the compilation. Any relative
pathnames in <CODE>CPPPATH</CODE> is interpreted relative to the directory in
which the associated construction environment was created (absolute
and top-relative names may also be used). This variable is used by
<CODE>CCCOM</CODE>. The behavior of this command can be modified by changing any
of the variables which are interpolated into <CODE>CCCOM</CODE>, such as <CODE>CC</CODE>,
<CODE>CFLAGS</CODE>, and, indirectly, <CODE>CPPPATH</CODE>. It's also possible to replace
the value of <CODE>CCCOM</CODE>, itself. As a convenience, this file returns the
list of object filenames.</P>
<P>
<H2><A NAME="the program method">The <CODE>Program</CODE> method</A></H2>
<P>The <CODE>Program</CODE> method arranges to link the specified program with the
specified object files. It is invoked in the following manner:</P>
<PRE>
  Program $env &lt;program name&gt;, &lt;source or object files&gt;;</PRE>
<P>The program name will have the value of the <CODE>SUFEXE</CODE> construction
variable appended (by default, <CODE>.exe</CODE> on Win32 systems, nothing on Unix
systems) if the suffix is not already present.</P>
<P>Source files may be specified in place of objects files--the <CODE>Objects</CODE>
method will be invoked to arrange the conversion of all the files into
object files, and hence all the observations about the <CODE>Objects</CODE> method,
above, apply to this method also.</P>
<P>The actual linking of the program will be handled by an external command
which results from expanding the <CODE>LINKCOM</CODE> construction variable, with
<A HREF="#item_%<"><CODE>%&lt;</CODE></A> set to the object files to be linked (in the order presented),
and <A HREF="#item_%>"><CODE>%&gt;</CODE></A> set to the target (see the <CODE>Command</CODE> method for expansion
details). The user may set additional variables in the construction
environment, including <CODE>LINK</CODE>, to define which program to use for
linking, <CODE>LIBPATH</CODE>, a colon-separated list of library search paths,
for use with library specifications of the form <EM>-llib</EM>, and <CODE>LIBS</CODE>,
specifying the list of libraries to link against (in either <EM>-llib</EM>
form or just as pathnames. Relative pathnames in both <CODE>LIBPATH</CODE> and
<CODE>LIBS</CODE> are interpreted relative to the directory in which the associated
construction environment is created (absolute and top-relative names may
also be used). Cons automatically sets up dependencies on any libraries
mentioned in <CODE>LIBS</CODE>: those libraries will be built before the command
is linked.</P>
<P>
<H2><A NAME="the library method">The <CODE>Library</CODE> method</A></H2>
<P>The <CODE>Library</CODE> method arranges to create the specified library from the
specified object files. It is invoked as follows:</P>
<PRE>
  Library $env &lt;library name&gt;, &lt;source or object files&gt;;</PRE>
<P>The library name will have the value of the <CODE>SUFLIB</CODE> construction
variable appended (by default, <CODE>.lib</CODE> on Win32 systems, <CODE>.a</CODE> on Unix
systems) if the suffix is not already present.</P>
<P>Source files may be specified in place of objects files--the <CODE>Objects</CODE>
method will be invoked to arrange the conversion of all the files into
object files, and hence all the observations about the <CODE>Objects</CODE> method,
above, apply to this method also.</P>
<P>The actual creation of the library will be handled by an external
command which results from expanding the <CODE>ARCOM</CODE> construction variable,
with <A HREF="#item_%<"><CODE>%&lt;</CODE></A> set to the library members (in the order presented),
and <A HREF="#item_%>"><CODE>%&gt;</CODE></A> to the library to be created (see the <CODE>Command</CODE> method
for expansion details). The user may set variables in the construction
environment which will affect the operation of the command. These
include <CODE>AR</CODE>, the archive program to use, <CODE>ARFLAGS</CODE>, which can be
used to modify the flags given to the program specified by <CODE>AR</CODE>, and
<CODE>RANLIB</CODE>, the name of a archive index generation program, if needed
(if the particular need does not require the latter functionality,
then <CODE>ARCOM</CODE> must be redefined to not reference <CODE>RANLIB</CODE>).</P>
<P>The <CODE>Library</CODE> method allows the same library to be specified in multiple
method invocations. All of the contributing objects from all the invocations
(which may be from different directories) are combined and generated by a
single archive command. Note, however, that if you prune a build so that
only part of a library is specified, then only that part of the library will
be generated (the rest will disappear!).</P>
<P>
<H2><A NAME="the module method">The <CODE>Module</CODE> method</A></H2>
<P>The <CODE>Module</CODE> method is a combination of the <CODE>Program</CODE> and <CODE>Command</CODE>
methods. Rather than generating an executable program directly, this command
allows you to specify your own command to actually generate a module. The
method is invoked as follows:</P>
<PRE>
  Module $env &lt;module name&gt;, &lt;source or object files&gt;, &lt;construction command&gt;;</PRE>
<P>This command is useful in instances where you wish to create, for example,
dynamically loaded modules, or statically linked code libraries.</P>
<P>
<H2><A NAME="the depends method">The <CODE>Depends</CODE> method</A></H2>
<P>The <CODE>Depends</CODE> method allows you to specify additional dependencies for a
target.  It is invoked as follows:</P>
<PRE>
  Depends $env &lt;target&gt;, &lt;dependencies&gt;;</PRE>
<P>This may be occasionally useful, especially in cases where no scanner exists
(or is writable) for particular types of files. Normally, dependencies are
calculated automatically from a combination of the explicit dependencies set
up by the method invocation or by scanning source files.</P>
<P>A set of identical dependencies for multiple targets may be specified
using a reference to a list of targets. In Perl, a list reference can
be created by enclosing a list in square brackets. Hence the following
command:</P>
<PRE>
  Depends $env ['foo', 'bar'], 'input_file_1', 'input_file_2';</PRE>
<P>specifies that both the <EM>foo</EM> and <EM>bar</EM> files depend on the listed
input files.</P>
<P>
<H2><A NAME="the ignore method">The <CODE>Ignore</CODE> method</A></H2>
<P>The <CODE>Ignore</CODE> method allows you to ignore explicitly dependencies that
Cons infers on its own.  It is invoked as follows:</P>
<PRE>
  Ignore &lt;patterns&gt;;</PRE>
<P>This can be used to avoid recompilations due to changes in system header
files or utilities that are known to not affect the generated targets.</P>
<P>If, for example, a program is built in an NFS-mounted directory on
multiple systems that have different copies of <EM>stdio.h</EM>, the differences
will affect the signatures of all derived targets built from source files
that <CODE>#include &lt;stdio.h&gt;</CODE>.  This will cause all those targets to
be rebuilt when changing systems.  If this is not desirable behavior, then
the following line will remove the dependencies on the <EM>stdio.h</EM> file:</P>
<PRE>
  Ignore '^/usr/include/stdio\.h$';</PRE>
<P>Note that the arguments to the <CODE>Ignore</CODE> method are regular expressions,
so special characters must be escaped and you may wish to anchor the
beginning or end of the expression with <CODE>^</CODE> or <CODE>$</CODE> characters.</P>
<P>
<H2><A NAME="the salt method">The <CODE>Salt</CODE> method</A></H2>
<P>The <CODE>Salt</CODE> method adds a constant value to the signature calculation
for every derived file.  It is invoked as follows:</P>
<PRE>
  Salt $string;</PRE>
<P>Changing the Salt value will force a complete rebuild of every derived
file.  This can be used to force rebuilds in certain desired
circumstances.  For example,</P>
<PRE>
  Salt `uname -s`;</PRE>
<P>Would force a complete rebuild of every derived file whenever the
operating system on which the build is performed (as reported by <CODE>uname
-s</CODE>) changes.</P>
<P>
<H2><A NAME="the usecache method">The <CODE>UseCache</CODE> method</A></H2>
<P>The <CODE>UseCache</CODE> method instructs Cons to maintain a cache of derived
files, to be shared among separate build trees of the same project.</P>
<PRE>
  UseCache(&quot;cache/&lt;buildname&gt;&quot;) || warn(&quot;cache directory not found&quot;);</PRE>
<P>
<H2><A NAME="the sourcepath method">The <CODE>SourcePath</CODE> method</A></H2>
<P>The <CODE>SourcePath</CODE> mathod returns the real source path name of a file,
as opposted to the path name within a build directory.  It is invoked
as follows:</P>
<PRE>
  $path = SourcePath &lt;buildpath&gt;;</PRE>
<P>
<H2><A NAME="the conspath method">The <CODE>ConsPath</CODE> method</A></H2>
<P>The <CODE>ConsPath</CODE> method returns true if the supplied path is a derivable
file, and returns undef (false) otherwise.
It is invoked as follows:</P>
<PRE>
  $result = ConsPath &lt;path&gt;;</PRE>
<P>
<H2><A NAME="the splitpath method">The <CODE>SplitPath</CODE> method</A></H2>
<P>The <CODE>SplitPath</CODE> method looks up multiple path names in a string separated
by the default path separator for the operating system (':' on UNIX
systems, ';' on Windows NT), and returns the fully-qualified names.
It is invoked as follows:</P>
<PRE>
  @paths = SplitPath &lt;pathlist&gt;;</PRE>
<P>The <CODE>SplitPath</CODE> method will convert  names prefixed '#' to the
appropriate top-level build name (without the '#') and will convert
relative names to top-level names.</P>
<P>
<H2><A NAME="the dirpath method">The <CODE>DirPath</CODE> method</A></H2>
<P>The <CODE>DirPath</CODE> method returns the build path <CODE>name(s)</CODE> of a directory or
list of directories.  It is invoked as follows:</P>
<PRE>
  $cwd = DirPath &lt;paths&gt;;</PRE>
<P>The most common use for the <CODE>DirPath</CODE> method is:</P>
<PRE>
  $cwd = DirPath '.';</PRE>
<P>to fetch the path to the current directory of a subsidiary <EM>Conscript</EM>
file.</P>
<P>
<H2><A NAME="the filepath method">The <CODE>FilePath</CODE> method</A></H2>
<P>The <CODE>FilePath</CODE> method returns the build path <CODE>name(s)</CODE> of a file or
list of files.  It is invoked as follows:</P>
<PRE>
  $file = FilePath &lt;path&gt;;</PRE>
<P>
<H2><A NAME="the help method">The <CODE>Help</CODE> method</A></H2>
<P>The <CODE>Help</CODE> method specifies help text that will be displayed when the
user invokes <CODE>cons -h</CODE>.  This can be used to provide documentation
of specific targets, values, build options, etc. for the build tree.
It is invoked as follows:</P>
<PRE>
  Help &lt;helptext&gt;;</PRE>
<P>The <CODE>Help</CODE> method may only be called once, and should typically be
specified in the top-level <EM>Construct</EM> file.</P>
<P>
<HR>
<H1><A NAME="extending cons">Extending Cons</A></H1>
<P>
<H2><A NAME="overriding construction variables">Overriding construction variables</A></H2>
<P>There are several ways of extending Cons, which vary in degree of
difficulty. The simplest method is to define your own construction
environment, based on the default environment, but modified to reflect your
particular needs. This will often suffice for C-based applications. You can
use the <CODE>new</CODE> constructor, and the <CODE>clone</CODE> and <CODE>copy</CODE> methods to create
hybrid environments. These changes can be entirely transparent to the
underlying <EM>Conscript</EM> files.</P>
<P>
<H2><A NAME="adding new methods">Adding new methods</A></H2>
<P>For slightly more demanding changes, you may wish to add new methods to the
<CODE>cons</CODE> package. Here's an example of a very simple extension,
<CODE>InstallScript</CODE>, which installs a tcl script in a requested location, but
edits the script first to reflect a platform-dependent path that needs to be
installed in the script:</P>
<PRE>
  # cons::InstallScript - Create a platform dependent version of a shell
  # script by replacing string ``#!your-path-here'' with platform specific
  # path $BIN_DIR.</PRE>
<PRE>
  sub cons::InstallScript {
        my ($env, $dst, $src) = @_;
        Command $env $dst, $src, qq(
                sed s+your-path-here+$BIN_DIR+ %&lt; &gt; %&gt;
                chmod oug+x %&gt;
        );
  }</PRE>
<P>Notice that this method is defined directly in the <CODE>cons</CODE> package (by
prefixing the name with <CODE>cons::</CODE>). A change made in this manner will be
globally visible to all environments, and could be called as in the
following example:</P>
<PRE>
  InstallScript $env &quot;$BIN/foo&quot;, &quot;foo.tcl&quot;;</PRE>
<P>For a small improvement in generality, the <CODE>BINDIR</CODE> variable could be
passed in as an argument or taken from the construction environment--as
<CODE>%BINDIR</CODE>.</P>
<P>
<H2><A NAME="overriding methods">Overriding methods</A></H2>
<P>Instead of adding the method to the <CODE>cons</CODE> name space, you could define a
new package which inherits existing methods from the <CODE>cons</CODE> package and
overrides or adds others. This can be done using Perl's inheritance
mechanisms.</P>
<P>The following example defines a new package <CODE>cons::switch</CODE> which overrides the
standard <CODE>Library</CODE> method. The overridden method builds linked library
modules, rather than library archives. A new constructor is
provided. Environments created with this constructor will have the new
library method; others won't.</P>
<PRE>
  package cons::switch;
  BEGIN {@ISA = 'cons'}</PRE>
<PRE>
  sub new {
        shift;
        bless new cons(@_);
  }</PRE>
<PRE>
  sub Library {
        my($env) = shift;
        my($lib) = shift;
        my(@objs) = Objects $env @_;
        Command $env $lib, @objs, q(
                %LD -r %LDFLAGS %&lt; -o %&gt;
        );
  }</PRE>
<P>This functionality could be invoked as in the following example:</P>
<PRE>
  $env = new cons::switch(@overrides);
  ...
  Library $env 'lib.o', 'foo.c', 'bar.c';</PRE>
<P>
<HR>
<H1><A NAME="invoking cons">Invoking Cons</A></H1>
<P>The <CODE>cons</CODE> command is usually invoked from the root of the build tree. A
<EM>Construct</EM> file must exist in that directory. If the <CODE>-f</CODE> argument is
used, then an alternate <EM>Construct</EM> file may be used (and, possibly, an
alternate root, since <CODE>cons</CODE> will cd to <EM>Construct</EM> file's containing
directory).</P>
<P>If <CODE>cons</CODE> is invoked from a child of the root of the build tree with
the <A HREF="#item_%2Dt"><CODE>-t</CODE></A> argument, it will walk up the directory hierarchy looking for a
<EM>Construct</EM> file.  (An alternate name may still be specified with <CODE>-f</CODE>.)
The targets supplied on the command line will be modified to be relative
to the discovered <EM>Construct</EM> file.  For example, from a directory
containing a top-level <EM>Construct</EM> file, the following invocation:</P>
<PRE>
  % cd libfoo/subdir
  % cons -t target</PRE>
<P>is exactly equivalent to:</P>
<PRE>
  % cons libfoo/subdir/target</PRE>
<P>If there are any <CODE>Default</CODE> targets specified in the directory hierarchy's
<EM>Construct</EM> or <EM>Conscript</EM> files, only the default targets at or below
the directory from which <CODE>cons -t</CODE> was invoked will be built.</P>
<P>The command is invoked as follows:</P>
<PRE>
  cons &lt;arguments&gt; -- &lt;construct-args&gt;</PRE>
<P>where <EM>arguments</EM> can be any of the following, in any order:</P>
<DL>
<DT><STRONG><A NAME="item_target"><EM>target</EM></A></STRONG><BR>
<DD>
Build the specified target. If <EM>target</EM> is a directory, then recursively
build everything within that directory.
<P></P>
<DT><STRONG><A NAME="item_%2Bpattern"><EM>+pattern</EM></A></STRONG><BR>
<DD>
Limit the <EM>Conscript</EM> files considered to just those that match <EM>pattern</EM>,
which is a Perl regular expression. Multiple <CODE>+</CODE> arguments are accepted.
<P></P>
<DT><STRONG><A NAME="item_name%3D%3Cval%3E"><EM>name</EM>=&lt;val&gt;</A></STRONG><BR>
<DD>
Sets <EM>name</EM> to value <EM>val</EM> in the <CODE>ARG</CODE> hash passed to the top-level
<EM>Construct</EM> file.
<P></P>
<DT><STRONG><A NAME="item_%2Dcc"><CODE>-cc</CODE></A></STRONG><BR>
<DD>
Show command that would have been executed, when retrieving from cache. No
indication that the file has been retrieved is given; this is useful for
generating build logs that can be compared with real build logs.
<P></P>
<DT><STRONG><A NAME="item_%2Dcd"><CODE>-cd</CODE></A></STRONG><BR>
<DD>
Disable all caching. Do not retrieve from cache nor flush to cache.
<P></P>
<DT><STRONG><A NAME="item_%2Dcr"><CODE>-cr</CODE></A></STRONG><BR>
<DD>
Build dependencies in random order. This is useful when building multiple
similar trees with caching enabled.
<P></P>
<DT><STRONG><A NAME="item_%2Dcs"><CODE>-cs</CODE></A></STRONG><BR>
<DD>
Synchronize existing build targets that are found to be up-to-date with
cache. This is useful if caching has been disabled with -cc or just recently
enabled with UseCache.
<P></P>
<DT><STRONG><A NAME="item_%2Dd"><CODE>-d</CODE></A></STRONG><BR>
<DD>
Enable dependency debugging.
<P></P>
<DT><STRONG><A NAME="item_%2Df_%3Cfile%3E"><CODE>-f</CODE> &lt;file&gt;</A></STRONG><BR>
<DD>
Use the specified file instead of <EM>Construct</EM> (but first change to
containing directory of <EM>file</EM>).
<P></P>
<DT><STRONG><A NAME="item_%2Dh"><CODE>-h</CODE></A></STRONG><BR>
<DD>
Show a help message local to the current build if one such is defined, and
exit.
<P></P>
<DT><STRONG><A NAME="item_%2Dk"><CODE>-k</CODE></A></STRONG><BR>
<DD>
Keep going as far as possible after errors.
<P></P>
<DT><STRONG><A NAME="item_%2Do_%3Cfile%3E"><CODE>-o</CODE> &lt;file&gt;</A></STRONG><BR>
<DD>
Read override file <EM>file</EM>.
<P></P>
<DT><STRONG><A NAME="item_%2Dp"><CODE>-p</CODE></A></STRONG><BR>
<DD>
Show construction products in specified trees. No build is attempted.
<P></P>
<DT><STRONG><A NAME="item_%2Dpa"><CODE>-pa</CODE></A></STRONG><BR>
<DD>
Show construction products and associated actions. No build is attempted.
<P></P>
<DT><STRONG><A NAME="item_%2Dpw"><CODE>-pw</CODE></A></STRONG><BR>
<DD>
Show products and where they are defined. No build is attempted.
<P></P>
<DT><STRONG><A NAME="item_%2Dq"><CODE>-q</CODE></A></STRONG><BR>
<DD>
Don't be verbose about Installing and Removing targets.
<P></P>
<DT><STRONG><A NAME="item_%2Dr"><CODE>-r</CODE></A></STRONG><BR>
<DD>
Remove construction products associated with &lt;targets&gt;. No build is
attempted.
<P></P>
<DT><STRONG><A NAME="item_%2DR_%3Crepos%3E"><CODE>-R</CODE> &lt;repos&gt;</A></STRONG><BR>
<DD>
Search for files in <EM>repos</EM>.  Multiple <STRONG>-R</STRONG> <EM>repos</EM> directories are
searched in the order specified.
<P></P>
<DT><STRONG><A NAME="item_%2Dt"><CODE>-t</CODE></A></STRONG><BR>
<DD>
Traverse up the directory hierarchy looking for a <EM>Construct</EM> file, if
none exists in the current directory.  Targets will be modified to be
relative to the <EM>Construct</EM> file.
<P></P>
<DT><STRONG><A NAME="item_%2Dv"><CODE>-v</CODE></A></STRONG><BR>
<DD>
Show <CODE>cons</CODE> version and continue processing.
<P></P>
<DT><STRONG><A NAME="item_%2DV"><CODE>-V</CODE></A></STRONG><BR>
<DD>
Show <CODE>cons</CODE> version and exit.
<P></P>
<DT><STRONG><A NAME="item_%2Dwf_%3Cfile%3E"><CODE>-wf</CODE> &lt;file&gt;</A></STRONG><BR>
<DD>
Write all filenames considered into <EM>file</EM>.
<P></P>
<DT><STRONG><A NAME="item_%2Dx"><CODE>-x</CODE></A></STRONG><BR>
<DD>
Show a help message similar to this one, and exit.
<P></P></DL>
<P>And <EM>construct-args</EM> can be any arguments that you wish to process in the
<EM>Construct</EM> file. Note that there should be a <STRONG>--</STRONG> separating the arguments
to cons and the arguments that you wish to process in the <EM>Construct</EM> file.</P>
<P>Processing of <EM>construct-args</EM> can be done by any standard package like
<STRONG>Getopt</STRONG> or its variants, or any user defined package. <STRONG>cons</STRONG> will pass in
the <EM>construct-args</EM> as <STRONG>@ARGV</STRONG> and will not attempt to interpret anything
after the <STRONG>--</STRONG>.</P>
<PRE>
  % cons -R /usr/local/repository -d os=solaris +driver -- -c test -f DEBUG</PRE>
<P>would pass the following to cons</P>
<PRE>
  -R /usr/local/repository -d os=solaris +driver</PRE>
<P>and the following, to the top level <EM>Construct</EM> file as <STRONG>@ARGV</STRONG></P>
<PRE>
  -c test -f DEBUG</PRE>
<P>Note that <CODE>cons -r .</CODE> is equivalent to a full recursive <CODE>make clean</CODE>,
but requires no support in the <EM>Construct</EM> file or any <EM>Conscript</EM>
files. This is most useful if you are compiling files into source
directories (if you separate the <EM>build</EM> and <EM>export</EM> directories,
then you can just remove the directories).</P>
<P>The options <A HREF="#item_%2Dp"><CODE>-p</CODE></A>, <A HREF="#item_%2Dpa"><CODE>-pa</CODE></A>, and <A HREF="#item_%2Dpw"><CODE>-pw</CODE></A> are extremely useful for use as an aid
in reading scripts or debugging them. If you want to know what script
installs <EM>export/include/foo.h</EM>, for example, just type:</P>
<PRE>
  % cons -pw export/include/foo.h</PRE>
<P>
<HR>
<H1><A NAME="using and writing dependency scanners">Using and writing dependency scanners</A></H1>
<P>QuickScan allows simple target-independent scanners to be set up for source
files. Only one QuickScan scanner may be associated with any given source
file and environment.</P>
<P>QuickScan is invoked as follows:</P>
<PRE>
  QuickScan CONSENV CODEREF, FILENAME [, PATH]</PRE>
<P>The subroutine referenced by CODEREF is expected to return a list of
filenames included directly by FILE. These filenames will, in turn, be
scanned. The optional PATH argument supplies a lookup path for finding
FILENAME and/or files returned by the user-supplied subroutine.  The PATH
may be a reference to an array of lookup-directory names, or a string of
names separated by the system's separator character (':' on UNIX systems,
';' on Windows NT).</P>
<P>The subroutine is called once for each line in the file, with $_ set to the
current line. If the subroutine needs to look at additional lines, or, for
that matter, the entire file, then it may read them itself, from the
filehandle SCAN. It may also terminate the loop, if it knows that no further
include information is available, by closing the filehandle.</P>
<P>Whether or not a lookup path is provided, QuickScan first tries to lookup
the file relative to the current directory (for the top-level file supplied
directly to QuickScan), or from the directory containing the file which
referenced the file. This is not very general, but seems good
enough--especially if you have the luxury of writing your own utilities and
can control the use of the search path in a standard way. Finally, the
search path is, currently, colon separated. This may not make the NT camp
happy.</P>
<P>Here's a real example, taken from a <EM>Construct</EM> file here:</P>
<PRE>
  sub cons::SMFgen {
      my($env, @tables) = @_;
      foreach $t (@tables) {
          $env-&gt;QuickScan(sub { /\b\S*?\.smf\b/g }, &quot;$t.smf&quot;,
                          $env-&gt;{SMF_INCLUDE_PATH});
          $env-&gt;Command(
              [&quot;$t.smdb.cc&quot;,&quot;$t.smdb.h&quot;,&quot;$t.snmp.cc&quot;,&quot;$t.ami.cc&quot;, &quot;$t.http.cc&quot;],
              &quot;$t.smf&quot;,
              q(
                smfgen %( %SMF_INCLUDE_OPT %) %&lt;
              )
          );
      }
  }</PRE>
<P>[NOTE that the form <CODE>$env-&gt;QuickScan ...</CODE>  and <CODE>$env-&gt;Command
...</CODE> should not be necessary, but, for some reason, is required
for this particular invocation. This appears to be a bug in Perl or
a misunderstanding on my part; this invocation style does not always
appear to be necessary.]</P>
<P>This finds all names of the form &lt;name&gt;.smf in the file. It will return the
names even if they're found within comments, but that's OK (the mechanism is
forgiving of extra files; they're just ignored on the assumption that the
missing file will be noticed when the program, in this example, smfgen, is
actually invoked).</P>
<P>A scanner is only invoked for a given source file if it is needed by some
target in the tree. It is only ever invoked once for a given source file.</P>
<P>Here is another way to build the same scanner. This one uses an
explicit code reference, and also (unecessarily, in this case) reads
the whole file itself:</P>
<PRE>
  sub myscan {
      my(@includes);
      do {
          push(@includes, /\b\S*?\.smf\b/g);
      } while &lt;SCAN&gt;;
      @includes
  }</PRE>
<P>Note that the order of the loop is reversed, with the loop test at the
end. This is because the first line is already read for you. This scanner
can be attached to a source file by:</P>
<PRE>
    QuickScan $env \myscan, &quot;$_.smf&quot;;</PRE>
<P>
<HR>
<H1><A NAME="support and suggestions">SUPPORT AND SUGGESTIONS</A></H1>
<P>Cons is maintained by the user community.  To subscribe, send mail to
<STRONG><A HREF="mailto:cons-discuss-request@gnu.org">cons-discuss-request@gnu.org</A></STRONG> with body <STRONG>subscribe</STRONG>.</P>
<P>Please report any suggestions through the <STRONG><A HREF="mailto:cons-discuss@gnu.org">cons-discuss@gnu.org</A></STRONG> mailing
list.</P>
<P>
<HR>
<H1><A NAME="bugs">BUGS</A></H1>
<P>Sure to be some. Please report any bugs through the <STRONG><A HREF="mailto:bug-cons@gnu.org">bug-cons@gnu.org</A></STRONG>
mailing list.</P>
<P>
<HR>
<H1><A NAME="information about cons">INFORMATION ABOUT CONS</A></H1>
<P>Information about CONS can be obtained from the official cons web site
<STRONG><A HREF="http://www.dsmit.com/cons/">http://www.dsmit.com/cons/</A></STRONG> or its mirrors listed there.</P>
<P>The cons maintainers can be contacted by email at
<STRONG><A HREF="mailto:cons-maintainers@gnu.org">cons-maintainers@gnu.org</A></STRONG></P>
<P>
<HR>
<H1><A NAME="authors">AUTHORS</A></H1>
<P>Originally by Bob Sidebotham. Then significantly enriched by the members
of the Cons community <STRONG><A HREF="mailto:cons-discuss@gnu.org">cons-discuss@gnu.org</A></STRONG>.</P>
<P>The Cons community would like to thank Ulrich Pfeifer for the original pod
documentation derived from the <EM>cons.html</EM> file. Cons documentation is now
a part of the program itself.</P>

</BODY>

</HTML>