aboutsummaryrefslogtreecommitdiff
path: root/en_US.ISO8859-1/books/porters-handbook/book.sgml
blob: a91f3d882acdc1e59d731554d746783ad323c510 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
<!--
     The FreeBSD Documentation Project

     $FreeBSD$
-->

<!DOCTYPE BOOK PUBLIC "-//FreeBSD//DTD DocBook V4.1-Based Extension//EN" [
<!ENTITY % books.ent PUBLIC "-//FreeBSD//ENTITIES DocBook FreeBSD Books Entity Set//EN">
%books.ent;
]>

<book>
  <bookinfo>
    <title>FreeBSD Porter's Handbook</title>

    <authorgroup>
      <corpauthor>The FreeBSD Documentation Project</corpauthor>
    </authorgroup>

    <pubdate>April 2000</pubdate>

    <copyright>
      <year>2000</year>
      <year>2001</year>
      <year>2002</year>
      <year>2003</year>
      <year>2004</year>
      <year>2005</year>
      <holder role="mailto:doc@FreeBSD.org">The FreeBSD Documentation
	Project</holder>
    </copyright>

    &bookinfo.trademarks;

    &bookinfo.legalnotice;
  </bookinfo>

    <chapter id="why-port">
      <title>Introduction</title>

      <para>The FreeBSD ports collection is the way almost everyone
	installs applications ("ports") on FreeBSD.  Like everything
	else about FreeBSD, it is primarily a volunteer effort.
	It is important to keep this in mind when reading this
	document.</para>

      <para>In FreeBSD, anyone may submit a new port, or volunteer
	to maintain an existing port if it is unmaintained&mdash;you
	do not need any special commit privileges to do so.</para>

    </chapter>

    <chapter id="own-port">
      <title>Making a port yourself</title>

      <para>So, you are interested in making your own port or
	upgrading an existing one?  Great!</para>

      <para>What follows are some guidelines for creating a new port for
	FreeBSD.  If you want to upgrade an existing port, you should
	read this and then read <xref linkend="port-upgrading">.</para>

      <para>When this document is not sufficiently detailed, you should
	refer to <filename>/usr/ports/Mk/bsd.port.mk</filename>, which
	all port Makefiles include.  Even if you do not hack Makefiles
	daily, it is well commented, and you will still gain much
	knowledge from it.  Additionally, you may send specific questions
	to the &a.ports;.</para>

      <note>
	<para>Only a fraction of the variables
	  (<makevar><replaceable>VAR</replaceable></makevar>) that can be
	  overridden are mentioned in this document.  Most (if not all)
	  are documented at the start of <filename>/usr/ports/Mk/bsd.port.mk</filename>;
	  the others probably ought to be.
	  Note that this file uses a non-standard tab setting:
	  <application>Emacs</application> and
	  <application>Vim</application> should recognize the setting on
	  loading the file.  Both &man.vi.1; and
	  &man.ex.1; can be set to use the correct value by
	  typing <command>:set tabstop=4</command> once the file has been
	  loaded.</para>
      </note>
    </chapter>

    <chapter id="quick-porting">
      <title>Quick Porting</title>

      <para>This section tells you how to do a quick port.  In many cases, it
	is not sufficient, so you will have to read further on into
	the document.</para>

      <para>First, get the original tarball and put it into
	<makevar>DISTDIR</makevar>, which defaults to
	<filename>/usr/ports/distfiles</filename>.</para>

      <note>
	<para>The following assumes that the software compiled out-of-the-box,
	  i.e., there was absolutely no change required for the port to work
	  on your FreeBSD box.  If you needed to change something, you will
	  have to refer to the next section too.</para>
      </note>

      <sect1 id="porting-makefile">
	<title>Writing the <filename>Makefile</filename></title>

	<para>The minimal <filename>Makefile</filename> would look something
	  like this:</para>

	<programlisting># New ports collection makefile for:   oneko
# Date created:        5 December 1994
# Whom:                asami
#
# &dollar;FreeBSD&dollar;
#

PORTNAME=      oneko
PORTVERSION=   1.1b
CATEGORIES=    games
MASTER_SITES=  ftp://ftp.cs.columbia.edu/archives/X11R5/contrib/

MAINTAINER=    asami@FreeBSD.org
COMMENT=       A cat chasing a mouse all over the screen

MAN1=          oneko.1
MANCOMPRESSED= yes
USE_IMAKE=     yes

.include &lt;bsd.port.mk&gt;</programlisting>

	<para>See if you can figure it out.  Do not worry about the contents
	  of the <literal>&dollar;FreeBSD&dollar;</literal> line, it will be
	  filled in automatically by CVS when the port is imported to our main
	  ports tree.  You can find a more detailed example in the <link
	    linkend="porting-samplem">sample Makefile</link> section.</para>
      </sect1>

      <sect1 id="porting-desc">
	<title>Writing the description files</title>

	<para>There are two description files that are required for
	  any port, whether they actually package or not. They are
	  <filename>pkg-descr</filename> and
	  <filename>pkg-plist</filename>.  Their
	  <filename>pkg-</filename> prefix distinguishes them from
	  other files.</para>

	<sect2>
	  <title><filename>pkg-descr</filename></title>

	  <para>This is a longer description of the port.  One to a few
	    paragraphs concisely explaining what the port does is
	    sufficient.</para>

	  <note>
	    <para>This is <emphasis>not</emphasis> a manual or an in-depth
	      description on how to use or compile the port! <emphasis>Please
	      be careful if you are copying from the
	      <filename>README</filename> or manpage</emphasis>; too often
	      they are not a concise description of the port or are in an
	      awkward format (e.g., manpages have justified spacing).  If the
	      ported software has an official WWW homepage, you should list it
	      here.  Prefix <emphasis>one</emphasis> of the websites with
	      <literal>WWW:</literal> so that automated tools will work
	      correctly.</para>
	  </note>

	  <para>The following example shows how your
	    <filename>pkg-descr</filename> should look:</para>

	  <programlisting>This is a port of oneko, in which a cat chases a poor mouse all over
the screen.
 :
(etc.)

WWW: http://www.oneko.org/</programlisting>
	</sect2>

	<sect2>
	  <title><filename>pkg-plist</filename></title>

	  <para>This file lists all the files installed by the port.  It is
	    also called the <quote>packing list</quote> because the package is
	    generated by packing the files listed here.  The pathnames are
	    relative to the installation prefix (usually
	    <filename>/usr/local</filename> or
	    <filename>/usr/X11R6</filename>).  If you are using the
	    <makevar>MAN<replaceable>n</replaceable></makevar> variables (as
	    you should be), do not list any manpages here.  If the port creates
	    directories during installation, make sure to add
	    <literal>@dirrm</literal> lines to remove them when the package is
	    deleted.</para>

	  <para>Here is a small example:</para>

	  <programlisting>bin/oneko
lib/X11/app-defaults/Oneko
lib/X11/oneko/cat1.xpm
lib/X11/oneko/cat2.xpm
lib/X11/oneko/mouse.xpm
@dirrm lib/X11/oneko</programlisting>

	  <para>Refer to the &man.pkg.create.1; manual page for details on the
	    packing list.</para>

	  <note>
	    <para>It is recommended that you keep all the filenames in this
	      file sorted alphabetically.  It will make verifying the changes
	      when you upgrade the port much easier.</para>
	  </note>

	  <note>
	    <para>Creating a packing list manually can be a very tedious
	      task.  If the port installs a large numbers of files, <link
		linkend="plist-autoplist">creating the packing list
		automatically</link> might save time.</para>
	  </note>

	  <para>There is only one case when <filename>pkg-plist</filename>
	    can be omitted from a port.  If the port installs just a handful
	    of files, and perhaps directories, the files and directories may
	    be listed in the variables <makevar>PLIST_FILES</makevar> and
	    <makevar>PLIST_DIRS</makevar>, respectively, within the port's
	    <filename>Makefile</filename>.  For instance, we could get along
	    without <filename>pkg-plist</filename> in the above
	    <filename>oneko</filename> port by adding the
	    following lines to the <filename>Makefile</filename>:</para>

	  <programlisting>PLIST_FILES=    bin/oneko \
                lib/X11/app-defaults/Oneko \
                lib/X11/oneko/cat1.xpm \
                lib/X11/oneko/cat2.xpm \
                lib/X11/oneko/mouse.xpm
PLIST_DIRS=     lib/X11/oneko</programlisting>

	  <para>Of course, <makevar>PLIST_DIRS</makevar> should be left
	    unset if a port installs no directories of its own.</para>

	  <para>The price for this way of listing port's files and
	    directories is that you cannot use command sequences
	    described in &man.pkg.create.1;.  Therefore, it is suitable
	    only for simple ports and makes them even simpler.  At the
	    same time, it has the advantage of reducing the number of files
	    in the ports collection.  Please consider using this technique
	    before you resort to <filename>pkg-plist</filename>.</para>

	  <para>Later we will see how <filename>pkg-plist</filename>
	    and <makevar>PLIST_FILES</makevar> can be used to fulfil
	    <link linkend="plist">more sophisticated
	    tasks</link>.</para>
	</sect2>
      </sect1>

      <sect1 id="porting-checksum">
	<title>Creating the checksum file</title>

	<para>Just type <command>make makesum</command>. The ports make rules
	  will automatically generate the file
	  <filename>distinfo</filename>.</para>

	<para>If a file fetched has its checksum changed regularly and you are
	  certain the source is trusted (i.e. it comes from manufacturer CDs
	  or documentation generated daily), you should specify these files in
	  the <makevar>IGNOREFILES</makevar> variable.
	  Then the checksum is not calculated for that file when you run
	  <command>make makesum</command>, but set to
	  <literal>IGNORE</literal>.</para>
      </sect1>

      <sect1 id="porting-testing">
	<title>Testing the port</title>

	<para>You should make sure that the port rules do exactly what you
	  want them to do, including packaging up the port.  These are the
	  important points you need to verify.</para>

	<itemizedlist>
	  <listitem>
	    <para><filename>pkg-plist</filename> does not contain anything not
	      installed by your port</para>
	  </listitem>

	  <listitem>
	    <para><filename>pkg-plist</filename> contains everything that is
	      installed by your port</para>
	  </listitem>

	  <listitem>
	    <para>Your port can be installed multiple times using the
	      <maketarget>reinstall</maketarget> target</para>
	  </listitem>

	  <listitem>
	    <para>Your port <link linkend="plist-cleaning">cleans up</link>
	      after itself upon deinstall</para>
	  </listitem>
	</itemizedlist>

	<procedure>
	  <title>Recommended test ordering</title>

	  <step>
	    <para><command>make install</command></para>
	  </step>

	  <step>
	    <para><command>make package</command></para>
	  </step>

	  <step>
	    <para><command>make deinstall</command></para>
	  </step>

	  <step>
	    <para><command>pkg_add <replaceable>package-name</replaceable>
	      </command></para>
	  </step>

	  <step>
	    <para><command>make deinstall</command></para>
	  </step>

	  <step>
	    <para><command>make reinstall</command></para>
	  </step>

	  <step>
	    <para><command>make package</command></para>
	  </step>
	</procedure>

	<para>Make sure that there are not any warnings issued in any of the
	  <maketarget>package</maketarget> and
	  <maketarget>deinstall</maketarget> stages.  After step 3, check to
	  see if all the new directories are correctly deleted.  Also, try
	  using the software after step 4, to ensure that it works correctly
	  when installed from a package.</para>
      </sect1>

      <sect1 id="porting-portlint">
	<title>Checking your port with <command>portlint</command></title>

	<para>Please use <command>portlint</command> to see if your port
	  conforms to our guidelines.  The <filename role="package">
	  devel/portlint</filename> program is part of the ports collection.
	  In particular, you may want to check if the
	  <link linkend="porting-samplem">Makefile</link> is in the right
	  shape and the <link linkend="porting-pkgname">package</link> is named
	  appropriately.</para>
      </sect1>

      <sect1 id="porting-submitting">
	<title>Submitting the port</title>

	<para>First, make sure you have read the <link
	    linkend="porting-dads">DOs and DON'Ts</link> section.</para>

	<para>Now that you are happy with your port, the only thing remaining
	  is to put it in the main FreeBSD ports tree and make everybody else
	  happy about it too.  We do not need your <filename>work</filename>
	  directory or the <filename>pkgname.tgz</filename> package, so delete
	  them now.  Next, simply include the output of <command>shar `find
	    port_dir`</command> in a bug report and send it with the
	    &man.send-pr.1; program (see <ulink url="&url.articles.contributing;/contrib-how.html#CONTRIB-GENERAL">Bug
	    Reports and General Commentary</ulink> for more information about
	    &man.send-pr.1;).  Be sure to classify the bug report as category
	  <literal>ports</literal> and class
	  <literal>change-request</literal>  (Do not mark the report
	  <literal>confidential</literal>!).
	  Also add a short description of the program you ported
	  to the <quote>Description</quote> field of the PR and
	  the shar to the <quote>Fix</quote> field.</para>

	<note>
	  <para>You can make our work a lot easier, if you use a good
	    description in the synopsis of the problem report.
	    We prefer something like
	    <quote>New port: &lt;category&gt;/&lt;portname&gt;
	    &lt;short description of the port&gt;</quote> for new ports and
	    <quote>Update port: &lt;category&gt;/&lt;portname&gt;
	    &lt;short description of the update&gt;</quote> for port updates.
	    If you stick to this scheme, the chance that someone will take a
	    look at your PR soon is much better.</para>
	</note>

	<para>One more time, <emphasis>do not include the original source
	    distfile, the <filename>work</filename> directory, or the package
	    you built with <command>make package</command></emphasis>.</para>

	<para>After you have submitted your port, please be patient.
	  Sometimes it can take a few months before a port is included
	  in FreeBSD, although it might only take a few days.  You can
	  view the list of <ulink
	  url="http://www.FreeBSD.org/cgi/query-pr-summary.cgi?category=ports">ports
	  waiting to be committed to FreeBSD</ulink>.</para>

	<para>Once we have looked at your port, we will get back to you if necessary, and put
	  it in the tree.  Your name will also appear in the list of
	  <ulink url="&url.articles.contributors;/contrib-additional.html">Additional FreeBSD Contributors</ulink>
	  and other files. Isn't that great?!? <!-- smiley
	  -->:-)</para>
      </sect1>
    </chapter>

    <chapter id="slow">
      <title>Slow Porting</title>

      <para>Ok, so it was not that simple, and the port required some
	modifications to get it to work.  In this section, we will explain,
	step by step, how to modify it to get it to work with the ports
	paradigm.</para>

      <sect1 id="slow-work">
	<title>How things work</title>

	<para>First, this is the sequence of events which occurs when the user
	  first types <command>make</command> in your port's directory.
	  You may find that having <filename>bsd.port.mk</filename> in another
	  window while you read this really helps to understand it.</para>

	<para>But do not worry if you do not really understand what
	  <filename>bsd.port.mk</filename> is doing, not many people do...
	  <!-- smiley --><emphasis>:-&gt;</emphasis></para>

	<procedure>

	  <step>
	    <para>The <maketarget>fetch</maketarget> target is run.  The
	      <maketarget>fetch</maketarget> target is responsible for making
	      sure that the tarball exists locally in
	      <makevar>DISTDIR</makevar>. If <maketarget>fetch</maketarget>
	      cannot find the required files in <makevar>DISTDIR</makevar> it
	      will look up the URL <makevar>MASTER_SITES</makevar>, which is
	      set in the Makefile, as well as our main FTP site at <ulink
		url="ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/"></ulink>,
	      where we put sanctioned distfiles as backup.  It will then
	      attempt to fetch the named distribution file with
	      <makevar>FETCH</makevar>, assuming that the requesting site has
	      direct access to the Internet.  If that succeeds, it will save
	      the file in <makevar>DISTDIR</makevar> for future use and
	      proceed.</para>
	  </step>

	  <step>
	    <para>The <maketarget>extract</maketarget> target is run.  It
	      looks for your port's distribution file (typically a gzip'd
	      tarball) in <makevar>DISTDIR</makevar> and unpacks it into a
	      temporary subdirectory specified by <makevar>WRKDIR</makevar>
	      (defaults to <filename>work</filename>).</para>
	  </step>

	  <step>
	    <para>The <maketarget>patch</maketarget> target is run.  First,
	      any patches defined in <makevar>PATCHFILES</makevar> are
	      applied.  Second, if any patch files named
	      <filename>patch-<replaceable>*</replaceable></filename> are found in
	      <makevar>PATCHDIR</makevar> (defaults to the
	      <filename>files</filename> subdirectory), they are applied at
	      this time in alphabetical order.</para>
	  </step>

	  <step>
	    <para>The <maketarget>configure</maketarget> target is run.  This
	      can do any one of many different things.</para>

	    <orderedlist>
	      <listitem>
		<para>If it exists, <filename>scripts/configure</filename> is
		  run.</para>
	      </listitem>

	      <listitem>
		<para>If <makevar>HAS_CONFIGURE</makevar> or
		  <makevar>GNU_CONFIGURE</makevar> is set,
		  <filename><makevar>WRKSRC</makevar>/configure</filename> is
		  run.</para>
	      </listitem>

	      <listitem>
		<para>If <makevar>USE_IMAKE</makevar> is set,
		  <makevar>XMKMF</makevar> (default: <command>xmkmf
		    -a</command>) is run.</para>
	      </listitem>
	    </orderedlist>
	  </step>

	  <step>
	    <para>The <maketarget>build</maketarget> target is run.  This is
	      responsible for descending into the port's private working
	      directory (<makevar>WRKSRC</makevar>) and building it.  If
	      <makevar>USE_GMAKE</makevar> is set, GNU <command>make</command>
	      will be used, otherwise the system <command>make</command> will
	      be used.</para>
	  </step>
	</procedure>

	<para>The above are the default actions.  In addition, you can define
	  targets
	  <maketarget>pre-<replaceable>something</replaceable></maketarget> or
	  <maketarget>post-<replaceable>something</replaceable></maketarget>,
	  or put scripts with those names, in the <filename>scripts</filename>
	  subdirectory, and they will be run before or after the default
	  actions are done.</para>

	<para>For example, if you have a <maketarget>post-extract</maketarget>
	  target defined in your <filename>Makefile</filename>, and a file
	  <filename>pre-build</filename> in the <filename>scripts</filename>
	  subdirectory, the <maketarget>post-extract</maketarget> target will
	  be called after the regular extraction actions, and the
	  <filename>pre-build</filename> script will be executed before the
	  default build rules are done.  It is recommended that you use
	  <filename>Makefile</filename> targets if the actions are simple
	  enough, because it will be easier for someone to figure out what
	  kind of non-default action the port requires.</para>

	<para>The default actions are done by the
	  <filename>bsd.port.mk</filename> targets
	  <maketarget>do-<replaceable>something</replaceable></maketarget>.
	  For example, the commands to extract a port are in the target
	  <maketarget>do-extract</maketarget>.  If you are not happy with the
	  default target, you can fix it by redefining the
	  <maketarget>do-<replaceable>something</replaceable></maketarget>
	  target in your <filename>Makefile</filename>.</para>

	<note>
	  <para>The <quote>main</quote> targets (e.g.,
	    <maketarget>extract</maketarget>,
	    <maketarget>configure</maketarget>, etc.) do nothing more than
	    make sure all  the stages up to that one are completed and call
	    the real targets or scripts, and they are not intended to be
	    changed.  If you want to fix the extraction, fix
	    <maketarget>do-extract</maketarget>, but never ever change
	    the way <maketarget>extract</maketarget> operates!</para>
	</note>

	<para>Now that you understand what goes on when the user types
	  <command>make</command>, let us go through the recommended steps to
	  create the perfect port.</para>
      </sect1>

      <sect1 id="slow-sources">
	<title>Getting the original sources</title>

	<para>Get the original sources (normally) as a compressed tarball
	  (<filename><replaceable>foo</replaceable>.tar.gz</filename> or
	  <filename><replaceable>foo</replaceable>.tar.Z</filename>) and copy
	  it into <makevar>DISTDIR</makevar>.  Always use
	  <emphasis>mainstream</emphasis> sources when and where you
	  can.</para>

	<para>You will need to set the variable <makevar>MASTER_SITES</makevar>
	  to reflect where the original tarball resides.  You will find
	  convenient shorthand definitions for most mainstream sites
	  in <filename>bsd.sites.mk</filename>.  Please use these
	  sites&mdash;and the associated definitions&mdash;if
	  at all possible, to help avoid the problem of having the same
	  information repeated over again many times in the source base.
	  As these sites tend to change over time, this becomes a
	  maintenance nightmare for everyone involved.</para>

	<para>If you cannot find a FTP/HTTP site that is well-connected to the
	  net, or can only find sites that have irritatingly non-standard
	  formats, you might want to put a copy on a reliable FTP or HTTP
	  server that you control (e.g., your home page).</para>

	<para>If you cannot find somewhere convenient and reliable to put the
	  distfile
	  we can <quote>house</quote> it ourselves
	  on <hostid>ftp.FreeBSD.org</hostid>; however, this is the
	  least-preferred solution.
	  The distfile must be placed into
	  <filename>~/public_distfiles/</filename> of someone's
	  <hostid>freefall</hostid> account.
	  Ask the person who commits your port to do this.
	  This person will also set <makevar>MASTER_SITES</makevar> to
	  <makevar>MASTER_SITE_LOCAL</makevar> and
	  <makevar>MASTER_SITE_SUBDIR</makevar> to their
	  <hostid>freefall</hostid> username.</para>

	<para>If your port's distfile changes all the time without any
	  kind of version update by the author,
	  consider putting the distfile on your home page and listing it as
	  the first <makevar>MASTER_SITES</makevar>.  If you can, try
	  to talk the port author out of doing this; it
	  really does help to establish some kind of source code control.
	  Hosting your own version will prevent users
	  from getting <errorname>checksum mismatch</errorname> errors, and
	  also reduce the workload of maintainers of our FTP site.  Also, if
	  there is only one master site for the port, it is recommended that
	  you house a backup at your site and list it as the second
	  <makevar>MASTER_SITES</makevar>.</para>

	<para>If your port requires some additional `patches' that are
	  available on the Internet, fetch them too and put them in
	  <makevar>DISTDIR</makevar>.  Do not worry if they come from a site
	  other than where you got the main source tarball, we have a way to
	  handle these situations (see the description of <link
	    linkend="porting-patchfiles">PATCHFILES</link> below).</para>
      </sect1>

      <sect1 id="slow-modifying">
	<title>Modifying the port</title>

	<para>Unpack a copy of the tarball in a private directory and make
	  whatever changes are necessary to get the port to compile properly
	  under the current version of FreeBSD.  Keep <emphasis>careful
	    track</emphasis> of everything you do, as you will be automating
	  the process shortly.  Everything, including the deletion, addition,
	  or modification of files should be doable using an automated script
	  or patch file when your port is finished.</para>

	<para>If your port requires significant user interaction/customization
	  to compile or install, you should take a look at one of Larry Wall's
	  classic <application>Configure</application> scripts and perhaps do
	  something similar yourself.  The goal of the new ports collection is
	  to make each port as <quote>plug-and-play</quote> as possible for the
	  end-user while using a minimum of disk space.</para>

	<note>
	  <para>Unless explicitly stated, patch files, scripts, and other
	    files you have created and contributed to the FreeBSD ports
	    collection are assumed to be covered by the standard BSD copyright
	    conditions.</para>
	</note>
      </sect1>

      <sect1 id="slow-patch">
	<title>Patching</title>

	<para>In the preparation of the port, files that have been added or
	  changed can be picked up with a recursive &man.diff.1;
	  for later feeding to &man.patch.1;.  Each set of patches you
	  wish to apply should be collected into a file named
	  <filename>patch-<replaceable>*</replaceable></filename> where
	  <replaceable>*</replaceable> indicates
	  the pathnames of the files that are patched,
	  such as <filename>patch-Imakefile</filename> or
	  <filename>patch-src-config.h</filename>.  These files should
	  be stored in <makevar>PATCHDIR</makevar>, from where they will be
	  automatically applied.  All patches must be relative to
	  <makevar>WRKSRC</makevar> (generally the directory your port's
	  tarball unpacks itself into, that being where the build is done).
	  To make fixes and upgrades easier, you should avoid having more than
	  one patch fix the same file (e.g., <filename>patch-file</filename> and
	  <filename>patch-file2</filename> both changing
	  <filename><makevar>WRKSRC</makevar>/foobar.c</filename>).</para>

	<para>Please only use characters <literal>[-+._a-zA-Z0-9]</literal> for
	  naming your patches.  Do not use any other characters besides them.
	  Do not name your patches like <filename>patch-aa</filename> or
	  <filename>patch-ab</filename> etc, always mention path and file name
	  in patch names.</para>

	<para>Do not put RCS strings in patches.  CVS will mangle them when we
	  put the files into the ports tree, and when we check them out again,
	  they will come out different and the patch will fail.  RCS strings
	  are surrounded by dollar (<literal>&dollar;</literal>) signs, and
	  typically start with <literal>&dollar;Id</literal> or
	  <literal>&dollar;RCS</literal>.</para>

	<para>Using the recurse (<option>-r</option>) option to
	  &man.diff.1; to generate patches is fine, but please take
	  a look at the resulting patches to make sure you do not have any
	  unnecessary junk in there.  In particular, diffs between two backup
	  files, <filename>Makefile</filename>s when the port uses
	  <command>Imake</command> or GNU <command>configure</command>, etc.,
	  are unnecessary and should be deleted.  If you had to edit
	  <filename>configure.in</filename> and run
	  <command>autoconf</command> to regenerate
	  <command>configure</command>, do not take the diffs of
	  <command>configure</command> (it often grows to a few thousand
	  lines!); define <literal>USE_AUTOCONF_VER=213</literal> and take the
	  diffs of <filename>configure.in</filename>.</para>

	<para>Quite often, there is a situation when the software being
	  ported, especially if it is primarily developed on &windows;, uses
	  the CR/LF convention for most of its source files.  This may cause
	  problems with further patching, compiler warnings, scripts
	  execution (<command>/bin/sh^M</command> not found), etc.  To
	  quickly convert those files from CR/LF to just LF, you can do
	  something like this:</para>

	<programlisting>USE_REINPLACE=	yes

post-extract:
	@${FIND} -E ${WRKDIR} -type f -iregex ".*\.(c|cpp|h|txt)" -print0 | \
		${XARGS} -0 ${REINPLACE_CMD} -e 's/[[:cntrl:]]*$$//'</programlisting>

	<para>Of course, if you need to process each and every file,
	  <option>-iregex</option> above can be omitted.  Be aware that this
	  piece of code will strip all trailing control characters from each
	  line of processed file (except <literal>\n</literal>).</para>

	<para>Also, if you had to delete a file, then you can do it in the
	  <maketarget>post-extract</maketarget> target rather than as part of
	  the patch.  Once you are happy with the resulting diff, please split
	  it up into one source file per patch file.</para>
      </sect1>

      <sect1 id="slow-configure">
	<title>Configuring</title>

	<para>Include any additional customization commands in your
	  <filename>configure</filename> script and save it in the
	  <filename>scripts</filename> subdirectory.  As mentioned above, you
	  can also do this with <filename>Makefile</filename> targets and/or
	  scripts with the name <filename>pre-configure</filename> or
	  <filename>post-configure</filename>.</para>
      </sect1>

      <sect1 id="slow-user-input">
	<title>Handling user input</title>

	<para>If your port requires user input to build, configure, or install,
	  you must set <makevar>IS_INTERACTIVE</makevar> in your <filename>Makefile</filename>.  This
	  will allow <quote>overnight builds</quote> to skip your port if the
	  user sets the variable <envar>BATCH</envar> in his environment (and
	  if the user sets the variable <envar>INTERACTIVE</envar>, then
	  <emphasis>only</emphasis> those ports requiring interaction are
	  built).  This will save a lot of wasted time on the set of
	  machines that continually build ports (see below).</para>

	<para>It is also recommended that if there are reasonable default
	  answers to the questions, you check the
	  <makevar>PACKAGE_BUILDING</makevar> variable and turn off the
	  interactive script when it is set.  This will allow us to build the
	  packages for CDROMs and FTP.</para>
      </sect1>
    </chapter>

    <chapter id="makefile">
      <title>Configuring the Makefile</title>

      <para>Configuring the <filename>Makefile</filename> is pretty simple, and again we suggest
	that you look at existing examples before starting. Also, there is a
	<link linkend="porting-samplem">sample Makefile</link> in this
	handbook, so take a look and please follow the ordering of variables
	and sections in that template to make your port easier for others to
	read.</para>

      <para>Now, consider the following problems in sequence as you design
	your new <filename>Makefile</filename>:</para>

      <sect1 id="makefile-source">
	<title>The original source</title>

	<para>Does it live in <makevar>DISTDIR</makevar> as a standard
	  gzip'd tarball named something like
	  <filename>foozolix-1.2.tar.gz</filename>? If so, you can go on
	  to the next step.  If not, you should look at overriding any of
	  the <makevar>DISTVERSION</makevar>, <makevar>DISTNAME</makevar>,
          <makevar>EXTRACT_CMD</makevar>,
	  <makevar>EXTRACT_BEFORE_ARGS</makevar>,
	  <makevar>EXTRACT_AFTER_ARGS</makevar>,
	  <makevar>EXTRACT_SUFX</makevar>, or <makevar>DISTFILES</makevar>
	  variables, depending on how alien a format your port's
	  distribution file is.  (The most common case is
	  <literal>EXTRACT_SUFX=.tar.Z</literal>, when the tarball is
	  condensed by regular <command>compress</command>, not
	  <command>gzip</command>.)</para>

	<para>In the worst case, you can simply create your own
	  <maketarget>do-extract</maketarget> target to override the
	  default, though this should be rarely, if ever,
	  necessary.</para>
      </sect1>

    <sect1 id="makefile-naming">
      <title>Naming</title>

      <para>The first part of the port's <filename>Makefile</filename> names
	the port, describes its version number, and lists it in the correct
	category.</para>

      <sect2>
	<title><makevar>PORTNAME</makevar> and <makevar>PORTVERSION</makevar></title>

	<para>You should set <makevar>PORTNAME</makevar> to the
	  base name of your port, and <makevar>PORTVERSION</makevar>
	  to the version number of the port.</para>
      </sect2>

      <sect2 id="makefile-naming-revepoch">
	<title><makevar>PORTREVISION</makevar> and
	  <makevar>PORTEPOCH</makevar></title>

	<sect3>
	  <title><makevar>PORTREVISION</makevar></title>

	  <para>The <makevar>PORTREVISION</makevar> variable is a
	    monotonically increasing value which is reset to 0 with
	    every increase of <makevar>PORTVERSION</makevar> (i.e.
	    every time a new official vendor release is made), and
	    appended to the package name if non-zero.
	    Changes to <makevar>PORTREVISION</makevar> are
	    used by automated tools (e.g.  &man.pkg.version.1;)
	    to highlight the fact that a new package is
	    available.</para>

	  <para><makevar>PORTREVISION</makevar> should be increased
	    each time a change is made to the port which significantly
	    affects the content or structure of the derived
	    package.</para>

	  <para>Examples of when <makevar>PORTREVISION</makevar>
	    should be bumped:</para>

	  <itemizedlist>
	    <listitem>
	      <para>Addition of patches to correct security
		vulnerabilities, bugs, or to add new functionality to
		the port.</para>
	    </listitem>

	    <listitem>
	      <para>Changes to the port <filename>Makefile</filename> to enable or disable
		compile-time options in the package.</para>
	    </listitem>

	    <listitem>
	      <para>Changes in the packing list or the install-time
		behavior of the package (e.g. change to a script
		which generates initial data for the package, like ssh
		host keys).</para>
	    </listitem>

	    <listitem>
	      <para>Version bump of a port's shared library dependency
		(in this case, someone trying to install the old
		package after installing a newer version of the
		dependency will fail since it will look for the old
		libfoo.x instead of libfoo.(x+1)).</para>
	    </listitem>

	    <listitem>
	      <para>Silent changes to the port distfile which have
		significant functional differences, i.e. changes to
		the distfile requiring a correction to
		<filename>distinfo</filename> with no corresponding change to
		<makevar>PORTVERSION</makevar>, where a <command>diff
		-ru</command> of the old and new versions shows
		non-trivial changes to the code.</para>
	    </listitem>
	  </itemizedlist>

	  <para>Examples of changes which do not require a
	    <makevar>PORTREVISION</makevar> bump:</para>

	  <itemizedlist>
	    <listitem>
	      <para>Style changes to the port skeleton with no
		functional change to what appears in the resulting
		package.</para>
	    </listitem>

	    <listitem>
	      <para>Changes to <makevar>MASTER_SITES</makevar> or
		other functional changes to the port which do not
		affect the resulting package.</para>
	    </listitem>

	    <listitem>
	      <para>Trivial patches to the distfile such as correction
		of typos, which are not important enough that users of
		the package should go to the trouble of
		upgrading.</para>
	    </listitem>

	    <listitem>
	      <para>Build fixes which cause a package to become
		compilable where it was previously failing (as long as
		the changes do not introduce any functional change on
		any other platforms on which the port did previously
		build). Since <makevar>PORTREVISION</makevar> reflects
		the content of the package, if the package was not
		previously buildable then there is no need to increase
		<makevar>PORTREVISION</makevar> to mark a
		change.</para>
	    </listitem>
	  </itemizedlist>

	  <para>A rule of thumb is to ask yourself whether a change
	    committed to a port is something which everyone
	    would benefit from having (either because of an
	    enhancement, fix, or by virtue that the new package will
	    actually work at all), and weigh that against that fact
	    that it will cause everyone who regularly updates their
	    ports tree to be compelled to update. If yes, the
	    <makevar>PORTREVISION</makevar> should be bumped.</para>
	</sect3>

	<sect3>
	  <title><makevar>PORTEPOCH</makevar></title>

	  <para>From time to time a software vendor or FreeBSD porter
	    will do something silly and release a version of their
	    software which is actually numerically less than the
	    previous version. An example of this is a port which goes
	    from foo-20000801 to foo-1.0 (the former will be
	    incorrectly treated as a newer version since 20000801 is a
	    numerically greater value than 1).</para>

	  <para>In situations such as this, the
	    <makevar>PORTEPOCH</makevar> version should be increased.
	    If <makevar>PORTEPOCH</makevar> is nonzero it is appended
	    to the package name as described in section 0 above.
	    <makevar>PORTEPOCH</makevar> must never be decreased or reset
	    to zero, because that would cause comparison to a package
	    from an earlier epoch to fail (i.e. the package would not
	    be detected as out of date): the new version number (e.g.
	    <literal>1.0,1</literal> in the above example) is still
	    numerically less than the previous version (20000801), but
	    the <literal>,1</literal> suffix is treated specially by
	    automated tools and found to be greater than the implied
	    suffix <literal>,0</literal> on the earlier package.</para>

	  <para>Dropping or resetting <makevar>PORTEPOCH</makevar>
	    incorrectly leads
	    to no end of grief; if you do not understand the above discussion,
	    please keep after it until you do, or ask questions on
	    the mailing lists.</para>

	  <para>It is expected that <makevar>PORTEPOCH</makevar> will
	    not be used for the majority of ports, and that sensible
	    use of <makevar>PORTVERSION</makevar> can often pre-empt
	    it becoming necessary if a future release of the software
	    should change the version structure. However, care is
	    needed by FreeBSD porters when a vendor release is made
	    without an official version number &mdash; such as a code
	    <quote>snapshot</quote> release.  The temptation is to label the
	    release with the release date, which will cause problems
	    as in the example above when a new <quote>official</quote> release is
	    made.</para>

	  <para>For example, if a snapshot release is made on the date
	    20000917, and the previous version of the software was
	    version 1.2, the snapshot release should be given a
	    <makevar>PORTVERSION</makevar> of 1.2.20000917 or similar,
	    not 20000917, so that the succeeding release, say 1.3, is
	    still a numerically greater value.</para>
	</sect3>

	<sect3>
	  <title>Example of <makevar>PORTREVISION</makevar> and
	    <makevar>PORTEPOCH</makevar> usage</title>

	  <para>The <literal>gtkmumble</literal> port, version
	    <literal>0.10</literal>, is committed to the ports
	    collection:</para>

	  <programlisting>PORTNAME=       gtkmumble
PORTVERSION=    0.10</programlisting>

	  <para><makevar>PKGNAME</makevar> becomes
	    <literal>gtkmumble-0.10</literal>.</para>

	  <para>A security hole is discovered which requires a local
	    FreeBSD patch. <makevar>PORTREVISION</makevar> is bumped
	    accordingly.</para>

	  <programlisting>PORTNAME=       gtkmumble
PORTVERSION=    0.10
PORTREVISION=   1</programlisting>

	  <para><makevar>PKGNAME</makevar> becomes
	    <literal>gtkmumble-0.10_1</literal></para>

	  <para>A new version is released by the vendor, numbered <literal>0.2</literal>
	    (it turns out the author actually intended
	    <literal>0.10</literal> to actually mean
	    <literal>0.1.0</literal>, not <quote>what comes after
	      0.9</quote> - oops, too late now). Since the new minor
	    version <literal>2</literal> is numerically less than the
	    previous version <literal>10</literal>, the
	    <makevar>PORTEPOCH</makevar> must be bumped to manually
	    force the new package to be detected as <quote>newer</quote>. Since it
	    is a new vendor release of the code,
	    <makevar>PORTREVISION</makevar> is reset to 0 (or removed
	    from the <filename>Makefile</filename>).</para>

	  <programlisting>PORTNAME=       gtkmumble
PORTVERSION=    0.2
PORTEPOCH=      1</programlisting>

	  <para><makevar>PKGNAME</makevar> becomes
	    <literal>gtkmumble-0.2,1</literal></para>

	  <para>The next release is 0.3. Since
	    <makevar>PORTEPOCH</makevar> never decreases, the version
	    variables are now:</para>

	  <programlisting>PORTNAME=       gtkmumble
PORTVERSION=    0.3
PORTEPOCH=      1</programlisting>

	  <para><makevar>PKGNAME</makevar> becomes
	    <literal>gtkmumble-0.3,1</literal></para>

	  <note>
	    <para>If <makevar>PORTEPOCH</makevar> were reset
	      to <literal>0</literal> with this upgrade, someone who had
	      installed the <literal>gtkmumble-0.10_1</literal> package would not detect
	      the <literal>gtkmumble-0.3</literal> package as newer, since
	      <literal>3</literal> is still numerically less than
	      <literal>10</literal>.  Remember, this is the whole point of
	      <makevar>PORTEPOCH</makevar> in the first place.</para>
	  </note>
	</sect3>
      </sect2>

      <sect2>
	<title><makevar>PKGNAMEPREFIX</makevar> and <makevar>PKGNAMESUFFIX</makevar></title>

	<para>Two optional variables, <makevar>PKGNAMEPREFIX</makevar> and
	  <makevar>PKGNAMESUFFIX</makevar>, are combined with
	  <makevar>PORTNAME</makevar> and
	  <makevar>PORTVERSION</makevar> to
	  form <makevar>PKGNAME</makevar> as
	  <literal>${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}-${PORTVERSION}</literal>.
	  Make sure this conforms to our <link
	  linkend="porting-pkgname">guidelines for a good package
	  name</link>.  In particular, you are <emphasis>not</emphasis> allowed to use a
	  hyphen (<literal>-</literal>) in
	  <makevar>PORTVERSION</makevar>.  Also, if the package name
	  has the <replaceable>language-</replaceable> or the
	  <replaceable>-compiled.specifics</replaceable> part (see below), use
	  <makevar>PKGNAMEPREFIX</makevar> and
	  <makevar>PKGNAMESUFFIX</makevar>, respectively.  Do not make
	  them part of <makevar>PORTNAME</makevar>.</para>
      </sect2>

    <sect2 id="porting-pkgname">
      <title>Package Naming Conventions</title>

      <para>The following are the conventions you should follow in naming your
	packages.  This is to have our package directory easy to scan, as
	there are already thousands of packages and users are going to
	turn away if they hurt their eyes!</para>

      <para>The package name should look like
	<filename><replaceable><optional>language<optional>_region</optional></optional>-name<optional><optional>-</optional>compiled.specifics</optional>-version.numbers</replaceable></filename>.</para>

      <para>The package name is defined as
	<literal>${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}-${PORTVERSION}</literal>.
	Make sure to set the variables to conform to that format.</para>

      <orderedlist>
	<listitem>
	  <para>FreeBSD strives to support the native language of its users.
	    The <replaceable>language-</replaceable> part should be a two
	    letter abbreviation of the natural language defined by ISO-639 if
	    the port is specific to a certain language.  Examples are
	    <literal>ja</literal> for Japanese, <literal>ru</literal> for
	    Russian, <literal>vi</literal> for Vietnamese,
	    <literal>zh</literal> for Chinese, <literal>ko</literal> for
	    Korean and <literal>de</literal> for German.</para>

	  <para>If the port is specific to a certain region within the
	    language area, add the two letter country code as well.
	    Examples are <literal>en_US</literal> for US English and
	    <literal>fr_CH</literal> for Swiss French.</para>

	  <para>The <replaceable>language-</replaceable> part should
	    be set in the <makevar>PKGNAMEPREFIX</makevar> variable.</para>
	</listitem>

	<listitem>
	  <para>The first letter of <filename>name</filename> part
	    should be lowercase.  (The rest of the name can contain
	    capital letters, so use your own discretion when you are
	    converting a software name that has some capital letters in it.)
	    There is a tradition of naming <literal>perl 5</literal> modules by
	    prepending <literal>p5-</literal> and converting the double-colon
	    separator to a hyphen; for example, the
	    <literal>Data::Dumper</literal> module becomes
	    <literal>p5-Data-Dumper</literal>.  If the software in question
	    has numbers, hyphens, or underscores in its name, you may include
	    them as well (like <literal>kinput2</literal>).</para>
	</listitem>

	<listitem>
	  <para>If the port can be built with different <link
	      linkend="makefile-masterdir">hardcoded defaults</link> (usually
	    part of the directory name in a family of ports), the
	    <replaceable>-compiled.specifics</replaceable> part should state
	    the compiled-in defaults (the hyphen is optional).  Examples are
	    papersize and font units.</para>

	  <para>The <replaceable>-compiled.specifics</replaceable> part
	    should be set in the <makevar>PKGNAMESUFFIX</makevar>
	    variable.</para>
	</listitem>

	<listitem>
	  <para>The version string should follow a dash
	    (<literal>-</literal>) and be a period-separated list of
	    integers and single lowercase alphabetics.  In particular,
	    it is not permissible to have another dash inside the
	    version string.  The only exception is the string
	    <literal>pl</literal> (meaning <quote>patchlevel</quote>), which can be
	    used <emphasis>only</emphasis> when there are no major and
	    minor version numbers in the software.  If the software
	    version has strings like <quote>alpha</quote>, <quote>beta</quote>, <quote>rc</quote>, or <quote>pre</quote>, take
	    the first letter and put it immediately after a period.
	    If the version string continues after those names, the
	    numbers should follow the single alphabet without an extra
	    period between them.</para>

	  <para>The idea is to make it easier to sort ports by looking
	    at the version string.  In particular, make sure version
	    number components are always delimited by a period, and
	    if the date is part of the string, use the
	    <literal><replaceable>yyyy</replaceable>.<replaceable>mm</replaceable>.<replaceable>dd</replaceable></literal>
	    format, not
	    <literal><replaceable>dd</replaceable>.<replaceable>mm</replaceable>.<replaceable>yyyy</replaceable></literal>
	    or the non-Y2K compliant
	    <literal><replaceable>yy</replaceable>.<replaceable>mm</replaceable>.<replaceable>dd</replaceable></literal>
	    format.</para>
	</listitem>
      </orderedlist>

      <para>Here are some (real) examples on how to convert the name
	as called by the software authors to a suitable package
	name:</para>

      <informaltable frame="none" pgwide="1">
	<tgroup cols="6">
	  <thead>
	    <row>
	      <entry>Distribution Name</entry>
	      <entry><makevar>PKGNAMEPREFIX</makevar></entry>
	      <entry><makevar>PORTNAME</makevar></entry>
	      <entry><makevar>PKGNAMESUFFIX</makevar></entry>
	      <entry><makevar>PORTVERSION</makevar></entry>
	      <entry>Reason</entry>
	    </row>
	  </thead>

	  <tbody>
	    <row>
	      <entry>mule-2.2.2</entry>
	      <entry>(empty)</entry>
	      <entry>mule</entry>
	      <entry>(empty)</entry>
	      <entry>2.2.2</entry>
	      <entry>No changes required</entry>
	    </row>

	    <row>
	      <entry>XFree86-3.3.6</entry>
	      <entry>(empty)</entry>
	      <entry>XFree86</entry>
	      <entry>(empty)</entry>
	      <entry>3.3.6</entry>
	      <entry>No changes required</entry>
	    </row>

	    <row>
	      <entry>EmiClock-1.0.2</entry>
	      <entry>(empty)</entry>
	      <entry>emiclock</entry>
	      <entry>(empty)</entry>
	      <entry>1.0.2</entry>
	      <entry>No uppercase names for single programs</entry>
	    </row>

	    <row>
	      <entry>rdist-1.3alpha</entry>
	      <entry>(empty)</entry>
	      <entry>rdist</entry>
	      <entry>(empty)</entry>
	      <entry>1.3.a</entry>
	      <entry>No strings like <literal>alpha</literal>
		allowed</entry>
	    </row>

	    <row>
	      <entry>es-0.9-beta1</entry>
	      <entry>(empty)</entry>
	      <entry>es</entry>
	      <entry>(empty)</entry>
	      <entry>0.9.b1</entry>
	      <entry>No strings like <literal>beta</literal>
		allowed</entry>
	    </row>

	    <row>
	      <entry>mailman-2.0rc3</entry>
	      <entry>(empty)</entry>
	      <entry>mailman</entry>
	      <entry>(empty)</entry>
	      <entry>2.0.r3</entry>
	      <entry>No strings like <literal>rc</literal>
		allowed</entry>
	    </row>

	    <row>
	      <entry>v3.3beta021.src</entry>
	      <entry>(empty)</entry>
	      <entry>tiff</entry>
	      <entry>(empty)</entry>
	      <entry>3.3</entry>
	      <entry>What the heck was that anyway?</entry>
	    </row>

	    <row>
	      <entry>tvtwm</entry>
	      <entry>(empty)</entry>
	      <entry>tvtwm</entry>
	      <entry>(empty)</entry>
	      <entry>pl11</entry>
	      <entry>Version string always required</entry>
	    </row>

	    <row>
	      <entry>piewm</entry>
	      <entry>(empty)</entry>
	      <entry>piewm</entry>
	      <entry>(empty)</entry>
	      <entry>1.0</entry>
	      <entry>Version string always required</entry>
	    </row>

	    <row>
	      <entry>xvgr-2.10pl1</entry>
	      <entry>(empty)</entry>
	      <entry>xvgr</entry>
	      <entry>(empty)</entry>
	      <entry>2.10.1</entry>
	      <entry><literal>pl</literal> allowed only when no
		major/minor version numbers</entry>
	    </row>

	    <row>
	      <entry>gawk-2.15.6</entry>
	      <entry>ja-</entry>
	      <entry>gawk</entry>
	      <entry>(empty)</entry>
	      <entry>2.15.6</entry>
	      <entry>Japanese language version</entry>
	    </row>

	    <row>
	      <entry>psutils-1.13</entry>
	      <entry>(empty)</entry>
	      <entry>psutils</entry>
	      <entry>-letter</entry>
	      <entry>1.13</entry>
	      <entry>Papersize hardcoded at package build time</entry>
	    </row>

	    <row>
	      <entry>pkfonts</entry>
	      <entry>(empty)</entry>
	      <entry>pkfonts</entry>
	      <entry>300</entry>
	      <entry>1.0</entry>
	      <entry>Package for 300dpi fonts</entry>
	    </row>
	  </tbody>
	</tgroup>
      </informaltable>

      <para>If there is absolutely no trace of version information in the
	original source and it is unlikely that the original author will ever
	release another version, just set the version string to
	<literal>1.0</literal> (like the <literal>piewm</literal> example above).  Otherwise, ask
	the original author or use the date string
	(<literal><replaceable>yyyy</replaceable>.<replaceable>mm</replaceable>.<replaceable>dd</replaceable></literal>)
	as the version.</para>
    </sect2>
    </sect1>

    <sect1 id="makefile-categories">
      <title>Categorization</title>

      <sect2>
	<title><makevar>CATEGORIES</makevar></title>

	<para>When a package is created, it is put under
	  <filename>/usr/ports/packages/All</filename> and links are made from
	  one or more subdirectories of
	  <filename>/usr/ports/packages</filename>.  The names of these
	  subdirectories are specified by the variable
	  <makevar>CATEGORIES</makevar>.  It is intended to make life easier
	  for the user when he is wading through the pile of packages on the
	  FTP site or the CDROM.  Please take a look at the <link
	    linkend="porting-categories">current list of categories</link> and pick the ones
	  that are suitable for your port.</para>

	<para>This list also determines where in the ports tree the port is
	  imported.  If you put more than one category here, it is assumed
	  that the port files will be put in the subdirectory with the name in
	  the first category.  See <link
	    linkend="choosing-categories">below</link> for more
	  discussion about how to pick the right categories.</para>
      </sect2>

      <sect2 id="porting-categories">
	<title>Current list of categories</title>

	<para>Here is the current list of port categories.  Those
	  marked with an asterisk (<literal>*</literal>) are
	  <emphasis>virtual</emphasis> categories&mdash;those that do not have
	  a corresponding subdirectory in the ports tree.  They are only
	  used as secondary categories, and only for search purposes.</para>

	<note>
	  <para>For non-virtual categories, you will find a one-line
	    description in the <makevar>COMMENT</makevar> in that
	    subdirectory's <filename>Makefile</filename>.</para>
	</note>

	<informaltable frame="none" pgwide="1">
	  <tgroup cols="3">
	    <thead>
	      <row>
		<entry>Category</entry>
		<entry>Description</entry>
		<entry>Notes</entry>
	      </row>
	    </thead>

	    <tbody>
	      <row>
		<entry><filename>accessibility</filename></entry>
		<entry>Ports to help disabled users.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>afterstep*</filename></entry>
		<entry>Ports to support the
		  <ulink url="http://www.afterstep.org">AfterStep</ulink>
		  window manager.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>arabic</filename></entry>
		<entry>Arabic language support.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>archivers</filename></entry>
		<entry>Archiving tools.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>astro</filename></entry>
		<entry>Astronomical ports.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>audio</filename></entry>
		<entry>Sound support.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>benchmarks</filename></entry>
		<entry>Benchmarking utilities.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>biology</filename></entry>
		<entry>Biology-related software.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>cad</filename></entry>
		<entry>Computer aided design tools.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>chinese</filename></entry>
		<entry>Chinese language support.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>comms</filename></entry>
		<entry>Communication software.</entry>
		<entry>Mostly software to talk to your serial port.</entry>
	      </row>

	      <row>
		<entry><filename>converters</filename></entry>
		<entry>Character code converters.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>databases</filename></entry>
		<entry>Databases.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>deskutils</filename></entry>
		<entry>Things that used to be on the desktop before
		  computers were invented.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>devel</filename></entry>
		<entry>Development utilities.</entry>
		<entry>Do not put libraries here just because they are
		  libraries&mdash;unless they truly do not belong anywhere
		  else, they should not be in this category.</entry>
	      </row>

	      <row>
		<entry><filename>dns</filename></entry>
		<entry>DNS-related software.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>editors</filename></entry>
		<entry>General editors.</entry>
		<entry>Specialized editors go in the section for those
		  tools (e.g., a mathematical-formula editor will go
		  in <filename>math</filename>).</entry>
	      </row>

	      <row>
		<entry><filename>elisp*</filename></entry>
		<entry>Emacs-lisp ports.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>emulators</filename></entry>
		<entry>Emulators for other operating systems.</entry>
		<entry>Terminal emulators do <emphasis>not</emphasis> belong
		  here&mdash;X-based ones should go to
		  <filename>x11</filename> and text-based ones to either
		  <filename>comms</filename> or <filename>misc</filename>,
		  depending on the exact functionality.</entry>
	      </row>

	      <row>
		<entry><filename>finance</filename></entry>
		<entry>Monetary, financial and related applications.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>french</filename></entry>
		<entry>French language support.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>ftp</filename></entry>
		<entry>FTP client and server utilities.</entry>
		<entry>If your port speaks both FTP and HTTP, put it in
		  <filename>ftp</filename> with a secondary
		  category of <filename>www</filename>.</entry>
	      </row>

	      <row>
		<entry><filename>games</filename></entry>
		<entry>Games.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>german</filename></entry>
		<entry>German language support.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>gnome*</filename></entry>
		<entry>Ports from the <ulink
		  url="http://www.gnome.org">GNOME</ulink>
		  Project.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>graphics</filename></entry>
		<entry>Graphics utilities.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>haskell*</filename></entry>
		<entry>Software related to the Haskell language.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>hebrew</filename></entry>
		<entry>Hebrew language support.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>hungarian</filename></entry>
		<entry>Hungarian language support.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>ipv6*</filename></entry>
		<entry>IPv6 related software.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>irc</filename></entry>
		<entry>Internet Relay Chat utilities.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>japanese</filename></entry>
		<entry>Japanese language support.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>java</filename></entry>
		<entry>Software related to the Java language.</entry>
		<entry>The <filename>java</filename> category shall not be
		  the only one for a port. Save for ports directly related to
		  the Java language, porters are also encouraged not to
		  use <filename>java</filename> as the main category of a
		  port.</entry>
	      </row>

	      <row>
		<entry><filename>kde*</filename></entry>
		<entry>Ports from the <ulink url="http://www.kde.org">K Desktop Environment (KDE)</ulink>
		  Project.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>korean</filename></entry>
		<entry>Korean language support.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>lang</filename></entry>
		<entry>Programming languages.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>linux*</filename></entry>
		<entry>Linux applications and support utilities.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>lisp*</filename></entry>
		<entry>Software related to the Lisp language.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>mail</filename></entry>
		<entry>Mail software.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>math</filename></entry>
		<entry>Numerical computation software and other utilities
		  for mathematics.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>mbone</filename></entry>
		<entry>MBone applications.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>misc</filename></entry>
		<entry>Miscellaneous utilities</entry>
		<entry>Basically things that
		  do not belong anywhere else.
		  If at all possible, try to
		  find a better category for your port than
		  <literal>misc</literal>, as ports tend to get overlooked
		  in here.</entry>
	      </row>

	      <row>
		<entry><filename>multimedia</filename></entry>
		<entry>Multimedia software.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>net</filename></entry>
		<entry>Miscellaneous networking software.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>net-mgmt</filename></entry>
		<entry>Networking management software.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>news</filename></entry>
		<entry>USENET news software.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>offix*</filename></entry>
		<entry>Ports from the <ulink url="http://leb.net/offix/">OffiX</ulink> suite.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>palm</filename></entry>
		<entry>Software support for the <ulink url="http://www.palm.com/">Palm&trade;</ulink> series.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>parallel*</filename></entry>
		<entry>Applications dealing with parallelism in computing.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>pear*</filename></entry>
		<entry>Ports related to the Pear PHP framework.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>perl5*</filename></entry>
		<entry>Ports that require <application>Perl</application> version 5 to run.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>plan9*</filename></entry>
		<entry>Various programs from <ulink url="http://www.cs.bell-labs.com/plan9dist/">Plan9</ulink>.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>polish</filename></entry>
		<entry>Polish language support.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>portuguese</filename></entry>
		<entry>Portuguese language support.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>print</filename></entry>
		<entry>Printing software.</entry>
		<entry>Desktop publishing tools
		  (previewers, etc.) belong here too.</entry>
	      </row>

	      <row>
		<entry><filename>python*</filename></entry>
		<entry>Software related to the <ulink url="http://www.python.org/">Python</ulink> language.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>ruby*</filename></entry>
		<entry>Software related to the <ulink url="http://www.ruby-lang.org/">Ruby</ulink> language.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>russian</filename></entry>
		<entry>Russian language support.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>scheme*</filename></entry>
		<entry>Software related to the Scheme language.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>science</filename></entry>
		<entry>Scientific ports that do not fit into other
		  categories such as <filename>astro</filename>,
		  <filename>biology</filename> and
		  <filename>math</filename>.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>security</filename></entry>
		<entry>Security utilities.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>shells</filename></entry>
		<entry>Command line shells.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>sysutils</filename></entry>
		<entry>System utilities.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>tcl80*</filename></entry>
		<entry>Ports that use Tcl version 8.0 to run.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>tcl81*</filename></entry>
		<entry>Ports that use Tcl version 8.1 to run.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>tcl82*</filename></entry>
		<entry>Ports that use Tcl version 8.2 to run.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>tcl83*</filename></entry>
		<entry>Ports that use Tcl version 8.3 to run.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>tcl84*</filename></entry>
		<entry>Ports that use Tcl version 8.4 to run.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>textproc</filename></entry>
		<entry>Text processing utilities.</entry>
		<entry>It does not include
		  desktop publishing tools, which go to <filename>print</filename>.</entry>
	      </row>

	      <row>
		<entry><filename>tk80*</filename></entry>
		<entry>Ports that use Tk version 8.0 to run.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>tk82*</filename></entry>
		<entry>Ports that use Tk version 8.2 to run.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>tk83*</filename></entry>
		<entry>Ports that use Tk version 8.3 to run.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>tk84*</filename></entry>
		<entry>Ports that use Tk version 8.4 to run.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>tkstep80*</filename></entry>
		<entry>Ports that use TkSTEP version 8.0 to run.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>ukrainian</filename></entry>
		<entry>Ukrainian language support.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>vietnamese</filename></entry>
		<entry>Vietnamese language support.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>windowmaker*</filename></entry>
		<entry>Ports to support the WindowMaker window
		  manager.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>www</filename></entry>
		<entry>Software related to the World Wide Web.</entry>
		<entry>HTML language
		  support belongs here too.</entry>
	      </row>

	      <row>
		<entry><filename>x11</filename></entry>
		<entry>The X Window System and friends.</entry>
		<entry>This category is only
		  for software that directly supports the window system.  Do not
		  put regular X applications here; most of them should go
		  into other <filename>x11-*</filename> categories (see below).
		  If your port <emphasis>is</emphasis> an X
		  application, define <makevar>USE_XLIB</makevar> (implied by
		  <makevar>USE_IMAKE</makevar>) and put it in the appropriate
		  category.</entry>
	      </row>

	      <row>
		<entry><filename>x11-clocks</filename></entry>
		<entry>X11 clocks.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>x11-fm</filename></entry>
		<entry>X11 file managers.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>x11-fonts</filename></entry>
		<entry>X11 fonts and font utilities.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>x11-servers</filename></entry>
		<entry>X11 servers.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>x11-themes</filename></entry>
		<entry>X11 themes.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>x11-toolkits</filename></entry>
		<entry>X11 toolkits.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>x11-wm</filename></entry>
		<entry>X11 window managers.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>xfce*</filename></entry>
		<entry>Ports relating to the
		  <ulink url="http://www.xfce.org/">Xfce</ulink> desktop
		  environment.</entry>
		<entry></entry>
	      </row>

	      <row>
		<entry><filename>zope*</filename></entry>
		<entry><ulink url="http://www.zope.org/">Zope</ulink> support.</entry>
		<entry></entry>
	      </row>
	    </tbody>
	  </tgroup>
	</informaltable>
      </sect2>

      <sect2 id="choosing-categories">
	<title>Choosing the right category</title>

	<para>As many of the categories overlap, you often have to choose
	  which of the categories should be the primary category of your port.
	  There are several rules that govern this issue.  Here is the list of
	  priorities, in decreasing order of precedence:</para>

	<itemizedlist>
	  <listitem>
	    <para>The first category must be a physical category (see
	      <link linkend="porting-categories">above</link>).  This is
	      necessary to make the packaging work.  Virtual categories and
	      physical categories may be intermixed after that.</para>
	  </listitem>

	  <listitem>
	    <para>Language specific categories always come first.  For
	      example, if your port installs Japanese X11 fonts, then your
	      <makevar>CATEGORIES</makevar> line would read <filename>japanese
		x11-fonts</filename>.</para>
	  </listitem>

	  <listitem>
	    <para>Specific categories are listed before less-specific ones.  For
	      instance, an HTML editor should be listed as <filename>www
		editors</filename>, not the other way around.  Also, you should not
	      list <filename>net</filename> when the port belongs to
	      any of <filename>irc</filename>, <filename>mail</filename>,
	      <filename>mbone</filename>, <filename>news</filename>,
	      <filename>security</filename>, or <filename>www</filename>, as
	      <filename>net</filename> is included implicitly.</para>
	  </listitem>

	  <listitem>
	    <para><filename>x11</filename> is used as a secondary category only
	      when the primary category is a natural language.  In particular,
	      you should not put <filename>x11</filename> in the category line
	      for X applications.</para>
	  </listitem>

	  <listitem>
	    <para><application>Emacs</application> modes should be
	      placed in the same ports category as the application
	      supported by the mode, not in
	      <filename>editors</filename>.  For example, an
	      <application>Emacs</application> mode to edit source
	      files of some programming language should go into
	      <filename>lang</filename>.
	      </para>
	  </listitem>

	  <listitem>
	    <para><filename>misc</filename>
		  should not appear with any other non-virtual category.
		  If you have <literal>misc</literal> with something else in
		  your <makevar>CATEGORIES</makevar> line, that means you can
		  safely delete <literal>misc</literal> and just put the port
		  in that other subdirectory!</para>
	  </listitem>

	  <listitem>
	    <para>If your port truly does not belong anywhere else, put it in
	      <filename>misc</filename>.</para>
	  </listitem>
	</itemizedlist>

	<para>If you are not sure about the category, please put a comment to
	  that effect in your &man.send-pr.1; submission so we can
	  discuss it before we import it.  If you are a committer, send a note
	  to the &a.ports; so we can discuss it first.  Too often, new ports are
	  imported to the wrong category only to be moved right away.
	  This causes unnecessary and undesirable bloat in the master
	  source repository.</para>
      </sect2>

      <sect2 id="proposing-categories">
	<title>Proposing a new category</title>

	<para>As the Ports Collection has grown over time, various new
	  categories have been introduced.  New categories can either
	  be <emphasis>virtual</emphasis> categories&mdash;those that do
	  not have a corresponding subdirectory in the ports tree&mdash;
	  or <emphasis>physical</emphasis> categories&mdash;those that
	  do.  The following text discusses the issues involved in creating
	  a new physical category so that you can understand them before
	  you propose one.</para>

	<para>Our existing practice has been to avoid creating a new
	  physical category unless either a large number of ports would
	  logically belong to it, or the ports that would belong to it
	  are a logically distinct group that is of limited general
	  interest (for instance, categories related to spoken human
	  languages), or preferably both.</para>

	<para>The rationale for this is that such a change creates a
	  <ulink url="&url.articles.committers-guide;/#ports">
	  fair amount of work</ulink> for both the committers and also
	  for all users who track changes to the Ports Collection.  In
	  addition, proposed category changes just naturally seem to
	  attract controversy.  (Perhaps this is because there is no
	  clear consensus on when a category is <quote>too big</quote>,
	  nor whether categories should lend themselves to browsing (and
	  thus what number of categories would be an ideal number), and
	  so forth.)</para>

	<para>Here is the procedure:</para>

	<procedure>
	  <step>
	    <para>Propose the new category on &a.ports;.  You should
	      include a detailed rationale for the new category,
	      including why you feel the existing categories are not
	      sufficient, and the list of existing ports proposed to move.
	      (If there are new ports pending in
	      <application>GNATS</application> that would fit this
	      category, list them too.)  If you are the maintainer and/or
	      submitter, respectively, mention that as it may help you
	      to make your case.</para>
	  </step>

	  <step>
	    <para>Participate in the discussion.</para>
	  </step>

	  <step>
	    <para>If it seems that there is support for your idea,
	      file a PR which includes both the rationale and the list
	      of existing ports that need to be moved.  Ideally, this
	      PR should also include patches for the following:</para>

	    <itemizedlist>
	      <listitem>
		<para><filename>Makefile</filename>s for the
		  new ports once they are repocopied</para>
	      </listitem>

	      <listitem>
		<para><filename>Makefile</filename> for the
		  new category</para>
	      </listitem>

	      <listitem>
		<para><filename>Makefile</filename> for the
		  old ports' categories</para>
	      </listitem>

	      <listitem>
		<para><filename>Makefile</filename>s for ports
		  that depend on the old ports</para>
	      </listitem>

	      <listitem>
		<para>(for extra credit, you can include the other
		  files that have to change, as per the procedure
		  in the Committer's Guide.)</para>
	      </listitem>
	    </itemizedlist>
	  </step>

	  <step>
	    <para>Since it affects the ports infrastructure and involves
	      not only performing repo-copies but also possibly running
	      regression tests on the build cluster, the PR should be
	      assigned to the &a.portmgr;.</para>
	  </step>

	  <step>
	    <para>If that PR is approved, a committer will need to follow
	      the rest of the procedure that is
	      <ulink url="&url.articles.committers-guide;/#ports">
	      outlined in the Committer's Guide</ulink>.</para>
	  </step>
	</procedure>

	<para>Proposing a new virtual category should be similar to
	  the above but much less involved, since no ports will
	  actually have to move.  In this case, the only patches to
	  include in the PR would be those to add the new category to the
	  <makevar>CATEGORIES</makevar>s of the affected ports.</para>
      </sect2>

      <sect2 id="proposing-reorg">
	<title>Proposing reorganizing all the categories</title>

	<para>Occasionally someone proposes reorganizing the categories
	  with either a 2-level structure, or some other kind of keyword
	  structure.  To date, nothing has come of any of these proposals
	  because, while they are very easy to make, the effort involved to
	  retrofit the entire existing ports collection with any kind of
	  reorganization is daunting to say the very least.  Please read
	  the history of these proposals in the mailing list archives before
	  you post this idea; furthermore, you should be prepared to be
	  challenged to offer a working prototype.</para>
      </sect2>
    </sect1>

    <sect1 id="makefile-distfiles">
      <title>The distribution files</title>

      <para>The second part of the <filename>Makefile</filename> describes the
	files that must be downloaded in order to build the port, and where
	they can be downloaded from.</para>

      <sect2>
	<title><makevar>DISTVERSION/DISTNAME</makevar></title>

	<para><makevar>DISTNAME</makevar> is the name of the port as
	  called by the authors of the software.
	  <makevar>DISTNAME</makevar> defaults to
	  <literal>${PORTNAME}-${PORTVERSION}</literal>, so override it only if necessary.
	  <makevar>DISTNAME</makevar> is only used in two places.
	  First, the distribution file list
	  (<makevar>DISTFILES</makevar>) defaults to
	  <makevar>${DISTNAME}</makevar><makevar>${EXTRACT_SUFX}</makevar>.
	  Second, the distribution file is expected to extract into a
	  subdirectory named <makevar>WRKSRC</makevar>, which defaults
	  to <filename>work/<makevar>${DISTNAME}</makevar></filename>.</para>

        <para>Some vendor's distribution names which do not fit into the
	  <literal>${PORTNAME}-${PORTVERSION}</literal>-scheme can be handled
	  automatically by setting <makevar>DISTVERSION</makevar>.
	  <makevar>PORTVERSION</makevar> and <makevar>DISTNAME</makevar> will be
	  derived automatically, but can of course be overridden.  The following
	  table lists some examples:</para>

	<informaltable frame="none" pgwide="1">
	  <tgroup cols="2">
	    <thead>
	      <row>
		<entry><makevar>DISTVERSION</makevar></entry>
		<entry><makevar>PORTVERSION</makevar></entry>
	      </row>
	    </thead>

	    <tbody>
	      <row>
		<entry>0.7.1d</entry>
		<entry>0.7.1.d</entry>
	      </row>
	      <row>
		<entry>10Alpha3</entry>
		<entry>10.a3</entry>
	      </row>
	      <row>
		<entry>3Beta7-pre2</entry>
		<entry>3.b7.p2</entry>
	      </row>
	      <row>
		<entry>8:f_17</entry>
		<entry>8f.17</entry>
	      </row>
	    </tbody>
	  </tgroup>
	</informaltable>

	<note>
	  <para><makevar>PKGNAMEPREFIX</makevar> and
	    <makevar>PKGNAMESUFFIX</makevar> do not affect
	    <makevar>DISTNAME</makevar>.  Also note that if
	    <makevar>WRKSRC</makevar> is equal to
	    <filename>work/<makevar>${PORTNAME}-${PORTVERSION}</makevar></filename>
	    while the original source archive is named something other than
	    <makevar>${PORTNAME}-${PORTVERSION}${EXTRACT_SUFX}</makevar>,
	    you should probably leave <makevar>DISTNAME</makevar>
	    alone&mdash; you are better off defining
	    <makevar>DISTFILES</makevar> than having to set both
	    <makevar>DISTNAME</makevar> and <makevar>WRKSRC</makevar>
	    (and possibly <makevar>EXTRACT_SUFX</makevar>).</para>
	</note>
      </sect2>

      <sect2>
	<title><makevar>MASTER_SITES</makevar></title>

	<para>Record the directory part of the FTP/HTTP-URL pointing at the
	  original tarball in <makevar>MASTER_SITES</makevar>.  Do not forget
	  the trailing slash (<filename>/</filename>)!</para>

	<para>The <command>make</command> macros will try to use this
	  specification for grabbing the distribution file with
	  <makevar>FETCH</makevar> if they cannot find it already on the
	  system.</para>

	<para>It is recommended that you put multiple sites on this list,
	  preferably from different continents.  This will safeguard against
	  wide-area network problems.  We are even planning to add support
	  for automatically determining the closest master site and fetching
	  from there; having multiple sites will go a long way towards
	  helping this effort.</para>

	<para>If the original tarball is part of one of the popular
	  archives such as X-contrib, GNU, or Perl CPAN, you may be able
	  refer to those sites in an easy compact form using
	  <makevar>MASTER_SITE_<replaceable>*</replaceable></makevar>
	  (e.g., <makevar>MASTER_SITE_XCONTRIB</makevar> and
	  <makevar>MASTER_SITE_PERL_GNU</makevar>).  Simply set
	  <makevar>MASTER_SITES</makevar> to one of these variables and
	  <makevar>MASTER_SITE_SUBDIR</makevar> to the path within the
	  archive.  Here is an example:</para>

	<programlisting>MASTER_SITES=         ${MASTER_SITE_XCONTRIB}
MASTER_SITE_SUBDIR=   applications</programlisting>

	<para>These variables are defined in
	  <filename>/usr/ports/Mk/bsd.sites.mk</filename>.  There are
	  new entries added all the time, so make sure to check the
	  latest version of this file before submitting a port.</para>

	<para>The user can also set the <makevar>MASTER_SITE_*</makevar>
	  variables in <filename>/etc/make.conf</filename> to override our
	  choices, and use their favorite mirrors of these popular archives
	  instead.</para>
      </sect2>

      <sect2>
	<title><makevar>EXTRACT_SUFX</makevar></title>

	<para>If you have one distribution file, and it uses an odd suffix to
	  indicate the compression mechanism, set
	  <makevar>EXTRACT_SUFX</makevar>.</para>

	<para>For example, if the distribution file was named
	  <filename>foo.tgz</filename> instead of the more normal
	  <filename>foo.tar.gz</filename>, you would write:</para>

	<programlisting>DISTNAME=      foo
EXTRACT_SUFX=  .tgz</programlisting>

	<para>The <makevar>USE_BZIP2</makevar> and <makevar>USE_ZIP</makevar>
	  variables automatically set <makevar>EXTRACT_SUFX</makevar> to
	  <literal>.tar.bz2</literal> or <literal>.zip</literal> as necessary.  If
	  neither of these are set then <makevar>EXTRACT_SUFX</makevar>
	  defaults to <literal>.tar.gz</literal>.</para>

	<note>
	  <para>You never need to set both <makevar>EXTRACT_SUFX</makevar> and
	    <makevar>DISTFILES</makevar>.</para>
	</note>
      </sect2>

      <sect2>
	<title><makevar>DISTFILES</makevar></title>

	<para>Sometimes the names of the files to be downloaded have no
	  resemblance to the name of the port.  For example, it might be
	  called <filename>source.tar.gz</filename> or similar.  In other
	  cases the application's source code might be in several different
	  archives, all of which must be downloaded.</para>

	<para>If this is the case, set <makevar>DISTFILES</makevar> to be a
	  space separated list of all the files that must be
	  downloaded.</para>

	<programlisting>DISTFILES=     source1.tar.gz source2.tar.gz</programlisting>

	<para>If not explicitly set, <makevar>DISTFILES</makevar> defaults to
	  <literal>${DISTNAME}${EXTRACT_SUFX}</literal>.</para>
      </sect2>

      <sect2>
	<title><makevar>EXTRACT_ONLY</makevar></title>

	<para>If only some of the <makevar>DISTFILES</makevar> must be
	  extracted&mdash;for example, one of them is the source code, while
	  another is an uncompressed document&mdash;list the filenames that
	  must be extracted in <makevar>EXTRACT_ONLY</makevar>.</para>

	<programlisting>DISTFILES=     source.tar.gz manual.html
EXTRACT_ONLY=  source.tar.gz</programlisting>

	<para>If <emphasis>none</emphasis> of the <makevar>DISTFILES</makevar>
	  should be uncompressed then set <makevar>EXTRACT_ONLY</makevar> to
	  the empty string.</para>

	<programlisting>EXTRACT_ONLY=</programlisting>
      </sect2>

      <sect2 id="porting-patchfiles">
	<title><makevar>PATCHFILES</makevar></title>

	<para>If your port requires some additional patches that are available
	  by FTP or HTTP, set <makevar>PATCHFILES</makevar> to the names of
	  the files and <makevar>PATCH_SITES</makevar> to the URL of the
	  directory that contains them (the format is the same as
	  <makevar>MASTER_SITES</makevar>).</para>

	<para>If the patch is not relative to the top of the source tree
	  (i.e., <makevar>WRKSRC</makevar>) because it contains some extra
	  pathnames, set <makevar>PATCH_DIST_STRIP</makevar> accordingly. For
	  instance, if all the pathnames in the patch have an extra
	  <literal>foozolix-1.0/</literal> in front of the filenames, then set
	  <literal>PATCH_DIST_STRIP=-p1</literal>.</para>

	<para>Do not worry if the patches are compressed; they will be
	  decompressed automatically if the filenames end with
	  <filename>.gz</filename> or <filename>.Z</filename>.</para>

	<para>If the patch is distributed with some other files, such as
	  documentation, in a gzip'd tarball, you cannot just use
	  <makevar>PATCHFILES</makevar>.  If that is the case, add the name
	  and the location of the patch tarball to
	  <makevar>DISTFILES</makevar> and <makevar>MASTER_SITES</makevar>.
	  Then, use the <makevar>EXTRA_PATCHES</makevar> variable to
	  point to those files and <filename>bsd.port.mk</filename>
	  will automatically apply them for you.  In particular, do
	  <emphasis>not</emphasis> copy patch files into the
	  <makevar>PATCHDIR</makevar> directory&mdash;that directory may
	  not be writable.</para>

	<note>
	  <para>The tarball will have been extracted alongside the
	    regular source by then, so there is no need to explicitly extract
	    it if it is a regular gzip'd or compress'd tarball. If you do the
	    latter, take extra care not to overwrite something that already
	    exists in that directory.  Also, do not forget to add a command to
	    remove the copied patch in the <maketarget>pre-clean</maketarget>
	    target.</para>
	</note>
      </sect2>

      <sect2 id="porting-master-sites-n">
	<title>Multiple distribution files or patches from different
	  sites and subdirectories
	  (<literal>MASTER_SITES:n</literal>)</title>

	<para>(Consider this to be a somewhat <quote>advanced topic</quote>;
	  those new to this document may wish to skip this section at first).
	  </para>

	<para>This section has information on the fetching mechanism
	  known as both <literal>MASTER_SITES:n</literal> and
	  <literal>MASTER_SITES_NN</literal>.  We will refer to this
	  mechanism as <literal>MASTER_SITES:n</literal>
	  hereon.</para>

	<para>A little background first.  OpenBSD has a neat feature
	  inside both <makevar>DISTFILES</makevar> and
	  <makevar>PATCHFILES</makevar> variables, both files and
	  patches can be postfixed with <literal>:n</literal>
	  identifiers where <literal>n</literal> both can be
	  <literal>[0-9]</literal> and denote a group designation.
	  For example:</para>

	<programlisting>DISTFILES=      alpha:0 beta:1</programlisting>

	<para>In OpenBSD, distribution file <filename>alpha</filename>
	  will be associated with variable
	  <makevar>MASTER_SITES0</makevar> instead of our common
	  <makevar>MASTER_SITES</makevar> and
	  <filename>beta</filename> with
	  <makevar>MASTER_SITES1</makevar>.</para>

	<para>This is a very interesting feature which can decrease
	  that endless search for the correct download site.</para>

	<para>Just picture 2 files in <makevar>DISTFILES</makevar> and
	  20 sites in <makevar>MASTER_SITES</makevar>, the sites slow
	  as hell where <filename>beta</filename> is carried by all
	  sites in <makevar>MASTER_SITES</makevar>, and
	  <filename>alpha</filename> can only be found in the 20th
	  site.  It would be such a waste to check all of them if
	  maintainer knew this beforehand, would it not?  Not a good
	  start for that lovely weekend!</para>

	<para>Now that you have the idea, just imagine more
	  <makevar>DISTFILES</makevar> and more
	  <makevar>MASTER_SITES</makevar>.  Surely our
	  <quote>distfiles survey meister</quote> would appreciate the
	  relief to network strain that this would bring.</para>

	<para>In the next sections, information will follow on the
	  FreeBSD implementation of this idea.	We improved a bit on
	  OpenBSD's concept.</para>

	<sect3>
	  <title>Simplified information</title>

	  <para>This section tells you how to quickly prepare fine
	    grained fetching of multiple distribution files and
	    patches from different sites and subdirectories.  We
	    describe here a case of simplified
	    <literal>MASTER_SITES:n</literal> usage.  This will be
	    sufficient for most scenarios.  However, if you need
	    further information, you will have to refer to the next
	    section.</para>

	  <para>Some applications consist of multiple distribution
	    files that must be downloaded from a number of different
	    sites.  For example,
	    <application>Ghostscript</application> consists of the
	    core of the program, and then a large number of driver
	    files that are used depending on the user's printer.  Some
	    of these driver files are supplied with the core, but many
	    others must be downloaded from a variety of different
	    sites.</para>

	  <para>To support this, each entry in
	    <makevar>DISTFILES</makevar> may be followed by a colon
	    and a <quote>tag name</quote>.  Each site listed in
	    <makevar>MASTER_SITES</makevar> is then followed by a
	    colon, and the tag that indicates which distribution files
	    should be downloaded from this site.</para>

	  <para>For example, consider an application with the source
	    split in two parts, <filename>source1.tar.gz</filename>
	    and <filename>source2.tar.gz</filename>, which must be
	    downloaded from two different sites.  The port's
	    <filename>Makefile</filename> would include lines like
	    <xref
	      linkend="ports-master-sites-n-example-simple-use-one-file-per-site">.</para>

	  <example
	    id="ports-master-sites-n-example-simple-use-one-file-per-site">
	    <title>Simplified use of <literal>MASTER_SITES:n</literal>
	      with 1 file per site</title>

	    <programlisting>MASTER_SITES=   ftp://ftp.example1.com/:source1 \
		ftp://ftp.example2.com/:source2
DISTFILES=      source1.tar.gz:source1 \
		source2.tar.gz:source2</programlisting>
	  </example>

	  <para>Multiple distribution files can have the same tag.
	    Continuing the previous example, suppose that there was a
	    third distfile, <filename>source3.tar.gz</filename>, that
	    should be downloaded from
	    <hostid>ftp.example2.com</hostid>.	The
	    <filename>Makefile</filename> would then be written like
	    <xref
	      linkend="ports-master-sites-n-example-simple-use-more-than-one-file-per-site">.</para>

	  <example
	    id="ports-master-sites-n-example-simple-use-more-than-one-file-per-site">
	    <title>Simplified use of <literal>MASTER_SITES:n</literal>
	      with more than 1 file per site</title>

	    <programlisting>MASTER_SITES=   ftp://ftp.example1.com/:source1 \
		ftp://ftp.example2.com/:source2
DISTFILES=      source1.tar.gz:source1 \
		source2.tar.gz:source2 \
		source3.tar.gz:source2</programlisting>
	  </example>
	</sect3>

	<sect3>
	  <title>Detailed information</title>

	  <para>Okay, so the previous section example did not reflect
	    your needs?	 In this section we will explain in detail how
	    the fine grained fetching mechanism
	    <literal>MASTER_SITES:n</literal> works and how you can
	    modify your ports to use it.</para>

	  <orderedlist>
	    <listitem>
	      <para>Elements can be postfixed with
		<literal>:<replaceable>n</replaceable></literal> where
		<replaceable>n</replaceable> is
		<literal>[^:,]+</literal>, i.e.,
		<replaceable>n</replaceable> could conceptually be any
		alphanumeric string but we will limit it to
		<literal>[a-zA-Z_][0-9a-zA-Z_]+</literal> for
		now.</para>

	      <para>Moreover, string matching is case sensitive;
		i.e., <literal>n</literal> is different from
		<literal>N</literal>.</para>

	      <para>However, the following words cannot be used for
		postfixing purposes since they yield special meaning:
		<literal>default</literal>, <literal>all</literal> and
		<literal>ALL</literal> (they are used internally in
		item <xref
		  linkend="porting-master-sites-n-what-changes-in-port-targets">).
		Furthermore, <literal>DEFAULT</literal> is a special
		purpose word (check item <xref
		  linkend="porting-master-sites-n-DEFAULT-group">).</para>
	    </listitem>

	    <listitem>
	      <para>Elements postfixed with <literal>:n</literal>
		belong to the group <literal>n</literal>,
		<literal>:m</literal> belong to group
		<literal>m</literal> and so forth.</para>
	    </listitem>

	    <listitem id="porting-master-sites-n-DEFAULT-group">
	      <para>Elements without a postfix are groupless, i.e.,
		they all belong to the special group
		<literal>DEFAULT</literal>.  If you postfix any
		elements with <literal>DEFAULT</literal>, you are just
		being redundant unless you want to have an element
		belonging to both <literal>DEFAULT</literal> and other
		groups at the same time (check item <xref
		  linkend="porting-master-sites-n-comma-operator">).</para>

	      <para>The following examples are equivalent but the
		first one is preferred:</para>

	      <programlisting>MASTER_SITES=   alpha

MASTER_SITES=   alpha:DEFAULT</programlisting>
	    </listitem>

	    <listitem>
	      <para>Groups are not exclusive, an element may belong to
		several different groups at the same time and a group
		can either have either several different elements or
		none at all.  Repeated elements within the same group
		will be simply that, repeated elements.</para>
	    </listitem>

	    <listitem id="porting-master-sites-n-comma-operator">
	      <para>When you want an element to belong to several
		groups at the same time, you can use the comma
		operator (<literal>,</literal>).</para>

	      <para>Instead of repeating it several times, each time
		with a different postfix, we can list several groups
		at once in a single postfix.  For instance,
		<literal>:m,n,o</literal> marks an element that
		belongs to group <literal>m</literal>,
		<literal>n</literal> and <literal>o</literal>.</para>

	      <para>All the following examples are equivalent but the
		last one is preferred:</para>

	      <programlisting>MASTER_SITES=   alpha alpha:SOME_SITE

MASTER_SITES=   alpha:DEFAULT alpha:SOME_SITE

MASTER_SITES=   alpha:SOME_SITE,DEFAULT

MASTER_SITES=   alpha:DEFAULT,SOME_SITE</programlisting>
	    </listitem>

	    <listitem>
	      <para>All sites within a given group are sorted
		according to <makevar>MASTER_SORT_AWK</makevar>.  All
		groups within <makevar>MASTER_SITES</makevar> and
		<makevar>PATCH_SITES</makevar> are sorted as
		well.</para>
	    </listitem>

	    <listitem id="porting-master-sites-n-group-semantics">
	      <para>Group semantics can be used in any of the
		following variables <makevar>MASTER_SITES</makevar>,
		<makevar>PATCH_SITES</makevar>,
		<makevar>MASTER_SITE_SUBDIR</makevar>,
		<makevar>PATCH_SITE_SUBDIR</makevar>,
		<makevar>DISTFILES</makevar>, and
		<makevar>PATCHFILES</makevar> according to the
		following syntax:</para>

	      <orderedlist>
		<listitem>
		  <para>All <makevar>MASTER_SITES</makevar>,
		    <makevar>PATCH_SITES</makevar>,
		    <makevar>MASTER_SITE_SUBDIR</makevar> and
		    <makevar>PATCH_SITE_SUBDIR</makevar> elements must
		    be terminated with the forward slash
		    <literal>/</literal> character.  If any elements
		    belong to any groups, the group postfix
		    <literal>:<replaceable>n</replaceable></literal>
		    must come right after the terminator
		    <literal>/</literal>.  The
		    <literal>MASTER_SITES:n</literal> mechanism relies
		    on the existence of the terminator
		    <literal>/</literal> to avoid confusing elements
		    where a <literal>:n</literal> is a valid part of
		    the element with occurrences where
		    <literal>:n</literal> denotes group
		    <literal>n</literal>.  For compatibility purposes,
		    since the <literal>/</literal> terminator was not
		    required before in both
		    <makevar>MASTER_SITE_SUBDIR</makevar> and
		    <makevar>PATCH_SITE_SUBDIR</makevar> elements, if
		    the postfix immediate preceding character is not
		    a <literal>/</literal> then <literal>:n</literal>
		    will be considered a valid part of the element
		    instead of a group postfix even if an element is
		    postfixed with <literal>:n</literal>.  See both
		    <xref
		      linkend="ports-master-sites-n-example-detailed-use-master-site-subdir">
		    and <xref
		      linkend="ports-master-sites-n-example-detailed-use-complete-example-master-sites">.</para>

		  <example id="ports-master-sites-n-example-detailed-use-master-site-subdir">
		    <title>Detailed use of
		      <literal>MASTER_SITES:n</literal> in
		      <makevar>MASTER_SITE_SUBDIR</makevar></title>

		    <programlisting>MASTER_SITE_SUBDIR=     old:n new/:NEW</programlisting>

		    <itemizedlist>
		      <listitem>
			<para>Directories within group
			  <literal>DEFAULT</literal> -> old:n</para>
		      </listitem>

		      <listitem>
			<para>Directories within group
			  <literal>NEW</literal> -> new</para>
		      </listitem>
		    </itemizedlist>
		  </example>

		  <example
		    id="ports-master-sites-n-example-detailed-use-complete-example-master-sites">
		      <title>Detailed use of
			<literal>MASTER_SITES:n</literal> with comma
			operator, multiple files, multiple sites and
			multiple subdirectories</title>

		    <programlisting>MASTER_SITES=   http://site1/%SUBDIR%/ http://site2/:DEFAULT \
		http://site3/:group3 http://site4/:group4 \
		http://site5/:group5 http://site6/:group6 \
		http://site7/:DEFAULT,group6 \
		http://site8/%SUBDIR%/:group6,group7 \
		http://site9/:group8
DISTFILES=      file1 file2:DEFAULT file3:group3 \
		file4:group4,group5,group6 file5:grouping \
		file6:group7
MASTER_SITE_SUBDIR=     directory-trial:1 directory-n/:groupn \
			directory-one/:group6,DEFAULT \
			directory</programlisting>

		    <para>The previous example results in the
		      following fine grained fetching.	Sites are
		      listed in the exact order they will be
		      used.</para>

		    <itemizedlist>
		      <listitem>
			<para><filename>file1</filename> will be
			  fetched from</para>

			<itemizedlist>
			  <listitem>
			    <para><makevar>MASTER_SITE_OVERRIDE</makevar></para>
			  </listitem>

			  <listitem>
			    <para>http://site1/directory-trial:1/</para>
			  </listitem>

			  <listitem>
			    <para>http://site1/directory-one/</para>
			  </listitem>

			  <listitem>
			    <para>http://site1/directory/</para>
			  </listitem>

			  <listitem>
			    <para>http://site2/</para>
			  </listitem>

			  <listitem>
			    <para>http://site7/</para>
			  </listitem>

			  <listitem>
			    <para><makevar>MASTER_SITE_BACKUP</makevar></para>
			  </listitem>
			</itemizedlist>
		      </listitem>

		      <listitem>
			<para><filename>file2</filename> will be
			  fetched exactly as
			  <filename>file1</filename> since they
			  both belong to the same group</para>

			<itemizedlist>
			  <listitem>
			    <para><makevar>MASTER_SITE_OVERRIDE</makevar></para>
			  </listitem>

			  <listitem>
			    <para>http://site1/directory-trial:1/</para>
			  </listitem>

			  <listitem>
			    <para>http://site1/directory-one/</para>
			  </listitem>

			  <listitem>
			    <para>http://site1/directory/</para>
			  </listitem>

			  <listitem>
			    <para>http://site2/</para>
			  </listitem>

			  <listitem>
			    <para>http://site7/</para>
			  </listitem>

			  <listitem>
			    <para><makevar>MASTER_SITE_BACKUP</makevar></para>
			  </listitem>
			</itemizedlist>
		      </listitem>

		      <listitem>
			<para><filename>file3</filename> will be
			  fetched from</para>

			<itemizedlist>
			  <listitem>
			    <para><makevar>MASTER_SITE_OVERRIDE</makevar></para>
			  </listitem>

			  <listitem>
			    <para>http://site3/</para>
			  </listitem>

			  <listitem>
			    <para><makevar>MASTER_SITE_BACKUP</makevar></para>
			  </listitem>
			</itemizedlist>
		      </listitem>

		      <listitem>
			<para><filename>file4</filename> will be
			  fetched from</para>

			<itemizedlist>
			  <listitem>
			    <para><makevar>MASTER_SITE_OVERRIDE</makevar></para>
			  </listitem>

			  <listitem>
			    <para>http://site4/</para>
			  </listitem>

			  <listitem>
			    <para>http://site5/</para>
			  </listitem>

			  <listitem>
			    <para>http://site6/</para>
			  </listitem>

			  <listitem>
			    <para>http://site7/</para>
			  </listitem>

			  <listitem>
			    <para>http://site8/directory-one/</para>
			  </listitem>

			  <listitem>
			    <para><makevar>MASTER_SITE_BACKUP</makevar></para>
			  </listitem>
			</itemizedlist>
		      </listitem>

		      <listitem>
			<para><filename>file5</filename> will be
			  fetched from</para>

			<itemizedlist>
			  <listitem>
			    <para><makevar>MASTER_SITE_OVERRIDE</makevar></para>
			  </listitem>

			  <listitem>
			    <para><makevar>MASTER_SITE_BACKUP</makevar></para>
			  </listitem>
			</itemizedlist>
		      </listitem>

		      <listitem>
			<para><filename>file6</filename> will be
			  fetched from</para>

			<itemizedlist>
			  <listitem>
			    <para><makevar>MASTER_SITE_OVERRIDE</makevar></para>
			  </listitem>

			  <listitem>
			    <para>http://site8/</para>
			  </listitem>

			  <listitem>
			    <para><makevar>MASTER_SITE_BACKUP</makevar></para>
			  </listitem>
			</itemizedlist>
		      </listitem>
		    </itemizedlist>
		  </example>
		</listitem>
	      </orderedlist>
	    </listitem>

	    <listitem>
	      <para>How do I group one of the special variables from
		<filename>bsd.sites.mk</filename>, e.g.,
		<makevar>MASTER_SITE_SOURCEFORGE</makevar>?</para>

	      <para>See <xref
		  linkend="ports-master-sites-n-example-detailed-use-master-site-sourceforge">.</para>

	      <example
		id="ports-master-sites-n-example-detailed-use-master-site-sourceforge">
		<title>Detailed use of
		  <literal>MASTER_SITES:n</literal> with
		  <makevar>MASTER_SITE_SOURCEFORGE</makevar></title>

		<programlisting>MASTER_SITES=   http://site1/ ${MASTER_SITE_SOURCEFORGE:S/$/:sourceforge,TEST/}
DISTFILES=      something.tar.gz:sourceforge</programlisting>
	      </example>

	      <para><filename>something.tar.gz</filename> will be
		fetched from all sites within
		<makevar>MASTER_SITE_SOURCEFORGE</makevar>.</para>
	    </listitem>

	    <listitem>
	      <para>How do I use this with <makevar>PATCH*</makevar>
		variables?</para>

	      <para>All examples were done with
		<makevar>MASTER*</makevar> variables but they work
		exactly the same for <makevar>PATCH*</makevar> ones as
		can be seen in <xref
		  linkend="ports-master-sites-n-example-detailed-use-patch-sites">.</para>

	      <example
		id="ports-master-sites-n-example-detailed-use-patch-sites">
		<title>Simplified use of
		  <literal>MASTER_SITES:n</literal> with
		  <makevar>PATCH_SITES</makevar>.</title>

		<programlisting>PATCH_SITES=    http://site1/ http://site2/:test
PATCHFILES=     patch1:test</programlisting>
	      </example>
	    </listitem>
	  </orderedlist>
	</sect3>

	<sect3>
	  <title>What does change for ports?  What does not?</title>

	  <orderedlist numeration="lowerroman">
	    <listitem>
	      <para>All current ports remain the same.  The
		<literal>MASTER_SITES:n</literal> feature code is only
		activated if there are elements postfixed with
		<literal>:<replaceable>n</replaceable></literal> like
		elements according to the aforementioned syntax rules,
		especially as shown in item <xref
		  linkend="porting-master-sites-n-group-semantics">.</para>
	    </listitem>

	    <listitem id="porting-master-sites-n-what-changes-in-port-targets">
	      <para>The port targets remain the same:
		<maketarget>checksum</maketarget>,
		<maketarget>makesum</maketarget>,
		<maketarget>patch</maketarget>,
		<maketarget>configure</maketarget>,
		<maketarget>build</maketarget>, etc.  With the obvious
		exceptions of <maketarget>do-fetch</maketarget>,
		<maketarget>fetch-list</maketarget>,
		<maketarget>master-sites</maketarget> and
		<maketarget>patch-sites</maketarget>.</para>

	      <itemizedlist>
		<listitem>
		  <para><maketarget>do-fetch</maketarget>: deploys the
		    new grouping postfixed
		    <makevar>DISTFILES</makevar> and
		    <makevar>PATCHFILES</makevar> with their matching
		    group elements within both
		    <makevar>MASTER_SITES</makevar> and
		    <makevar>PATCH_SITES</makevar> which use matching
		    group elements within both
		    <makevar>MASTER_SITE_SUBDIR</makevar> and
		    <makevar>PATCH_SITE_SUBDIR</makevar>.  Check <xref
		      linkend="ports-master-sites-n-example-detailed-use-complete-example-master-sites">.</para>
		</listitem>

		<listitem>
		  <para><maketarget>fetch-list</maketarget>: works
		    like old <maketarget>fetch-list</maketarget> with
		    the exception that it groups just like
		    <maketarget>do-fetch</maketarget>.</para>
		</listitem>

		<listitem>
		  <para><maketarget>master-sites</maketarget> and
		    <maketarget>patch-sites</maketarget>:
		    (incompatible with older versions) only return the
		    elements of group <literal>DEFAULT</literal>;  in
		    fact, they execute targets
		    <maketarget>master-sites-default</maketarget> and
		    <maketarget>patch-sites-default</maketarget>
		    respectively.</para>

		  <para>Furthermore, using target either
		    <maketarget>master-sites-all</maketarget> or
		    <maketarget>patch-sites-all</maketarget> is
		    preferred to directly checking either
		    <maketarget>MASTER_SITES</maketarget> or
		    <maketarget>PATCH_SITES</maketarget>.  Also,
		    directly checking is not guaranteed to work in any
		    future versions.  Check item <xref
		      linkend="porting-master-sites-n-new-port-targets-master-sites-all">
		    for more information on these new port
		    targets.</para>
		</listitem>

	      </itemizedlist>
	    </listitem>

	    <listitem>
	      <para>New port targets</para>

	      <orderedlist>
		<listitem>
		  <para>There are
		    <maketarget>master-sites-<replaceable>n</replaceable></maketarget>
		    and
		    <maketarget>patch-sites-<replaceable>n</replaceable></maketarget>
		    targets which will list the elements of the
		    respective group <replaceable>n</replaceable>
		    within <makevar>MASTER_SITES</makevar> and
		    <makevar>PATCH_SITES</makevar> respectively.  For
		    instance, both
		    <maketarget>master-sites-DEFAULT</maketarget> and
		    <maketarget>patch-sites-DEFAULT</maketarget> will
		    return the elements of group
		    <literal>DEFAULT</literal>,
		    <maketarget>master-sites-test</maketarget> and
		    <maketarget>patch-sites-test</maketarget> of group
		    <literal>test</literal>, and thereon.</para>
		</listitem>

		<listitem id="porting-master-sites-n-new-port-targets-master-sites-all">
		  <para>There are new targets
		    <maketarget>master-sites-all</maketarget> and
		    <maketarget>patch-sites-all</maketarget> which do
		    the work of the old
		    <maketarget>master-sites</maketarget> and
		    <maketarget>patch-sites</maketarget> ones.  They
		    return the elements of all groups as if they all
		    belonged to the same group with the caveat that it
		    lists as many
		    <makevar>MASTER_SITE_BACKUP</makevar> and
		    <makevar>MASTER_SITE_OVERRIDE</makevar> as there
		    are groups defined within either
		    <makevar>DISTFILES</makevar> or
		    <makevar>PATCHFILES</makevar>;  respectively for
		    <maketarget>master-sites-all</maketarget> and
		    <maketarget>patch-sites-all</maketarget>.</para>
		</listitem>
	      </orderedlist>
	    </listitem>
	  </orderedlist>
	</sect3>
      </sect2>

      <sect2>
	<title><makevar>DIST_SUBDIR</makevar></title>

	<para>Do not let your port clutter
	  <filename>/usr/ports/distfiles</filename>.  If your port requires a
	  lot of files to be fetched, or contains a file that has a name that
	  might conflict with other ports (e.g.,
	  <filename>Makefile</filename>), set <makevar>DIST_SUBDIR</makevar>
	  to the name of the port (<literal>${PORTNAME}</literal> or
	  <literal>${PKGNAMEPREFIX}${PORTNAME}</literal>
	  should work fine).  This will change
	  <makevar>DISTDIR</makevar> from the default
	  <filename>/usr/ports/distfiles</filename> to
	  <filename>/usr/ports/distfiles/<makevar>DIST_SUBDIR</makevar></filename>,
	  and in effect puts everything that is required for your port into
	  that subdirectory.</para>

	<para>It will also look at the subdirectory with the same name on the
	  backup master site at <filename>ftp.FreeBSD.org</filename>.
	  (Setting <makevar>DISTDIR</makevar> explicitly in your
	  <makevar>Makefile</makevar> will not accomplish this, so please use
	  <makevar>DIST_SUBDIR</makevar>.)</para>

	<note>
	  <para>This does not affect the <makevar>MASTER_SITES</makevar> you
	    define in your <filename>Makefile</filename>.</para>
	</note>
      </sect2>
    </sect1>

      <sect1 id="makefile-maintainer">
	<title><makevar>MAINTAINER</makevar></title>

	<para>Set your mail-address here.  Please.  <!-- smiley
	  --><emphasis>:-)</emphasis></para>

	<para>Note that only a single address without the comment part is
	  allowed as a <makevar>MAINTAINER</makevar> value.
	  The format used should be <literal>user@hostname.domain</literal>.
	  Please do not include any descriptive text such as your real
	  name in this entry&mdash;that merely confuses
	  <filename>bsd.port.mk</filename>.</para>

	<para>For a detailed description of the responsibilities of maintainers,
	  refer to the <ulink url="&url.books.developers-handbook;/policies.html#POLICIES-MAINTAINER">MAINTAINER on
	    Makefiles</ulink> section.</para>

	<para>If the maintainer of a port does not respond to an update
	  request from a user after two weeks (excluding major public
	  holidays), then that is considered a maintainer timeout, and the
	  update may be made without explicit maintainer approval.  If the
	  maintainer does not respond within three months, then that
	  maintainer is considered absent without leave, and can be
	  replaced as the maintainer of the particular port in question.
	  Exceptions to this are anything maintained by the &a.portmgr;, or
	  the &a.security-officer;.  No unauthorized commits may ever be
	  made to ports maintained by those groups.</para>

	<para>The &a.portmgr; reserves the right to revoke or override
	  anyone's maintainership for any reason, and the &a.security-officer;
	  reserves the right to revoke or override maintainership for security
	  reasons.</para>
      </sect1>

      <sect1 id="makefile-comment">
	<title><makevar>COMMENT</makevar></title>

	<para>This is a one-line description of the port.
	  <emphasis>Please</emphasis> do not include the package name (or
	  version number of the software) in the comment.  The comment
	  should begin with a capital and end without a period.  Here
	  is an example:</para>

	<programlisting>COMMENT=       A cat chasing a mouse all over the screen</programlisting>

	<para>The COMMENT variable should immediately follow the MAINTAINER
	  variable in the <filename>Makefile</filename>.</para>

	<para>Please try to keep the COMMENT line less than 70
	  characters, as it is displayed to users as a one-line
	  summary of the port.</para>
      </sect1>

      <sect1 id="makefile-depend">
	<title>Dependencies</title>

	<para>Many ports depend on other ports.  There are seven variables that
	  you can use to ensure that all the required bits will be on the
	  user's machine.  There are also some pre-supported dependency
	  variables for common cases, plus a few more to control the behavior
	  of dependencies.</para>

	<sect2>
	  <title><makevar>LIB_DEPENDS</makevar></title>

	  <para>This variable specifies the shared libraries this port depends
	    on.  It is a list of
	    <replaceable>lib</replaceable>:<replaceable>dir</replaceable><optional><replaceable>:target</replaceable></optional>
	    tuples where <replaceable>lib</replaceable> is the name of the
	    shared library, <replaceable>dir</replaceable> is the
	    directory in which to find it in case it is not available, and
	    <replaceable>target</replaceable> is the target to call in that
	    directory.  For example,
	    <programlisting>LIB_DEPENDS=   jpeg.9:${PORTSDIR}/graphics/jpeg:install</programlisting>
	    will check for a shared jpeg library with major version 9, and
	    descend into the <filename>graphics/jpeg</filename> subdirectory
	    of your ports tree to build and install it if it is not found.
	    The <replaceable>target</replaceable> part can be omitted if it is
	    equal to <makevar>DEPENDS_TARGET</makevar> (which defaults to
	    <literal>install</literal>).</para>

	  <note>
	    <para>The <replaceable>lib</replaceable> part is a regular
	      expression which is being looked up in the
	      <command>ldconfig -r</command> output.  Values such as
	      <literal>intl.[5-7]</literal> and <literal>intl</literal> are
	      allowed.  The first pattern,
	      <literal>intl.[5-7]</literal>, will match any of:
	      <literal>intl.5</literal>, <literal>intl.6</literal> or
	      <literal>intl.7</literal>.  The second pattern,
	      <literal>intl</literal>, will match any version of the
	      <literal>intl</literal> library.</para>
	  </note>

	  <para>The dependency is checked twice, once from within the
	    <maketarget>extract</maketarget> target and then from within the
	    <maketarget>install</maketarget> target.  Also, the name of the
	    dependency is put into the package so that
	    &man.pkg.add.1; will automatically install it if it is
	    not on the user's system.</para>
	</sect2>

	<sect2>
	  <title><makevar>RUN_DEPENDS</makevar></title>

	  <para>This variable specifies executables or files this port depends
	    on during run-time.  It is a list of
	    <replaceable>path</replaceable>:<replaceable>dir</replaceable><optional><replaceable>:target</replaceable></optional>
	    tuples where <replaceable>path</replaceable> is the name of the
	    executable or file, <replaceable>dir</replaceable> is the
	    directory in which to find it in case it is not available, and
	    <replaceable>target</replaceable> is the target to call in that
	    directory.  If <replaceable>path</replaceable> starts with a slash
	    (<literal>/</literal>), it is treated as a file and its existence
	    is  tested with <command>test -e</command>; otherwise, it is
	    assumed to be an executable, and <command>which -s</command> is
	    used to determine if the program exists in the search path.</para>

	  <para>For example,</para>

	    <programlisting>RUN_DEPENDS=   ${LOCALBASE}/etc/innd:${PORTSDIR}/news/inn \
	       wish8.0:${PORTSDIR}/x11-toolkits/tk80</programlisting>

	  <para>will check if the file or directory
	    <filename>/usr/local/etc/innd</filename> exists, and build and
	    install it from the <filename>news/inn</filename> subdirectory of
	    the ports tree if it is not found.  It will also see if an
	    executable called <command>wish8.0</command> is in the search
	    path, and descend into the <filename>x11-toolkits/tk80</filename>
	    subdirectory of your ports tree to build and install it if it is
	    not found.</para>

	  <note>
	    <para>In this case, <command>innd</command> is actually an
	      executable; if an executable is in a place that is not expected
	      to be in the search path, you should use the full
	      pathname.</para>
	  </note>

	  <note>
	    <para>The official search <envar>PATH</envar> used on the ports
	      build cluster is</para>

	    <programlisting>/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin</programlisting>
	  </note>

	  <para>The dependency is checked from within the
	    <maketarget>install</maketarget> target.  Also, the name of the
	    dependency is put into the  package so that
	    &man.pkg.add.1; will automatically install it if it is
	    not on the user's system.  The <replaceable>target</replaceable>
	    part can be omitted if it is the same as
	    <makevar>DEPENDS_TARGET</makevar>.</para>
	</sect2>

	<sect2>
	  <title><makevar>BUILD_DEPENDS</makevar></title>

	  <para>This variable specifies executables or files this port
	    requires to build.  Like <makevar>RUN_DEPENDS</makevar>, it is a
	    list of
	    <replaceable>path</replaceable>:<replaceable>dir</replaceable><optional><replaceable>:target</replaceable></optional>
	    tuples. For example, <programlisting> BUILD_DEPENDS=
	      unzip:${PORTSDIR}/archivers/unzip</programlisting> will check
	    for an executable called <command>unzip</command>, and descend
	    into the <filename>archivers/unzip</filename> subdirectory of your
	    ports tree to build and install it if it is not found.</para>

	  <note>
	    <para><quote>build</quote> here means everything from extraction to
	      compilation.  The dependency is checked from within the
	      <maketarget>extract</maketarget> target.  The
	      <replaceable>target</replaceable> part can be omitted if it is
	      the same as <makevar>DEPENDS_TARGET</makevar></para>
	  </note>
	</sect2>

	<sect2>
	  <title><makevar>FETCH_DEPENDS</makevar></title>

	  <para>This variable specifies executables or files this port
	    requires to fetch.  Like the previous two, it is a list of
	    <replaceable>path</replaceable>:<replaceable>dir</replaceable><optional><replaceable>:target</replaceable></optional>
	    tuples.  For example, <programlisting> FETCH_DEPENDS=
	      ncftp2:${PORTSDIR}/net/ncftp2</programlisting> will check for an
	    executable called <command>ncftp2</command>, and descend into the
	    <filename>net/ncftp2</filename> subdirectory of your ports tree to
	    build and install it if it is not found.</para>

	  <para>The dependency is checked from within the
	    <maketarget>fetch</maketarget> target.  The
	    <replaceable>target</replaceable> part can be omitted if it is the
	    same as <makevar>DEPENDS_TARGET</makevar>.</para>
	</sect2>

	<sect2>
	  <title><makevar>EXTRACT_DEPENDS</makevar></title>

	  <para>This variable specifies executables or files this port
	    requires for extraction.  Like the previous, it is a list of
	    <replaceable>path</replaceable>:<replaceable>dir</replaceable><optional><replaceable>:target</replaceable></optional>
	    tuples.  For example, <programlisting>EXTRACT_DEPENDS=
	      unzip:${PORTSDIR}/archivers/unzip</programlisting> will check
	    for an executable called <command>unzip</command>, and descend
	    into the <filename>archivers/unzip</filename> subdirectory of
	    your ports tree to build and install it if it is not found.</para>

	  <para>The dependency is checked from within the
	    <maketarget>extract</maketarget> target.  The
	    <replaceable>target</replaceable> part can be omitted if it is the
	    same as <makevar>DEPENDS_TARGET</makevar>.</para>

	  <note>
	    <para>Use this variable only if the extraction does not already
	      work (the default assumes <command>gzip</command>) and cannot
	      be made to work using <makevar>USE_ZIP</makevar> or
	      <makevar>USE_BZIP2</makevar> described in <xref
		linkend="use-vars">.</para>
	  </note>
	</sect2>

	<sect2>
	  <title><makevar>PATCH_DEPENDS</makevar></title>

	  <para>This variable specifies executables or files this port
	    requires to patch.  Like the previous, it is a list of
	    <replaceable>path</replaceable>:<replaceable>dir</replaceable><optional><replaceable>:target</replaceable></optional>
	    tuples.  For example, <programlisting> PATCH_DEPENDS=
	      ${NONEXISTENT}:${PORTSDIR}/java/jfc:extract
		</programlisting>will descend into the
	    <filename>java/jfc</filename> subdirectory of your ports tree to
	    build and install it if it is not found.</para>

	  <para>The dependency is checked from within the
	    <maketarget>patch</maketarget> target.  The
	    <replaceable>target</replaceable> part can be omitted if it is the
	    same as <makevar>DEPENDS_TARGET</makevar>.</para>
	</sect2>

	<sect2>
	  <title><makevar>DEPENDS</makevar></title>

	  <para>If there is a dependency that does not fall into either of the
	    above categories, or your port requires having the source of
	    the other port extracted in addition to having it installed,
	    then use this variable.  This is a list of
	    <replaceable>dir</replaceable><optional><replaceable>:target</replaceable></optional>,
	    as there is nothing to check, unlike the previous four.  The
	    <replaceable>target</replaceable> part can be omitted if it is the
	    same as <makevar>DEPENDS_TARGET</makevar>.</para>
	</sect2>

	<sect2 id="use-vars">
	<title><makevar>USE_<replaceable>*</replaceable></makevar></title>

	<para>A number of variables exist in order to encapsulate common
	  dependencies that many ports have.  Although their use is
	  optional, they can help to reduce the verbosity of the port
	  <filename>Makefile</filename>s.  Each of them is styled
	  as <makevar>USE_<replaceable>*</replaceable></makevar>.  The
	  usage of these variables is restricted to the port
	  <filename>Makefile</filename>s and
	  <filename>ports/Mk/bsd.*.mk</filename> and is not designed
	  to encapsulate user-settable options &mdash; use
	  <makevar>WITH_<replaceable>*</replaceable></makevar> and
	  <makevar>WITHOUT_<replaceable>*</replaceable></makevar>
	  for that purpose.</para>

	<note>
	  <para>It is <emphasis>always</emphasis> incorrect to set
	    any <makevar>USE_<replaceable>*</replaceable></makevar>
	    in <filename>/etc/make.conf</filename>.  For instance,
	    setting <programlisting>USE_GCC=3.2</programlisting>
	    would adds a dependency on gcc32 for every port,
	    including gcc32 itself!</para>
	</note>

	<table frame="none">
	  <title>The <makevar>USE_<replaceable>*</replaceable></makevar>
	    variables</title>

	  <tgroup cols="2">
	    <thead>
	      <row>
		<entry>Variable</entry>

		<entry>Means</entry>
	      </row>
	    </thead>

	    <tbody>
	      <row>
		<entry><makevar>USE_BZIP2</makevar></entry>

		<entry>The port's tarballs are compressed with
		  <command>bzip2</command>.</entry>
	      </row>

	      <row>
		<entry><makevar>USE_ZIP</makevar></entry>

		<entry>The port's tarballs are compressed with
		  <command>zip</command>.</entry>
	      </row>

	      <row>
		<entry><makevar>USE_BISON</makevar></entry>

		<entry>The port uses <command>bison</command> for
		  building.</entry>
	      </row>

	      <row>
		<entry><makevar>USE_GCC</makevar></entry>

		<entry>The port requires a specific version of
		  <command>gcc</command> to build.  The exact version can be
		  specified with value such as <literal>3.2</literal>.
		  The minimal required version can be specified as
		  <literal>3.2+</literal>.  The <command>gcc</command> from
		  the base system is used when it satisfies the requested
		  version, otherwise an appropriate <command>gcc</command> is
		  compiled from ports and the <makevar>CC</makevar> and
		  <makevar>CXX</makevar> variables are adjusted.
		  <makevar>USE_GCC</makevar> can't be used together with
		  <makevar>USE_LIBTOOL_VER</makevar>.</entry>
	      </row>

	    </tbody>
	  </tgroup>
	</table>

	  <para>Variables related to <application>gmake</application>,
	    <filename>configure</filename> script,
	    <application>autoconf</application>,
	    <application>automake</application> and
	    <application>libtool</application> are described in
	    <xref linkend="using-autotools">.  <application>Perl</application>
	    related variables are described in <xref linkend="using-perl">.
	    X11 variables are listed in <xref linkend="using-x11">.  <xref
	    linkend="using-gnome"> deals with GNOME and <xref
	    linkend="using-kde"> with KDE related variables.  <xref
	    linkend="using-java"> documents Java variables, while <xref
	    linkend="using-php"> contains information on
	    <application>Apache</application>, <application>PHP</application>
	    and PEAR modules.  <application>Python</application> is discussed
	    in <xref linkend="using-python">, while
	    <application>Ruby</application> in <xref linkend="using-ruby">.
	    Finally, <xref linkend="using-sdl"> provides variables used for
	    <application>SDL</application> applications.</para>

	</sect2>

	<sect2>
	  <title>Notes on dependencies</title>

	  <para>As mentioned above, the default target to call when a
	    dependency is required is <maketarget>DEPENDS_TARGET</maketarget>.
	    It defaults to <literal>install</literal>.  This is a user
	    variable; it is never defined in a port's
	    <filename>Makefile</filename>.  If your port needs a special way
	    to handle a dependency, use the <literal>:target</literal> part of
	    the <makevar>*_DEPENDS</makevar> variables instead of redefining
	    <makevar>DEPENDS_TARGET</makevar>.</para>

	  <para>When you type <command>make clean</command>, its dependencies
	    are automatically cleaned too.  If you do not wish this to happen,
	    define the variable <makevar>NOCLEANDEPENDS</makevar> in your
	    environment.  This may be particularly desirable if the port
	    has something that takes a long time to rebuild in its
	    dependency list, such as KDE, GNOME or Mozilla.</para>

	  <para>To depend on another port unconditionally, use the
	    variable <makevar>${NONEXISTENT}</makevar> as the first field
	    of <makevar>BUILD_DEPENDS</makevar> or
	    <makevar>RUN_DEPENDS</makevar>.  Use this only when you need to
	    get the source of the other port.  You can often save
	    compilation time by specifying the target too.  For
	    instance

	    <programlisting>BUILD_DEPENDS=   ${NONEXISTENT}:${PORTSDIR}/graphics/jpeg:extract</programlisting>

	    will always descend to the <literal>jpeg</literal> port and extract it.</para>

	  <para>Do not use <makevar>DEPENDS</makevar> unless there is no other
	    way the behavior you want can be accomplished.  It will cause the
	    other port to always be built (and installed, by default), and the
	    dependency will go into the packages as well.  If this is really
	    what you need, you should probably write it as
	    <literal>BUILD_DEPENDS</literal> and
	    <literal>RUN_DEPENDS</literal> instead&mdash;at least the
	    intention will be clear.</para>
	</sect2>

      <sect2>
	<title>Circular dependencies are fatal</title>

	<important>
	  <para>Do not introduce any circular dependencies into the
	  ports tree!</para>
	</important>

	<para>The ports building technology does not tolerate
	  circular dependencies.  If you introduce one, you will have
	  someone, somewhere in the world, whose FreeBSD installation will
	  break almost immediately, with many others quickly to follow.
	  These can really be hard to detect; if in doubt, before
	  you make that change, make sure you have done the following:
	  <command>cd /usr/ports; make index</command>.  That process
	  can be quite slow on older machines, but you may be able to
	  save a large number of people&mdash;including yourself&mdash;
	  a lot of grief in the process.</para>
      </sect2>

      </sect1>

    <sect1 id="makefile-masterdir">
      <title><makevar>MASTERDIR</makevar></title>

      <para>If your port needs to build slightly different versions of
	packages by having a variable (for instance, resolution, or paper
	size) take different values, create one subdirectory per package to
	make it easier for users to see what to do, but try to share as many
	files as possible between ports.  Typically you only need a very short
	<filename>Makefile</filename> in all but one of the directories if you
	use variables cleverly.  In the sole <filename>Makefile</filename>,
	you can use <makevar>MASTERDIR</makevar> to specify the directory
	where the rest of the files are.  Also, use a variable as part of
	<link linkend="porting-pkgname"><makevar>PKGNAMESUFFIX</makevar></link> so
	the packages will have different names.</para>

      <para>This will be best demonstrated by an example.  This is part of
	<filename>japanese/xdvi300/Makefile</filename>;</para>

      <programlisting>PORTNAME=       xdvi
PORTVERSION=    17
PKGNAMEPREFIX=  ja-
PKGNAMESUFFIX=  ${RESOLUTION}
 :
# default
RESOLUTION?=   300
.if ${RESOLUTION} != 118 && ${RESOLUTION} != 240 && \
       ${RESOLUTION} != 300 && ${RESOLUTION} != 400
       @${ECHO} "Error: invalid value for RESOLUTION: \"${RESOLUTION}\""
       @${ECHO} "Possible values are: 118, 240, 300 (default) and 400."
       @${FALSE}
.endif</programlisting>

      <para><filename role="package">japanese/xdvi300</filename> also has all the regular
	patches, package files, etc.  If you type <command>make</command>
	there, it will take the default value for the resolution (300) and
	build the port normally.</para>

      <para>As for other resolutions, this is the <emphasis>entire</emphasis>
	<filename>xdvi118/Makefile</filename>:</para>

      <programlisting>RESOLUTION=     118
MASTERDIR=      ${.CURDIR}/../xdvi300

.include "${MASTERDIR}/Makefile"</programlisting>

      <para>(<filename>xdvi240/Makefile</filename> and
	<filename>xdvi400/Makefile</filename> are similar).  The
	<makevar>MASTERDIR</makevar> definition tells
	<filename>bsd.port.mk</filename> that the regular set of
	subdirectories like <makevar>FILESDIR</makevar> and
	<makevar>SCRIPTDIR</makevar> are to be found under
	<filename>xdvi300</filename>.  The <literal>RESOLUTION=118</literal>
	line will override the <literal>RESOLUTION=300</literal> line in
	<filename>xdvi300/Makefile</filename> and the port will be built with
	resolution set to 118.</para>
    </sect1>

    <sect1 id="makefile-manpages">
      <title>Manpages</title>

      <para>The <makevar>MAN[1-9LN]</makevar> variables will automatically add
	any manpages to <filename>pkg-plist</filename> (this means you must
	<emphasis>not</emphasis> list manpages in the
	<filename>pkg-plist</filename>&mdash;see <link
	  linkend="plist-sub">generating PLIST</link> for more).  It also
	makes the install stage automatically compress or uncompress manpages
	depending on the setting of <makevar>NOMANCOMPRESS</makevar> in
	<filename>/etc/make.conf</filename>.</para>

      <para>If your port tries to install multiple names for manpages using
	symlinks or hardlinks, you must use the <makevar>MLINKS</makevar>
	variable to identify these.  The link installed by your port will
	be destroyed and recreated by <filename>bsd.port.mk</filename>
	to make sure it points to the correct file.  Any manpages
	listed in MLINKS must not be listed in the
	<filename>pkg-plist</filename>.</para>

      <para>To specify whether the manpages are compressed upon installation,
	use the <makevar>MANCOMPRESSED</makevar> variable. This variable can
	take three values, <literal>yes</literal>, <literal>no</literal> and
	<literal>maybe</literal>. <literal>yes</literal> means manpages are
	already installed compressed, <literal>no</literal> means they are
	not, and <literal>maybe</literal> means the software already respects
	the value of <makevar>NOMANCOMPRESS</makevar> so
	<filename>bsd.port.mk</filename> does not have to do anything
	special.</para>

      <para><makevar>MANCOMPRESSED</makevar> is automatically set to
	<literal>yes</literal> if <makevar>USE_IMAKE</makevar> is set and
	<makevar>NO_INSTALL_MANPAGES</makevar> is not set, and to
	<literal>no</literal> otherwise.  You do not have to explicitly define
	it unless the default is not suitable for your port.</para>

      <para>If your port anchors its man tree somewhere other than
	<makevar>PREFIX</makevar>, you can use the
	<makevar>MANPREFIX</makevar> to set it.  Also, if only manpages in
	certain sections go in a non-standard place, such as some <literal>perl</literal> modules
	ports, you can set individual man paths using
	<makevar>MAN<replaceable>sect</replaceable>PREFIX</makevar> (where
	<replaceable>sect</replaceable> is one of <literal>1-9</literal>,
	<literal>L</literal> or <literal>N</literal>).</para>

      <para>If your manpages go to language-specific subdirectories, set the
	name of the languages to <makevar>MANLANG</makevar>.  The value of
	this variable defaults to <literal>""</literal> (i.e., English
	only).</para>

      <para>Here is an example that puts it all together.</para>

      <programlisting>MAN1=          foo.1
MAN3=          bar.3
MAN4=          baz.4
MLINKS=        foo.1 alt-name.8
MANLANG=       "" ja
MAN3PREFIX=    ${PREFIX}/share/foobar
MANCOMPRESSED= yes</programlisting>

      <para>This states that six files are installed by this port;</para>

	  <programlisting>${PREFIX}/man/man1/foo.1.gz
${PREFIX}/man/ja/man1/foo.1.gz
${PREFIX}/share/foobar/man/man3/bar.3.gz
${PREFIX}/share/foobar/man/ja/man3/bar.3.gz
${PREFIX}/man/man4/baz.4.gz
${PREFIX}/man/ja/man4/baz.4.gz</programlisting>

      <para>Additionally <filename>${PREFIX}/man/man8/alt-name.8.gz</filename>
	may or may not be installed by your port.  Regardless, a
	symlink will be made to join the foo(1) manpage and
	alt-name(8) manpage.</para>

    </sect1>

    <sect1 id="makefile-info">
      <title>Info files</title>

      <para>If your package needs to install GNU info files, they should be
	listed in the <makevar>INFO</makevar> variable (without the trailing
	<literal>.info</literal>), and appropriate installation/de-installation
	code will be automatically added to the temporary
	<filename>pkg-plist</filename> before package registration.</para>
    </sect1>

      <sect1 id="makefile-options">
      <title>Makefile Options</title>

      <para>Some large applications can be built in a number of
	configurations, adding functionality if one of a number of
	libraries or applications is available.  Examples include
	choice of natural (human) language, GUI versus command-line,
	or type of database to support.  Since not all users
	want those libraries or applications, the ports system
	provides hooks that the port author can use to control which
	configuration should be built. Supporting these properly will
	make users happy, and effectively provide 2 or more ports for the
	price of one.</para>

        <sect2>
	  <title><makevar>WITH_<replaceable>*</replaceable></makevar> and
	    <makevar>WITHOUT_<replaceable>*</replaceable></makevar></title>

	  <para>These variables are designed to be set by the system
	    administrator.  There are many that are standardized in
	    <filename>ports/Mk/bsd.*.mk</filename>; others are not,
	    which can be confusing.  If you need to add such a
	    configuration variable, please consider using one of the
	    ones from the following list.</para>

	  <note>
	    <para>You should not assume that a
	      <makevar>WITH_<replaceable>*</replaceable></makevar>
	      necessarily has a corresponding
	      <makevar>WITHOUT_<replaceable>*</replaceable></makevar>
	      variable and vice versa.  In general, the default is
	      simply assumed.</para>
	  </note>

	  <note>
	    <para>Unless otherwise specified, these variables are only
	      tested for being set or not set, rather than being set to
	      some kind of variable such as <literal>YES</literal> or
	      <literal>NO</literal>.</para>
	  </note>

	  <table frame="none">
	    <title>The <makevar>WITH_<replaceable>*</replaceable></makevar>
	      and <makevar>WITHOUT_<replaceable>*</replaceable></makevar>
	      variables</title>

	    <tgroup cols="2">
	      <thead>
	        <row>
		  <entry>Variable</entry>

		  <entry>Means</entry>
	        </row>
	      </thead>

	      <tbody>
	        <row>
		  <entry><makevar>WITH_APACHE2</makevar></entry>

		  <entry>If set, use
		    <filename role="package">www/apache2</filename>
		    instead of the default of
		    <filename role="package">www/apache</filename>.</entry>
	        </row>

	        <row>
		  <entry><makevar>WITH_BERKELEY_DB</makevar></entry>

		  <entry>Define this variable to specify the ability to
		    use a variant of the Berkeley database package such as
		    <filename role="package">databases/db41</filename>.
		    An associated variable,
		    <makevar>WITH_BDB_VER</makevar>, may be
		    set to values such as 2, 3, 4, 41 or 42.</entry>
	        </row>

	        <row>
		  <entry><makevar>WITH_MYSQL</makevar></entry>

		  <entry>Define this variable to specify the ability to
		    use a variant of the MySQL database package such as
		    <filename role="package">databases/mysql40-server</filename>.
		    An associated variable,
		    <makevar>WANT_MYSQL_VER</makevar>, may be
		    set to values such as 323, 40, 41, or 50.</entry>
	        </row>

	        <row>
		  <entry><makevar>WITHOUT_NLS</makevar></entry>

		  <entry>If set, says that internationalization is not
		    needed, which can save compile time.  By default,
		    internationalization is used.</entry>
	        </row>

	        <row>
		  <entry><makevar>WITH_OPENSSL_BASE</makevar></entry>

		  <entry>Use the version of OpenSSL in the base system.</entry>
	        </row>

	        <row>
		  <entry><makevar>WITH_OPENSSL_PORT</makevar></entry>

		  <entry>Use the version of OpenSSL from
		    <filename role="package">security/openssh</filename>,
		    overwriting the version that was originally installed
		    in the base system.</entry>
	        </row>

	        <row>
		  <entry><makevar>WITH_POSTGRESQL</makevar></entry>

		  <entry>Define this variable to specify the ability to
		    use a variant of the PostGreSQL database package such as
		    <filename role="package">databases/postgresql72</filename>.
		    </entry>
	        </row>

	        <row>
		  <entry><makevar>WITHOUT_X11</makevar></entry>

		  <entry>If the port can be built both with and without
		    X support, then it should normally be built with
		    X support. If this variable is defined, then
		    the version that does not have X support should
		    be built instead.</entry>
	        </row>
	      </tbody>
	    </tgroup>
	  </table>

      </sect2>

      <sect2>
	<title><makevar>OPTIONS</makevar></title>

	<sect3>
	  <title>Background</title>
	    <para>The <makevar>OPTIONS</makevar> variable gives the user who
	      installs the port a dialog with the available options and saves
	      them to <filename>/var/db/ports/portname/options</filename>.  Next
	      time when the port has to be rebuild, the options are reused.  Never
	      again you will have to remember all the twenty
	      <makevar>WITH_<replaceable>*</replaceable></makevar> and
	      <makevar>WITHOUT_<replaceable>*</replaceable></makevar> options you
	      used to build this port!</para>

	    <para>When the user runs <command>make config</command> (or runs
	      <command>make build</command> for the first time), the framework will
	      check for
	      <filename>/var/db/ports/<replaceable>portname</replaceable>/options</filename>.
	      If that file does not exist, it will use the values of
	      <makevar>OPTIONS</makevar> to create a dialogbox where the options
	      can be enabled or disabled.  Then the
	      <filename>options</filename> file is saved and the selected
	      variables will be used when building the port.</para>

	    <para>Use <command>make showconfig</command> to see the saved
	      configuration.  Use <command>make rmconfig</command> to remove the
	      saved configuration.</para>
	</sect3>

	<sect3>
	  <title>Syntax</title>
	    <para>The syntax for the <makevar>OPTIONS</makevar> variable is:

<programlisting>OPTIONS=	OPTION	"descriptive text" default ...
</programlisting>

	      The value for default is either <literal>ON</literal> or
	      <literal>OFF</literal>.  Multiple repetitions of these three fields
	      are allowed.</para>

	    <para><makevar>OPTIONS</makevar> definition must appear before
	      the inclusion of <filename>bsd.port.pre.mk</filename>.
	      The <makevar>WITH_*</makevar> and <makevar>WITHOUT_*</makevar>
	      variables can only be tested after the inclusion of
	      <filename>bsd.port.pre.mk</filename>.  Due to a deficiency
	      in the infrastructure, you can only test
	      <makevar>WITH_*</makevar> variables for options, which are
	      <literal>ON</literal> by default, and
	      <makevar>WITHOUT_*</makevar> variables for options, which
	      defaults to <literal>OFF</literal>.</para>

	<sect3>
	  <title>Example</title>
	  <example id="ports-options-simple-use">
	    <title>Simple use of <makevar>OPTIONS</makevar></title>
	    <para><programlisting>OPTIONS=      FOO "Enable option foo" On \
              BAR "Support feature bar" Off

.include &lt;bsd.port.pre.mk&gt;

.if defined(WITHOUT_FOO)
CONFIGURE_ARGS+=	--without-foo
.else
CONFIGURE_ARGS+=	--with-foo
.endif

.if defined(WITH_BAR)
RUN_DEPENDS+=	bar:${PORTSDIR}/bar/bar
.endif

.include &lt;bsd.port.post.mk&gt;</programlisting></para>
	  </example>

	<sect3>
	  <title>Brokenness</title>
	  <itemizedlist>
	    <listitem>
	      <para><makevar>OPTIONS</makevar> are ignored in
		<makevar>BATCH</makevar> mode.</para>
	    </listitem>
	  </itemizedlist>
	</sect3>
	
      </sect2>

    </sect1>

    <sect1 id="makefile-wrkdir">
      <title>Specifying the working directory</title>

      <para>Each port is extracted in to a working directory, which must be
	writable.  The ports system defaults to having the
	<makevar>DISTFILES</makevar> unpack in to a directory called
	<literal>${DISTNAME}</literal>.  In other words, if you have
	set:</para>

      <programlisting>PORTNAME=      foo
PORTVERSION=   1.0</programlisting>

      <para>then the port's distribution files contain a top-level directory,
	<filename>foo-1.0</filename>, and the rest of the files are located
	under that directory.</para>

      <para>There are a number of variables you can override if that is not the
	case.</para>

      <sect2>
	<title><makevar>WRKSRC</makevar></title>

	<para>The variable lists the name of the directory that is created when
	  the application's distfiles are extracted.  If our previous example
	  extracted into a directory called <filename>foo</filename> (and not
	  <filename>foo-1.0</filename>) you would write:</para>

	<programlisting>WRKSRC=      ${WRKDIR}/foo</programlisting>

	<para>or possibly</para>

	<programlisting>WRKSRC=      ${WRKDIR}/${PORTNAME}</programlisting>
      </sect2>

      <sect2>
	<title><makevar>NO_WRKSUBDIR</makevar></title>

	<para>If the port does not extract in to a subdirectory at all then
	  you should set <makevar>NO_WRKSUBDIR</makevar> to indicate
	  that.</para>

	<programlisting>NO_WRKSUBDIR= yes</programlisting>
      </sect2>
    </sect1>

    <sect1 id="conflicts">
      <title><makevar>CONFLICTS</makevar></title>

	<para>If your package cannot coexist with other packages
	  (because of file conflicts, runtime incompatibility, etc.),
	  list the other package names in the <makevar>CONFLICTS</makevar>
	  variable. You can use shell globs like <literal>*</literal> and
	  <literal>?</literal> here.  Packages names should be
	  enumerated the same way they appear in
	  <filename>/var/db/pkg</filename>.  Please make sure that
	  <makevar>CONFLICTS</makevar> does not match this port's
	  package itself, or else forcing its installation with
	  <makevar>FORCE_PKG_REGISTER</makevar> will no longer work.
       </para>

      <note>
	<para><makevar>CONFLICTS</makevar> automatically sets
	  <makevar>IGNORE</makevar>, which is more fully documented
	  in <xref linkend="dads-noinstall">.</para>
      </note>
    </sect1>

    </chapter>

    <chapter id="special">
      <title>Special considerations</title>

      <para>There are some more things you have to take into account when you
	create a port.  This section explains the most common of those.</para>

      <sect1 id="porting-shlibs">
	<title>Shared Libraries</title>

	<para>If your port installs one or more shared libraries, define a
	  <makevar>INSTALLS_SHLIB</makevar> make variable, which will instruct
	  a <filename>bsd.port.mk</filename> to run
	  <literal>&dollar;{LDCONFIG} -m</literal> on the directory where the
	  new library is installed (usually
	  <filename><makevar>PREFIX</makevar>/lib</filename>) during
	  <maketarget>post-install</maketarget> target to register it into the
	  shared library cache.  This variable, when defined, will also
	  facilitate addition of an appropriate
	  <literal>@exec /sbin/ldconfig -m</literal> and
	  <literal>@unexec /sbin/ldconfig -R</literal> pair into your
	  <filename>pkg-plist</filename> file, so that a user who installed
	  the package can start using the shared library immediately and
	  de-installation will not cause the system to still believe the
	  library is there.</para>

	<para>If you need, you can override the default location where the new
	  library is installed by defining the <makevar>LDCONFIG_DIRS</makevar>
	  make variable, which should contain a list of directories into which
	  shared libraries are to be installed.  For example if your port
	  installs shared libraries into
	  <filename><makevar>PREFIX</makevar>/lib/foo</filename> and
	  <filename><makevar>PREFIX</makevar>/lib/bar</filename> directories
	  you could use the following in your
	  <filename>Makefile</filename>:</para>

	<programlisting>INSTALLS_SHLIB= yes
LDCONFIG_DIRS=  %%PREFIX%%/lib/foo %%PREFIX%%/lib/bar</programlisting>

	<para>Note that content of <makevar>LDCONFIG_DIRS</makevar> is passed
	  through &man.sed.1; just like the rest of <filename>pkg-plist</filename>,
	  so <makevar>PLIST_SUB</makevar> substitutions also apply here.  It is
	  recommended that you use <literal>%%PREFIX%%</literal> for
	  <makevar>PREFIX</makevar>, <literal>%%LOCALBASE%%</literal> for
	  <makevar>LOCALBASE</makevar> and <literal>%%X11BASE%%</literal> for
	  <makevar>X11BASE</makevar>.</para>

	<para>Try to keep shared library version numbers in the
	  <filename>libfoo.so.0</filename> format.  Our runtime linker only
	  cares for the major (first) number.</para>

	<para>When the major library version number increments in the update
	  to the new port version, all other ports that link to the affected
	  library should have their <makevar>PORTREVISION</makevar> incremented,
	  to force recompilation with the new library version.</para>

      </sect1>

    <sect1 id="porting-restrictions">
      <title>Ports with distribution restrictions</title>

      <para>Licenses vary, and some of them place restrictions on how the
	application can be packaged, whether it can be sold for profit, and so
	on.</para>

      <important>
	<para>It is your responsibility as a porter to read the licensing
	  terms of the software and make sure that the FreeBSD project will
	  not be held accountable for violating them by redistributing the
	  source or compiled binaries either via FTP/HTTP or CD-ROM.  If in doubt,
	  please contact the &a.ports;.</para>
      </important>

      <para>In situations like this, the variables described in the following
	sections can be set.</para>

      <sect2>
	<title><makevar>NO_PACKAGE</makevar></title>

	<para>This variable indicates that we may not generate a binary
	  package of the application.  For instance, the license may
	  disallow binary redistribution, or it may prohibit distribution
	  of packages created from patched sources.</para>

	<para>However, the port's <makevar>DISTFILES</makevar> may be
	  freely mirrored on FTP/HTTP.  They may also be distributed on
	  a CD-ROM (or similar media) unless <makevar>NO_CDROM</makevar>
	  is set as well.</para>

	<para><makevar>NO_PACKAGE</makevar> should also be used if the binary
	  package is not generally useful, and the application should always
	  be compiled from the source code.  For example, if the application
	  has configuration information that is site specific hard coded in to
	  it at compile time, set <makevar>NO_PACKAGE</makevar>.</para>

	<para><makevar>NO_PACKAGE</makevar> should be set to a string
	  describing the reason why the package should not be
	  generated.</para>
      </sect2>

      <sect2>
	<title><makevar>NO_CDROM</makevar></title>

	<para>This variable alone indicates that, although we are allowed
	  to generate binary packages, we may put neither those packages
	  nor the port's <makevar>DISTFILES</makevar> onto a CD-ROM (or
	  similar media) for resale.  However, the binary packages and
	  the port's <makevar>DISTFILES</makevar> will still be available
	  via FTP/HTTP.</para>

	<para> If this variable is set along with
	  <makevar>NO_PACKAGE</makevar>, then only the port's
	  <makevar>DISTFILES</makevar> will be available, and only via
	  FTP/HTTP.</para>

	<para><makevar>NO_CDROM</makevar> should be set to a string
	  describing the reason why the port cannot be redistributed
	  on CD-ROM.  For instance, this should be used if the port's license
	  is for <quote>non-commercial</quote> use only.</para>
      </sect2>

      <sect2>
	<title><makevar>RESTRICTED</makevar></title>

	<para>Set this variable alone if the application's license permits
	  neither mirroring the application's <makevar>DISTFILES</makevar>
	  nor distributing the binary package in any way.</para>

	<para><makevar>NO_CDROM</makevar> or <makevar>NO_PACKAGE</makevar>
	  should not be set along with <makevar>RESTRICTED</makevar>
	  since the latter variable implies the former ones.</para>

	<para><makevar>RESTRICTED</makevar> should be set to a string
	  describing the reason why the port cannot be redistributed.
	  Typically, this indicates that the port contains proprietary
	  software and that the user will need to manually download the
	  <makevar>DISTFILES</makevar>, possibly after registering for the
	  software or agreeing to accept the terms of an
	  <acronym>EULA</acronym>.</para>
      </sect2>

      <sect2>
	<title><makevar>RESTRICTED_FILES</makevar></title>

	<para>When <makevar>RESTRICTED</makevar> or <makevar>NO_CDROM</makevar>
	  is set, this variable defaults to <literal>${DISTFILES}
	  ${PATCHFILES}</literal>, otherwise it is empty.  If only some of the
	  distribution files are restricted, then set this variable to list
	  them.</para>

	<para>Note that the port committer should add an entry to
	  <filename>/usr/ports/LEGAL</filename> for every listed distribution
	  file, describing exactly what the restriction entails.</para>
      </sect2>
    </sect1>

    <sect1 id="using-autotools">
      <title>Building mechanisms</title>

      <sect2 id="using-make">
	<title><command>make</command>, <command>gmake</command>, and
	  <command>imake</command></title>

	<para>If your port uses <application>GNU make</application>, set
	  <literal>USE_GMAKE=yes</literal>.</para>

	  <table frame="none">
	    <title>Variables for ports related to gmake</title>

	    <tgroup cols="2">
	      <thead>
		<row>
		  <entry>Variable</entry>

		  <entry>Means</entry>
		</row>
	      </thead>

	      <tbody>
		<row>
		  <entry><makevar>USE_GMAKE</makevar></entry>

		  <entry>The port requires <command>gmake</command> to
		    build.</entry>
		</row>

		<row>
		  <entry><makevar>GMAKE</makevar></entry>

		  <entry>The full path for <command>gmake</command> if it is not
		    in the <envar>PATH</envar>.</entry>
		</row>
	      </tbody>
	    </tgroup>
	  </table>

	  <para>If your port is an X application that creates
	    <filename>Makefile</filename> files from
	    <filename>Imakefile</filename> files using
	    <application>imake</application>, then set
	    <literal>USE_IMAKE=yes</literal>.  This will cause the
	    configure stage to automatically do an <command>xmkmf -a</command>.
	    If the <option>-a</option> flag is a problem for your port, set
	    <literal>XMKMF=xmkmf</literal>.  If the port uses
	    <application>imake</application> but does not understand the
	    <maketarget>install.man</maketarget> target,
	    <literal>NO_INSTALL_MANPAGES=yes</literal> should be set.</para>

	  <para>If your port's source <filename>Makefile</filename> has
	    something else than <maketarget>all</maketarget> as the main build
	    target, set <makevar>ALL_TARGET</makevar> accordingly.  Same goes
	    for <maketarget>install</maketarget> and
	    <makevar>INSTALL_TARGET</makevar>.</para>

	</sect2>

	<sect2 id="using-configure">
	  <title><command>configure</command> script</title>

	<para>If your port uses the <command>configure</command> script to
	  generate <filename>Makefile</filename> files from
	  <filename>Makefile.in</filename> files, set
	  <literal>GNU_CONFIGURE=yes</literal>.  If you want to give extra
	  arguments to the <command>configure</command> script (the default
	  argument is <literal>--prefix=&dollar;{PREFIX}
	  &dollar;{CONFIGURE_TARGET}</literal>), set those
	  extra arguments in <makevar>CONFIGURE_ARGS</makevar>.  Extra
	  environment variables can be passed using
	  <makevar>CONFIGURE_ENV</makevar> variable.</para>

	<para>If your package uses GNU <command>configure</command>, and
	  the resulting executable file has a <quote>strange</quote> name
	  like
	  <filename>i386-portbld-freebsd4.7-</filename><replaceable>appname</replaceable>,
	  you will need to additionally override the
	  <makevar>CONFIGURE_TARGET</makevar> variable to specify the
	  target in the way required by scripts generated by recent
	  versions of <command>autoconf</command>.  Add the following line
	  immediately after the <literal>GNU_CONFIGURE=yes</literal> line
	  in your <filename>Makefile</filename>:</para>

	<para>
	  <literal>CONFIGURE_TARGET=--build=${MACHINE_ARCH}-portbld-freebsd${OSREL}</literal>
	  </para>

	  <table frame="none">
	    <title>Variables for ports that use configure</title>

	    <tgroup cols="2">
	      <thead>
		<row>
		  <entry>Variable</entry>

		  <entry>Means</entry>
		</row>
	      </thead>

	      <tbody>
		<row>
		  <entry><makevar>GNU_CONFIGURE</makevar></entry>

		  <entry>The port uses <command>configure</command> script to
		    prepare build.</entry>
		</row>

		<row>
		  <entry><makevar>HAS_CONFIGURE</makevar></entry>

		  <entry>Same as <makevar>GNU_CONFIGURE</makevar>, except
		    default configure target is not added to
		    <makevar>CONFIGURE_ARGS</makevar>.</entry>
		</row>

		<row>
		  <entry><makevar>CONFIGURE_ARGS</makevar></entry>

		  <entry>Additional arguments passed to
		    <command>configure</command> script.</entry>
		</row>

		<row>
		  <entry><makevar>CONFIGURE_ENV</makevar></entry>

		  <entry>Additional environment variables to be set
		    for <command>configure</command> script run.</entry>
		</row>

		<row>
		  <entry><makevar>CONFIGURE_TARGET</makevar></entry>

		  <entry>Override default configure target.  Default value is
		    <literal>&dollar;{MACHINE_ARCH}-portbld-freebsd&dollar;{OSREL}</literal>.</entry>
		</row>
	      </tbody>
	    </tgroup>
	  </table>
	</sect2>

	<sect2 id="using-autoconf">
	  <title><command>autoconf</command></title>

	  <para>Some ports do not contain a <filename>configure</filename>
	    script, but do contain an <application>autoconf</application> template
	    in the <filename>configure.ac</filename> file.  You can use
	    <makevar>USE_AUTOCONF_VER</makevar> variable to let
	    <application>autoconf</application> create
	    the <filename>configure</filename> script.  It is also useful for
	    recreating the <filename>configure</filename> script after patching
	    <filename>configure.ac</filename>.</para>

	  <table frame="none">
	    <title>Variables for ports that use autoconf</title>

	    <tgroup cols="2">
	      <thead>
		<row>
		  <entry>Variable</entry>

		  <entry>Means</entry>
		</row>
	      </thead>

	      <tbody>
		<row>
		  <entry><makevar>USE_AUTOCONF_VER</makevar></entry>

		  <entry>Specifies that the port uses <command>autoconf</command>.
		    Implies <literal>GNU_CONFIGURE</literal>.  Valid values are
		    <literal>213</literal>, <literal>253</literal>, and
		    <literal>259</literal>.</entry>
		</row>

		<row>
		  <entry><makevar>AUTOCONF</makevar></entry>

		  <entry>Set to the path of GNU <command>autoconf</command> if it
		    is not in the <envar>PATH</envar>.  The default is set
		    according to the <makevar>USE_AUTOCONF_VER</makevar>
		    variable.</entry>
		</row>

		<row>
		  <entry><makevar>AUTOCONF_ARGS</makevar></entry>

		  <entry>Command line arguments to pass to
		    <command>autoconf</command>.</entry>
		</row>

		<row>
		  <entry><makevar>AUTOCONF_ENV</makevar></entry>

		  <entry>Set these
		    <literal><replaceable>variable</replaceable>=<replaceable>value</replaceable></literal>
		    pairs in the environment before running
		    <command>autoconf</command>.</entry>
		</row>

		<row>
		  <entry><makevar>USE_AUTOHEADER_VER</makevar></entry>

		  <entry>Specifies that the port uses <command>autoheader</command>.
		    Implies <literal>USE_AUTOCONF_VER</literal>.</entry>
		</row>

		<row>
		  <entry><makevar>AUTOHEADER</makevar></entry>

		  <entry>Set to the path of GNU <command>autoheader</command> if
		    it is not in the <envar>PATH</envar>.  The default is set
		    according to <makevar>USE_AUTOCONF_VER</makevar>.</entry>
		</row>

		<row>
		  <entry><makevar>AUTORECONF</makevar></entry>

		  <entry>Set to the path of GNU <command>autoreconf</command> if
		    it is not in the <envar>PATH</envar>.  The default is set
		    according to <makevar>USE_AUTOCONF_VER</makevar>.</entry>
		</row>

		<row>
		  <entry><makevar>AUTOSCAN</makevar></entry>

		  <entry>Set to the path of GNU <command>autoscan</command> if it
		    is not set in the <envar>PATH</envar>.  The default is set
		    according to <makevar>USE_AUTOCONF_VER</makevar>.</entry>
		</row>

		<row>
		  <entry><makevar>AUTOIFNAMES</makevar></entry>

		  <entry>Set to the path of GNU <command>autoifnames</command> if
		    it is not set in the <envar>PATH</envar>.  The default is set
		    according to <makevar>USE_AUTOCONF_VER</makevar>.</entry>
		</row>
	      </tbody>
	    </tgroup>
	  </table>
	</sect2>

	<sect2 id="using-automake">
	  <title><command>automake</command></title>

	  <para>Some packages only contain <filename>Makefile.am</filename>
	    files.  These have to be converted into
	    <filename>Makefile.in</filename> files using
	    <application>automake</application>.  Specify the
	    <makevar>USE_AUTOMAKE_VER</makevar> variable.</para>

	  <table frame="none">
	    <title>Variables for ports that use automake</title>

	    <tgroup cols="2">
	      <thead>
		<row>
		  <entry>Variable</entry>

		  <entry>Means</entry>
		</row>
	      </thead>

	      <tbody>
		<row>
		  <entry><makevar>AUTOMAKE</makevar></entry>

		  <entry>The full path for <command>automake</command>, if it is
		    not in the <envar>PATH</envar>.</entry>
		</row>

		<row>
		  <entry><makevar>USE_AUTOMAKE_VER</makevar></entry>

		  <entry>The port uses <command>automake</command>.  Valid values
		    for this variable are <literal>14</literal>,
		    <literal>15</literal>, and <literal>19</literal>, and sets
		    the <makevar>AUTOMAKE_DIR</makevar> and
		    <makevar>ACLOCAL_DIR</makevar> variables
		    appropriately.</entry>
		</row>

		<row>
		  <entry><makevar>AUTOMAKE_ARGS</makevar></entry>

		  <entry>One or more command line arguments to pass to
		    <makevar>AUTOMAKE</makevar> if
		    <makevar>USE_AUTOMAKE_VER</makevar> is set.</entry>
		</row>

		<row>
		  <entry><makevar>AUTOMAKE_ENV</makevar></entry>

		  <entry>One or more environment variables to set (and their
		    values) before running <makevar>AUTOMAKE</makevar>.</entry>
		</row>

		<row>
		  <entry><makevar>ACLOCAL</makevar></entry>

		  <entry>Set to the path of the GNU <command>aclocal</command> if
		    it is not in the <envar>PATH</envar>.  The default is set
		    according to the <makevar>USE_AUTOMAKE_VER</makevar>
		    variable.</entry>
		</row>

		<row>
		  <entry><makevar>ACLOCAL_DIR</makevar></entry>

		  <entry>Set to the path of the GNU <command>aclocal</command>
		    shared directory.  The default is set according to the
		    <makevar>USE_AUTOMAKE_VER</makevar> variable.</entry>
		</row>

		<row>
		  <entry><makevar>AUTOMAKE_DIR</makevar></entry>

		  <entry>Set to the path of the GNU <command>automake</command>
		    shared directory.  The default is set according to the
		    <makevar>USE_AUTOMAKE_VER</makevar> variable.</entry>
		</row>
	      </tbody>
	    </tgroup>
	  </table>

	</sect2>
	<sect2 id="using-libtool">
	  <title><command>libtool</command></title>

	  <para>Shared libraries using the GNU building framework usually use
	    <application>libtool</application> to adjust the compilation
	    and installation of shared library to match the customs of given
	    operating system.  The Ports Collection provides a version
	    of <application>libtool</application> modified for &os;.  Changes
	    include suppressing of minor version numbers in names of installed
	    files, and prevention of <filename>*.la</filename> (libtool archive)
	    files installation.</para>

	  <para>To replace copy of <application>libtool</application> included
	    in the port with our modified copy, specify
	    <makevar>USE_LIBTOOL_VER</makevar> variable.  If, for any reason,
	    our modified <application>libtool</application> does not work,
	    omit any <application>libtool</application> related variables
	    to use bundled copy of <application>libtool</application>.</para>

	  <table frame="none">
	    <title>Variables for ports that use libtool</title>

	    <tgroup cols="2">
	      <thead>
		<row>
		  <entry>Variable</entry>

		  <entry>Means</entry>
		</row>
	      </thead>

	      <tbody>
		<row>
		  <entry><makevar>USE_LIBTOOL_VER</makevar></entry>

		  <entry>The port uses <command>libtool</command>.  Implies
		    <makevar>GNU_CONFIGURE</makevar>.
		    The <filename>configure</filename> script will be patched
		    to use system copy of <command>libtool</command>.
		    Valid values are <literal>13</literal> and
		    <literal>15</literal>.</entry>
		</row>

		<row>
		  <entry><makevar>USE_INC_LIBTOOL_VER</makevar></entry>

		  <entry>Same as <makevar>USE_LIBTOOL_VER</makevar>, except
		    the <filename>configure</filename> patching will not be
		    performed.  You must take care of it yourself.</entry>
		</row>

		<row>
		  <entry><makevar>LIBTOOL</makevar></entry>

		  <entry>Set to the path of <command>libtool</command> if it is
		    not set in the <envar>PATH</envar>.</entry>
		</row>

		<row>
		  <entry><makevar>LIBTOOLFILES</makevar></entry>

		  <entry>The files to patch for <command>libtool</command>.
		    Defaults to <literal>aclocal.m4</literal> if
		    <makevar>USE_AUTOCONF</makevar> is defined,
		    <literal>configure</literal> otherwise.</entry>
		</row>

		<row>
		  <entry><makevar>LIBTOOLFLAGS</makevar></entry>

		  <entry>Additional flags to pass to
		    <command>ltconfig</command>.  Defaults to
		    <literal>--disable-ltlibs</literal>.</entry>
		</row>

		<row>
		  <entry><makevar>USE_LIBLTDL</makevar></entry>

		  <entry>The port uses <command>libltdl</command>.</entry>
		</row>
	      </tbody>
	    </tgroup>
	  </table>

	  <note>
	    <para><makevar>USE_LIBTOOL_VER</makevar> does not work together
	      with <makevar>USE_GCC</makevar>.  You have to use
	      <makevar>USE_INC_LIBTOOL_VER</makevar> and perform manual patching.
	      Look at <literal>patch-autotools</literal> target in
	      <filename role="package">devel/glibmm</filename>
	      for an example.</para>
	  </note>

      </sect2>
    </sect1>

    <sect1 id="using-perl">
      <title>Using <literal>perl</literal></title>

      <table frame="none">
	<title>Variables for ports that use <literal>perl</literal></title>

	<tgroup cols="2">
	  <thead>
	    <row>
	      <entry>Variable</entry>

	      <entry>Means</entry>
	    </row>
	  </thead>

	  <tbody>
	    <row>
	      <entry><makevar>USE_PERL5</makevar></entry>

	      <entry>Says that the port uses <literal>perl 5</literal> to build and run.</entry>
	    </row>

	    <row>
	      <entry><makevar>USE_PERL5_BUILD</makevar></entry>

	      <entry>Says that the port uses <literal>perl 5</literal> to build.</entry>
	    </row>

	    <row>
	      <entry><makevar>USE_PERL5_RUN</makevar></entry>

	      <entry>Says that the port uses <literal>perl 5</literal> to run.</entry>
	    </row>

	    <row>
	      <entry><makevar>PERL</makevar></entry>

	      <entry>The full path of <literal>perl 5</literal>, either in the
		system or installed from a port, but without the version
		number.  Use this if you need to replace
		<quote><literal>#!</literal></quote>lines in scripts.</entry>
	    </row>

	    <row>
	      <entry><makevar>PERL_CONFIGURE</makevar></entry>

	      <entry>Configure using Perl's MakeMaker.  It implies
		<makevar>USE_PERL5</makevar>.</entry>
	    </row>

	    <row>
	      <entry><makevar>PERL_MODBUILD</makevar></entry>

	      <entry>Configure, build and install using Module::Build.  It
		implies <makevar>PERL_CONFIGURE</makevar>.</entry>
	    </row>
	  </tbody>
	</tgroup>

	<tgroup cols="2">
	  <thead>
	    <row>
	      <entry>Read only variables</entry>
	    </row>
	  </thead>

	  <tbody>
	    <row>
	      <entry><makevar>PERL_VERSION</makevar></entry>

	      <entry>The full version of <literal>perl</literal> installed (e.g.,
		<literal>5.00503</literal>).</entry>
	    </row>

	    <row>
	      <entry><makevar>PERL_VER</makevar></entry>

	      <entry>The short version of <literal>perl</literal> installed (e.g.,
		<literal>5.005</literal>).</entry>
	    </row>

	    <row>
	      <entry><makevar>PERL_LEVEL</makevar></entry>

	      <entry>The installed <literal>perl</literal> version as an integer of the form <literal>MNNNPP</literal>
		(e.g., <literal>500503</literal>).</entry>
	    </row>

	    <row>
	      <entry><makevar>PERL_ARCH</makevar></entry>

	      <entry>Where <literal>perl</literal> stores architecture dependent libraries.
		Defaults to <literal>${ARCH}-freebsd</literal>.</entry>
	    </row>

	    <row>
	      <entry><makevar>PERL_PORT</makevar></entry>

	      <entry>Name of the <literal>perl</literal> port that is
		installed (e.g., <literal>perl5</literal>).</entry>
	    </row>

	    <row>
	      <entry><makevar>SITE_PERL</makevar></entry>

	      <entry>Directory name where site specific
		<literal>perl</literal> packages go.
		This value is added to PLIST_SUB.</entry>
	    </row>
	  </tbody>
	</tgroup>
      </table>

      <note>
	<para>Ports of Perl modules, which do not have an official website,
	  should link <hostid>cpan.org</hostid> in the WWW line of a
	  <filename>pkg-descr</filename> file.  The suggested URL scheme is
	  <literal>http://search.cpan.org/dist/Module-Name</literal>.</para>
      </note>

    </sect1>

    <sect1 id="using-x11">
      <title>Using X11</title>

      <sect2 id="x11-variables">
	<title>Variable definitions</title>

      <table frame="none">
	<title>Variables for ports that use X</title>

	<tgroup cols="2">
	  <tbody>
	    <row>
	      <entry><makevar>USE_X_PREFIX</makevar></entry>

	      <entry>The port installs in <makevar>X11BASE</makevar>, not
		<makevar>PREFIX</makevar>.</entry>
	    </row>

	    <row>
	      <entry><makevar>USE_XLIB</makevar></entry>

	      <entry>The port uses the X libraries.</entry>
	    </row>

	    <row>
	      <entry><makevar>USE_MOTIF</makevar></entry>

	      <entry>The port uses the Motif toolkit.  Implies
		<makevar>USE_XPM</makevar>.</entry>
	    </row>

	    <row>
	      <entry><makevar>USE_IMAKE</makevar></entry>

	      <entry>The port uses <command>imake</command>.  Implies
		<makevar>USE_X_PREFIX</makevar>.</entry>
	    </row>

	    <row>
	      <entry><makevar>XMKMF</makevar></entry>

	      <entry>Set to the path of <command>xmkmf</command> if not in the
		<envar>PATH</envar>.  Defaults to <literal>xmkmf
		  -a</literal>.</entry>
	    </row>
	  </tbody>
	</tgroup>
      </table>

      <table frame="none">
	<title>Variables for depending on individual parts of X11</title>

	<tgroup cols="2">
	  <tbody>
	    <row>
	      <entry><makevar>X_IMAKE_PORT</makevar></entry>

	      <entry>Port providing <command>imake</command> and several
		other utilities used to build X11.</entry>
	    </row>

	    <row>
	      <entry><makevar>X_LIBRARIES_PORT</makevar></entry>

	      <entry>Port providing X11 libraries.</entry>
	    </row>

	    <row>
	      <entry><makevar>X_CLIENTS_PORT</makevar></entry>

	      <entry>Port providing X clients.</entry>
	    </row>

	    <row>
	      <entry><makevar>X_SERVER_PORT</makevar></entry>

	      <entry>Port providing X server.</entry>
	    </row>

	    <row>
	      <entry><makevar>X_FONTSERVER_PORT</makevar></entry>

	      <entry>Port providing font server.</entry>
	    </row>

	    <row>
	      <entry><makevar>X_PRINTSERVER_PORT</makevar></entry>

	      <entry>Port providing print server.</entry>
	    </row>

	    <row>
	      <entry><makevar>X_VFBSERVER_PORT</makevar></entry>

	      <entry>Port providing virtual framebuffer server.</entry>
	    </row>

	    <row>
	      <entry><makevar>X_NESTSERVER_PORT</makevar></entry>

	      <entry>Port providing a nested X server.</entry>
	    </row>

	    <row>
	      <entry><makevar>X_FONTS_ENCODINGS_PORT</makevar></entry>

	      <entry>Port providing encodings for fonts.</entry>
	    </row>

	    <row>
	      <entry><makevar>X_FONTS_MISC_PORT</makevar></entry>

	      <entry>Port providing miscellaneous bitmap fonts.</entry>
	    </row>

	    <row>
	      <entry><makevar>X_FONTS_100DPI_PORT</makevar></entry>

	      <entry>Port providing 100dpi bitmap fonts.</entry>
	    </row>

	    <row>
	      <entry><makevar>X_FONTS_75DPI_PORT</makevar></entry>

	      <entry>Port providing 75dpi bitmap fonts.</entry>
	    </row>

	    <row>
	      <entry><makevar>X_FONTS_CYRILLIC_PORT</makevar></entry>

	      <entry>Port providing cyrillic bitmap fonts.</entry>
	    </row>

	    <row>
	      <entry><makevar>X_FONTS_TTF_PORT</makevar></entry>

	      <entry>Port providing &truetype; fonts.</entry>
	    </row>

	    <row>
	      <entry><makevar>X_FONTS_TYPE1_PORT</makevar></entry>

	      <entry>Port providing Type1 fonts.</entry>
	    </row>

	    <row>
	      <entry><makevar>X_MANUALS_PORT</makevar></entry>

	      <entry>Port providing developer oriented manual pages</entry>
	    </row>
	  </tbody>
	</tgroup>
      </table>

      <example id="using-x11-vars">
	<title>Using X11 related variables in port</title>
	<programlisting># Use X11 libraries and depend on
# font server as well as cyrillic fonts.
RUN_DEPENDS=   ${X11BASE}/bin/xfs:${X_FONTSERVER_PORT} \
               ${X11BASE}/lib/X11/fonts/cyrillic/crox1c.pcf.gz:${X_FONTS_CYRILLIC_PORT}

USE_XLIB=      yes</programlisting>
      </example>

      </sect2>

      <sect2 id="x11-motif">
	<title>Ports that require Motif</title>

	<para>If your port requires a Motif library, define
	  <makevar>USE_MOTIF</makevar> in the <filename>Makefile</filename>.
	  Default Motif implementation is
	  <filename role="package">x11-toolkits/open-motif</filename>.
	  Users can choose
	  <filename role="package">x11-toolkits/lesstif</filename> instead
	  by setting <makevar>WANT_LESSTIF</makevar> variable.</para>

	<para>The <makevar>MOTIFLIB</makevar> variable will be set by
	  <filename>bsd.port.mk</filename> to reference the appropriate
	  Motif library.  Please patch the source of your port to
	  use <literal>&dollar;{MOTIFLIB}</literal> wherever the Motif library is referenced in the original
	  <filename>Makefile</filename> or
	  <filename>Imakefile</filename>.</para>

	<para>There are two common cases:</para>

	<itemizedlist>
	  <listitem>
	    <para>If the port refers to the Motif library as
	      <literal>-lXm</literal> in its <filename>Makefile</filename> or
	      <filename>Imakefile</filename>, simply substitute
	      <literal>&dollar;{MOTIFLIB}</literal> for it.</para>
	  </listitem>

	  <listitem>
	    <para>If the port uses <literal>XmClientLibs</literal> in its
	      <filename>Imakefile</filename>, change it to
	      <literal>&dollar;{MOTIFLIB} &dollar;{XTOOLLIB}
		&dollar;{XLIB}</literal>.</para>
	  </listitem>

	</itemizedlist>

	<para>Note that <makevar>MOTIFLIB</makevar> (usually) expands to
	  <literal>-L/usr/X11R6/lib -lXm</literal> or
	  <literal>/usr/X11R6/lib/libXm.a</literal>, so there is no need to
	  add <literal>-L</literal> or <literal>-l</literal> in front.</para>

      </sect2>

      <sect2>
	<title>X11 fonts</title>

	<para>If your port installs fonts for the X Window System, put them in
	  <filename><makevar>X11BASE</makevar>/lib/X11/fonts/local</filename>.<para>

      </sect2>

    </sect1>

    <sect1 id="using-gnome">
      <title>Using GNOME</title>

      <para>The FreeBSD/GNOME project uses its own set of variables
	to define which GNOME components a
	particular port uses. A
	<ulink url="http://www.FreeBSD.org/gnome/docs/porting.html">comprehensive
	list of these variables</ulink> exists within the FreeBSD/GNOME
	project's homepage.</para>

      <note>
	<para>Your port does not need to depend on GNOME if it merely installs
	  <application>pkg-config</application> metadata files to
	  <filename><makevar>PREFIX</makevar>/libdata/pkgconfig</filename>.
	  As usual, your port should be prepared to clean up after itself
	  and remove that directory if it becomes empty.
	  Assuming that your port installs a file named
	  <filename>gtkmumble.pc</filename> to the said location, just add
	  the following lines to <filename>pkg-plist</filename>:</para>

	<programlisting>libdata/pkgconfig/gtkmumble.pc
@unexec rmdir %B 2>/dev/null || true</programlisting>

	<para>The latter line must appear immediately after the former one
	  so that <literal>%B</literal> expands correctly.  Please refer
	  to &man.pkg.create.1; for a detailed description of the syntax
	  used in <filename>pkg-plist</filename>.</para>
      </note>

    </sect1>

    <sect1 id="using-kde">
      <title>Using KDE</title>

      <table frame="none">
	<title>Variables for ports that use KDE</title>

	<tgroup cols="2">
	  <tbody>
	    <row>
	      <entry><makevar>USE_QT_VER</makevar></entry>

	      <entry>The port uses the Qt toolkit.  Possible values are
		<literal>1</literal> and
		<literal>3</literal>;  each specify the major version
		of Qt to use.  Sets both <makevar>MOC</makevar> and
		<makevar>QTCPPFLAGS</makevar>to default appropriate
		values.</entry>
	    </row>

	    <row>
	      <entry><makevar>USE_KDELIBS_VER</makevar></entry>

	      <entry>The port uses KDE libraries.  Possible values are
		<literal>3</literal>;  each specify the major version
		of KDE to use.  Implies <makevar>USE_QT_VER</makevar>
		of the appropriate version.</entry>
	    </row>

	    <row>
	      <entry><makevar>USE_KDEBASE_VER</makevar></entry>

	      <entry>The port uses KDE base.  Possible values are
		<literal>3</literal>;  each specify the major version
		of KDE to use.  Implies <makevar>USE_KDELIBS_VER</makevar>
		of the appropriate version.</entry>
	    </row>

	    <row>
	      <entry><makevar>MOC</makevar></entry>

	      <entry>Set to the path of <command>moc</command>.
		Default set according to <makevar>USE_QT_VER</makevar>
		value.</entry>
	    </row>

	    <row>
	      <entry><makevar>QTCPPFLAGS</makevar></entry>

	      <entry>Set the <makevar>CPPFLAGS</makevar> to use when
		processing Qt code.  Default set according to
		<makevar>USE_QT_VER</makevar> value.</entry>
	    </row>
	  </tbody>
	</tgroup>
      </table>

    </sect1>

    <sect1 id="using-java">
      <title>Using Java</title>

      <sect2 id="java-variables">
	<title>Variable definitions</title>

      <para>If your port needs a Java&trade; Development Kit (JDK) to
	either build, run or even extract the distfile, then it should
	define <makevar>USE_JAVA</makevar>.</para>

      <para>There are several JDKs in the ports collection, from various
	vendors, and in several versions.  If your port must use one of
	these versions, you can define which one.  The most current
	version is <filename role="package">java/jdk14</filename>.</para>

      <table frame="none">
	<title>Variables that may be set by ports that use Java</title>

	<tgroup cols="2">
	  <thead>
	    <row>
	      <entry>Variable</entry>
	      <entry>Means</entry>
	    </row>
	  </thead>
	  <tbody>
	    <row>
	      <entry><makevar>USE_JAVA</makevar></entry>
	      <entry>Should be defined for the remaining variables to have any
		effect.</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_VERSION</makevar></entry>
	      <entry>List of space-separated suitable Java versions for
		the port.  An optional <literal>"+"</literal> allows you to
		specify a range of versions (allowed values:
		<literal>1.1[+] 1.2[+] 1.3[+] 1.4[+]</literal>).</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_OS</makevar></entry>
	      <entry>List of space-separated suitable JDK port operating
		systems for the port (allowed values: <literal>native
		linux</literal>).</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_VENDOR</makevar></entry>
	      <entry>List of space-separated suitable JDK port vendors for
		the port (allowed values: <literal>freebsd bsdjava sun ibm
		blackdown</literal>).</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_BUILD</makevar></entry>
	      <entry>When set, it means that the selected JDK port should
		be added to the build dependencies of the port.</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_RUN</makevar></entry>
	      <entry>When set, it means that the selected JDK port should
		be added to the run dependencies of the port.</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_EXTRACT</makevar></entry>
	      <entry>When set, it means that the selected JDK port should
		be added to the extract dependencies of the port.</entry>
	    </row>
	    <row>
	      <entry><makevar>USE_JIKES</makevar></entry>
	      <entry>Whether the port should or should not use the
		<command>jikes</command> bytecode compiler to build. When
		no value is set for this variable, the port will use
		<command>jikes</command> to build if available. You may
		also explicitly forbid or enforce the use of
		<command>jikes</command> (by setting <literal>'no'</literal>
		or <literal>'yes'</literal>). In the later case, <filename
		role="package">devel/jikes</filename> will be added to build
		dependencies of the port. In any case that <command>jikes</command>
		is actually used in place of <command>javac</command>, then the
		<makevar>HAVE_JIKES</makevar> variable is defined by
		<filename>bsd.java.mk</filename>.</entry>
	    </row>
	  </tbody>
	</tgroup>
      </table>

      <para>Below is the list of all settings a port will receive after
	setting <makevar>USE_JAVA</makevar>:</para>

      <table frame="none">
	<title>Variables provided to ports that use Java</title>

	<tgroup cols="2">
	  <thead>
	    <row>
	      <entry>Variable</entry>
	      <entry>Value</entry>
	    </row>
	  </thead>
	  <tbody>
	    <row>
	      <entry><makevar>JAVA_PORT</makevar></entry>
	      <entry>The name of the JDK port (e.g.
		<literal>'java/jdk14'</literal>).</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_PORT_VERSION</makevar></entry>
	      <entry>The full version of the JDK port (e.g.
		<literal>'1.4.2'</literal>). If you only need the first
		two digits of this version number, use
		<makevar>${JAVA_PORT_VERSION:C/^([0-9])\.([0-9])(.*)$/\1.\2/}</makevar>.</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_PORT_OS</makevar></entry>
	      <entry>The operating system used by the JDK port (e.g.
		<literal>'linux'</literal>).</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_PORT_VENDOR</makevar></entry>
	      <entry>The vendor of the JDK port (e.g.
		<literal>'sun'</literal>).</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_PORT_OS_DESCRIPTION</makevar></entry>
	      <entry>Description of the operating system used by the JDK port
		(e.g. <literal>'Linux'</literal>).</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_PORT_VENDOR_DESCRIPTION</makevar></entry>
	      <entry>Description of the vendor of the JDK port (e.g.
		<literal>'FreeBSD Foundation'</literal>).</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_HOME</makevar></entry>
	      <entry>Path to the installation directory of the JDK (e.g.
		<filename>'/usr/local/jdk1.3.1'</filename>).</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVAC</makevar></entry>
	      <entry>Path to the Java compiler to use (e.g.
		<filename>'/usr/local/jdk1.1.8/bin/javac'</filename> or
		<filename>'/usr/local/bin/jikes'</filename>).</entry>
	    </row>
	    <row>
	      <entry><makevar>JAR</makevar></entry>
	      <entry>Path to the <command>jar</command> tool to use (e.g.
		<filename>'/usr/local/jdk1.2.2/bin/jar'</filename> or
		<filename>'/usr/local/bin/fastjar'</filename>).</entry>
	    </row>
	    <row>
	      <entry><makevar>APPLETVIEWER</makevar></entry>
	      <entry>Path to the <command>appletviewer</command> utility (e.g.
		<filename>'/usr/local/linux-jdk1.2.2/bin/appletviewer'</filename>).</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA</makevar></entry>
	      <entry>Path to the <command>java</command> executable. Use
		this for executing Java programs (e.g.
		<filename>'/usr/local/jdk1.3.1/bin/java'</filename>).</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVADOC</makevar></entry>
	      <entry>Path to the <command>javadoc</command> utility
		program.</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVAH</makevar></entry>
	      <entry>Path to the <command>javah</command> program.</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVAP</makevar></entry>
	      <entry>Path to the <command>javap</command> program.</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_KEYTOOL</makevar></entry>
	      <entry>Path to the <command>keytool</command> utility program.
		This variable is available only if the JDK is Java 1.2 or
		higher.</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_N2A</makevar></entry>
	      <entry>Path to the <command>native2ascii</command> tool.</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_POLICYTOOL</makevar></entry>
	      <entry>Path to the <command>policytool</command> program.
		This variable is available only if the JDK is Java 1.2 or
		higher.</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_SERIALVER</makevar></entry>
	      <entry>Path to the <command>serialver</command> utility
		program.</entry>
	    </row>
	    <row>
	      <entry><makevar>RMIC</makevar></entry>
	      <entry>Path to the RMI stub/skeleton generator,
		<command>rmic</command>.</entry>
	    </row>
	    <row>
	      <entry><makevar>RMIREGISTRY</makevar></entry>
	      <entry>Path to the RMI registry program,
		<command>rmiregistry</command>.</entry>
	    </row>
	    <row>
	      <entry><makevar>RMID</makevar></entry>
	      <entry>Path to the RMI daemon program <command>rmid</command>.
		This variable is only available if the JDK is Java 1.2
		or higher.</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVA_CLASSES</makevar></entry>
	      <entry>Path to the archive that contains the JDK class
		files. On JDK 1.2 or later, this is
		<filename>${JAVA_HOME}/jre/lib/rt.jar</filename>.  Earlier
		JDKs used
		<filename>${JAVA_HOME}/lib/classes.zip</filename>.</entry>
	    </row>
	    <row>
	      <entry><makevar>HAVE_JIKES</makevar></entry>
	      <entry>Defined whenever <command>jikes</command> is used by
	        the port (see <makevar>USE_JIKES</makevar> above).</entry>
	    </row>
	  </tbody>
	</tgroup>
      </table>

      <para>You may use the <literal>java-debug</literal> make target
	to get information for debugging your port. It will display the
	value of many of the forecited variables.</para>

      <para>Additionally, the following constants are defined so all
	Java ports may be installed in a consistent way:</para>

      <table frame="none">
	<title>Constants defined for ports that use Java</title>

	<tgroup cols="2">
	  <thead>
	    <row>
	      <entry>Constant</entry>
	      <entry>Value</entry>
	    </row>
	  </thead>
	  <tbody>
	    <row>
	      <entry><makevar>JAVASHAREDIR</makevar></entry>
	      <entry>The base directory for everything related to Java.
		Default: <filename>${PREFIX}/share/java</filename>.
	      </entry>
	    </row>
	    <row>
	      <entry><makevar>JAVAJARDIR</makevar></entry>
	      <entry>The directory where JAR files should be installed.
		Default:
		<filename>${JAVASHAREDIR}/classes</filename>.</entry>
	    </row>
	    <row>
	      <entry><makevar>JAVALIBDIR</makevar></entry>
	      <entry>The directory where JAR files installed by other
	        ports are located. Default:
		<filename>${LOCALBASE}/share/java/classes</filename>.</entry>
	    </row>
	  </tbody>
	</tgroup>
      </table>

      <para>The related entries are defined in both
	<makevar>PLIST_SUB</makevar> (documented in
	<xref linkend="plist-sub">) and
	<makevar>SUB_LIST</makevar>.</para>

      </sect2>

      <sect2 id="java-building-with-ant">
	<title>Building with Ant</title>

	<para>When the port is to be built using Apache Ant, it has to
	  define <makevar>USE_ANT</makevar>. Ant is thus considered to be
	  the sub-make command. When no <literal>do-build</literal> target
	  is defined by the port, a default one will be set that simply
	  runs Ant according to <makevar>MAKE_ENV</makevar>,
	  <makevar>MAKE_ARGS</makevar> and <makevar>ALL_TARGETS</makevar>.
	  This is similar to the <makevar>USE_GMAKE</makevar> mechanism,
	  which is documented in <xref linkend="using-autotools">.</para>

	<para>If <command>jikes</command> is used in place of
	  <command>javac</command> (see <makevar>USE_JIKES</makevar> in
	  <xref linkend="java-variables">), then Ant will automatically
	  use it to build the port.</para>

      </sect2>

      <sect2 id="java-best-practices">
	<title>Best practices</title>

	<para>When porting a Java library, your port should install the
	  JAR file(s) in <filename>${JAVAJARDIR}</filename>, and everything
	  else under <filename>${JAVASHAREDIR}/${PORTNAME}</filename>
	  (except for the documentation, see below). In order to reduce
	  the packing file size, you may reference the JAR file(s) directly
	  in the <filename>Makefile</filename>. Just use the following
	  statement (where <filename>myport.jar</filename> is the name
	  of the JAR file installed as part of the port):</para>

	<programlisting>PLIST_FILES+= %%JAVAJARDIR%%/myport.jar</programlisting>

	<para>When porting a Java application, the port usually installs
	  everything under a single directory (including its JAR
	  dependencies).  The use of
	  <filename>${JAVASHAREDIR}/${PORTNAME}</filename> is strongly
	  encouraged in this regard.  It is up the porter to decide
	  whether the port should install the additional JAR dependencies
	  under this directory or directly use the already installed ones
	  (from <filename>${JAVAJARDIR}</filename>).</para>

	<para>Regardless of the type of your port (library or application),
	  the additional documentation should be installed in the
	  <link linkend="dads-documentation">same location</link> as for
	  any other port.  The JavaDoc tool is known to produce a
	  different set of files depending on the version of the JDK that
	  is used. For ports that do not enforce the use of a particular
	  JDK, it is therefore a complex task to specify the packing list
	  (<filename>pkg-plist</filename>).  This is one reason why
	  porters are strongly encouraged to use the
	  <makevar>PORTDOCS</makevar> macro.  Moreover, even if you can
	  predict the set of files that will be generated by
	  <command>javadoc</command>, the size of the resulting
	  <filename>pkg-plist</filename> advocates for the use of
	  <makevar>PORTDOCS</makevar>.</para>

	<para>The default value for <makevar>DATADIR</makevar> is
	  <filename>${PREFIX}/share/${PORTNAME}</filename>.  It is a good
	  idea to override <makevar>DATADIR</makevar> to
	  <filename>${JAVASHAREDIR}/${PORTNAME}</filename> for Java ports.
	  Indeed, <makevar>DATADIR</makevar> is automatically added to
	  <makevar>PLIST_SUB</makevar> (documented in <xref
	  linkend="plist-sub">) so you may use
	  <literal>%%DATADIR%%</literal> directly in
	  <filename>pkg-plist</filename>.</para>

	<para>As for the choice of building Java ports from source or
	  directly installing them from a binary distribution, there is
	  no defined policy at the time of writing.  However, people from
	  the <ulink
	  url="http://www.freebsd.org/java/">&os; Java Project</ulink>
	  encourage porters to have their ports built from source whenever
	  it is a trivial task.</para>

	<para>All the features that have been presented in this section
	  are implemented in <filename>bsd.java.mk</filename>. If you
	  ever think that your port needs more sophisticated Java support,
	  please first have a look at the <ulink
	  url="http://www.freebsd.org/cgi/cvsweb.cgi/ports/Mk/bsd.java.mk">
	  bsd.java.mk CVS log</ulink> as it usually takes some time to
	  document the latest features.  Then, if you think the support
	  you are lacking would be beneficial to many other Java ports,
	  feel free to discuss it on the &a.java;.</para>

	<para>Although there is a <literal>java</literal> category for
	  PRs, it refers to the JDK porting effort from the &os; Java
	  project.  Therefore, you should submit your Java port in the
	  <literal>ports</literal> category as for any other port, unless
	  the issue you are trying to resolve is related to either a JDK
	  implementation or <filename>bsd.java.mk</filename>.</para>

	<para>Similarly, there is a defined policy regarding the
	  <makevar>CATEGORIES</makevar> of a Java port, which is detailed
	  in <xref linkend="makefile-categories">.</para>

      </sect2>

    </sect1>

    <sect1 id="using-php">
      <title>Using Apache and PHP</title>

      <sect2 id="using-apache">
	<title>Apache</title>

	<table frame="none">
	  <title>Variables for ports that use Apache</title>

	  <tgroup cols="2">
	    <tbody>

	      <row>
		<entry>USE_APACHE</entry>

		<entry>The port requires Apache.</entry>
	      </row>

	      <row>
		<entry>WITH_APACHE2</entry>

		<entry>The port requires Apache 2.0.  Without this variable,
		  the port will depend on Apache 1.3.</entry>
	      </row>

	      <row>
		<entry>APXS</entry>

		<entry>Full path to the <command>apxs</command> binary
		  (read-only variable).</entry>
	      </row>

	    </tbody>
	  </tgroup>
	</table>

      </sect2>

      <sect2 id="php-variables">
	<title>PHP</title>

	<table frame="none">
	  <title>Variables for ports that use PHP</title>

	  <tgroup cols="2">
	    <tbody>
	      <row>
		<entry><makevar>USE_PHP</makevar></entry>

		<entry>The port requires PHP.  The value <literal>yes</literal>
		  adds a dependency on PHP.  The list of required PHP extensions
		  can be specified instead.  Example: <literal>pcre xml
		  gettext</literal></entry>
	      </row>

	      <row>
		<entry><makevar>DEFAULT_PHP_VER</makevar></entry>

		<entry>Selects which major version of PHP will be installed as
		  a dependency when no PHP is installed yet.  Default is
		  <literal>4</literal>. Possible values: <literal>4</literal>,
		  <literal>5</literal></entry>
	      </row>

	      <row>
		<entry><makevar>BROKEN_WITH_PHP</makevar></entry>

		<entry>The port does not work with PHP of the given version.
		  Possible values: <literal>4</literal>,
		  <literal>5</literal></entry>
	      </row>

	      <row>
		<entry><makevar>USE_PHPIZE</makevar></entry>

		<entry>The port will be built as a PHP extension.</entry>
	      </row>

	      <row>
		<entry><makevar>USE_PHPEXT</makevar></entry>

		<entry>The port will be treated as a PHP extension, including
		  installation and registration in the extension registry.</entry>
	      </row>

	      <row>
		<entry><makevar>USE_PHP_BUILD</makevar></entry>

		<entry>Set PHP as a build dependency.</entry>
	      </row>

	      <row>
		<entry><makevar>WANT_PHP_CLI</makevar></entry>

		<entry>Want the CLI (command line) version of PHP.</entry>
	      </row>

	      <row>
		<entry><makevar>WANT_PHP_CGI</makevar></entry>

		<entry>Want the CGI version of PHP.</entry>
	      </row>

	      <row>
		<entry><makevar>WANT_PHP_MOD</makevar></entry>

		<entry>Want the Apache module version of PHP.</entry>
	      </row>

	      <row>
		<entry><makevar>WANT_PHP_SCR</makevar></entry>

		<entry>Want the CLI or the CGI version of PHP.</entry>
	      </row>

	      <row>
		<entry><makevar>WANT_PHP_WEB</makevar></entry>

		<entry>Want the Apache module or the CGI version of PHP.</entry>
	      </row>

	      <row>
		<entry><makevar>WANT_PHP_PEAR</makevar></entry>

		<entry>Want the PEAR framework.</entry>
	      </row>

	    </tbody>
	  </tgroup>
	</table>

      </sect2>

      <sect2>
	<title>PEAR modules</title>

	<para>Porting PEAR modules is a very simple process.</para>

	<para>Use the variables <makevar>FILES</makevar>,
	  <makevar>TESTS</makevar>, <makevar>DATA</makevar>,
	  <makevar>SQLS</makevar>, <makevar>SCRIPTFILES</makevar>,
	  <makevar>DOCS</makevar> and <makevar>EXAMPLES</makevar> to list the
	  files you want to install.  All listed files will be automatically
	  installed into the appropriate locations and added to
	  <filename>pkg-plist</filename>.</para>

	<para>Include
	  <filename>&dollar;{PORTSDIR}/devel/pear-PEAR/Makefile.common</filename>
	  on the last line of the <filename>Makefile</filename>.</para>

	<example id="pear-makefile">
	  <title>Example Makefile for PEAR class</title>
	  <programlisting>PORTNAME=       Date
PORTVERSION=    1.4.3
CATEGORIES=     devel www pear

MAINTAINER=     example@domain.com
COMMENT=        PEAR Date and Time Zone Classes

BUILD_DEPENDS=  ${PEARDIR}/PEAR.php:${PORTSDIR}/devel/pear-PEAR
RUN_DEPENDS=    ${BUILD_DEPENDS}

FILES=          Date.php Date/Calc.php Date/Human.php Date/Span.php     \
                Date/TimeZone.php
TESTS=          test_calc.php test_date_methods_span.php testunit.php   \
                testunit_date.php testunit_date_span.php wknotest.txt   \
                bug674.php bug727_1.php bug727_2.php bug727_3.php       \
                bug727_4.php bug967.php weeksinmonth_4_monday.txt       \
                weeksinmonth_4_sunday.txt weeksinmonth_rdm_monday.txt   \
                weeksinmonth_rdm_sunday.txt
DOCS=           TODO
_DOCSDIR=       .

.include &lt;bsd.port.pre.mk&gt;
.include "&dollar;{PORTSDIR}/devel/pear-PEAR/Makefile.common"
.include &lt;bsd.port.post.mk&gt;</programlisting>

	</example>

      </sect2>

    </sect1>

    <sect1 id="using-python">
      <title>Using Python</title>

      <table frame="none">
	<title>Most useful variables for ports that use Python</title>

	<tgroup cols="2">
	  <tbody>
	    <row>
	      <entry><makevar>USE_PYTHON</makevar></entry>

	      <entry>The port needs Python.  Minimal required version can be
		specified with values such as <literal>2.3+</literal>.
		Version ranges can also be specified, by separating two version
		numbers with a dash, e.g.: <literal>2.1-2.3</literal></entry>
	    </row>

	    <row>
	      <entry><makevar>USE_PYDISTUTILS</makevar></entry>

	      <entry>Use Python distutils for configuring, compiling and
		installing.  This is required when the port comes with
		<filename>setup.py</filename>. This overrides the
		<maketarget>do-build</maketarget> and
		<maketarget>do-install</maketarget> targets
		and may also override <maketarget>do-configure</maketarget> if
		<makevar>GNU_CONFIGURE</makevar> is not defined.</entry>
	    </row>

	    <row>
	      <entry><makevar>PYTHON_PKGNAMEPREFIX</makevar></entry>

	      <entry>Used as a <makevar>PKGNAMEPREFIX</makevar> to distinguish
		packages for different Python versions.
		Example: <literal>py24-</literal></entry>
	    </row>

	    <row>
	      <entry><makevar>PYTHON_SITELIBDIR</makevar></entry>

	      <entry>Location of the site-packages tree, that contains
		installation path of Python (usually <makevar>LOCALBASE</makevar>).
		The <makevar>PYTHON_SITELIBDIR</makevar> variable can be very
	 	useful when installing Python modules.</entry>
	    </row>

	    <row>
	      <entry><makevar>PYTHONPREFIX_SITELIBDIR</makevar></entry>

	      <entry>The PREFIX-clean variant of PYTHON_SITELIBDIR.
	      	Always use
		<literal>%%PYTHON_SITELIBDIR%%</literal> in
		<filename>pkg-plist</filename> when possible. The default value of
		<literal>%%PYTHON_SITELIBDIR%%</literal> is
		<literal>lib/python%%PYTHON_VERSION%%/site-packages</literal></entry>
	    </row>

	    <row>
	      <entry><makevar>PYTHON_CMD</makevar></entry>

	      <entry>Python interpreter command line, including version
	      number.</entry>
	    </row>

	    <row>
	      <entry><makevar>PYNUMERIC</makevar></entry>

	      <entry>Dependency line for numeric extension.</entry>
	    </row>

	    <row>
	      <entry><makevar>PYXML</makevar></entry>

	      <entry>Dependency line for XML extension (not needed for
	      Python 2.0 and higher as it is also in base distribution).</entry>
	    </row>

	    <row>
	      <entry><makevar>USE_TWISTED</makevar></entry>

	      <entry>Add dependency on twistedCore.  The list of required
		components can be specified as a value of this
		variable.  Example: <literal>web lore pair
		flow</literal></entry>
	    </row>

	    <row>
	      <entry><makevar>USE_ZOPE</makevar></entry>

	      <entry>Add dependency on Zope, a web application platform.
		Change Python dependency to Python 2.3.  Set
		<makevar>ZOPEBASEDIR</makevar> containing a directory with
		Zope installation.</entry>
	    </row>

	  </tbody>
	</tgroup>
      </table>

      <para>A complete list of available variables can be found in
	<filename>/usr/ports/Mk/bsd.python.mk</filename>.</para>

    </sect1>

    <sect1 id="using-emacs">
      <title>Using Emacs</title>

      <para>This section is yet to be written.</para>
    </sect1>

    <sect1 id="using-ruby">
      <title>Using Ruby</title>

      <table frame="none">
	<title>Useful variables for ports that use Ruby</title>

	<tgroup cols="2">
	  <thead>
	    <row>
	      <entry>Variable</entry>
	      <entry>Description</entry>
	    </row>
	  </thead>
	  <tbody>
	    <row>
	      <entry><makevar>USE_RUBY</makevar></entry>

	      <entry>The port requires Ruby.</entry>
	    </row>

	    <row>
	      <entry><makevar>USE_RUBY_EXTCONF</makevar></entry>

	      <entry>The port uses <filename>extconf.rb</filename> to
		configure.</entry>
	    </row>

	    <row>
	      <entry><makevar>USE_RUBY_SETUP</makevar></entry>

	      <entry>The port uses <filename>setup.rb</filename> to
		configure.</entry>
	    </row>

	    <row>
	      <entry><makevar>RUBY_SETUP</makevar></entry>

	      <entry>Set to the alternative name of
		<filename>setup.rb</filename>.  Common value is
		<filename>install.rb</filename>.</entry>
	    </row>

	  </tbody>
	</tgroup>
      </table>

      <para>The following table shows the selected variables available to port
	authors via the ports infrastructure.  These variables should be used
	to install files into their proper locations.  Use them in
	<filename>pkg-plist</filename> as much as possible.  These variables
	should not be redefined in the port.</para>

      <table frame="none">
	<title>Selected read-only variables for ports that use Ruby</title>

	<tgroup cols="3">
	  <thead>
	    <row>
	      <entry>Variable</entry>
	      <entry>Description</entry>
	      <entry>Example value</entry>
	    </row>
	  </thead>
	  <tbody>

	    <row>
	      <entry><makevar>RUBY_PKGNAMEPREFIX</makevar></entry>

	      <entry>Used as a <makevar>PKGNAMEPREFIX</makevar> to distinguish
		packages for different Ruby versions.</entry>

	      <entry><literal>ruby18-</literal></entry>
	    </row>

	    <row>
	      <entry><makevar>RUBY_VERSION</makevar></entry>

	      <entry>Full version of Ruby in the form of
		<literal>x.y.z</literal>.</entry>

	      <entry><literal>1.8.2</literal></entry>
	    </row>

	    <row>
	      <entry><makevar>RUBY_SITELIBDIR</makevar></entry>

	      <entry>Architecture independent libraries installation
		path.</entry>

	      <entry><literal>/usr/local/lib/ruby/site_ruby/1.8</literal></entry>
	    </row>

	    <row>
	      <entry><makevar>RUBY_SITEARCHILIBDIR</makevar></entry>

	      <entry>Architecture dependent libraries installation
		path.</entry>

	      <entry><literal>/usr/local/lib/ruby/site_ruby/1.8/amd64-freebsd6</literal></entry>
	    </row>

	    <row>
	      <entry><makevar>RUBY_MODDOCDIR</makevar></entry>

	      <entry>Module documentation installation path.</entry>

	      <entry><literal>/usr/local/share/doc/ruby18/patsy</literal></entry>
	    </row>

	    <row>
	      <entry><makevar>RUBY_MODEXAMPLESDIR</makevar></entry>

	      <entry>Module examples installation path.</entry>

	      <entry><literal>/usr/local/share/examples/ruby18/patsy</literal></entry>
	    </row>

	  </tbody>
	</tgroup>
      </table>

      <para>A complete list of available variables can be found in
	<filename>/usr/ports/Mk/bsd.ruby.mk</filename>.</para>

    </sect1>

    <sect1 id="using-sdl">
      <title>Using SDL</title>

      <para>The <makevar>USE_SDL</makevar> variable is used to autoconfigure
	the dependencies for ports which use an SDL based library like
	<filename role="package">devel/sdl12</filename> and
	<filename role="package">x11-toolkits/sdl_gui</filename>.</para>

      <para>The following SDL libraries are recognized at the moment:</para>

      <itemizedlist>
	<listitem>
	  <para>sdl: <filename role="package">devel/sdl12</filename></para>
	</listitem>

	<listitem>
	  <para>gfx: <filename role="package">graphics/sdl_gfx</filename></para>
	</listitem>

	<listitem>
	  <para>gui: <filename role="package">x11-toolkits/sdl_gui</filename></para>
	</listitem>

	<listitem>
	  <para>image: <filename role="package">graphics/sdl_image</filename></para>
	</listitem>

	<listitem>
	  <para>ldbad: <filename role="package">devel/sdl_ldbad</filename></para>
	</listitem>

	<listitem>
	  <para>mixer: <filename role="package">audio/sdl_mixer</filename></para>
	</listitem>

	<listitem>
	  <para>mm: <filename role="package">devel/sdlmm</filename></para>
	</listitem>

	<listitem>
	  <para>net: <filename role="package">net/sdl_net</filename></para>
	</listitem>

	<listitem>
	  <para>sound: <filename role="package">audio/sdl_sound</filename></para>
	</listitem>

	<listitem>
	  <para>ttf: <filename role="package">graphics/sdl_ttf</filename></para>
	</listitem>
      </itemizedlist>

      <para>Therefore, if a port has a dependency on
	<filename role="package">net/sdl_net</filename> and
	<filename role="package">audio/sdl_mixer</filename>,
	the syntax will be:</para>

      <programlisting>USE_SDL=        net mixer</programlisting>

      <para>The dependency <filename role="package">devel/sdl12</filename>,
	which is required by <filename role="package">net/sdl_net</filename> and
	<filename role="package">audio/sdl_mixer</filename>, is automatically
	added as well.</para>

      <para>If you use <makevar>USE_SDL</makevar>, it will automatically:</para>

      <itemizedlist>
	<listitem>
	  <para>Add a dependency on <application>sdl12-config</application> to
	    <makevar>BUILD_DEPENDS</makevar></para>
	</listitem>

	<listitem>
	  <para>Add the variable <makevar>SDL_CONFIG</makevar> to
	    <makevar>CONFIGURE_ENV</makevar></para>
	</listitem>

	<listitem>
	  <para>Add the dependencies of the selected libraries to the
	    <makevar>LIB_DEPENDS</makevar></para>
	</listitem>
      </itemizedlist>

      <para>To check whether an SDL library is available, you can do it
	with the <makevar>WANT_SDL</makevar> variable:</para>

      <programlisting>WANT_SDL=yes

.include &lt;bsd.port.pre.mk&gt;

.if ${HAVE_SDL:Mmixer}!=""
USE_SDL+=   mixer
.endif

.include &lt;bsd.port.post.mk&gt;</programlisting>

    </sect1>
  </chapter>

    <chapter id="plist">
      <title>Advanced <filename>pkg-plist</filename> practices</title>

      <sect1 id="plist-sub">
	<title>Changing <filename>pkg-plist</filename> based on make
	  variables</title>

	<para>Some ports, particularly the <literal>p5-</literal> ports,
	  need to change their <filename>pkg-plist</filename> depending on
	  what options they are configured with (or version of
	  <literal>perl</literal>, in the case of <literal>p5-</literal>
	  ports).  To make this easy, any instances in the
	  <filename>pkg-plist</filename> of <literal>%%OSREL%%</literal>,
	  <literal>%%PERL_VER%%</literal>, and
	  <literal>%%PERL_VERSION%%</literal> will be substituted for
	  appropriately.  The value of <literal>%%OSREL%%</literal> is the
	  numeric revision of the operating system (e.g.,
	  <literal>4.9</literal>).  <literal>%%PERL_VERSION%%</literal> is
	  the full version number of <command>perl</command> (e.g.,
	  <literal>5.00502</literal>) and <literal>%%PERL_VER%%</literal>
	  is the <command>perl</command> version number minus
	  the patchlevel (e.g., <literal>5.005</literal>).  Several other
	  <literal>%%<replaceable>VARS</replaceable>%%</literal> related to
	  port's documentation files are described in <link
	  linkend="dads-documentation">the relevant section</link>.</para>

	<para>If you need to make other substitutions, you can set the
	  <makevar>PLIST_SUB</makevar> variable with a list of
	  <literal><replaceable>VAR</replaceable>=<replaceable>VALUE</replaceable></literal>
	  pairs and instances of
	  <literal>%%<replaceable>VAR</replaceable>%%</literal> will be
	  substituted with <replaceable>VALUE</replaceable> in the
	  <filename>pkg-plist</filename>.</para>

	<para>For instance, if you have a port that installs many files in a
	  version-specific subdirectory, you can put something like</para>

	<programlisting>OCTAVE_VERSION= 2.0.13
PLIST_SUB=      OCTAVE_VERSION=${OCTAVE_VERSION}</programlisting>

	<para>in the <filename>Makefile</filename> and use
	  <literal>%%OCTAVE_VERSION%%</literal> wherever the version shows up
	  in <filename>pkg-plist</filename>.  That way, when you upgrade the port,
	  you will not have to change dozens (or in some cases, hundreds) of
	  lines in the <filename>pkg-plist</filename>.</para>

	<para>This substitution (as well as addition of any <link
	  linkend="makefile-manpages">manual pages</link>) will be done between
	  the <maketarget>pre-install</maketarget> and
	  <maketarget>do-install</maketarget> targets, by reading from
	  <filename><makevar>PLIST</makevar></filename> and writing to
	  <filename><makevar>TMPPLIST</makevar></filename>
	  (default:
	  <filename><makevar>WRKDIR</makevar>/.PLIST.mktmp</filename>).  So if
	  your port builds <filename><makevar>PLIST</makevar></filename>
	  on the fly, do so in or
	  before <maketarget>pre-install</maketarget>.  Also, if your port
	  needs to edit the resulting file, do so in
	  <maketarget>post-install</maketarget> to a file named
	  <filename><makevar>TMPPLIST</makevar></filename>.</para>

	<para>Another possibility to modify port's packing list is based
	  on setting the variables <makevar>PLIST_FILES</makevar> and
	  <makevar>PLIST_DIRS</makevar>.  The value of each variable
	  is regarded as a list of pathnames to
	  write to <filename><makevar>TMPPLIST</makevar></filename>
	  along with <filename><makevar>PLIST</makevar></filename>
	  contents.  Names listed in <makevar>PLIST_FILES</makevar>
	  and <makevar>PLIST_DIRS</makevar> are subject to
	  <literal>%%<replaceable>VAR</replaceable>%%</literal>
	  substitution, as described above.
	  Except for that, names from <makevar>PLIST_FILES</makevar>
	  will appear in the final packing list unchanged,
	  while <literal>@dirrm</literal> will be
	  prepended to names from <makevar>PLIST_DIRS</makevar>.
	  To take effect, <makevar>PLIST_FILES</makevar> and
	  <makevar>PLIST_DIRS</makevar> must be set before
	  <filename><makevar>TMPPLIST</makevar></filename> is written,
	  i.e. in <maketarget>pre-install</maketarget> or earlier.</para>
      </sect1>

      <sect1 id="plist-cleaning">
	<title>Empty directories</title>

	<sect2 id="plist-dir-cleaning">
	  <title>Cleaning up empty directories</title>

	<para>Do make your ports remove empty directories when they are
	  de-installed.  This is usually accomplished by adding
	  <literal>@dirrm</literal> lines for all directories that are
	  specifically created by the port.  You need to delete subdirectories
	  before you can delete parent directories.</para>

	<programlisting> :
lib/X11/oneko/pixmaps/cat.xpm
lib/X11/oneko/sounds/cat.au
 :
@dirrm lib/X11/oneko/pixmaps
@dirrm lib/X11/oneko/sounds
@dirrm lib/X11/oneko</programlisting>

	<para>However, sometimes <literal>@dirrm</literal> will give you
	  errors because other ports share the same directory.  You
	  can call <command>rmdir</command> from <literal>@unexec</literal> to
	  remove only empty directories without warning.</para>

	<programlisting>@unexec rmdir %D/share/doc/gimp 2>/dev/null || true</programlisting>

	<para>This will neither print any error messages nor cause
	  &man.pkg.delete.1; to exit abnormally even if
	  <filename><makevar>PREFIX</makevar>/share/doc/gimp</filename> is not
	  empty due to other ports installing some files in there.</para>
	</sect2>

	<sect2 id="plist-dir-empty">
	  <title>Creating empty directories</title>

	  <para>Empty directories created during port installation need special
	    attention.  They will not get created when installing the package,
	    because packages only store the files, and &man.pkg.add.1; creates
	    directories for them as needed.  To make sure the empty directory
	    is created when installing the package, add this line to
	    <filename>pkg-plist</filename> above the corresponding
	    <literal>@dirrm</literal> line:</para>

	  <programlisting>@exec mkdir -p %D/share/foo/templates</programlisting>
	</sect2>

      </sect1>

      <sect1 id="plist-config">
	<title>Configuration files</title>

	<para>If your port requires some configuration files in
	  <filename><makevar>PREFIX</makevar>/etc</filename>, do
	  <emphasis>not</emphasis> just install them and list them in
	  <filename>pkg-plist</filename>.  That will cause
	  &man.pkg.delete.1; to delete files carefully edited by
	  the user and a new installation to wipe them out.</para>

	<para>Instead, install sample files with a suffix
	  (<filename><replaceable>filename</replaceable>.sample</filename>
	  will work well).  Copy the sample file as the real configuration
	  file, if it does not exist.  On deinstall, delete the configuration
	  file, but only if it was not modified by the user.  You need to
	  handle this both in the port <filename>Makefile</filename>, and in
	  the <filename>pkg-plist</filename> (for installation from
	  the package).</para>

	<para>Example of the <filename>Makefile</filename> part:</para>

	<programlisting>post-install:
	@if [ ! -f ${PREFIX}/etc/orbit.conf ]; then \
		${CP} -p ${PREFIX}/etc/orbit.conf.sample ${PREFIX}/etc/orbit.conf ; \
	fi</programlisting>

	<para>Example of the <filename>pkg-plist</filename> part:</para>

	<programlisting>@unexec if cmp -s %D/etc/orbit.conf.sample %D/etc/orbit.conf; then rm -f %D/etc/orbit.conf; fi
etc/orbit.conf.sample
@exec if [ ! -f %D/etc/orbit.conf ] ; then cp -p %D/%F %B/orbit.conf; fi</programlisting>

	<para>Alternatively, print out a <link
	    linkend="porting-message">message</link> pointing out that the
	  user has to copy and edit the file before the software can be made
	  to work.</para>
      </sect1>

    <sect1 id="plist-autoplist">
      <title>Automated package list creation</title>

      <para>First, make sure your port is almost complete, with only
	<filename>pkg-plist</filename> missing.</para>

      <para>Next, create a temporary directory tree into which your port can be
	installed, and install any dependencies.
	<replaceable>port-type</replaceable> should be <literal>local</literal>
	for non-X ports and <literal>x11-4</literal> or <literal>x11</literal>
	for ports which install into the directory hierarchy of XFree86 4
	or an earlier XFree86 release, respectively.</para>

      <screen>&prompt.root; <userinput>mkdir /var/tmp/<replaceable>port-name</replaceable></userinput>
&prompt.root; <userinput>mtree -U -f /etc/mtree/BSD.<replaceable>port-type</replaceable>.dist -d -e -p /var/tmp/<replaceable>port-name</replaceable></userinput>
&prompt.root; <userinput>make depends PREFIX=/var/tmp/<replaceable>port-name</replaceable></userinput></screen>

      <para>Store the directory structure in a new file.</para>

      <screen>&prompt.root; <userinput>(cd /var/tmp/<replaceable>port-name</replaceable> && find -d * -type d) | sort &gt; OLD-DIRS</userinput></screen>

      <para>Create an empty <filename>pkg-plist</filename> file:</para>

      <screen>&prompt.root; <userinput>touch pkg-plist</userinput></screen>

      <para>If your port honors <makevar>PREFIX</makevar> (which it should)
	you can then install the port and create the package list.</para>

      <screen>&prompt.root; <userinput>make install PREFIX=/var/tmp/<replaceable>port-name</replaceable></userinput>
&prompt.root; <userinput>(cd /var/tmp/<replaceable>port-name</replaceable> && find -d * \! -type d) | sort &gt; pkg-plist</userinput></screen>

      <para>You must also add any newly created directories to the packing
	list.</para>

      <screen>&prompt.root; <userinput>(cd /var/tmp/<replaceable>port-name</replaceable> && find -d * -type d) | sort | comm -13 OLD-DIRS - | sort -r | sed -e 's#^#@dirrm #' &gt;&gt; pkg-plist</userinput></screen>

      <para>Finally, you need to tidy up the packing list by hand; it is not
	<emphasis>all</emphasis> automated.  Manual pages should be listed in
	the port's <filename>Makefile</filename> under
	<makevar>MAN<replaceable>n</replaceable></makevar>, and not in the
	package list.  User configuration files should be removed, or
	installed as
	<filename><replaceable>filename</replaceable>.sample</filename>.
	The <filename>info/dir</filename> file should not be listed
	and appropriate <filename>install-info</filename> lines should
	be added as noted in the <link linkend="makefile-info">info
	files</link> section.  Any
	libraries installed by the port should be listed as specified in the
	<link linkend="porting-shlibs">shared libraries</link> section.</para>

      <para>Alternatively, use the <command>plist</command> script in
	<filename>/usr/ports/Tools/scripts/</filename> to build the
	package list automatically.  The first step is the same as
	above: take the first three lines, that is,
	<command>mkdir</command>, <command>mtree</command> and
	<command>make depends</command>.  Then build and install the
	port:</para>

      <screen>&prompt.root; <userinput>make install PREFIX=/var/tmp/<replaceable>port-name</replaceable></userinput></screen>

      <para>And let <command>plist</command> create the
	<filename>pkg-plist</filename> file:</para>

      <screen>&prompt.root; <userinput>/usr/ports/Tools/scripts/plist -Md -m /etc/mtree/BSD.<replaceable>port-type</replaceable>.dist /var/tmp/<replaceable>port-name</replaceable> &gt; pkg-plist</userinput></screen>

      <para>The packing list still have to tidied up the by hand as
        stated above.</para>

    </sect1>

    </chapter>

    <chapter id="pkg-files">
      <title>The <filename>pkg-<replaceable>*</replaceable></filename> files</title>

      <para>There are some tricks we have not mentioned yet about the
	<filename>pkg-<replaceable>*</replaceable></filename> files
	that come in handy sometimes.</para>

      <sect1 id="porting-message">
	<title><filename>pkg-message</filename></title>

	<para>If you need to display a message to the installer, you may place
	  the message in <filename>pkg-message</filename>.  This capability is
	  often useful to display additional installation steps to be taken
	  after a &man.pkg.add.1; or to display licensing
	  information.</para>

	<note>
	  <para>The <filename>pkg-message</filename> file does not need to be
	    added to <filename>pkg-plist</filename>.  Also, it will not get
	    automatically printed if the user is using the port, not the
	    package, so you should probably display it from the
	    <maketarget>post-install</maketarget> target yourself.</para>
	</note>
      </sect1>

      <sect1 id="pkg-install">
	<title><filename>pkg-install</filename></title>

	<para>If your port needs to execute commands when the binary package
	  is installed with &man.pkg.add.1; you can do this via the
	  <filename>pkg-install</filename> script.  This script will
	  automatically be added to the package, and will be run twice by
	  &man.pkg.add.1;: the first time as
	  <literal>&dollar;{SH} pkg-install &dollar;{PKGNAME}
	  PRE-INSTALL</literal> and the second time as
	  <literal>&dollar;{SH} pkg-install &dollar;{PKGNAME} POST-INSTALL</literal>.
	  <literal>&dollar;2</literal> can be tested to determine which mode
	  the script is being run in.  The <envar>PKG_PREFIX</envar>
	  environmental variable will be set to the package installation
	  directory.  See &man.pkg.add.1; for
	  additional information.</para>

	<note>
	  <para>This script is not run automatically if you install the port
	    with <command>make install</command>.  If you are depending on it
	    being run, you will have to explicitly call it from your port's
	    <filename>Makefile</filename>, with a line like
	    <literal>PKG_PREFIX=&dollar;{PREFIX} &dollar;{SH} &dollar;{PKGINSTALL}
	    &dollar;{PKGNAME} PRE-INSTALL</literal>.</para>
	</note>
      </sect1>

      <sect1 id="pkg-deinstall">
	<title><filename>pkg-deinstall</filename></title>

	<para>This script executes when a package is removed.</para>

	<para>
	  This script will be run twice by &man.pkg.delete.1;.
	  The first time as <literal>&dollar;{SH} pkg-deinstall &dollar;{PKGNAME}
	  DEINSTALL</literal> and the second time as
	  <literal>&dollar;{SH} pkg-deinstall &dollar;{PKGNAME} POST-DEINSTALL</literal>.
	</para>
      </sect1>

      <sect1 id="pkg-req">
	<title><filename>pkg-req</filename></title>

	<para>If your port needs to determine if it should install or not, you
	  can create a <filename>pkg-req</filename> <quote>requirements</quote>
	  script.  It will be invoked automatically at
	  installation/de-installation time to determine whether or not
	  installation/de-installation should proceed.</para>

	<para>The script will be run at installation time by
	  &man.pkg.add.1; as
	  <literal>pkg-req &dollar;{PKGNAME} INSTALL</literal>.
	  At de-installation time it will be run by
	  &man.pkg.delete.1; as
	  <literal>pkg-req &dollar;{PKGNAME} DEINSTALL</literal>.</para>
      </sect1>

      <sect1 id="pkg-names">
	<title id="porting-pkgfiles">Changing the names of
	  <filename>pkg-<replaceable>*</replaceable></filename> files</title>

	<para>All the names of <filename>pkg-<replaceable>*</replaceable></filename> files
	  are defined using variables so you can change them in your
	  <filename>Makefile</filename> if need be.  This is especially useful
	  when you are sharing the same <filename>pkg-<replaceable>*</replaceable></filename> files
	  among  several ports or have to write to one of the above files (see
	  <link linkend="porting-wrkdir">writing to places other than
	  <makevar>WRKDIR</makevar></link> for why it is a bad idea to write
	  directly into the <filename>pkg-<replaceable>*</replaceable></filename> subdirectory).</para>

	<para>Here is a list of variable names and their default
	  values.  (<makevar>PKGDIR</makevar> defaults to
	  <makevar>${MASTERDIR}</makevar>.)</para>

	<informaltable frame="none" pgwide="1">
	  <tgroup cols="2">
	    <thead>
	      <row>
		<entry>Variable</entry>
		<entry>Default value</entry>
	      </row>
	    </thead>

	    <tbody>
	      <row>
		<entry><makevar>DESCR</makevar></entry>
		<entry><literal>${PKGDIR}/pkg-descr</literal></entry>
	      </row>

	      <row>
		<entry><makevar>PLIST</makevar></entry>
		<entry><literal>${PKGDIR}/pkg-plist</literal></entry>
	      </row>

	      <row>
		<entry><makevar>PKGINSTALL</makevar></entry>
		<entry><literal>${PKGDIR}/pkg-install</literal></entry>
	      </row>

	      <row>
		<entry><makevar>PKGDEINSTALL</makevar></entry>
		<entry><literal>${PKGDIR}/pkg-deinstall</literal></entry>
	      </row>

	      <row>
		<entry><makevar>PKGREQ</makevar></entry>
		<entry><literal>${PKGDIR}/pkg-req</literal></entry>
	      </row>

	      <row>
		<entry><makevar>PKGMESSAGE</makevar></entry>
		<entry><literal>${PKGDIR}/pkg-message</literal></entry>
	      </row>
	    </tbody>
	  </tgroup>
	</informaltable>

	<para>Please change these variables rather than overriding
	  <makevar>PKG_ARGS</makevar>.  If you change
	  <makevar>PKG_ARGS</makevar>, those files will not correctly be
	  installed in <filename>/var/db/pkg</filename> upon install from a
	  port.</para>
      </sect1>

      <sect1 id="using-sub-files">
	<title>Making use of <makevar>SUB_FILES</makevar> and
	  <makevar>SUB_LIST</makevar></title>

	<para>The <makevar>SUB_FILES</makevar> and <makevar>SUB_LIST</makevar>
	  variables are useful for dynamic values in port files, such as the
	  installation <makevar>PREFIX</makevar> in
	  <filename>pkg-message</filename>.</para>

	<para>The <makevar>SUB_FILES</makevar> variable specifies a list
	  of files to be automatically modified.  Each
	  <replaceable>file</replaceable> in the
	  <makevar>SUB_FILES</makevar> list must have a corresponding
	  <filename><replaceable>file</replaceable>.in</filename> present
	  in <makevar>FILESDIR</makevar>.  A modified version will
	  be created in <makevar>WRKDIR</makevar>.  Files defined as a
	  value of <makevar>USE_RC_SUBR</makevar> and
	  <makevar>USE_RCORDER</makevar> are automatically added to
	  <makevar>SUB_FILES</makevar>.  For the files
	  <filename>pkg-message</filename>,
	  <filename>pkg-install</filename>, <filename>pkg-deinstall</filename>
	  and <filename>pkg-reg</filename>, the corresponding Makefile variable
	  is automatically set to point to the processed version.</para>

	<para>The <makevar>SUB_LIST</makevar> variable is a list of
	  <literal>VAR=VALUE</literal> pairs.  For each pair
	  <literal>%%VAR%%</literal> will get replaced
	  with <literal>VALUE</literal> in each file listed in
	  <makevar>SUB_FILES</makevar>.  Several common pairs are
	  automatically defined: <makevar>PREFIX</makevar>,
	  <makevar>LOCALBASE</makevar>, <makevar>X11BASE</makevar>,
	  <makevar>DATADIR</makevar>, <makevar>DOCSDIR</makevar>,
	  <makevar>EXAMPLESDIR</makevar>.  Any line beginning with
	  <literal>@comment</literal> will be deleted from resulting files
	  after a variable substitution.</para>

	<para>The following example will replace <literal>%%ARCH%%</literal>
	  with the system architecture
	  in a <filename>pkg-message</filename>:</para>

	<programlisting>SUB_FILES=     pkg-message
SUB_LIST=      ARCH=${ARCH}</programlisting>

	<para>Note that for this example, the
	  <filename>pkg-message.in</filename> file must exist in
	  <makevar>FILESDIR</makevar>.</para>

	<para>Example of a good <filename>pkg-message.in</filename>:</para>

	<programlisting>Now it's time to configure this package.
Copy %%PREFIX%%/share/examples/putsy/%%ARCH%%.conf into your home directory
as .putsy.conf and edit it.</programlisting>

      </sect1>
    </chapter>

  <chapter id="testing">
    <title>Testing your port</title>

      <sect1 id="make-describe">
	<title>Running <command>make describe</command></title>

	<para>Several of the &os; port maintenance tools, such as
	  &man.portupgrade.1;, rely on a database called
	  <filename>/usr/ports/INDEX</filename> which keeps track of such
	  items as port dependencies.  <filename>INDEX</filename> is created
	  by the top-level <filename>ports/Makefile</filename> via
	  <command>make index</command>, which descends into each
	  port subdirectory and executes <command>make describe</command>
	  there.  Thus, if <command>make describe</command> fails in any
	  port, no one can generate <filename>INDEX</filename>, and many
	  people will quickly become unhappy.</para>

	<note>
	  <para>It is important to be able to generate this file no
	  matter what options are present in <filename>make.conf</filename>,
	  so please avoid doing things such as using <literal>.error</literal>
	  statements when (for instance) a dependency is not satisfied.</para>
	</note>

	<example id="dot-error-breaks-index">
	  <title>How to avoid using <literal>.error</literal></title>
	  <para>Assume that someone has the line
	    <programlisting>USE_POINTYHAT=yes</programlisting>
	    in <filename>make.conf</filename>.  The first of
	    the next two <filename>Makefile</filename> snippets will
	    cause <command>make index</command> to fail, while the
	    second one will not:</para>
	    <programlisting>.if USE_POINTYHAT
.error "POINTYHAT is not supported"
.endif</programlisting>
	    <programlisting>.if USE_POINTYHAT
IGNORE=POINTYHAT is not supported
.endif</programlisting>
	</example>

	<para>If <command>make describe</command> produces a string
	  rather than an error message, you are probably safe.  See
	  <filename>bsd.port.mk</filename> for the meaning of the
	  string produced.</para>

	<para>Also note that running a recent version of
	  <command>portlint</command> (as specified in the next section)
	  will cause <command>make describe</command> to be run
	  automatically.</para>
      </sect1>

      <sect1 id="testing-portlint">
	<title>Portlint</title>

	<para>Do check your work with <link
	    linkend="porting-portlint"><command>portlint</command></link>
	  before you submit or commit it.  <command>portlint</command>
	  warns you about many common errors, both functional and
	  stylistic.  For a new (or repocopied) port,
	  <command>portlint -A</command> is the most thorough; for an
	  existing port, <command>portlint -C</command> is sufficient.</para>

	<para>Since <command>portlint</command> uses heuristics to
	  try to figure out errors, it can produce false positive
	  warnings.  In addition, occasionally something that is
	  flagged as a problem really cannot be done in any other
	  way due to limitations in the ports framework.  When in
	  doubt, the best thing to do is ask on &a.ports;.</para>
      </sect1>

      <sect1 id="porting-prefix">
	<title><makevar>PREFIX</makevar></title>

	<para>Do try to make your port install relative to
	  <makevar>PREFIX</makevar>.  The value of this variable will be set
	  to <makevar>LOCALBASE</makevar> (default
	  <filename>/usr/local</filename>).  If
	  <makevar>USE_X_PREFIX</makevar> or <makevar>USE_IMAKE</makevar> is
	  set, <makevar>PREFIX</makevar> will be <makevar>X11BASE</makevar> (default
	  <filename>/usr/X11R6</filename>).  If
	  <makevar>USE_LINUX_PREFIX</makevar> is set, <makevar>PREFIX</makevar>
	  will be <makevar>LINUXBASE</makevar> (default
	  <filename>/compat/linux</filename>).</para>

	<para>Avoiding the hard-coding of <filename>/usr/local</filename> or
	  <filename>/usr/X11R6</filename> anywhere in the source will make the
	  port much more flexible and able to cater to the needs of other
	  sites.  For X ports that use <command>imake</command>, this is
	  automatic; otherwise, this can often be done by simply replacing the
	  occurrences of <filename>/usr/local</filename> (or
	  <filename>/usr/X11R6</filename> for X ports that do not use imake)
	  in the various <filename>scripts/Makefile</filename>s in the port to read
	  <makevar>${PREFIX}</makevar>, as this variable is automatically passed
	  down to every stage of the build and install processes.</para>

	<para>Make sure your application is not installing things in
	<filename>/usr/local</filename> instead of <makevar>PREFIX</makevar>.
	A quick test for this is to do this is:</para>

	<screen>&prompt.root; <userinput>make clean; make package PREFIX=/var/tmp/<replaceable>port-name</replaceable></userinput></screen>

	<para>If anything is installed outside of <makevar>PREFIX</makevar>,
	the package creation process will complain that it
	cannot find the files.</para>

	<!-- XXX This paragraph is confusing and poorly indented. -->
	<para>This does not test for the existence of internal references,
	or correct use of <makevar>LOCALBASE</makevar> for references to
	files from other ports.  Testing the installation in
	<filename>/var/tmp/<replaceable>port-name</replaceable></filename>
	to do that while you have it installed would do that.</para>

	<para>Do not set <makevar>USE_X_PREFIX</makevar> unless your port
	  truly requires it (i.e., it links against X libs or it needs to
	  reference files in <makevar>X11BASE</makevar>).</para>

	<para>The variable <makevar>PREFIX</makevar> can be reassigned in your
	  <filename>Makefile</filename> or in the user's environment.
	  However, it is strongly discouraged for individual ports to set this
	  variable explicitly in the <filename>Makefile</filename>s.</para>

	<para>Also, refer to programs/files from other ports with the
	  variables mentioned above, not explicit pathnames.  For instance, if
	  your port requires a macro <literal>PAGER</literal> to be the full
	  pathname of <command>less</command>, use the compiler flag:

	  <programlisting>-DPAGER=\"&dollar;{LOCALBASE}/bin/less\"</programlisting>

	  instead of
	  <literal>-DPAGER=\"/usr/local/bin/less\"</literal>. This way it will
	  have a better chance of working if the system administrator has
	  moved the whole <filename>/usr/local</filename> tree somewhere else.</para>
      </sect1>
  </chapter>

    <chapter id="port-upgrading">
      <title>Upgrading</title>

      <para>When you notice that a port is out of date compared to the latest
	version from the original authors, you should first ensure that you
	have the latest
	port.  You can find them in the
	<filename>ports/ports-current</filename> directory of the &os; FTP mirror
	sites.  However, if you are working with more than a few
	ports, you will probably find it easier to use
	<application>CVSup</application> to keep your whole ports collection
	up-to-date, as described in the
	<ulink url="&url.books.handbook;/synching.html#CVSUP-CONFIG">Handbook</ulink>.
	This will have the added benefit of tracking all the ports'
	dependencies.</para>

      <para>The next step is to see if there is an update already pending.
	To do this, you have two options.  There is a searchable interface
	to the
	<ulink url="http://www.FreeBSD.org/cgi/query-pr-summary.cgi?query">
	FreeBSD Problem Report (PR) database</ulink> (also known as
	<literal>GNATS</literal>).  Select <literal>ports</literal> in the
	dropdown, and enter the name of the port.</para>

      <para>However, sometimes people forget to put the name of the port
	into the Synopsis field in an unambiguous fashion.  In that case,
	you can try the <link linkend="portsmon">
	FreeBSD Ports Monitoring System</link> (also known as
	<literal>portsmon</literal>).  This system attempts to classify
	port PRs by portname.  To search for PRs about a particular port,
	use the <ulink url="http://portsmon.FreeBSD.org/portoverview.py">
	Overview of One Port</ulink>.</para>

      <para>If there is no pending PR, the next step is to send an email
	to the port's maintainer, as shown by
	<command>make maintainer</command>.  That person may
	already be working on an upgrade, or have a reason to not upgrade the
	port right now (because of, for example, stability problems of the new
	version); you would not want to duplicate their work.  Note that
	unmaintained ports are listed with a maintainer of
	<literal>ports@FreeBSD.org</literal>, which is just the general
	ports mailing list, so sending mail there
	probably will not help in this case.</para>

      <para>If the maintainer asks you to do the upgrade or there is
	no maintainer, then you have a chance to help out &os; by
	preparing the update yourself!  Please make the changes and save
	the result of the
	recursive <command>diff</command> output
	of the new and old
	ports directories (e.g., if your modified port directory is
	called <filename>superedit</filename> and the original is in our tree
	as <filename>superedit.bak</filename>, then save the result of
	<command>diff -ruN superedit.bak superedit</command>).  Either
	unified or context diff is fine, but port committers generally
	prefer unified diffs.  Note the use of the <literal>-N</literal>
	option&mdash;this is the accepted way to force diff to properly
	deal with the case of new files being added or old files being
	deleted.  Before sending us the diff, please examine the
	output to make sure all the changes make sense.  To
	simplify common operations with patch files, you can use
	<filename>/usr/ports/Tools/scripts/patchtool.py</filename>.
	Before using it, please read
	<filename>/usr/ports/Tools/scripts/README.patchtool</filename>.</para>

      <para>If the port is unmaintained, and you are actively using
	it yourself, please consider volunteering to become its
	maintainer.  &os; has over 2000 ports without maintainers,
	and this is an area where more volunteers are always needed.
	(For a detailed description of the responsibilities of maintainers,
	refer to the
	<ulink url="&url.books.developers-handbook;/policies.html#POLICIES-MAINTAINER">
	MAINTAINER on Makefiles</ulink> section.)</para>

      <para> The best way to
	send us the diff is by including it via &man.send-pr.1; (category
	<literal>ports</literal>).  If you are volunteering to maintain the
	port,
	be sure to put <literal>[maintainer update]</literal> at the beginning
	of your synopsis line and set the <quote>Class</quote> of your PR
	to <literal>maintainer-update</literal>.  Otherwise, the
	<quote>Class</quote> of your PR should be
	<literal>change-request</literal>.  Please mention any added or
	deleted files in the message, as they have to be explicitly specified
	to &man.cvs.1; when doing a commit.  If the diff is more than about 20KB,
	please compress and uuencode it; otherwise, just include it in the PR
	as is.</para>

      <para>Before you &man.send-pr.1;, you should review the
	<ulink url="&url.articles.problem-reports;/pr-writing.html">
	Writing the problem report</ulink> section in the Problem
	Reports article; it contains far more information about how to write
	useful problem reports.</para>

      <important>
	<para>If your upgrade is motivated by security concerns or a
	  serious fault in the currently committed port, please notify
	  the &a.portmgr; to request immediate rebuilding and
	  redistribution of your port's package.  Unsuspecting users
	  of &man.pkg.add.1; will otherwise continue to install the
	  old version via <command>pkg_add -r</command> for several
	  weeks.</para>
      </important>

      <note>
	<para>Once again, please use &man.diff.1; and not &man.shar.1; to send
	  updates to existing ports!</para>
      </note>

      <para>Now that you have done all that, you will want to read about
	how to keep up-to-date in <xref linkend="keeping-up">.</para>

    </chapter>

    <chapter id="security">
      <title>Ports security</title>

      <sect1 id="security-intro">
	<title>Why security is so important</title>

	<para>Bugs are occasionally introduced to the software.
	  Arguably, the most dangerous of them are those opening
	  security vulnerabilities.  From the technical viewpoint,
	  such vulnerabilities are to be closed by exterminating
	  the bugs that caused them.  However, the policies for
	  handling mere bugs and security vulnerabilities are
	  very different.</para>

	<para>A typical small bug affects only those users who have
	  enabled some combination of options triggering the bug.
	  The developer will eventually release a patch followed
	  by a new version of the software, free of the bug, but
	  the majority of users will not take the trouble of upgrading
	  immediately because the bug has never vexed them.  A
	  critical bug that may cause data loss represents a graver
	  issue.  Nevertheless, prudent users know that a lot of
	  possible accidents, besides software bugs, are likely to
	  lead to data loss, and so they make backups of important
	  data; in addition, a critical bug will be discovered
	  really soon.</para>

	<para>A security vulnerability is all different.  First,
	  it may remain unnoticed for years because often it does
	  not cause software malfunction.  Second, a malicious party
	  can use it to gain unauthorized access to a vulnerable
	  system, to destroy or alter sensitive data; and in the
	  worst case the user will not even notice the harm caused.
	  Third, exposing a vulnerable system often assists attackers
	  to break into other systems that could not be compromised
	  otherwise.  Therefore closing a vulnerability alone is
	  not enough: the audience should be notified of it in most
	  clear and comprehensive manner, which will allow to
	  evaluate the danger and take appropriate actions.</para>
      </sect1>

      <sect1 id="security-fix">
	<title>Fixing security vulnerabilities</title>

	<para>While on the subject of ports and packages, a security
	  vulnerability may initially appear in the original
	  distribution or in the port files.  In the former case,
	  the original software developer is likely to release a
	  patch or a new version instantly, and you will
	  only need to update the port promptly with respect to
	  the author's fix.  If the fix is delayed for some reason,
	  you should either <link linkend="dads-noinstall">mark the port as
	  <makevar>FORBIDDEN</makevar></link>
	  or introduce a patch file of your own to the port.  In
	  the case of a vulnerable port, just fix the port as soon as
	  possible.  In either case, <link linkend="port-upgrading">the
	  standard procedure for submitting your change</link> should
	  be followed unless you have rights to commit it directly
	  to the ports tree.</para>

	<important>
	  <para>Being a ports committer is not enough to commit to
	    an arbitrary port.  Remember that ports usually have
	    maintainers, whom you should respect.</para>
	</important>

	<para>Please make sure that the port's revision is bumped
	  as soon as the vulnerability has been closed.
	  That is how the users who upgrade installed packages
	  on a regular basis will see they need to run an update.
	  Besides, a new package will be built and distributed
	  over FTP and WWW mirrors, replacing the vulnerable one.
	  <makevar>PORTREVISION</makevar> should be bumped unless
	  <makevar>PORTVERSION</makevar> has changed in the course
	  of correcting the vulnerability.  That is you should
	  bump <makevar>PORTREVISION</makevar> if you have added a
	  patch file to the port, but you should not if you have updated
	  the port to the latest software version and thus already
	  touched <makevar>PORTVERSION</makevar>.  Please refer to the
	  <link linkend="makefile-naming-revepoch">corresponding section</link>
	  for more information.</para>
      </sect1>

      <sect1 id="security-notify">
	<title>Keeping the community informed</title>

	<sect2 id="security-notify-vuxml-db">
	  <title>The VuXML database</title>

	  <para>A very important and urgent step to take as early as
	    a security vulnerability is discovered is to notify the
	    community of port users about the jeopardy.  Such
	    notification serves two purposes.  First, should the danger
	    be really severe, it will be wise to apply an instant workaround,
	    e.g., stop the affected network service or even deinstall
	    the port completely, until the vulnerability is closed.
	    Second, a lot of users tend to upgrade installed packages
	    just occasionally.  They will know from the notification
	    that they <emphasis>must</emphasis> update the package
	    without delay as soon as a corrected version is available.</para>

	  <para>Given the huge number of ports in the tree,
	    a security advisory cannot be issued on each incident
	    without creating a flood and losing the attention of
	    the audience by the time it comes to really serious
	    matters.  Therefore security vulnerabilities found in
	    ports are recorded in <ulink
	    url="http://vuxml.freebsd.org/">the FreeBSD VuXML
	    database</ulink>.  The Security Officer Team members
	    are monitoring it for issues requiring their
	    intervention.</para>

	  <para>If you have committer rights, you can update the VuXML
	    database by yourself.  So you will both help the Security
	    Officer Team and deliver the crucial information to the
	    community earlier.  However, if you are not a committer,
	    or you believe you have found an exceptionally severe
	    vulnerability, or whatever, please do not hesitate to
	    contact the Security Officer Team directly as described
	    on the <ulink
	    url="http://www.freebsd.org/security/#how">FreeBSD
	    Security Information</ulink> page.</para>

	  <para>All right, you elected the hard way.  As it may be obvious
	    from its title, the VuXML database is essentially an
	    XML document.  Its source file <filename>vuln.xml</filename>
	    is kept right inside the port <filename
	    role="package">security/vuxml</filename>.  Therefore
	    the file's full pathname will be
	    <filename><envar>PORTSDIR</envar>/security/vuxml/vuln.xml</filename>.
	    Each time you discover a security vulnerability in a
	    port, please add an entry for it to that file.
	    Until you are familiar with VuXML, the best thing you can
	    do is to find an existing entry fitting your case, then copy
	    it and use as a template.</para>
	</sect2>

	<sect2 id="security-notify-vuxml-intro">
	  <title>A short introduction to VuXML</title>

	  <para>The full-blown XML is complex and far beyond the scope of
	    this book.  However, to gain basic insight on the structure
	    of a VuXML entry, you need only the notion of tags.  XML
	    tag names are enclosed in angle brackets.  Each opening
	    &lt;tag&gt; must have a matching closing &lt;/tag&gt;.
	    Tags may be nested.  If nesting, the inner tags must be
	    closed before the outer ones.  There is a hierarchy of
	    tags, i.e.  more complex rules of nesting them.  Sounds
	    very similar to HTML, doesn't it?  The major difference
	    is that XML is e<emphasis>X</emphasis>tensible, i.e. based
	    on defining custom tags.  Due to its intrinsic structure,
	    XML puts otherwise amorphous data into shape.  VuXML is
	    particularly tailored to mark up descriptions of security
	    vulnerabilities.</para>

	  <para>Now let's consider a realistic VuXML entry:</para>

	  <programlisting>&lt;vuln vid="f4bc80f4-da62-11d8-90ea-0004ac98a7b9"&gt; <co id="co-vx-vid">
  &lt;topic&gt;Several vulnerabilities found in Foo&lt;/topic&gt; <co id="co-vx-top">
  &lt;affects&gt;
    &lt;package&gt;
      &lt;name&gt;foo&lt;/name&gt; <co id="co-vx-nam">
      &lt;name&gt;foo-devel&lt;/name&gt;
      &lt;name&gt;ja-foo&lt;/name&gt;
      &lt;range&gt;&lt;ge&gt;1.6&lt;/ge&gt;&lt;lt&gt;1.9&lt;/lt&gt;&lt;/range&gt; <co id="co-vx-rng">
      &lt;range&gt;&lt;ge&gt;2.*&lt;/ge&gt;&lt;lt&gt;2.4_1&lt;/lt&gt;&lt;/range&gt;
      &lt;range&gt;&lt;eq&gt;3.0b1&lt;/eq&gt;&lt;/range&gt;
    &lt;/package&gt;
    &lt;package&gt;
      &lt;name&gt;openfoo&lt;/name&gt; <co id="co-vx-nm2">
      &lt;range&gt;&lt;lt&gt;1.10_7&lt;/lt&gt;&lt;/range&gt; <co id="co-vx-epo">
      &lt;range&gt;&lt;ge&gt;1.2,1&lt;/ge&gt;&lt;lt&gt;1.3_1,1&lt;/lt&gt;&lt;/range&gt;
    &lt;/package&gt;
  &lt;/affects&gt;
  &lt;description&gt;
    &lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;p&gt;J. Random Hacker reports:&lt;/p&gt; <co id="co-vx-bdy">
      &lt;blockquote
        cite="http://j.r.hacker.com/advisories/1"&gt;
        &lt;p&gt;Several issues in the Foo software may be exploited
          via carefully crafted QUUX requests.  These requests will
          permit the injection of Bar code, mumble theft, and the
          readability of the Foo administrator account.&lt;/p&gt;
      &lt;/blockquote&gt;
    &lt;/body&gt;
  &lt;/description&gt;
  &lt;references&gt; <co id="co-vx-ref">
    &lt;freebsdsa&gt;SA-10:75.foo&lt;/freebsdsa&gt; <co id="co-vx-fsa">
    &lt;freebsdpr&gt;ports/987654&lt;/freebsdpr&gt; <co id="co-vx-fpr">
    &lt;cvename&gt;CAN-2010-0201&lt;/cvename&gt; <co id="co-vx-cve">
    &lt;cvename&gt;CAN-2010-0466&lt;/cvename&gt;
    &lt;bid&gt;96298&lt;/bid&gt; <co id="co-vx-bid">
    &lt;certsa&gt;CA-2010-99&lt;/certsa&gt; <co id="co-vx-cts">
    &lt;certvu&gt;740169&lt;/certvu&gt; <co id="co-vx-ctv">
    &lt;uscertsa&gt;SA10-99A&lt;/uscertsa&gt; <co id="co-vx-ucs">
    &lt;uscertta&gt;SA10-99A&lt;/uscertta&gt; <co id="co-vx-uct">
    &lt;mlist msgid="201075606@hacker.com"&gt;http://marc.theaimsgroup.com/?l=bugtraq&amp;amp;m=203886607825605&lt;/mlist&gt; <co id="co-vx-mls">
    &lt;url&gt;http://j.r.hacker.com/advisories/1&lt;/url&gt; <co id="co-vx-url">
  &lt;/references&gt;
  &lt;dates&gt;
    &lt;discovery&gt;2010-05-25&lt;/discovery&gt; <co id="co-vx-dsc">
    &lt;entry&gt;2010-07-13&lt;/entry&gt; <co id="co-vx-ent">
    &lt;modified&gt;2010-09-17&lt;/entry&gt; <co id="co-vx-mod">
  &lt;/dates&gt;
&lt;/vuln&gt;</programlisting>

	  <para>The tag names are supposed to be self-descriptive,
	    so we shall take a closer look only at fields you will need
	    to fill in by yourself:</para>

	  <calloutlist>
	    <callout arearefs="co-vx-vid">
	      <para>This is the top-level tag of a VuXML entry.  It has
		a mandatory attribute, <literal>vid</literal>,
		specifying a universally unique identifier (UUID) for
		this entry (in quotes).  You should generate a UUID
		for each new VuXML entry (and do not forget to substitute
		it for the template UUID unless you are writing the
		entry from scratch).  You can use &man.uuidgen.1; in
		FreeBSD 5.x, or you may install the port <filename
		role="package">devel/p5-Data-UUID</filename> and issue
		the following command:</para>

	      <programlisting>perl -MData::UUID -le 'print lc new Data::UUID-&gt;create_str'</programlisting>
	    </callout>

	    <callout arearefs="co-vx-top">
	      <para>This is a one-line description of the issue found.</para>
	    </callout>

	    <callout arearefs="co-vx-nam">
	      <para>The names of packages affected are listed there.
		Multiple names can be given since several packages may be
		based on a single master port or software product.  This
		may include stable and development branches, localized
		versions, and slave ports featuring different choices of
		important build-time configuration options.</para>

	      <important>
		<para>It is your responsibility to find all such related
		  packages when writing a VuXML entry.  Keep in mind that
		  <literal>make search name=foo</literal> is your friend.
		  The primary points to look for are as follows:</para>

		<itemizedlist>
		  <listitem>
		    <para>the <filename>foo-devel</filename> variant
		      for a <filename>foo</filename> port;</para>
		  </listitem>

		  <listitem>
		    <para>other variants with a suffix like
		      <literal>-a4</literal> (for print-related packages),
		      <literal>-without-gui</literal> (for packages with X
		      support disabled), or similar;</para>
		  </listitem>

		  <listitem>
		    <para><literal>jp-</literal>, <literal>ru-</literal>,
		      <literal>zh-</literal>, and other possible localized
		      variants in the corresponding national categories of
		      the ports collection.</para>
		  </listitem>
		</itemizedlist>
	      </important>
	    </callout>

	    <callout arearefs="co-vx-rng">
	      <para>Affected versions of the package(s) are specified
		there as one or more ranges using a combination of
		<literal>&lt;lt&gt;</literal>, <literal>&lt;le&gt;</literal>,
		<literal>&lt;eq&gt;</literal>, <literal>&lt;ge&gt;</literal>,
		and <literal>&lt;gt&gt;</literal> elements.  The
		version ranges given should not overlap.</para>

	      <para>In a range specification, <literal>*</literal> (asterisk)
		denotes the smallest version number.  In particular,
		<literal>2.*</literal> is less than <literal>2.a</literal>.
		Therefore an asterisk may be used for a range to match all
		possible <literal>alpha</literal>, <literal>beta</literal>,
		and <literal>RC</literal> versions.  For instance,
		<literal>&lt;ge&gt;2.*&lt;/ge&gt;&lt;lt&gt;3.*&lt;/lt&gt;</literal>
		will selectively match every <literal>2.x</literal> version while
		<literal>&lt;ge&gt;2.0&lt;/ge&gt;&lt;lt&gt;3.0&lt;/lt&gt;</literal>
		will obviously not since the latter misses
		<literal>2.r3</literal> and matches
		<literal>3.b</literal>.</para>

	      <para>The above example
		specifies that affected are versions from <literal>1.6</literal>
		to <literal>1.9</literal> inclusive, versions
		<literal>2.x</literal> before <literal>2.4_1</literal>,
		and version <literal>3.0b1</literal>.</para>
	    </callout>

	    <callout arearefs="co-vx-nm2">
	      <para>Several related package groups (essentially, ports)
		can be listed in the <literal>&lt;affected&gt;</literal>
		section.  This can be used if several software products
		(say FooBar, FreeBar and OpenBar) grow from the same code base
		and still share its bugs and vulnerabilities.  Note the
		difference from listing multiple names within a single
		&lt;package&gt; section.</para>
	    </callout>

	    <callout arearefs="co-vx-epo">
	      <para>The version ranges should allow for
		<makevar>PORTEPOCH</makevar> and
		<makevar>PORTREVISION</makevar> if applicable.
		Please remember that according to the collation rules,
		a version with a non-zero <makevar>PORTEPOCH</makevar> is
		greater than any version without
		<makevar>PORTEPOCH</makevar>, e.g., <literal>3.0,1</literal>
		is greater than <literal>3.1</literal> or even than
		<literal>8.9</literal>.</para>
	    </callout>

	    <callout arearefs="co-vx-bdy">
	      <para>This is a summary of the issue.
		XHTML is used in this field.  At least enclosing
		<literal>&lt;p&gt;</literal> and <literal>&lt;/p&gt;</literal>
		should appear.  More complex mark-up may be used, but only for
		the sake of accuracy and clarity:  No eye candy please.</para>
	    </callout>

	    <callout arearefs="co-vx-ref">
	      <para>This section contains references to relevant documents.
		As many references as apply are encouraged.</para>
	    </callout>

	    <callout arearefs="co-vx-fsa">
	      <para>This is a
		<ulink url="http://www.freebsd.org/security/#adv">FreeBSD
		security advisory</ulink>.</para>
	    </callout>

	    <callout arearefs="co-vx-fpr">
	      <para>This is a
		<ulink url="http://www.freebsd.org/support.html#gnats">FreeBSD
		problem report</ulink>.</para>
	    </callout>

	    <callout arearefs="co-vx-cve">
	      <para>This is a <ulink url="http://www.cve.mitre.org/">Mitre
		CVE</ulink> identifier.</para>
	    </callout>

	    <callout arearefs="co-vx-bid">
	      <para>This is a
		<ulink url="http://www.securityfocus.com/bid">SecurityFocus
		Bug ID</ulink>.</para>
	    </callout>

	    <callout arearefs="co-vx-cts">
	      <para>This is a
		<ulink url="http://www.cert.org/">US-CERT</ulink>
		security advisory.</para>
	    </callout>

	    <callout arearefs="co-vx-ctv">
	      <para>This is a
		<ulink url="http://www.cert.org/">US-CERT</ulink>
		vulnerability note.</para>
	    </callout>

	    <callout arearefs="co-vx-ucs">
	      <para>This is a
		<ulink url="http://www.cert.org/">US-CERT</ulink>
		Cyber Security Alert.</para>
	    </callout>

	    <callout arearefs="co-vx-uct">
	      <para>This is a
		<ulink url="http://www.cert.org/">US-CERT</ulink>
		Technical Cyber Security Alert.</para>
	    </callout>

	    <callout arearefs="co-vx-mls">
	      <para>This is a URL to an archived posting in a mailing list.
		The attribute <literal>msgid</literal> is optional and
		may specify the message ID of the posting.</para>
	    </callout>

	    <callout arearefs="co-vx-url">
	      <para>This is a generic URL.  It should be used only if none of
		the other reference categories apply.</para>
	    </callout>

	    <callout arearefs="co-vx-dsc">
	      <para>This is the date when the issue was disclosed
		(<replaceable>YYYY-MM-DD</replaceable>).</para>
	    </callout>

	    <callout arearefs="co-vx-ent">
	      <para>This is the date when the entry was added
		(<replaceable>YYYY-MM-DD</replaceable>).</para>
	    </callout>

	    <callout arearefs="co-vx-mod">
	      <para>This is the date when any information in the entry
		was last modified (<replaceable>YYYY-MM-DD</replaceable>).
		New entries must not include this field.  It should be added
		upon editing an existing entry.</para>
	    </callout>
	  </calloutlist>
	</sect2>

	<sect2 id="security-notify-vuxml-testing">
	  <title>Testing your changes to the VuXML database</title>

	  <para>Assume you just wrote or filled in an entry for a
	    vulnerability in the package <literal>clamav</literal>
	    that has been fixed in version <literal>0.65_7</literal>.</para>

	  <para>As a prerequisite, you need to install fresh versions of the
	    ports <filename role="package">security/portaudit</filename> and
	    <filename role="package">security/portaudit-db</filename>.</para>

	  <para>First, check whether there already is an entry for this
	    vulnerability.  If there were such entry, it would match the
	    previous version of the package,
	    <literal>0.65_6</literal>:</para>

	  <screen>&prompt.user; <userinput>packaudit</userinput>
&prompt.user; <userinput>portaudit clamav-0.65_6</userinput></screen>

	  <note>
	    <para>To run <command>packaudit</command>, you must have
	      permission to write to its
	      <filename><makevar>DATABASEDIR</makevar></filename>,
	      typically <filename>/var/db/portaudit</filename>.</para>
	  </note>

	  <para>If there is none found, you get the green light to add
	    a new entry for this vulnerability.  Now you can generate
	    a brand-new UUID (assume it's
	    <literal>74a9541d-5d6c-11d8-80e3-0020ed76ef5a</literal>) and
	    add your new entry to the VuXML database.  Please verify
	    its syntax after that as follows:</para>

	  <screen>&prompt.user; <userinput>cd ${PORTSDIR}/security/vuxml && make validate</userinput></screen>

	  <note>
	    <para>You will need at least one of the following packages
	      installed: <filename role="package">textproc/libxml2</filename>,
	      <filename role="package">textproc/jade</filename>.</para>
	  </note>

	  <para>Now rebuild the <command>portaudit</command> database
	    from the VuXML file:</para>

	  <screen>&prompt.user; <userinput>packaudit</userinput></screen>

	  <para>To verify that the <literal>&lt;affected&gt;</literal>
	    section of your entry will match correct package(s), issue
	    the following command:</para>

	  <screen>&prompt.user; <userinput>portaudit -f /usr/ports/INDEX -r 74a9541d-5d6c-11d8-80e3-0020ed76ef5a</userinput></screen>

	  <note>
	    <para>Please refer to &man.portaudit.1; for better understanding
	      of the command syntax.</para>
	  </note>

	  <para>Make sure that your entry produces no spurious matches
	    in the output.</para>

	  <para>Now check whether the right package versions are matched
	    by your entry:</para>

	  <screen>&prompt.user; <userinput>portaudit clamav-0.65_6 clamav-0.65_7</userinput>
Affected package: clamav-0.65_6 (matched by clamav&lt;0.65_7)
Type of problem: clamav remote denial-of-service.
Reference: &lt;http://www.freebsd.org/ports/portaudit/74a9541d-5d6c-11d8-80e3-0020ed76ef5a.html&gt;

1 problem(s) found.</screen>

	  <para>Obviously, the former version should match while the
	    latter one should not.</para>

	  <para>Finally, verify whether the web page generated from the
	    VuXML database looks like expected:</para>

	  <screen>&prompt.user; <userinput>mkdir -p ~/public_html/portaudit</userinput>
&prompt.user; <userinput>packaudit</userinput>
&prompt.user; <userinput>lynx ~/public_html/portaudit/74a9541d-5d6c-11d8-80e3-0020ed76ef5a.html</userinput></screen>
	</sect2>

	<sect2 id="security-notify-noxml">
	  <title>If VuXML still scares you...</title>

	  <para>As an easy alternative to writing VuXML, you may opt to add
	    a single line to a different file with much simpler syntax,
	    <filename><envar>PORTSDIR</envar>/security/portaudit-db/database/portaudit.txt</filename>,
	    which resides within the port <filename
	    role="package">security/portaudit-db</filename>, and
	    send a request for review to the Security Officer Team
	    as described on the <ulink
	    url="http://www.freebsd.org/security/#how">FreeBSD
	    Security Information</ulink> page.</para>

	  <para>A line in that file consists of four fields
	    separated by <literal>|</literal>, a pipe character.
	    The first field is a &man.pkg.version.1; pattern
	    expression matching the vulnerable packages.  The second
	    field contains URLs to relevant information, separated
	    by space characters.  The third field is a one-line
	    description of the issue.  The fourth and last field
	    is the entry's UUID.</para>

	  <para>You may want take a closer look at existing entries in
	    <filename>portaudit.txt</filename> before adding your
	    first line to that file.</para>
	</sect2>
      </sect1>
    </chapter>

    <chapter id="porting-dads">
      <title>Dos and Don'ts</title>

      <sect1 id="dads-intro">
	<title>Introduction</title>

      <para>Here is a list of common dos and don'ts that you encounter during
	the porting process.  You should check your own port against this list,
	but you can also check ports in the <ulink url="http://www.FreeBSD.org/cgi/query-pr-summary.cgi?query">PR database</ulink> that others have
	submitted.  Submit any comments on ports you check as described in
	<ulink url="&url.articles.contributing;/contrib-how.html#CONTRIB-GENERAL">Bug Reports and General
	  Commentary</ulink>.  Checking ports in the PR database will both make
	it faster for us to commit them, and prove that you know what you are
	doing.</para>
      </sect1>

      <sect1 id="dads-strip">
	<title>Stripping Binaries</title>

	<para>Do not strip binaries manually unless you have to.  All binaries
	  should be stripped, but the <maketarget>INSTALL_PROGRAM</maketarget>
	  macro will install and strip a binary at the same time (see the next
	  section).</para>

	<para>If you need to strip a file, but do not wish to use the
	  <makevar>INSTALL_PROGRAM</makevar> macro,
	  <makevar>${STRIP_CMD}</makevar> will strip your program.  This is
	  typically done within the <literal>post-install</literal>
	  target.  For example:</para>

	<programlisting>post-install:
	${STRIP_CMD} ${PREFIX}/bin/xdl</programlisting>

	<para>Use the &man.file.1; command on the installed executable to
	  check whether the binary is stripped or not.  If it does not say
	  <literal>not stripped</literal>, it is stripped.  Additionally,
	  &man.strip.1; will not strip a previously stripped program; it
	  will instead exit cleanly.</para>
      </sect1>

      <sect1 id="dads-install">
	<title>INSTALL_* macros</title>

	<para>Do use the macros provided in <filename>bsd.port.mk</filename>
	  to ensure correct modes and ownership of files in your own
	  <maketarget>*-install</maketarget> targets.</para>

	<itemizedlist>
	  <listitem>
	    <para><makevar>INSTALL_PROGRAM</makevar> is a command to install
	      binary executables.</para>
	  </listitem>

	  <listitem>
	    <para><makevar>INSTALL_SCRIPT</makevar> is a command to install
	      executable scripts.</para>
	  </listitem>

	  <listitem>
	    <para><makevar>INSTALL_DATA</makevar> is a command to install
	      sharable data.</para>
	  </listitem>

	  <listitem>
	    <para><makevar>INSTALL_MAN</makevar> is a command to install
	      manpages and other documentation (it does not compress
	      anything).</para>
	  </listitem>
	</itemizedlist>

	<para>These are basically the <command>install</command> command with
	  all the appropriate flags.  See below for an example on how to use
	  them.</para>
      </sect1>

      <sect1 id="porting-wrkdir">
	<title><makevar>WRKDIR</makevar></title>

	<para>Do not write anything to files outside
	  <makevar>WRKDIR</makevar>.  <makevar>WRKDIR</makevar> is the only
	  place that is guaranteed to be writable during the port build (see
	  <ulink url="&url.books.handbook;/ports-using.html#PORTS-CD">
	  installing ports from a CDROM</ulink> for an
	  example of building ports from a read-only tree).  If you need to
	  modify one of the <filename>pkg-<replaceable>*</replaceable></filename>
	  files, do so by <link
	  linkend="porting-pkgfiles">redefining a variable</link>, not by
	  writing over it.</para>
      </sect1>

      <sect1 id="porting-wrkdirprefix">
	<title><makevar>WRKDIRPREFIX</makevar></title>

	<para>Make sure your port honors <makevar>WRKDIRPREFIX</makevar>.
	  Most ports do not have to worry about this.  In particular, if you
	  are referring to a <makevar>WRKDIR</makevar> of another port, note
	  that the correct location is
	  <filename><makevar>WRKDIRPREFIX</makevar><makevar>PORTSDIR</makevar>/<replaceable>subdir</replaceable>/<replaceable>name</replaceable>/work</filename> not <filename><makevar>PORTSDIR</makevar>/<replaceable>subdir</replaceable>/<replaceable>name</replaceable>/work</filename> or <filename><makevar>.CURDIR</makevar>/../../<replaceable>subdir</replaceable>/<replaceable>name</replaceable>/work</filename> or some such.</para>

	<para>Also, if you are defining <makevar>WRKDIR</makevar> yourself,
	  make sure you prepend
	  <literal>&dollar;{WRKDIRPREFIX}&dollar;{.CURDIR}</literal> in the
	  front.</para>
      </sect1>

      <sect1 id="porting-versions">
	<title>Differentiating operating systems and OS versions</title>

	<para>You may come across code that needs modifications or conditional
	  compilation based upon what version of Unix it is running under.  If
	  you need to make such changes to the code for conditional
	  compilation, make sure you make the changes as general as possible
	  so that we can back-port code to older FreeBSD systems and cross-port
	  to other BSD systems such as 4.4BSD from CSRG, BSD/386, 386BSD,
	  NetBSD, and OpenBSD.</para>

	<para>The preferred way to tell 4.3BSD/Reno (1990) and newer versions
	  of the BSD code apart is by using the <literal>BSD</literal> macro
	  defined in
	  <ulink url="http://cvsweb.freebsd.org/src/sys/sys/param.h">sys/param.h</ulink>.
	  Hopefully that
	  file is already included; if not, add the code:</para>

	<programlisting>#if (defined(__unix__) || defined(unix)) &amp;&amp; !defined(USG)
#include &lt;sys/param.h&gt;
#endif</programlisting>

	<para>to the proper place in the <filename>.c</filename> file.  We
	  believe that every system that defines these two symbols has
	  <filename>sys/param.h</filename>.  If you find a system that
	  does not, we would like to know.  Please send mail to the
	  &a.ports;.</para>

	<para>Another way is to use the GNU Autoconf style of doing
	  this:</para>

	<programlisting>#ifdef HAVE_SYS_PARAM_H
#include &lt;sys/param.h&gt;
#endif</programlisting>

	<para>Do not forget to add <literal>-DHAVE_SYS_PARAM_H</literal> to the
	  <makevar>CFLAGS</makevar> in the <filename>Makefile</filename> for
	  this method.</para>

	<para>Once you have <filename>sys/param.h</filename> included, you may
	  use:</para>

	<programlisting>#if (defined(BSD) &amp;&amp; (BSD &gt;= 199103))</programlisting>

	<para>to detect if the code is being compiled on a 4.3 Net2 code base
	  or newer (e.g. FreeBSD 1.x, 4.3/Reno, NetBSD 0.9, 386BSD, BSD/386
	  1.1 and below).</para>

	<para>Use:</para>

	<programlisting>#if (defined(BSD) &amp;&amp; (BSD &gt;= 199306))</programlisting>

	<para>to detect if the code is being compiled on a 4.4 code base or
	  newer (e.g. FreeBSD 2.x, 4.4, NetBSD 1.0, BSD/386 2.0 or
	  above).</para>

	<para>The value of the <literal>BSD</literal> macro is
	  <literal>199506</literal> for the 4.4BSD-Lite2 code base.  This is
	  stated for informational purposes only.  It should not be used to
	  distinguish between versions of FreeBSD based only on 4.4-Lite vs.
	  versions that have merged in changes from 4.4-Lite2.  The
	  <literal>__FreeBSD__</literal> macro should be used instead.</para>

	<para>Use sparingly:</para>

	<itemizedlist>
	  <listitem>
	    <para><literal>__FreeBSD__</literal> is defined in all versions of
	      FreeBSD.  Use it if the change you are making
	      <emphasis>only</emphasis> affects FreeBSD.  Porting gotchas like
	      the use of <literal>sys_errlist[]</literal> vs
	      <function>strerror()</function> are Berkeley-isms, not FreeBSD
	      changes.</para>
	  </listitem>

	  <listitem>
	    <para>In FreeBSD 2.x, <literal>__FreeBSD__</literal> is defined to
	      be <literal>2</literal>.  In earlier versions, it is
	      <literal>1</literal>.  Later versions always bump it to match
	      their major version number.</para>
	  </listitem>

	  <listitem>
	    <para>If you need to tell the difference between a FreeBSD 1.x
	      system and a FreeBSD 2.x or above system, usually the right answer
	      is to use the <literal>BSD</literal> macros described above.  If
	      there actually is a FreeBSD specific change (such as special
	      shared library options when using <command>ld</command>) then it
	      is OK to use <literal>__FreeBSD__</literal> and <literal>#if
		__FreeBSD__ &gt; 1</literal> to detect a FreeBSD 2.x and later
	      system.  If you need more granularity in detecting FreeBSD
	      systems since 2.0-RELEASE you can use the following:</para>

	    <programlisting>#if __FreeBSD__ &gt;= 2
#include &lt;osreldate.h&gt;
#    if __FreeBSD_version &gt;= 199504
	 /* 2.0.5+ release specific code here */
#    endif
#endif</programlisting>
	  </listitem>
	</itemizedlist>

	<para>In the hundreds of ports that have been done, there have only
	  been one or two cases where <literal>__FreeBSD__</literal> should
	  have been used.  Just because an earlier port screwed up and used it
	  in the wrong place does not mean you should do so too.</para>
      </sect1>

      <sect1 id="freebsd-versions">
	<title>__FreeBSD_version values</title>

	  <para>Here is a convenient list of
	    <literal>__FreeBSD_version</literal> values as defined in
	    <ulink url="http://cvsweb.freebsd.org/src/sys/sys/param.h">sys/param.h</ulink>:</para>

		<table frame="none">
		  <title>__FreeBSD_version values</title>
		<tgroup cols="2">
		<thead>
		  <row>
		    <entry>Release</entry>
		    <entry><literal>__FreeBSD_version</literal></entry>
		  </row>
		</thead>

		<tbody>
		  <row>
		    <entry>2.0-RELEASE</entry>
		    <entry>119411</entry>
		  </row>

		  <row>
		    <entry>2.1-CURRENT</entry>
		    <entry>199501, 199503</entry>
		  </row>

		  <row>
		    <entry>2.0.5-RELEASE</entry>
		    <entry>199504</entry>
		  </row>

		  <row>
		    <entry>2.2-CURRENT before 2.1</entry>
		    <entry>199508</entry>
		  </row>

		  <row>
		    <entry>2.1.0-RELEASE</entry>
		    <entry>199511</entry>
		  </row>

		  <row>
		    <entry>2.2-CURRENT before 2.1.5</entry>
		    <entry>199512</entry>
		  </row>

		  <row>
		    <entry>2.1.5-RELEASE</entry>
		    <entry>199607</entry>
		  </row>

		  <row>
		    <entry>2.2-CURRENT before 2.1.6</entry>
		    <entry>199608</entry>
		  </row>

		  <row>
		    <entry>2.1.6-RELEASE</entry>
		    <entry>199612</entry>
		  </row>

		  <row>
		    <entry>2.1.7-RELEASE</entry>
		    <entry>199612</entry>
		  </row>

		  <row>
		    <entry>2.2-RELEASE</entry>
		    <entry>220000</entry>
		  </row>

		  <row>
		    <entry>2.2.1-RELEASE</entry>
		    <entry>220000 (no change)</entry>
		  </row>

		  <row>
		    <entry>2.2-STABLE after 2.2.1-RELEASE</entry>
		    <entry>220000 (no change)</entry>
		  </row>

		  <row>
		    <entry>2.2-STABLE after texinfo-3.9</entry>
		    <entry>221001</entry>
		  </row>

		  <row>
		    <entry>2.2-STABLE after top</entry>
		    <entry>221002</entry>
		  </row>

		  <row>
		    <entry>2.2.2-RELEASE</entry>
		    <entry>222000</entry>
		  </row>

		  <row>
		    <entry>2.2-STABLE after 2.2.2-RELEASE</entry>
		    <entry>222001</entry>
		  </row>

		  <row>
		    <entry>2.2.5-RELEASE</entry>
		    <entry>225000</entry>
		  </row>

		  <row>
		    <entry>2.2-STABLE after 2.2.5-RELEASE</entry>
		    <entry>225001</entry>
		  </row>

		  <row>
		    <entry>2.2-STABLE after ldconfig -R merge</entry>
		    <entry>225002</entry>
		  </row>

		  <row>
		    <entry>2.2.6-RELEASE</entry>
		    <entry>226000</entry>
		  </row>

		  <row>
		    <entry>2.2.7-RELEASE</entry>
		    <entry>227000</entry>
		  </row>

		  <row>
		    <entry>2.2-STABLE after 2.2.7-RELEASE</entry>
		    <entry>227001</entry>
		  </row>

		  <row>
		    <entry>2.2-STABLE after &man.semctl.2; change</entry>
		    <entry>227002</entry>
		  </row>

		  <row>
		    <entry>2.2.8-RELEASE</entry>
		    <entry>228000</entry>
		  </row>

		  <row>
		    <entry>2.2-STABLE after 2.2.8-RELEASE</entry>
		    <entry>228001</entry>
		  </row>

		  <row>
		    <entry>3.0-CURRENT before &man.mount.2; change</entry>
		    <entry>300000</entry>
		  </row>

		  <row>
		    <entry>3.0-CURRENT after &man.mount.2; change</entry>
		    <entry>300001</entry>
		  </row>

		  <row>
		    <entry>3.0-CURRENT after &man.semctl.2; change</entry>
		    <entry>300002</entry>
		  </row>

		  <row>
		    <entry>3.0-CURRENT after ioctl arg changes</entry>
		    <entry>300003</entry>
		  </row>

		  <row>
		    <entry>3.0-CURRENT after ELF conversion</entry>
		    <entry>300004</entry>
		  </row>

		  <row>
		    <entry>3.0-RELEASE</entry>
		    <entry>300005</entry>
		  </row>

		  <row>
		    <entry>3.0-CURRENT after 3.0-RELEASE</entry>
		    <entry>300006</entry>
		  </row>

		  <row>
		    <entry>3.0-STABLE after 3/4 branch</entry>
		    <entry>300007</entry>
		  </row>

		  <row>
		    <entry>3.1-RELEASE</entry>
		    <entry>310000</entry>
		  </row>

		  <row>
		    <entry>3.1-STABLE after 3.1-RELEASE</entry>
		    <entry>310001</entry>
		  </row>

		  <row>
		    <entry>3.1-STABLE after C++ constructor/destructor order
		      change</entry>
		    <entry>310002</entry>
		  </row>

		  <row>
		    <entry>3.2-RELEASE</entry>
		    <entry>320000</entry>
		  </row>

		  <row>
		    <entry>3.2-STABLE</entry>
		    <entry>320001</entry>
		  </row>

		  <row>
		    <entry>3.2-STABLE after binary-incompatible IPFW and
		      socket changes</entry>
		    <entry>320002</entry>
		  </row>

		  <row>
		    <entry>3.3-RELEASE</entry>
		    <entry>330000</entry>
		  </row>

		  <row>
		    <entry>3.3-STABLE</entry>
		    <entry>330001</entry>
		  </row>

		  <row>
		    <entry>3.3-STABLE after adding &man.mkstemp.3;
		      to libc</entry>
		    <entry>330002</entry>
		  </row>

		  <row>
		    <entry>3.4-RELEASE</entry>
		    <entry>340000</entry>
		  </row>

		  <row>
		    <entry>3.4-STABLE</entry>
		    <entry>340001</entry>
		  </row>

		  <row>
		    <entry>3.5-RELEASE</entry>
		    <entry>350000</entry>
		  </row>

		  <row>
		    <entry>3.5-STABLE</entry>
		    <entry>350001</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after 3.4 branch</entry>
		    <entry>400000</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after change in dynamic linker
		      handling</entry>
		    <entry>400001</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after C++ constructor/destructor
		      order change</entry>
		    <entry>400002</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after functioning &man.dladdr.3;</entry>
		    <entry>400003</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after __deregister_frame_info dynamic
		      linker bug fix (also 4.0-CURRENT after EGCS 1.1.2
		      integration)
		    </entry>
		    <entry>400004</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after &man.suser.9; API change
		      (also 4.0-CURRENT after newbus)</entry>
		    <entry>400005</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after cdevsw registration change</entry>
		    <entry>400006</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after the addition of so_cred for
		      socket level credentials</entry>
		    <entry>400007</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after the addition of a poll syscall
		      wrapper to libc_r</entry>
		    <entry>400008</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after the change of the kernel's
		      <literal>dev_t</literal> type to <literal>struct
		      specinfo</literal> pointer</entry>
		    <entry>400009</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after fixing a hole
		      in &man.jail.2;</entry>
		    <entry>400010</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after the <literal>sigset_t</literal>
		      datatype change</entry>
		    <entry>400011</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after the cutover to the GCC 2.95.2
		      compiler</entry>
		    <entry>400012</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after adding pluggable linux-mode
		      ioctl handlers</entry>
		    <entry>400013</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after importing OpenSSL</entry>
		    <entry>400014</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after the C++ ABI change in GCC 2.95.2
		      from -fvtable-thunks to -fno-vtable-thunks by
		      default</entry>
		    <entry>400015</entry>
		  </row>

		  <row>
		    <entry>4.0-CURRENT after importing OpenSSH</entry>
		    <entry>400016</entry>
		  </row>

		  <row>
		    <entry>4.0-RELEASE</entry>
		    <entry>400017</entry>
		  </row>

		  <row>
		    <entry>4.0-STABLE after 4.0-RELEASE</entry>
		    <entry>400018</entry>
		  </row>

		  <row>
		    <entry>4.0-STABLE after the introduction of delayed
		      checksums.</entry>
		    <entry>400019</entry>
		  </row>

		  <row>
		    <entry>4.0-STABLE after merging libxpg4 code into
		      libc.</entry>
		    <entry>400020</entry>
		  </row>

		  <row>
		    <entry>4.0-STABLE after upgrading Binutils to 2.10.0, ELF
		      branding changes, and tcsh in the base system.</entry>
		    <entry>400021</entry>
		  </row>

		  <row>
		    <entry>4.1-RELEASE</entry>
		    <entry>410000</entry>
		  </row>

		  <row>
		    <entry>4.1-STABLE after 4.1-RELEASE</entry>
		    <entry>410001</entry>
		  </row>

		  <row>
		    <entry>4.1-STABLE after &man.setproctitle.3; moved from
		      libutil to libc.</entry>
		    <entry>410002</entry>
		  </row>

		  <row>
		    <entry>4.1.1-RELEASE</entry>
		    <entry>411000</entry>
		  </row>

		  <row>
		    <entry>4.1.1-STABLE after 4.1.1-RELEASE</entry>
		    <entry>411001</entry>
		  </row>

		  <row>
		    <entry>4.2-RELEASE</entry>
		    <entry>420000</entry>
		  </row>

		  <row>
		    <entry>4.2-STABLE after combining libgcc.a and
		      libgcc_r.a, and associated GCC linkage changes.</entry>
		    <entry>420001</entry>
		  </row>

		  <row>
		    <entry>4.3-RELEASE</entry>
		    <entry>430000</entry>
		  </row>

		  <row>
		    <entry>4.3-STABLE after wint_t introduction.</entry>
		    <entry>430001</entry>
		  </row>

		  <row>
		    <entry>4.3-STABLE after PCI powerstate API merge.</entry>
		    <entry>430002</entry>
		  </row>

		  <row>
		    <entry>4.4-RELEASE</entry>
		    <entry>440000</entry>
		  </row>

		  <row>
		    <entry>4.4-STABLE after d_thread_t introduction.</entry>
		    <entry>440001</entry>
		  </row>

		  <row>
		    <entry>4.4-STABLE after mount structure changes (affects
		      filesystem klds).</entry>
		    <entry>440002</entry>
		  </row>

		  <row>
		    <entry>4.4-STABLE after the userland components of smbfs
		      were imported.</entry>
		    <entry>440003</entry>
		  </row>

		  <row>
		    <entry>4.5-RELEASE</entry>
		    <entry>450000</entry>
		  </row>

		  <row>
		    <entry>4.5-STABLE after the usb structure element rename.</entry>
		    <entry>450001</entry>
		  </row>

		  <row>
		    <entry>4.5-STABLE after the
		      <literal>sendmail_enable</literal> &man.rc.conf.5;
		      variable was made to take the value
		      <literal>NONE</literal>.</entry>
		    <entry>450004</entry>
		  </row>

		  <row>
		    <entry>4.5-STABLE after moving to XFree86 4 by default
		      for package builds.</entry>
		    <entry>450005</entry>
		  </row>

		  <row>
		    <entry>4.5-STABLE after accept filtering was fixed so
		      that is no longer susceptible to an easy DoS.</entry>
		    <entry>450006</entry>
		  </row>

		  <row>
		    <entry>4.6-RELEASE</entry>
		    <entry>460000</entry>
		  </row>

		  <row>
		    <entry>4.6-STABLE &man.sendfile.2; fixed to comply with
		      documentation, not to count any headers sent against
		      the amount of data to be sent from the file.</entry>
		    <entry>460001</entry>
		  </row>

		  <row>
		    <entry>4.6.2-RELEASE</entry>
		    <entry>460002</entry>
		  </row>

		  <row>
		    <entry>4.6-STABLE</entry>
		    <entry>460100</entry>
		  </row>

		  <row>
		    <entry>4.6-STABLE after MFC of `sed -i'.</entry>
		    <entry>460101</entry>
		  </row>

		  <row>
		    <entry>4.6-STABLE after MFC of many new pkg_install
		      features from the HEAD.</entry>
		    <entry>460102</entry>
		  </row>

		  <row>
		    <entry>4.7-RELEASE</entry>
		    <entry>470000</entry>
		  </row>

		  <row>
		    <entry>4.7-STABLE</entry>
		    <entry>470100</entry>
		  </row>

		  <row>
		    <entry>Start generated __std{in,out,err}p references rather
		      than __sF.  This changes std{in,out,err} from a
		      compile time expression to a runtime one.</entry>
		    <entry>470101</entry>
		  </row>

		  <row>
		    <entry>4.7-STABLE after MFC of mbuf changes to replace
		       m_aux mbufs by m_tag's</entry>
		    <entry>470102</entry>
		  </row>

		  <row>
		    <entry>4.7-STABLE gets OpenSSL 0.9.7</entry>
		    <entry>470103</entry>
		  </row>

		  <row>
		    <entry>4.8-RELEASE</entry>
		    <entry>480000</entry>
		  </row>

		  <row>
		    <entry>4.8-STABLE</entry>
		    <entry>480100</entry>
		  </row>

		  <row>
		    <entry>4.8-STABLE after &man.realpath.3; has been made
		      thread-safe</entry>
		    <entry>480101</entry>
		  </row>

		  <row>
		    <entry>4.8-STABLE 3ware API changes to twe.</entry>
		    <entry>480102</entry>
		  </row>

		  <row>
		    <entry>4.9-RELEASE</entry>
		    <entry>490000</entry>
		  </row>

		  <row>
		    <entry>4.9-STABLE</entry>
		    <entry>490100</entry>
		  </row>

		  <row>
		    <entry>4.9-STABLE after e_sid was added to struct
		      kinfo_eproc.</entry>
		    <entry>490101</entry>
		  </row>

		  <row>
		    <entry>4.9-STABLE after MFC of libmap functionality
		      for rtld.</entry>
		    <entry>490102</entry>
		  </row>

		  <row>
		    <entry>4.10-RELEASE</entry>
		    <entry>491000</entry>
		  </row>

		  <row>
		    <entry>4.10-STABLE</entry>
		    <entry>491100</entry>
		  </row>

		  <row>
		    <entry>4.10-STABLE after MFC of revision 20040629 of
		      the package tools</entry>
		    <entry>491101</entry>
		  </row>

		  <row>
		    <entry>4.10-STABLE after VM fix dealing with unwiring
		      of fictitious pages</entry>
		    <entry>491102</entry>
		  </row>

		  <row>
		    <entry>4.11-RELEASE</entry>
		    <entry>492000</entry>
		  </row>

		  <row>
		    <entry>4.11-STABLE</entry>
		    <entry>492100</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT</entry>
		    <entry>500000</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after adding addition ELF header fields,
		      and changing our ELF binary branding method.</entry>
		    <entry>500001</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after kld metadata changes.</entry>
		    <entry>500002</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after buf/bio changes.</entry>
		    <entry>500003</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after binutils upgrade.</entry>
		    <entry>500004</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after merging libxpg4 code into
		      libc and after TASKQ interface introduction.</entry>
		    <entry>500005</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after the addition of AGP
		      interfaces.</entry>
		    <entry>500006</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after Perl upgrade to 5.6.0</entry>
		    <entry>500007</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after the update of KAME code to
		      2000/07 sources.</entry>
		    <entry>500008</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after ether_ifattach() and
		      ether_ifdetach() changes.</entry>
		    <entry>500009</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after changing mtree defaults
		      back to original variant, adding -L to follow
		      symlinks.</entry>
		    <entry>500010</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after kqueue API changed.</entry>
		    <entry>500011</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after &man.setproctitle.3; moved from
		      libutil to libc.</entry>
		    <entry>500012</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after the first SMPng commit.</entry>
		    <entry>500013</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after &lt;sys/select.h&gt; moved to
		      &lt;sys/selinfo.h&gt;.</entry>
		    <entry>500014</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after combining libgcc.a and
		      libgcc_r.a, and associated GCC linkage changes.</entry>
		    <entry>500015</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after change allowing libc and libc_r
		      to be linked together, deprecating -pthread
		      option.</entry>
		    <entry>500016</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after switch from struct ucred to
		      struct xucred to stabilize kernel-exported API for
		      mountd et al.</entry>
		    <entry>500017</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after addition of CPUTYPE make variable
		      for controlling CPU-specific optimizations.</entry>
		    <entry>500018</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after moving machine/ioctl_fd.h to
		      sys/fdcio.h</entry>
		    <entry>500019</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after locale names renaming.</entry>
		    <entry>500020</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after Bzip2 import.
		    Also signifies removal of S/Key.</entry>
		    <entry>500021</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after SSE support.</entry>
		    <entry>500022</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after KSE Milestone 2.</entry>
		    <entry>500023</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after d_thread_t,
		      and moving UUCP to ports.</entry>
		    <entry>500024</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after ABI change for descriptor
		      and creds passing on 64 bit platforms.</entry>
		    <entry>500025</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after moving to XFree86 4 by default for
		      package builds, and after the new libc strnstr() function
		      was added.</entry>
		    <entry>500026</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after the new libc strcasestr() function
		      was added.</entry>
		    <entry>500027</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after the userland components of smbfs
		      were imported.</entry>
		    <entry>500028</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after the new C99 specific-width
		      integer types were added.</entry>
		    <entry>(Not incremented.)</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after a change was made in the return
		      value of &man.sendfile.2;.</entry>
		    <entry>500029</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after the introduction of the
		      type <literal>fflags_t</literal>, which is the
		      appropriate size for file flags.</entry>
		    <entry>500030</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after the usb structure element rename.</entry>
		    <entry>500031</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after the introduction of
		      Perl 5.6.1.</entry>
		    <entry>500032</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after the
		      <literal>sendmail_enable</literal> &man.rc.conf.5;
		      variable was made to take the value
		      <literal>NONE</literal>.</entry>
		    <entry>500033</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after mtx_init() grew a third argument.</entry>
		    <entry>500034</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT with Gcc 3.1.</entry>
		    <entry>500035</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT without Perl in /usr/src</entry>
		    <entry>500036</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after the addition of &man.dlfunc.3;</entry>
		    <entry>500037</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after the types of some struct
		      sockbuf members were changed and the structure was
		      reordered.</entry>
		    <entry>500038</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after GCC 3.2.1 import.
		      Also after headers stopped using
		      _BSD_FOO_T_ and started using _FOO_T_DECLARED.
		      This value can also be used as a conservative
		      estimate of the start of &man.bzip2.1; package
		      support.</entry>
		    <entry>500039</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after various changes to disk functions
		      were made in the name of removing dependency on disklabel
		      structure internals.</entry>
		    <entry>500040</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after the addition of &man.getopt.long.3;
		      to libc.</entry>
		    <entry>500041</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after Binutils 2.13 upgrade, which
		      included new FreeBSD emulation, vec, and output format.
		      </entry>
		    <entry>500042</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after adding weak pthread_XXX stubs
		      to libc, obsoleting libXThrStub.so.  5.0-RELEASE.</entry>
		    <entry>500043</entry>
		  </row>

		  <row>
		    <entry>5.0-CURRENT after branching for RELENG_5_0</entry>
		    <entry>500100</entry>
		  </row>
		  <row>
		    <entry>&lt;sys/dkstat.h&gt; is empty and should
		    not be included.</entry>
		    <entry>500101</entry>
		  </row>
		  <row>
		    <entry>5.0-CURRENT after the d_mmap_t interface
		      change.</entry>
		    <entry>500102</entry>
		  </row>
		  <row>
		    <entry>5.0-CURRENT after taskqueue_swi changed to run
		      without Giant, and taskqueue_swi_giant added to run
		      with Giant.</entry>
		    <entry>500103</entry>
		  </row>
		  <row>
		    <entry>cdevsw_add() and cdevsw_remove() no
		      longer exists.
		      Appearance of MAJOR_AUTO allocation facility.</entry>
		    <entry>500104</entry>
		  </row>
		  <row>
		    <entry>5.0-CURRENT after new cdevsw initialization method.</entry>
		    <entry>500105</entry>
		  </row>
		  <row>
		    <entry>devstat_add_entry() has been replaced by
		      devstat_new_entry()</entry>
		    <entry>500106</entry>
		  </row>
		  <row>
		    <entry>Devstat interface change; see sys/sys/param.h 1.149</entry>
		    <entry>500107</entry>
		  </row>
		  <row>
		    <entry>Token-Ring interface changes.</entry>
		    <entry>500108</entry>
		  </row>
		  <row>
		    <entry>Addition of vm_paddr_t.</entry>
		    <entry>500109</entry>
		  </row>
		  <row>
		    <entry>5.0-CURRENT after &man.realpath.3; has been made
		      thread-safe</entry>
		    <entry>500110</entry>
		  </row>
		  <row>
		    <entry>5.0-CURRENT after &man.usbhid.3; has been synced with
		      NetBSD</entry>
		    <entry>500111</entry>
		  </row>
		  <row>
		    <entry>5.0-CURRENT after new NSS implementation
		      and addition of POSIX.1 getpw*_r, getgr*_r
		      functions</entry>
		    <entry>500112</entry>
		  </row>
		  <row>
		    <entry>5.0-CURRENT after removal of the old rc system.</entry>
		    <entry>500113</entry>
		  </row>
		  <row>
		    <entry>5.1-RELEASE.</entry>
		    <entry>501000</entry>
		  </row>
		  <row>
		    <entry>5.1-CURRENT after branching for RELENG_5_1.</entry>
		    <entry>501100</entry>
		  </row>
		  <row>
		    <entry>5.1-CURRENT after correcting the semantics of
		      sigtimedwait(2) and sigwaitinfo(2).</entry>
		    <entry>501101</entry>
		  </row>
		  <row>
		    <entry>5.1-CURRENT after adding the lockfunc and lockfuncarg
		      fields to &man.bus.dma.tag.create.9;.</entry>
		    <entry>501102</entry>
		  </row>
		  <row>
		    <entry>5.1-CURRENT after GCC 3.3.1-pre 20030711 snapshot
		      integration.</entry>
		    <entry>501103</entry>
		  </row>
		  <row>
		    <entry>5.1-CURRENT 3ware API changes to twe.</entry>
		    <entry>501104</entry>
		  </row>
		  <row>
		    <entry>5.1-CURRENT dynamically-linked /bin and /sbin
		      support and movement of libraries to /lib.</entry>
		    <entry>501105</entry>
		  </row>
		  <row>
		    <entry>5.1-CURRENT after adding kernel support for
		      Coda 6.x.</entry>
		    <entry>501106</entry>
		  </row>
		  <row>
		    <entry>5.1-CURRENT after 16550 UART constants moved from
		      <filename>&lt;dev/sio/sioreg.h&gt;</filename> to
		      <filename>&lt;dev/ic/ns16550.h&gt;</filename>.
		      Also when libmap functionality was unconditionally
		      supported by rtld.</entry>
		    <entry>501107</entry>
		  </row>
		  <row>
		    <entry>5.1-CURRENT after PFIL_HOOKS API update</entry>
		    <entry>501108</entry>
		  </row>
		  <row>
		    <entry>5.1-CURRENT after adding kiconv(3)</entry>
		    <entry>501109</entry>
		  </row>
		  <row>
		    <entry>5.1-CURRENT after changing default operations
			for open and close in cdevsw</entry>
		    <entry>501110</entry>
		  </row>
		  <row>
		    <entry>5.1-CURRENT after changed layout of cdevsw</entry>
		    <entry>501111</entry>
		  </row>
		  <row>
		    <entry> 5.1-CURRENT after adding kobj multiple inheritance
		    </entry>
		    <entry>501112</entry>
		  </row>
		  <row>
		    <entry> 5.1-CURRENT after the if_xname change in
			struct ifnet</entry>
		    <entry>501113</entry>
		  </row>
		  <row>
		    <entry> 5.1-CURRENT after changing /bin and /sbin to
			be dynamically linked</entry>
		    <entry>501114</entry>
		  </row>
		  <row>
		    <entry>5.2-RELEASE</entry>
		    <entry>502000</entry>
		  </row>
		  <row>
		    <entry>5.2.1-RELEASE</entry>
		    <entry>502010</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after branching for RELENG_5_2</entry>
		    <entry>502100</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after __cxa_atexit/__cxa_finalize
			functions were added to libc.</entry>
		    <entry>502101</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after change of default thread library
			from libc_r to libpthread.</entry>
		    <entry>502102</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after device driver API megapatch.
		    </entry>
		    <entry>502103</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after getopt_long_only() addition.
		    </entry>
		    <entry>502104</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after NULL is made into ((void *)0)
			for C, creating more warnings.
		    </entry>
		    <entry>502105</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after pf is linked to the build and
			install.
		    </entry>
		    <entry>502106</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after time_t is changed to a
			64-bit value on sparc64.
		    </entry>
		    <entry>502107</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after Intel C/C++ compiler support in some headers and execve(2) changes to be more strictly conforming to POSIX.
		    </entry>
		    <entry>502108</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after the introduction of the
		      bus_alloc_resource_any API
		    </entry>
		    <entry>502109</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after the addition of UTF-8 locales
		    </entry>
		    <entry>502110</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after the removal of the getvfsent(3)
		      API
		    </entry>
		    <entry>502111</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after the addition of the .warning
		      directive for make.</entry>
		    <entry>502112</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after ttyioctl() was made mandatory
		      for serial drivers.</entry>
		    <entry>502113</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after import of the ALTQ framework.
		    </entry>
		    <entry>502114</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after changing sema_timedwait(9) to
		      return 0 on success and a non-zero error code on
		      failure.
		    </entry>
		    <entry>502115</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after changing kernel dev_t to
		      be pointer to struct cdev *.
		    </entry>
		    <entry>502116</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after changing kernel udev_t to dev_t.
		    </entry>
		    <entry>502117</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after adding support for CLOCK_VIRTUAL
		      and CLOCK_PROF to clock_gettime(2) and clock_getres(2).
		    </entry>
		    <entry>502118</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after changing network interface
		      cloning overhaul.
		    </entry>
		    <entry>502119</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after the update of the package tools
		      to revision 20040629.
		    </entry>
		    <entry>502120</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after marking Bluetooth code as
		      non-i386 specific.
		    </entry>
		    <entry>502121</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after the introduction of the KDB
		      debugger framework, the conversion of DDB into a
		      backend and the introduction of the GDB backend.
		    </entry>
		    <entry>502122</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after change to make
		      VFS_ROOT take a struct
		      thread argument as does vflush.  Struct kinfo_proc
		      now has a user data pointer.
		      The switch of the default X implementation to
		      <literal>xorg</literal> was also made at this time.
		    </entry>
		    <entry>502123</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after the change to separate the way
		      ports rc.d and legacy scripts are started.
		    </entry>
		    <entry>502124</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after the backout of the
		      previous change.
		    </entry>
		    <entry>502125</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after the removal of
		      kmem_alloc_pageable() and the import of gcc 3.4.2.
		    </entry>
		    <entry>502126</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after changing the UMA kernel
		      API to allow ctors/inits to fail.
		    </entry>
		    <entry>502127</entry>
		  </row>
		  <row>
		    <entry>5.2-CURRENT after the change of the
		      vfs_mount signature as well as global replacement of
		      PRISON_ROOT with SUSER_ALLOWJAIL for the suser(9)
		      API.
		    </entry>
		    <entry>502128</entry>
		  </row>
		  <row>
		    <entry>5.3-BETA/RC before the pfil API change</entry>
		    <entry>503000</entry>
		  </row>
		  <row>
		    <entry>5.3-RELEASE</entry>
		    <entry>503001</entry>
		  </row>
		  <row>
		    <entry>5.3-STABLE after branching for RELENG_5_3</entry>
		    <entry>503100</entry>
		  </row>
		  <row>
		    <entry>5.3-STABLE after addition of glibc style
		      &man.strftime.3; padding options.</entry>
		    <entry>503101</entry>
		  </row>
		  <row>
		    <entry>5.3-STABLE after OpenBSD's nc(1) import MFC.</entry>
		    <entry>503102</entry>
		  </row>
		  <row>
		    <entry>5.4-PRERELEASE after the MFC of the fixes in
			<filename>&lt;src/include/stdbool.h&gt;</filename> and
			<filename>&lt;src/sys/i386/include/_types.h&gt;</filename>
			for using the GCC-compatibility of the Intel C/C++ compiler.</entry>
		    <entry>503103</entry>
 		  </row>
		  <row>
		    <entry>5.4-PRERELEASE after the MFC of the change of
		       ifi_epoch from wall clock time to uptime.</entry>
		    <entry>503104</entry>
 		  </row>
		  <row>
		    <entry>5.4-PRERELEASE after the MFC of the fix of EOVERFLOW check in vswprintf(3).</entry>
		    <entry>503105</entry>
		  </row>
		  <row>
		    <entry>5.4-RELEASE.</entry>
		    <entry>504000</entry>
		  </row>
		  <row>
		    <entry>5.4-STABLE after branching for RELENG_5_4</entry>
		    <entry>504100</entry>
		  </row>
		  <row>
		    <entry>5.4-STABLE after increasing the default
		      thread stacksizes</entry>
		    <entry>504101</entry>
		  </row>
		  <row>
		    <entry>5.4-STABLE after the addition of sha256</entry>
		    <entry>504102</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT</entry>
		    <entry>600000</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after permanently enabling PFIL_HOOKS
		      in the kernel.
		    </entry>
		    <entry>600001</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after initial addition of
		      ifi_epoch to struct if_data.  Backed out after a
		      few days.  Do not use this value.
		    </entry>
		    <entry>600002</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after the re-addition of the
		      ifi_epoch member of struct if_data.
		    </entry>
		    <entry>600003</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after addition of the struct inpcb
		      argument to the pfil API.
		    </entry>
		    <entry>600004</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after addition of the "-d
		      DESTDIR" argument to newsyslog.
		    </entry>
		    <entry>600005</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after addition of glibc style
		      &man.strftime.3; padding options.
		    </entry>
		    <entry>600006</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after addition of 802.11 framework
		      updates.
		    </entry>
		    <entry>600007</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after changes to VOP_*VOBJECT() functions
		      and introduction of MNTK_MPSAFE flag for Giantfree filesystems.
		    </entry>
		    <entry>600008</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after addition of the cpufreq framework
		      and drivers.
		    </entry>
		    <entry>600009</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after importing OpenBSD's nc(1).</entry>
		    <entry>600010</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after removing semblance of SVID2
			<literal>matherr()</literal> support.</entry>
		    <entry>600011</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after increase of default thread stacks'
			size.</entry>
		    <entry>600012</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after fixes in
			<filename>&lt;src/include/stdbool.h&gt;</filename> and
			<filename>&lt;src/sys/i386/include/_types.h&gt;</filename>
			for using the GCC-compatibility of the Intel C/C++ compiler.</entry>
		    <entry>600013</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after EOVERFLOW checks in vswprintf(3) fixed.</entry>
		    <entry>600014</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after changing the struct if_data
		       member, ifi_epoch, from wall clock time to uptime.</entry>
		    <entry>600015</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after LC_CTYPE disk format changed.</entry>
		    <entry>600016</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after NLS catalogs disk format changed.</entry>
		    <entry>600017</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after LC_COLLATE disk format changed.</entry>
		    <entry>600018</entry>
		  </row>
		  <row>
		    <entry>Installation of acpica includes into /usr/include.</entry>
		    <entry>600019</entry>
		  </row>
		  <row>
		    <entry>Addition of MSG_NOSIGNAL flag to send(2) API.</entry>
		    <entry>600020</entry>
		  </row>
		  <row>
		    <entry>Addition of fields to cdevsw</entry>
		    <entry>600021</entry>
		  </row>
		  <row>
		    <entry>Removed gtar from base system.</entry>
		    <entry>600022</entry>
		  </row>
		  <row>
		    <entry>LOCAL_CREDS, LOCAL_CONNWAIT socket options added to unix(4).</entry>
		    <entry>600023</entry>
		  </row>
		  <row>
		    <entry>&man.hwpmc.4; and related tools added to 6.0-CURRENT.</entry>
		    <entry>600024</entry>
		  </row>
		  <row>
		    <entry>struct icmphdr added to 6.0-CURRENT.</entry>
		    <entry>600025</entry>
		  </row>
		  <row>
		    <entry>pf updated to 3.7.</entry>
		    <entry>600026</entry>
		  </row>
		  <row>
		    <entry>Kernel libalias and ng_nat introduced.</entry>
		    <entry>600027</entry>
		  </row>
		  <row>
		    <entry>POSIX ttyname_r(3) made available through unistd.h and libc.</entry>
		    <entry>600028</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after libpcap updated to v0.9.1 alpha 096.</entry>
		    <entry>600029</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after importing NetBSD's if_bridge(4).</entry>
		    <entry>600030</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after struct ifnet was broken out
		      of the driver softcs.</entry>
		    <entry>600031</entry>
		  </row>
		  <row>
		    <entry>6.0-CURRENT after the import of libpcap v0.9.1.</entry>
		    <entry>600032</entry>
		  </row>
		  <row>
		    <entry>6.0-STABLE after bump of all shared library
		      versions that had not been changed since
		      RELENG_5.</entry>
		    <entry>600033</entry>
		  </row>
		  <row>
		    <entry>6.0-STABLE after credential argument is added to
		      dev_clone vent handler.</entry>
		    <entry>600034</entry>
		  </row>
		  <row>
		    <entry>7.0-CURRENT.</entry>
		    <entry>700000</entry>
		  </row>
		  <row>
		    <entry>7.0-CURRENT after bump of all shared library
		      versions that had not been changed since
		      RELENG_5.</entry>
		    <entry>700001</entry>
		  </row>
		  <row>
		    <entry>7.0-CURRENT after credential argument is added to
		      dev_clone vent handler.</entry>
		    <entry>700002</entry>
		  </row>
		  <row>
		    <entry>7.0-CURRENT after memmem(3) is added to libc.</entry>
		    <entry>700003</entry>
		  </row>
		</tbody>
	      </tgroup>
	    </table>

	<note>
	  <para>Note that 2.2-STABLE sometimes identifies itself as
	    <quote>2.2.5-STABLE</quote> after the 2.2.5-RELEASE.  The pattern
	    used to be year followed by the month, but we decided to change it
	    to a more straightforward major/minor system starting from 2.2.
	    This is because the parallel development on several branches made
	    it infeasible to classify the releases simply by their real
	    release dates.  If you are making a port now, you do not have to
	    worry about old -CURRENTs; they are listed here just for your
	    reference.</para>
	</note>
      </sect1>

      <sect1 id="dads-after-port-mk">
	<title>Writing something after
	  <filename>bsd.port.mk</filename></title>

	<para>Do not write anything after the <literal>.include
	    &lt;bsd.port.mk&gt;</literal> line.  It usually can be avoided by
	  including <filename>bsd.port.pre.mk</filename> somewhere in the
	  middle of your <filename>Makefile</filename> and
	  <filename>bsd.port.post.mk</filename> at the end.</para>

	<note>
	  <para>You need to include either the
	    <filename>bsd.port.pre.mk</filename>/<filename>bsd.port.post.mk</filename> pair or
	    <filename>bsd.port.mk</filename> only; do not mix these two usages.</para>
	</note>

	<para><filename>bsd.port.pre.mk</filename> only defines a few
	  variables, which can be used in tests in the
	  <filename>Makefile</filename>, <filename>bsd.port.post.mk</filename>
	  defines the rest.</para>

	<para>Here are some important variables defined in
	  <filename>bsd.port.pre.mk</filename> (this is not the complete list,
	  please read <filename>bsd.port.mk</filename> for the complete
	  list).</para>

	<informaltable frame="none" pgwide="1">
	  <tgroup cols="2">
	    <thead>
	      <row>
		<entry>Variable</entry>
		<entry>Description</entry>
	      </row>
	    </thead>

	    <tbody>
	      <row>
		<entry><makevar>ARCH</makevar></entry>
		<entry>The architecture as returned by <command>uname
		    -m</command> (e.g., <literal>i386</literal>)</entry>
	      </row>

	      <row>
		<entry><makevar>OPSYS</makevar></entry>
		<entry>The operating system type, as returned by
		  <command>uname -s</command> (e.g.,
		  <literal>FreeBSD</literal>)</entry>
	      </row>

	      <row>
		<entry><makevar>OSREL</makevar></entry>
		<entry>The release version of the operating system (e.g.,
		  <literal>2.1.5</literal> or
		  <literal>2.2.7</literal>)</entry>
	      </row>

	      <row>
		<entry><makevar>OSVERSION</makevar></entry>
		<entry>The numeric version of the operating system; the same as
		  <link
		    linkend="freebsd-versions"><literal>__FreeBSD_version</literal></link>.</entry>
	      </row>

	      <row>
		<entry><makevar>PORTOBJFORMAT</makevar></entry>
		<entry>The object format of the system
		  (<literal>elf</literal> or <literal>aout</literal>;
		  note that for <quote>modern</quote> versions of FreeBSD,
		  <literal>aout</literal> is deprecated.)</entry>
	      </row>

	      <row>
		<entry><makevar>LOCALBASE</makevar></entry>
		<entry>The base of the <quote>local</quote> tree (e.g.,
		  <literal>/usr/local/</literal>)</entry>
	      </row>

	      <row>
		<entry><makevar>X11BASE</makevar></entry>
		<entry>The base of the <quote>X11</quote> tree (e.g.,
		  <literal>/usr/X11R6</literal>)</entry>
	      </row>

	      <row>
		<entry><makevar>PREFIX</makevar></entry>
		<entry>Where the port installs itself (see <link
		    linkend="porting-prefix">more on
		    <makevar>PREFIX</makevar></link>).</entry>
	      </row>
	    </tbody>
	  </tgroup>
	</informaltable>

	<note>
	  <para>If you have to define the variables
	    <makevar>USE_IMAKE</makevar>, <makevar>USE_X_PREFIX</makevar>, or
	    <makevar>MASTERDIR</makevar>, do so before including
	    <filename>bsd.port.pre.mk</filename>.</para>
	</note>

	<para>Here are some examples of things you can write after
	  <filename>bsd.port.pre.mk</filename>:</para>

	<programlisting># no need to compile lang/perl5 if perl5 is already in system
.if ${OSVERSION} > 300003
BROKEN= perl is in system
.endif

# only one shlib version number for ELF
.if ${PORTOBJFORMAT} == "elf"
TCL_LIB_FILE=  ${TCL_LIB}.${SHLIB_MAJOR}
.else
TCL_LIB_FILE=  ${TCL_LIB}.${SHLIB_MAJOR}.${SHLIB_MINOR}
.endif

# software already makes link for ELF, but not for a.out
post-install:
.if ${PORTOBJFORMAT} == "aout"
       ${LN} -sf liblinpack.so.1.0 ${PREFIX}/lib/liblinpack.so
.endif</programlisting>

	<para>You did remember to use tab instead of spaces after
	  <literal>BROKEN=</literal> and
	  <literal>TCL_LIB_FILE=</literal>, did you not?
	  <!-- smiley -->:-).</para>
      </sect1>

      <sect1 id="dads-documentation">
	<title>Install additional documentation</title>

	<para>If your software has some documentation other than the standard
	  man and info pages that you think is useful for the user, install it
	  under <filename><makevar>PREFIX</makevar>/share/doc</filename>.
	  This can be done, like the previous item, in the
	  <maketarget>post-install</maketarget> target.</para>

	<para>Create a new directory for your port.  The directory name should
	  reflect what the port is.  This usually means
	  <makevar>PORTNAME</makevar>. However, if you
	  think the user might want different versions of the port to be
	  installed at the same time, you can use the whole
	  <makevar>PKGNAME</makevar>.</para>

	<para>Make the installation dependent on the variable
	  <makevar>NOPORTDOCS</makevar> so that users can disable it in
	  <filename>/etc/make.conf</filename>, like this:</para>

	<programlisting>post-install:
.if !defined(NOPORTDOCS)
	${MKDIR} ${DOCSDIR}
	${INSTALL_MAN} ${WRKSRC}/docs/xvdocs.ps ${DOCSDIR}
.endif</programlisting>

	<para>Here are some handy variables and how they are expanded
	  by default when used
	  in the <filename>Makefile</filename>:</para>

	<itemizedlist>
	  <listitem>
	    <para><makevar>DATADIR</makevar> gets expanded to
	      <filename><makevar>PREFIX</makevar>/share/<makevar>PORTNAME</makevar></filename>.</para>
	  </listitem>

	  <listitem>
	    <para><makevar>DOCSDIR</makevar> gets expanded to
	      <filename><makevar>PREFIX</makevar>/share/doc/<makevar>PORTNAME</makevar></filename>.</para>
	  </listitem>

	  <listitem>
	    <para><makevar>EXAMPLESDIR</makevar> gets expanded to
	      <filename><makevar>PREFIX</makevar>/share/examples/<makevar>PORTNAME</makevar></filename>.</para>
	  </listitem>
	</itemizedlist>

	<para>These variables are exported to <makevar>PLIST_SUB</makevar>.
	  Their values will appear there as pathnames relative to
	  <filename><makevar>PREFIX</makevar></filename> if possible.
	  That is, <filename>share/doc/<makevar>PORTNAME</makevar></filename>
	  will be substituted for <literal>%%DOCSDIR%%</literal>
	  in the packing list by default, and so on.
	  (See more on <filename>pkg-plist</filename> substitution
	  <link linkend="plist-sub">here</link>.)</para>

	<para>All documentation files and directories installed should
	  be included in <filename>pkg-plist</filename> with the
	  <literal>%%PORTDOCS%%</literal> prefix, for example:</para>

	<programlisting>%%PORTDOCS%%%%DOCSDIR%%/AUTHORS
%%PORTDOCS%%%%DOCSDIR%%/CONTACT
%%PORTDOCS%%@dirrm %%DOCSDIR%%</programlisting>

	<para>As an alternative to enumerating the documentation files
	  in <filename>pkg-plist</filename>, a port can set the variable
	  <makevar>PORTDOCS</makevar> to a list of file names and shell
	  glob patterns to add to the final packing list.
	  The names will be relative to <makevar>DOCSDIR</makevar>.
	  Therefore, a port that utilizes <makevar>PORTDOCS</makevar> and
	  uses a non-default location for its documentation should set
	  <makevar>DOCSDIR</makevar> accordingly.
	  If a directory is listed in <makevar>PORTDOCS</makevar>
	  or matched by a glob pattern from this variable,
	  the entire subtree of contained files and directories will be
	  registered in the final packing list.  <makevar>PORTDOCS</makevar>
	  should not be set if <makevar>NOPORTDOCS</makevar> is in
	  effect.  Installing the documentation at <makevar>PORTDOCS</makevar>
	  as shown above remains up to the port itself.
	  A typical example of utilizing <makevar>PORTDOCS</makevar>
	  looks as follows:</para>

        <programlisting>.if !defined(NOPORTDOCS)
        PORTDOCS=       *
.endif</programlisting>

	<note>
	  <para>You can also use the <filename>pkg-message</filename> file to
	    display messages upon installation.  See <link
	    linkend="porting-message">the section on using
	    <filename>pkg-message</filename></link> for details.
	    The <filename>pkg-message</filename> file does not need to be
	    added to <filename>pkg-plist</filename>.</para>
	</note>
      </sect1>

      <sect1 id="dads-subdirs">
	<title>Subdirectories</title>

	<para>Try to let the port put things in the right subdirectories of
	  <makevar>PREFIX</makevar>.  Some ports lump everything and put it in
	  the subdirectory with the port's name, which is incorrect.  Also,
	  many ports put everything except binaries, header files and manual
	  pages in the a subdirectory of <filename>lib</filename>, which does
	  not work well with the BSD paradigm.  Many of the files should be
	  moved to one of the following: <filename>etc</filename>
	  (setup/configuration files), <filename>libexec</filename>
	  (executables started internally), <filename>sbin</filename>
	  (executables for superusers/managers), <filename>info</filename>
	  (documentation for info browser) or  <filename>share</filename>
	  (architecture independent files).  See &man.hier.7; for details;
	  the rules governing
	  <filename>/usr</filename> pretty much apply to
	  <filename>/usr/local</filename> too.  The exception are ports
	  dealing with USENET <quote>news</quote>.  They may use
	  <filename><makevar>PREFIX</makevar>/news</filename> as a destination
	  for their files.</para>
      </sect1>

      <sect1 id="dads-uid-and-gids">
	<title>UIDs and GIDs</title>

	<para>If your port requires a certain user to be on the installed
	  system, let the <filename>pkg-install</filename> script call
	  <command>pw</command> to create it automatically.  Look at
	  <filename role="package">net/cvsup-mirror</filename> for an example.</para>

	<para>If your port must use the same user/group ID number when it is
	  installed as a binary package as when it was compiled, then you must
	  choose a free UID from 50 to 999 and register it below.  Look at
	  <filename role="package">japanese/Wnn6</filename> for an example.</para>

	<para>Make sure you do not use a UID already used by the system or
	  other ports.</para>

	<para>This is the current list of UIDs between 50 and 999.</para>

	<!-- Please keep this list sorted by uid -->
	<programlisting>bind:*:53:53:Bind Sandbox:/:/sbin/nologin
majordom:*:54:54:Majordomo Pseudo User:/usr/local/majordomo:/nonexistent
rdfdb:*:55:55:rdfDB Daemon:/var/db/rdfdb:/bin/sh
spamd:*:58:58:SpamAssassin user:/var/spool/spamd:/sbin/nologin
cyrus:*:60:60:the cyrus mail server:/nonexistent:/nonexistent
gnats:*:61:1:GNATS database owner:/usr/local/share/gnats/gnats-db:/bin/sh
proxy:*:62:62:Packet Filter pseudo-user:/nonexistent:/nonexistent
uucp:*:66:66:UUCP pseudo-user:/var/spool/uucppublic:/usr/libexec/uucp/uucico
xten:*:67:67:X-10 daemon:/usr/local/xten:/nonexistent
pop:*:68:6:Post Office Owner (popper):/nonexistent:/sbin/nologin
wnn:*:69:7:Wnn:/nonexistent:/nonexistent
pgsql:*:70:70:PostgreSQL pseudo-user:/usr/local/pgsql:/bin/sh
oracle:*:71:71::0:0:Oracle:/usr/local/oracle7:/sbin/nologin
ircd:*:72:72:IRC daemon:/nonexistent:/nonexistent
ircservices:*:73:73:IRC services:/nonexistent:/nonexistent
simscan:*:74:74:Simscan User:/nonexistent:/sbin/nologin
ifmail:*:75:66:Ifmail user:/nonexistent:/nonexistent
www:*:80:80:World Wide Web Owner:/nonexistent:/sbin/nologin
alias:*:81:81:QMail user:/var/qmail/alias:/nonexistent
qmaild:*:82:81:QMail user:/var/qmail:/nonexistent
qmaill:*:83:81:QMail user:/var/qmail:/nonexistent
qmailp:*:84:81:QMail user:/var/qmail:/nonexistent
qmailq:*:85:82:QMail user:/var/qmail:/nonexistent
qmailr:*:86:82:QMail user:/var/qmail:/nonexistent
qmails:*:87:82:QMail user:/var/qmail:/nonexistent
mysql:*:88:88:MySQL Daemon:/var/db/mysql:/sbin/nologin
vpopmail:*:89:89:VPop Mail User:/usr/local/vpopmail:/nonexistent
firebird:*:90:90:Firebird Database Administrator:/usr/local/firebird:/bin/sh
mailman:*:91:91:Mailman User:/usr/local/mailman:/sbin/nologin
gdm:*:92:92:GDM Sandbox:/:/sbin/nologin
jabber:*:93:93:Jabber Daemon:/nonexistent:/nonexistent
p4admin:*:94:94:Perforce admin:/usr/local/perforce:/sbin/nologin
interch:*:95:95:Interchange user:/usr/local/interchange:/sbin/nologin
squeuer:*:96:96:SQueuer Owner:/nonexistent:/bin/sh
mud:*:97:97:MUD Owner:/nonexistent:/bin/sh
msql:*:98:98:mSQL-2 pseudo-user:/var/db/msqldb:/bin/sh
rscsi:*:99:99:Remote SCSI:/usr/local/rscsi:/usr/local/sbin/rscsi
squid:*:100:100:squid caching-proxy pseudo user:/usr/local/squid:/sbin/nologin
quagga:*:101:101:Quagga route daemon pseudo user:/usr/local/etc/quagga:/sbin/nologin
ganglia:*:102:102:Ganglia User:/nonexistent:/sbin/nologin
sgeadmin:*:103:103:Sun Grid Engine Admin:/nonexistent:/sbin/nologin
slimserv:*:104:104:Slim Devices SlimServer pseudo-user:/nonexistent:/sbin/nologin
dnetc:*:105:105:distributed.net client and proxy pseudo-user:/nonexistent:/sbin/nologin
clamav:*:106:106:Clamav Antivirus:/nonexistent:/sbin/nologin
cacti:*:107:107:Cacti Sandbox:/nonexistent:/sbin/nologin
webkit:*:108:108:WebKit Default User:/usr/local/www/webkit:/bin/sh
quickml:*:109:109:quickml Server:/nonexistent:/sbin/nologin
vscan:*:110:110:Scanning Virus Account:/var/amavis:/bin/sh
fido:*:111:111:Fido System:/usr/local/fido:/bin/sh
dcc:*:112:112:Distributed Checksum Clearinghouse:/nonexistent:/sbin/nologin
amavis:*:113:113:Amavis-stats Account:/nonexistent:/sbin/nologin
dhis:*:114:114:DHIS Daemon:/nonexistent:/sbin/nologin
_symon:*:115:115:Symon Account:/var/empty:/sbin/nologin
postfix:*:125:125:Postfix Mail System:/var/spool/postfix:/sbin/nologin
rbldns:*:153:153:rbldnsd pseudo-user:/nonexistent:/sbin/nologin
sfs:*:171:171:Self-Certifying File System:/nonexistent:/sbin/nologin
agk:*:172:172:AquaGateKeeper:/nonexistent:/nonexistent
polipo:*:173:173:polipo web cache:/nonexistent:/sbin/nologin
bogomilter:*:174:174:milter-bogom:/nonexistent:/sbin/nologin
moinmoin:*:192:192:MoinMoin User:/nonexistent:/sbin/nologin
sympa:*:200:200:Sympa Owner:/nonexistent:/sbin/nologin
dspam:*:202:202:Dspam:/nonexistent:/sbin/nologin
_tor:*:256:256:Tor anonymising router:/var/db/tor:/bin/sh
ldap:*:389:389:OpenLDAP Server:/nonexistent:/sbin/nologin
drweb:*:426:426:Dr.Web Mail Scanner:/nonexistent:/sbin/nologin
courier:*:465:465:Courier Mail Server:/nonexistent:/sbin/nologin
_bbstored:*:505:505::0:0:BoxBackup Store Daemon:/nonexistent:/bin/sh
qtss:*:554:554:Darwin Streaming Server:/nonexistent:/sbin/nologin
ircdru:*:555:555:Russian hybrid IRC server:/nonexistent:/bin/sh
messagebus:*:556:556:D-BUS Daemon User:/nonexistent:/sbin/nologin
bnetd:*:700:700:Bnetd user:/nonexistent:/sbin/nologin
bopm:*:717:717:Blitzed Open Proxy Monitor:/nonexistent:/bin/sh
bacula:*:910:910:Bacula Daemon:/var/db/bacula:/sbin/nologin</programlisting>

	<para>This is the current list of reserved GIDs.</para>

	<!-- Please keep this list sorted by gid -->
	<!-- XXX incomplete! -->
	<programlisting>bind:*:53:
rdfdb:*:55:
spamd:*:58:
cyrus:*:60:
proxy:*:62:
authpf:*:63:
uucp:*:66:
xten:*:67:
dialer:*:68:
network:*:69:
pgsql:*:70:
simscan:*:74:
www:*:80:
qnofiles:*:81:
qmail:*:82:
mysql:*:88:
vpopmail:*:89:
firebird:*:90:
mailman:*:91:
gdm:*:92:
jabber:*:93:
p4admin:*:94:
interch:*:95:
squeuer:*:96:
mud:*:97:
msql:*:98:
rscsi:*:99:
squid:*:100:
quagga:*:101:
ganglia:*:102:
sgeadmin:*:103:
slimserv:*:104:
dnetc:*:105:
clamav:*:106:
cacti:*:107:
webkit:*:108:
quickml:*:109:
vscan:*:110:
fido:*:111:
dcc:*:112:
amavis:*:113:
dhis:*:114:
_symon:*:115:
postfix:*:125:
maildrop:*:126:
rbldns:*:153:
sfs:*:171:
agk:*:172:
polipo:*:173:
moinmoin:*:192:
sympa:*:200:
dspam:*:202:
_tor:*:256:
ldap:*:389:
drweb:*:426:
courier:*:465:
_bbstored:*:505:
qtss:*:554:
ircdru:*:555:
messagebus:*:556:
realtime:*:557:
bnetd:*:700:
bopm:*:717:
bacula:*:910:</programlisting>

	<para>Please include a notice when you submit a port (or an upgrade)
	  that reserves a new UID or GID in this range.  This allows us to
	  keep the list of reserved IDs up to date.</para>
      </sect1>

      <sect1 id="dads-rational">
	<title>Do things rationally</title>

	<para>The <filename>Makefile</filename> should do things simply and
	  reasonably.  If you can make it a couple of lines shorter or more
	  readable, then do so.  Examples include using a make
	  <literal>.if</literal> construct instead of a shell
	  <literal>if</literal> construct, not redefining
	  <maketarget>do-extract</maketarget> if you can redefine
	  <makevar>EXTRACT*</makevar> instead, and using
	  <makevar>GNU_CONFIGURE</makevar> instead of <literal>CONFIGURE_ARGS
	    += --prefix=&dollar;{PREFIX}</literal>.</para>

	<para>If you find yourself having to write a lot
	  of new code to try to do something, please go back and review
	  <filename>bsd.port.mk</filename> to see if it contains an
	  existing implementation of what you are trying to do.  While
	  hard to read, there are a great many seemingly-hard problems for
	  which <filename>bsd.port.mk</filename> already provides a
	  shorthand solution.</para>
      </sect1>

      <sect1 id="dads-cc">
	<title>Respect both <makevar>CC</makevar> and
	  <makevar>CXX</makevar></title>

	<para>The port should respect both <makevar>CC</makevar>
	  and <makevar>CXX</makevar> variables.  What we mean by this
	  is that the port should not set the values of these variables
	  absolutely, overriding existing values; instead, it should append
	  whatever values it needs to the existing values.  This is so that
	  build options that affect all ports can be set globally.</para>

	<para>If the port does not respect these variables,
	  please add <literal>NO_PACKAGE=ignores either cc or
	  cxx</literal> to the <filename>Makefile</filename>.</para>

	<para>An example of a <filename>Makefile</filename> respecting
	  both <makevar>CC</makevar> and <makevar>CXX</makevar>
	  variables follows.  Note the <makevar>?=</makevar>:</para>

	<programlisting>CC?= gcc</programlisting>
	<programlisting>CXX?= g++</programlisting>

	<para>Here is an example which respects neither
	  <makevar>CC</makevar> nor <makevar>CXX</makevar>
	  variables:</para>

	<programlisting>CC= gcc</programlisting>
	<programlisting>CXX= g++</programlisting>

	<para>Both <makevar>CC</makevar> and <makevar>CXX</makevar>
	  variables can be defined on FreeBSD systems in
	  <filename>/etc/make.conf</filename>.  The first example
	  defines a value if it was not previously set in
	  <filename>/etc/make.conf</filename>, preserving any
	  system-wide definitions.  The second example clobbers
	  anything previously defined.</para>
      </sect1>

      <sect1 id="dads-cflags">
	<title>Respect <makevar>CFLAGS</makevar></title>

	<para>The port should respect the <makevar>CFLAGS</makevar> variable.
	  What we mean by this is that the port should not set the value of
	  this variable absolutely, overriding the existing value; instead,
	  it should append whatever values it needs to the existing value.
	  This is so that build options that affect all ports can be set
	  globally.</para>

	<para>If it does not, please add <literal>NO_PACKAGE=ignores
	    cflags</literal> to the <filename>Makefile</filename>.</para>

	<para>An example of a <filename>Makefile</filename> respecting
	  the <makevar>CFLAGS</makevar> variable follows.  Note the
	  <makevar>+=</makevar>:</para>

	<programlisting>CFLAGS+= -Wall -Werror</programlisting>

	<para>Here is an example which does not respect the
	  <makevar>CFLAGS</makevar> variable:</para>

	<programlisting>CFLAGS= -Wall -Werror</programlisting>

	<para>The <makevar>CFLAGS</makevar> variable is defined on
	  FreeBSD systems in <filename>/etc/make.conf</filename>.  The
	  first example appends additional flags to the
	  <makevar>CFLAGS</makevar> variable, preserving any system-wide
	  definitions.  The second example clobbers anything previously
	  defined.</para>

	<para>You should remove optimization flags from the third party
	  <filename>Makefile</filename>s.  System <makevar>CFLAGS</makevar>
	  contains system-wide optimization flags.  An example from
	  an unmodified <filename>Makefile</filename>:</para>

	<programlisting>CFLAGS= -O3 -funroll-loops -DHAVE_SOUND</programlisting>

	<para>Using system optimization flags, the
	  <filename>Makefile</filename> would look similar to the
	  following example:</para>

	<programlisting>CFLAGS+= -DHAVE_SOUND</programlisting>

      </sect1>

      <sect1 id="dads-freedback">
	<title>Feedback</title>

	<para>Do send applicable changes/patches to the original
	  author/maintainer for inclusion in next release of the code.  This
	  will only make your job that much easier for the next
	  release.</para>
      </sect1>

      <sect1 id="dads-readme">
	<title><filename>README.html</filename></title>

	<para>Do not include the <filename>README.html</filename> file.  This
	  file is not part of the cvs collection but is generated using the
	  <command>make readme</command> command.
	</para>
      </sect1>

      <sect1 id="dads-noinstall">
	<title>Marking a port not installable with <makevar>BROKEN</makevar>,
	  <makevar>FORBIDDEN</makevar>, or <makevar>IGNORE</makevar></title>

	<para>In certain cases users should be prevented from installing
	  a port.  To tell a user that
	  a port should not be installed, there are several
	  <command>make</command> variables that can be used in a port's
	  <filename>Makefile</filename>.  The value of the following
	  <command>make</command> variables will be the reason that is
	  given back to users for why the port refuses to install itself.
	  Please use the correct <command>make</command> variable as
	  each make variable conveys radically different meanings to
	  both users, and to automated systems that depend on the
	  <filename>Makefile</filename>s, such as
	<link linkend="build-cluster">the ports build cluster</link>,
	<link linkend="freshports">FreshPorts</link>, and
	<link linkend="portsmon">portsmon</link>.</para>

	<sect2 id="dads-noinstall-variables">
	  <title>Variables</title>

	<itemizedlist>
	  <listitem>
	    <para><makevar>BROKEN</makevar> is reserved for ports that
	      currently do not compile, install, or deinstall correctly.
	      It should be used for ports where the the problem is
	      believed to be temporary.
	      The build cluster will still attempt to try to build
	      them to see if the underlying problem has been
	      resolved.  For instance, use
	      <makevar>BROKEN</makevar> when a port:</para>

	    <itemizedlist>
	      <listitem>
		<para>does not compile</para>
	      </listitem>

	      <listitem>
		<para>fails its configuration or installation process</para>
	      </listitem>

	      <listitem>
		<para>installs files outside of
		  <filename>${LOCALBASE}</filename> and
		  <filename>${X11BASE}</filename></para>
	      </listitem>

	      <listitem>
		<para>does not remove all its files cleanly upon
		  deinstall (however, it may be acceptable, and desirable,
		  for the port to leave user-modified files behind)</para>
	      </listitem>
	    </itemizedlist>

	  </listitem>

	  <listitem>
	    <para><makevar>FORBIDDEN</makevar> is used for ports that
	      do contain a security vulnerability or induce grave
	      concern regarding the security of a FreeBSD system with
	      a given port installed (ex: a reputably insecure program
	      or a program that provides easily exploitable services).
	      Ports should be marked as <makevar>FORBIDDEN</makevar>
	      as soon as a particular piece of software has a
	      vulnerability and there is no released upgrade.  Ideally
	      ports should be upgraded as soon as possible when a
	      security vulnerability is discovered so as to reduce the
	      number of vulnerable FreeBSD hosts (we like being known
	      for being secure), however sometimes there is a
	      noticeable time gap between disclosure of a
	      vulnerability and an updated release of the
	      vulnerable software.  Do not mark a port
	      <makevar>FORBIDDEN</makevar> for any reason other than
	      security.</para>
	  </listitem>

	  <listitem>
	    <para><makevar>IGNORE</makevar> is reserved for ports that
	      should not be built for some other reason.
	      It should be used for ports where the the problem is
	      believed to be structural.
	      The build
	      cluster will not, under any
	      circumstances, build ports marked as
	      <makevar>IGNORE</makevar>.  For instance, use
	      <makevar>IGNORE</makevar> when a port:</para>

	    <itemizedlist>
	      <listitem>
		<para>compiles but does not run properly</para>
	      </listitem>

	      <listitem>
		<para>does not work on the installed version of &os;</para>
	      </listitem>

	      <listitem>
		<para>requires &os; kernel sources to build, but the
		  user does not have them installed</para>
	      </listitem>

	      <listitem>
		<para>has a distfile which may not be automatically
		  fetched due to licensing restrictions</para>
	      </listitem>

	      <listitem>
		<para>does not work with some other currently installed
		  port (for instance, the port depends on
		  <filename role="package">www/apache21</filename> but
		  <filename role="package">www/apache13</filename>
		  is installed)</para>
	      </listitem>
	    </itemizedlist>

	    <note>
	      <para>If a port would conflict with a currently installed
		port (for example, if they install a file in the same
		place that perfoms a different function),
		<link linkend="conflicts">use
		<makevar>CONFLICTS</makevar> instead</link>.
		<makevar>CONFLICTS</makevar> will set
		<makevar>IGNORE</makevar> by itself.</para>
	    </note>
	  </listitem>

	  <listitem>
	    <para>If a port sould be marked <makevar>IGNORE</makevar>
	      only on certain architectures, there are two other
	      convenience variables that will automatically set
	      <makevar>IGNORE</makevar> for you:
	      <makevar>ONLY_FOR_ARCHS</makevar> and
	      <makevar>NOT_FOR_ARCHS</makevar>.  Examples:</para>

	    <programlisting>ONLY_FOR_ARCHS= i386 amd64</programlisting>

	    <programlisting>NOT_FOR_ARCHS= alpha ia64 sparc64</programlisting>
	  </listitem>

	</itemizedlist>

	</sect2>
	<sect2 id="dads-noinstall-notes">
	  <title>Implementation Notes</title>

	  <para>Due to vagaries in the usage of <makevar>IGNORECMD</makevar>
	    in <filename>bsd.port.mk</filename> among other places,
	    the value of <makevar>BROKEN</makevar> should be enclosed
	    in quotes, and the value of <makevar>IGNORE</makevar> should
	    not be enclosed in quotes.</para>

	  <para>Also, the wording of the string should be somewhat
	    different due to the way the information is shown to the
	    user.  Examples:</para>

	  <programlisting>BROKEN= "this port is unsupported on FreeBSD 5.x"</programlisting>

	  <programlisting>IGNORE= is unsupported on FreeBSD 5.x</programlisting>

	  <para>resulting in the following output from
	    <command>make describe</command>:</para>

	  <programlisting>===>  foobar-0.1 is marked as broken: this port is unsupported on FreeBSD 5.x.</programlisting>

	  <programlisting>===>  foobar-0.1 is unsupported on FreeBSD 5.x.</programlisting>
	</sect2>
      </sect1>

      <sect1 id="dads-deprecated">
	<title>Marking a port for removal with <makevar>DEPRECATED</makevar>
	  or <makevar>EXPIRATION_DATE</makevar></title>

	<para>Do remember that <makevar>BROKEN</makevar> and
	  <makevar>FORBIDDEN</makevar> are to be used as a
	  temporary resort if a port is not working.  Permanently
	  broken ports should be removed from the tree
	  entirely.</para>

	<para>When it makes sense to do so, users can be warned about
	  a pending port removal with <makevar>DEPRECATED</makevar>
	  and <makevar>EXPIRATION_DATE</makevar>.  The former is
	  simply a string stating why the port is scheduled for removal;
	  the latter is a string in ISO 8601 format (YYYY-MM-DD).  Both
	  will be shown to the user.</para>

	<para>It is possible to set <makevar>DEPRECATED</makevar>
	  without an <makevar>EXPIRATION_DATE</makevar> (for
	  instance, recommending a newer version of the port), but
	  the converse does not make any sense.</para>

	<para>There is no set policy on how much notice to give.
	  Current practice seems to be one month for security-related
	  issues and two months for build issues.  This also gives any
	  interested committers a little time to fix the problems.</para>
      </sect1>

      <sect1 id="dads-workarounds">
	<title>Necessary workarounds</title>

	<para>Sometimes it is necessary to work around bugs in
	  software included with older versions of &os;.</para>

	<itemizedlist>
	  <listitem>
	    <para>Some versions of &man.make.1; were broken
	      on at least 4.8 and 5.0 with respect to handling
	      comparisons based on <makevar>OSVERSION</makevar>.
	      This would often lead to failures during
	      <command>make describe</command> (and thus, the overall
	      ports <command>make index</command>).  The workaround is
	      to enclose the conditional comparison in spaces, e.g.:
	      <programlisting>if ( ${OSVERSION} > 500023 )</programlisting>
	      Be aware that test-installing a port on 4.9 or 5.2
	      will <emphasis>not</emphasis> detect this problem.</para>
	  </listitem>

	</itemizedlist>

      </sect1>

      <sect1 id="dads-misc">
	<title>Miscellanea</title>

	<para>The files
	  <filename>pkg-descr</filename> and <filename>pkg-plist</filename>
	  should each be double-checked.  If you are reviewing a port and feel
	  they can be worded better, do so.</para>

	<para>Do not copy more copies of the GNU General Public License into
	  our system, please.</para>

	<para>Please be careful to note any legal issues! Do not let us
	  illegally distribute software!</para>
      </sect1>

    </chapter>

    <chapter id="porting-samplem">
      <title>A Sample <filename>Makefile</filename></title>

      <para>Here is a sample <filename>Makefile</filename> that you can use to
	create a new port.  Make sure you remove all the extra comments (ones
	between brackets)!</para>

      <para>It is recommended that you follow this format (ordering of
	variables, empty lines between sections, etc.).  This format is
	designed so that the most important information is easy to locate.  We
	recommend that you use <link
	  linkend="porting-portlint">portlint</link> to check the
	<filename>Makefile</filename>.</para>

      <programlisting>[the header...just to make it easier for us to identify the ports.]
# New ports collection makefile for:   xdvi
[the "version required" line is only needed when the PORTVERSION
 variable is not specific enough to describe the port.]
# Date created:                26 May 1995
[this is the person who did the original port to FreeBSD, in particular, the
person who wrote the first version of this Makefile.  Remember, this should
not be changed when upgrading the port later.]
# Whom:                        Satoshi Asami &lt;asami@FreeBSD.org&gt;
#
# &dollar;FreeBSD&dollar;
[ ^^^^^^^^^ This will be automatically replaced with RCS ID string by CVS
when it is committed to our repository.  If upgrading a port, do not alter
this line back to "&dollar;FreeBSD&dollar;".  CVS deals with it automatically.]
#

[section to describe the port itself and the master site - PORTNAME
 and PORTVERSION are always first, followed by CATEGORIES,
 and then MASTER_SITES, which can be followed by MASTER_SITE_SUBDIR.
 PKGNAMEPREFIX and PKGNAMESUFFIX, if needed, will be after that.
 Then comes DISTNAME, EXTRACT_SUFX and/or DISTFILES, and then
 EXTRACT_ONLY, as necessary.]
PORTNAME=      xdvi
PORTVERSION=   18.2
CATEGORIES=    print
[do not forget the trailing slash ("/")!
 if you are not using MASTER_SITE_* macros]
MASTER_SITES=  ${MASTER_SITE_XCONTRIB}
MASTER_SITE_SUBDIR= applications
PKGNAMEPREFIX= ja-
DISTNAME=      xdvi-pl18
[set this if the source is not in the standard ".tar.gz" form]
EXTRACT_SUFX=  .tar.Z

[section for distributed patches -- can be empty]
PATCH_SITES=   ftp://ftp.sra.co.jp/pub/X11/japanese/
PATCHFILES=    xdvi-18.patch1.gz xdvi-18.patch2.gz

[maintainer; *mandatory*!  This is the person (preferably with commit
 privileges) whom a user can contact for questions and bug reports - this
 person should be the porter or someone who can forward questions to the
 original porter reasonably promptly.  If you really do not want to have
 your address here, set it to "ports@FreeBSD.org".]
MAINTAINER=    asami@FreeBSD.org
COMMENT=       A DVI Previewer for the X Window System

[dependencies -- can be empty]
RUN_DEPENDS=   gs:${PORTSDIR}/print/ghostscript
LIB_DEPENDS=   Xpm.5:${PORTSDIR}/graphics/xpm

[this section is for other standard bsd.port.mk variables that do not
 belong to any of the above]
[If it asks questions during configure, build, install...]
IS_INTERACTIVE=        yes
[If it extracts to a directory other than ${DISTNAME}...]
WRKSRC=                ${WRKDIR}/xdvi-new
[If the distributed patches were not made relative to ${WRKSRC}, you
 may need to tweak this]
PATCH_DIST_STRIP=      -p1
[If it requires a "configure" script generated by GNU autoconf to be run]
GNU_CONFIGURE= yes
[If it requires GNU make, not /usr/bin/make, to build...]
USE_GMAKE=     yes
[If it is an X application and requires "xmkmf -a" to be run...]
USE_IMAKE=     yes
[et cetera.]

[non-standard variables to be used in the rules below]
MY_FAVORITE_RESPONSE=  "yeah, right"

[then the special rules, in the order they are called]
pre-fetch:
	i go fetch something, yeah

post-patch:
	i need to do something after patch, great

pre-install:
	and then some more stuff before installing, wow

[and then the epilogue]
.include &lt;bsd.port.mk&gt;</programlisting>
    </chapter>

    <chapter id="keeping-up">
      <title>Keeping Up</title>

      <para>The &os; Ports Collection is constantly changing.  Here is
	some information on how to keep up.</para>

      <sect1 id="freshports">
	<title>FreshPorts</title>

	<para>One of the easiest ways to learn about updates that have
	  already been committed is by subscribing to
	  <ulink url="http://www.FreshPorts.org/">FreshPorts</ulink>.
	  You can select multiple ports to monitor.  Maintainers are
	  strongly encouraged to subscribe, because they will receive
	  notification of not only their own changes, but also any
	  changes that any other &os; committer has made.  (These are
	  often necessary to keep up with changes in the underlying
	  ports framework&mdash;although it would be most polite to
	  receive an advance heads-up from those committing such changes,
	  sometimes this is overlooked or just simply impractical.
	  Also, in some cases, the changes are very minor in nature.
	  We expect everyone to use their best judgement in these
	  cases.)</para>

	<para>If you wish to use FreshPorts, all you need is an
	  account.  If your registered email address is
	  <literal>@FreeBSD.org</literal>, you will see the opt-in link on the
	  right hand side of the webpages.
	  For those of you who already have a FreshPorts account, but are not
	  using your <literal>@FreeBSD.org</literal> email address,
	  just change your email to <literal>@FreeBSD.org</literal>, subscribe,
	  then change it back again.</para>

	<para>FreshPorts also has
	  a sanity test feature which automatically tests each commit to the
	  FreeBSD ports tree.  If subscribed to this service, you will be
	  notified of any errors which FreshPorts detects during sanity
	  testing of your commits.</para>
      </sect1>

      <sect1 id="cvsweb">
	<title>The Web Interface to the Source Repository</title>

	<para>It is possible to browse the files in the source repository by
	  using a web interface.  Changes that affect the entire port system
	  are now documented in the
	  <ulink url="http://cvsweb.FreeBSD.org/ports/CHANGES">
	  CHANGES</ulink> file.  Changes that affect individual ports
	  are now documented in the
	  <ulink url="http://cvsweb.FreeBSD.org/ports/UPDATING">
	  UPDATING</ulink> file.  However, the definitive answer to any
	  question is undoubtedly to read the source code of <ulink
	  url="http://cvsweb.FreeBSD.org/ports/Mk/bsd.port.mk">
	  bsd.port.mk</ulink>, and associated files.</para>

      </sect1>

      <sect1 id="ports-mailling-list">
	<title>The &os; Ports Mailing List</title>

	<para>If you maintain ports, you should consider following the
	  &a.ports;.  Important changes to the way ports work will be announced
	  there, and then committed to <filename>CHANGES</filename>.</para>

      </sect1>

      <sect1 id="build-cluster">
	<title>The &os; Port Building Cluster on
	  <hostid role="hostname">pointyhat.FreeBSD.org</hostid></title>

	  <para>One of the least-publicized strengths of &os; is that
	    an entire cluster of machines is dedicated to continually
	    building the Ports Collection, for each of the major OS
	    releases and for each Tier-1 architecture.  You can find
	    the results of these builds at
	    <ulink url="http://pointyhat.FreeBSD.org/">package building logs
	    and errors</ulink>.</para>

	  <para>Individual ports are built unless they are specifically
	    marked with <makevar>IGNORE</makevar>.  Ports that are
	    marked with <makevar>BROKEN</makevar> will still be attempted,
	    to see if the underlying problem has been resolved.  (This
	    is done by passing <makevar>TRYBROKEN</makevar> to the
	    port's <filename>Makefile</filename>.)</para>

      </sect1>

      <sect1 id="distfile-survey">
	<title>The &os; Port Distfile Survey</title>

	  <para>The build cluster is dedicated to building the latest
	    release of each port with distfiles that have already been
	    fetched.  However, as the Internet continually changes,
	    distfiles can quickly go missing.  The <ulink
	    url="http://people.FreeBSD.org/~fenner/portsurvey/">FreeBSD
	    Ports distfiles survey</ulink> attempts to query every
	    download site for every port to find out if each distfile
	    is still currently available.  Maintainers are asked to
	    check this report periodically, not only to speed up the
	    building process for users, but to help avoid wasting
	    bandwidth of the sites that volunteer to host all these
	    distfiles.</para>

      </sect1>

      <sect1 id="portsmon">

	<title>The &os; Ports Monitoring System</title>

	<para>Another handy resource is the
	  <ulink url="http://portsmon.FreeBSD.org">
	  FreeBSD Ports Monitoring System</ulink> (also known as
	  <literal>portsmon</literal>).  This system comprises a
	  database that processes information from several sources
	  and allows its to be browsed via a web interface.  Currently,
	  the ports Problem Reports (PRs), the error logs from
	  the build cluster, and individual files from the ports
	  collection are used.  In the future, this will be expanded
	  to include the distfile survey, as well as other sources.</para>

	<para>To get started, you can view all information about a
	  particular port by using the
	  <ulink url="http://portsmon.FreeBSD.org/portoverview.py">
	  Overview of One Port</ulink>.</para>

	<para>As of this writing, this is the only resource available
	  that maps GNATS PR entries to portnames.  (PR submitters
	  do not always include the portname in their Synopsis, although
	  we would prefer that they did.)  So, <literal>portsmon</literal>
	  is a good place to start if you want to find out whether an
	  existing port has any PRs filed against it and/or any build
	  errors; or, to find out if a new port that you may be thinking
	  about creating has already been submitted.</para>
      </sect1>

    </chapter>
</book>

<!--
     Local Variables:
     mode: sgml
     sgml-indent-data: t
     sgml-omittag: nil
     sgml-always-quote-attributes: t
     End:
-->