|
root / base
base Plain Text 9255 lines 320.7 KB
   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
#!/bin/bash
# Build script for bzip2

set -e
cd "$SRCDIR"

# Build bzip2 (uses simple Makefile, not autotools)
gmake -j${JOBS:-1} CC=gcc

# Install
gmake install PREFIX="$PKGDIR$PREFIX"

# Also install shared library
gmake -f Makefile-libbz2_so clean
gmake -f Makefile-libbz2_so CC=gcc
cp -a libbz2.so* "$PKGDIR$PREFIX/lib/"
# bzip2 - High-quality data compressor
# https://sourceware.org/bzip2/

[package]
name = "bzip2"
version = "1.0.8"
release = 1
description = "High-quality data compressor"
url = "https://sourceware.org/bzip2/"
license = "BSD-4-Clause"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "bzip2-1.0.8.tar.gz"
urls = ["https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz"]
checksum = "ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269"


[build]
parallel = true
#!/bin/sh
# Build script for cairo (Meson, Template B).
# Deps: pixman, freetype, fontconfig, libpng, libX11, libXext, libXrender
# (all ported, M2/M3a), glib2 (this task, above).
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
# GOTCHA (Task 6, same class as glib2): illumos's <time.h> gates the
# POSIX 2-arg ctime_r()/asctime_r() prototypes behind
# _POSIX_C_SOURCE>=199506L || _POSIX_PTHREAD_SEMANTICS, same as
# getpwnam_r/getpwuid_r in <pwd.h>. Without it, cairo-ps-surface.c's
# 3-arg ctime_r() call ("too few arguments") fails against the POSIX
# 2-arg prototype that __EXTENSIONS__ alone leaves selected.
export CFLAGS="${CFLAGS} -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -Wl,-R,$PREFIX/lib"

meson setup build \
    --prefix="$PREFIX" \
    --libdir=lib \
    --buildtype=release \
    -Ddefault_library=shared \
    -Dxlib=enabled \
    -Dxcb=enabled \
    -Dtests=disabled \
    -Dglib=enabled \
    -Dfreetype=enabled \
    -Dfontconfig=enabled \
    -Dpng=enabled

ninja -C build -j${JOBS:-1}
DESTDIR="$PKGDIR" ninja -C build install
# cairo - 2D graphics library (pango / Openbox render dep)
# https://www.cairographics.org/releases/

[package]
name = "cairo"
version = "1.18.4"
release = 1
description = "2D graphics library"
url = "https://www.cairographics.org/"
license = "LGPL-2.1-or-later OR MPL-1.1"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["pixman", "freetype", "fontconfig", "libpng", "libX11", "libXext", "libXrender", "glib2"]
build = ["pixman", "freetype", "fontconfig", "libpng", "libX11", "libXext", "libXrender", "glib2"]

[[source]]
file = "cairo-1.18.4.tar.xz"
urls = ["https://www.cairographics.org/releases/cairo-1.18.4.tar.xz"]
checksum = "445ed8208a6e4823de1226a74ca319d3600e83f6369f99b14265006599c32ccb"

[build]
parallel = true
#!/bin/sh
# Build script for conky (CMake, Ninja generator). RISKY per task brief:
# conky's native stats backend is Linux/BSD/Solaris-specific and illumos is
# not an upstream-supported OS name (it only recognizes "SunOS").
#
# GOOD NEWS: conky already ships a real Solaris/illumos kstat-based stats
# backend (src/data/os/solaris.cc, gated on OS_SOLARIS, which is set from
# `CMAKE_SYSTEM_NAME MATCHES "SunOS"`). Hammerhead's uname -s is
# "Hammerhead", not "SunOS", so that gate never fires and CMake instead
# hits ConkyPlatformChecks.cmake's final `if(NOT OS_LINUX AND NOT ...)
# message(FATAL_ERROR "platform not supported")`. Patch the OS_SOLARIS
# gate to also match "Hammerhead" (see patches/001-illumos-os-detect.patch
# for the readable diff) so the REAL native kstat backend builds - the
# M3 config's ${exec}-based widgets don't strictly need this, but it's a
# strictly better outcome than a stub, and Hammerhead does ship libkstat.
set -e
cd "$SRCDIR"

sed -i \
    -e 's/if(CMAKE_SYSTEM_NAME MATCHES "SunOS")/if(CMAKE_SYSTEM_NAME MATCHES "SunOS" OR CMAKE_SYSTEM_NAME MATCHES "Hammerhead")/' \
    -e 's/else(CMAKE_SYSTEM_NAME MATCHES "SunOS")/else(CMAKE_SYSTEM_NAME MATCHES "SunOS" OR CMAKE_SYSTEM_NAME MATCHES "Hammerhead")/' \
    -e 's/endif(CMAKE_SYSTEM_NAME MATCHES "SunOS")/endif(CMAKE_SYSTEM_NAME MATCHES "SunOS" OR CMAKE_SYSTEM_NAME MATCHES "Hammerhead")/' \
    cmake/ConkyPlatformChecks.cmake

# solaris.cc is missing get_battery_power_draw() - every OTHER platform
# backend (linux.cc, freebsd.cc, netbsd.cc, haiku.cc, darwin.mm) implements
# it, but upstream conky's Solaris/illumos backend never got battery-draw
# support (real Solaris/illumos servers rarely have batteries). common.cc
# calls it unconditionally regardless of platform -> link failure
# ("undefined reference to get_battery_power_draw"). Add the same
# "not implemented" stub every other unsupported-metric function in this
# file already uses (get_battery_short_status, get_acpi_fan, ...).
cat >> src/data/os/solaris.cc <<'EOF'

void get_battery_power_draw(char *buffer, unsigned int n, const char *bat) {
  /* Not implemented - illumos/Solaris kstat has no standard battery
   * power-draw metric; real servers rarely have batteries. */
  (void)bat;
  if (buffer && n > 0) memset(buffer, 0, n);
}
EOF

# Same Platform-module gotcha as base/tint2 and base/libjpeg-turbo: CMake
# has no Platform/Hammerhead.cmake, so map it onto the (real) SunOS module
# for shared-lib/UNIX conventions.
mkdir -p "$SRCDIR/.cmake/Platform"
echo 'include(Platform/SunOS)' > "$SRCDIR/.cmake/Platform/Hammerhead.cmake"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"

# -DRELEASE=ON: cmake/Conky.cmake only shells out to `git rev-parse` (for a
# -pre-<sha> dev version string) when RELEASE is unset; the tarball has no
# .git and Hammerhead has no git binary yet, so this is a hard
# `message(FATAL_ERROR "Unable to find program 'git'")` without it.
cmake -B build -G Ninja \
    -DCMAKE_MODULE_PATH="$SRCDIR/.cmake" \
    -DCMAKE_PREFIX_PATH="$PREFIX" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX="$PREFIX" \
    -DCMAKE_INSTALL_RPATH="$PREFIX/lib" \
    -DCMAKE_C_FLAGS="-D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS -fpermissive -fcommon" \
    -DCMAKE_CXX_FLAGS="-D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS" \
    -DBUILD_TESTING=OFF \
    -DBUILD_X11=ON \
    -DBUILD_LUA_CAIRO=ON \
    -DBUILD_WLAN=OFF \
    -DBUILD_CURL=OFF \
    -DBUILD_IRC=OFF \
    -DBUILD_HTTP=OFF \
    -DBUILD_ICAL=OFF \
    -DBUILD_NCURSES=OFF \
    -DBUILD_DOCS=OFF \
    -DBUILD_I18N=OFF \
    -DRELEASE=ON

ninja -C build -j${JOBS:-1}
DESTDIR="$PKGDIR" ninja -C build install
# conky - lightweight system monitor for X (via ${exec} calls to illumos
# tools in the M3 config; conky's own native Solaris/kstat backend is also
# enabled here since illumos already carries one - see build.sh)
# https://github.com/brndnmtthws/conky

[package]
name = "conky"
version = "1.24.2"
release = 1
description = "Lightweight system monitor for X11"
url = "https://github.com/brndnmtthws/conky"
license = "GPL-3.0-or-later"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11", "libXext", "libXdamage", "libXinerama", "libXft", "cairo", "lua"]
build = ["libX11", "libXext", "libXdamage", "libXinerama", "libXft", "cairo", "lua"]

[[source]]
file = "conky-1.24.2.tar.gz"
urls = ["https://github.com/brndnmtthws/conky/archive/refs/tags/v1.24.2.tar.gz"]
checksum = "1366b6efcee2cd2c56e5d3430c9d8a1f16d6fef76c5560ff1d8f3fc59dd23959"

[build]
parallel = true
--- a/cmake/ConkyPlatformChecks.cmake
+++ b/cmake/ConkyPlatformChecks.cmake
@@
-if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
+if(CMAKE_SYSTEM_NAME MATCHES "SunOS" OR CMAKE_SYSTEM_NAME MATCHES "Hammerhead")
   set(OS_SOLARIS true)
   set(conky_libs ${conky_libs} -lkstat)
-else(CMAKE_SYSTEM_NAME MATCHES "SunOS")
+else(CMAKE_SYSTEM_NAME MATCHES "SunOS" OR CMAKE_SYSTEM_NAME MATCHES "Hammerhead")
   set(OS_SOLARIS false)
-endif(CMAKE_SYSTEM_NAME MATCHES "SunOS")
+endif(CMAKE_SYSTEM_NAME MATCHES "SunOS" OR CMAKE_SYSTEM_NAME MATCHES "Hammerhead")
#!/bin/bash
# Build script for Coral package manager
#
# Builds coral from source tarball using Reef compiler

set -e

# Find source directory — SRCDIR from coral, or auto-detect
if [ -z "$SRCDIR" ] || [ ! -d "$SRCDIR" ]; then
    WORKDIR="${SRCDIR:-$(pwd)}"
    SRCDIR="$(cd "$WORKDIR" && ls -d */ 2>/dev/null | head -1)"
    SRCDIR="${WORKDIR}/${SRCDIR%/}"
fi
cd "$SRCDIR"

# Set up Reef environment (bootstrap installs to /usr)
export PATH="/usr/bin:$PATH"
export LIBRARY_PATH="/usr/lib/reef/runtime/lib:/usr/lib:${LIBRARY_PATH:-}"

# Build with illumos socket libraries explicitly
echo "Building Coral..."
reefc build -l socket -l nsl

# Find the built binary (named after directory)
BINARY=$(ls build/coral* 2>/dev/null | head -1)
if [ -z "$BINARY" ]; then
    echo "Error: No binary found in build/"
    exit 1
fi
echo "Built binary: $BINARY"

# Install
mkdir -p "$PKGDIR$PREFIX/bin"
cp "$BINARY" "$PKGDIR$PREFIX/bin/coral"
chmod +x "$PKGDIR$PREFIX/bin/coral"

# Create initial config directory structure
mkdir -p "$PKGDIR$SYSCONFDIR/coral"
mkdir -p "$PKGDIR/var/lib/coral/installed"
mkdir -p "$PKGDIR/var/lib/coral/packages"
mkdir -p "$PKGDIR/var/lib/coral/sources"
mkdir -p "$PKGDIR/var/lib/coral/trusted-keys"
mkdir -p "$PKGDIR/var/tmp/coral/work"
mkdir -p "$PKGDIR/var/tmp/coral/pkg"
# Coral - Package manager for Zygaena
# https://git.sharkos.one/zygaena/coral

[package]
name = "coral"
version = "0.4.5"
release = 1
description = "Package manager for Zygaena, written in Reef"
url = "https://git.sharkos.one/zygaena/coral"
license = "BSD-2-Clause"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["reef"]
build = ["reef"]

[[source]]
file = "coral-0.4.5-source.tar.xz"
urls = ["coral-0.4.5-source.tar.xz"]
checksum = "ea8ad5f63cbc80f939593a661aa4a9bc592f024077feb64e91a85b4cc3f1d6f1"
extract = true

[build]
parallel = false
#!/bin/bash
# Build script for curl
# Command line tool for transferring data with URLs

set -e

cd "$SRCDIR"

# Ensure runtime linker can find our libraries
export LD_LIBRARY_PATH="/usr/lib:$LD_LIBRARY_PATH"

# Configure curl with LibreSSL
./configure \
    --build=$BUILD_TRIPLE \
    --host=$BUILD_TRIPLE \
    --prefix=$PREFIX \
    --with-ssl=/usr \
    --with-zlib=/usr \
    --enable-ipv6 \
    --enable-unix-sockets \
    --disable-ldap \
    --disable-ldaps \
    --without-brotli \
    --without-zstd \
    --without-libidn2 \
    --without-libpsl \
    --without-nghttp2 \
    --without-nghttp3 \
    --without-ngtcp2 \
    --without-librtmp \
    --without-libssh2

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# curl - Command line tool for transferring data with URLs
# https://curl.se/

[package]
name = "curl"
version = "8.18.0"
release = 1
description = "Command line tool and library for transferring data with URLs"
url = "https://curl.se/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["zlib"]
build = ["zlib"]

[[source]]
file = "curl-8.18.0.tar.xz"
urls = ["https://curl.se/download/curl-8.18.0.tar.xz"]
checksum = "40df79166e74aa20149365e11ee4c798a46ad57c34e4f68fd13100e2c9a91946"


[build]
parallel = true
jobs = 0
#!/bin/sh
# Build script for dejavu-fonts (data-only, no compile). Pre-built TTF
# distribution - just install the .ttf files; fc-cache picks them up.
set -e
cd "$SRCDIR"

mkdir -p "$PKGDIR$PREFIX/share/fonts/dejavu"
find . -name '*.ttf' -exec cp {} "$PKGDIR$PREFIX/share/fonts/dejavu/" \;
# dejavu-fonts - DejaVu TrueType font family (pre-built .ttf distribution,
# no compile step). https://dejavu-fonts.github.io/

[package]
name = "dejavu-fonts"
version = "2.37"
release = 1
description = "DejaVu TrueType font family"
url = "https://dejavu-fonts.github.io/"
license = "Bitstream-Vera AND Public-Domain"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["fontconfig"]
build = []

[[source]]
file = "dejavu-fonts-ttf-2.37.zip"
urls = ["https://downloads.sourceforge.net/project/dejavu/dejavu/2.37/dejavu-fonts-ttf-2.37.zip"]
checksum = "7576310b219e04159d35ff61dd4a4ec4cdba4f35c00e002a136f00e96a908b0a"

[build]
parallel = false
#!/bin/sh
# Build script for dmenu (suckless, plain Makefile - NOT a template build).
# Deps: libX11, libXft, libXinerama, fontconfig (all ported).
#
# Same class of fix as base/st: dmenu's shipped config.mk hardcodes
# X11INC/X11LIB to /usr/X11R6 (doesn't exist on Hammerhead) and links
# -lX11/-lXinerama/-lfontconfig/-lXft directly instead of going through
# pkg-config. Rewrite config.mk to resolve everything via pkg-config
# against $PREFIX.
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"

# NOTE: dmenu 5.4's config.mk (unlike st's) has no PKG_CONFIG variable at
# all - use the literal `pkg-config` binary name directly rather than a
# $(PKG_CONFIG) make-variable reference that would expand to nothing.
sed -i \
    -e "s#^PREFIX = .*#PREFIX = $PREFIX#" \
    -e '/^X11INC/d' -e '/^X11LIB/d' \
    -e '/^XINERAMALIBS/d' -e '/^FREETYPELIBS/d' -e '/^FREETYPEINC/d' \
    -e 's#^INCS = .*#INCS = `pkg-config --cflags x11 xft xinerama fontconfig`#' \
    -e 's#^LIBS = .*#LIBS = `pkg-config --libs x11 xft xinerama fontconfig`#' \
    config.mk

# __EXTENSIONS__: hidden POSIX/SysV prototypes on illumos headers - same
# gotcha as every other X11 port here. Add rpath since /usr/local/lib is
# not on Hammerhead's default ld.so search path.
sed -i \
    -e 's#^CFLAGS   = .*#CFLAGS   = -std=c99 -pedantic -Wall -Os $(INCS) $(CPPFLAGS) -D__EXTENSIONS__#' \
    -e "s#^LDFLAGS  = .*#LDFLAGS  = \$(LIBS) -Wl,-R,$PREFIX/lib#" \
    config.mk

gmake CC=gcc PREFIX="$PREFIX"

mkdir -p "$PKGDIR$PREFIX/bin"
gmake PREFIX="$PREFIX" DESTDIR="$PKGDIR" install
# dmenu - dynamic menu (suckless)
# https://tools.suckless.org/dmenu/

[package]
name = "dmenu"
version = "5.4"
release = 1
description = "Dynamic menu for X, driven by dmenu_run/openbox"
url = "https://tools.suckless.org/dmenu/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11", "libXft", "libXinerama", "fontconfig"]
build = ["libX11", "libXft", "libXinerama", "fontconfig"]

[[source]]
file = "dmenu-5.4.tar.gz"
urls = ["https://dl.suckless.org/tools/dmenu-5.4.tar.gz"]
checksum = "8fbace2a0847aa80fe861066b118252dcc7b4ca0a0a8f3a93af02da8fb6cd453"

[build]
parallel = true
#!/bin/sh
# Build script for feh (plain Makefile - no configure, no pkg-config use).
# Deps: imlib2, libX11, libXinerama, libpng - all under $PREFIX.
# feh's config.mk hardcodes LDLIBS (-lm -lpng -lX11 -lImlib2) with no -I/-L
# of its own, relying on the compiler's default search paths - which does
# NOT include $PREFIX/include or $PREFIX/lib on Hammerhead. Supply those
# via CFLAGS/LDFLAGS in the environment (config.mk's CFLAGS uses `?=`/`+=`
# so an exported CFLAGS is picked up as the base and appended to).
# curl=0 exif=0 per the task brief (no libcurl/libexif ports); xinerama=1
# (libXinerama is ported).
#
# verscmp=0: feh defaults verscmp=1 (assumes glibc's GNU strverscmp()),
# but illumos libc has no strverscmp() at all (not even hidden behind
# __EXTENSIONS__ - it's a pure GNU extension). With verscmp=0 feh's own
# Makefile pulls in its bundled strverscmp.c fallback implementation
# instead, avoiding the "implicit declaration of function 'strverscmp'"
# build failure.
set -e
cd "$SRCDIR"

export CFLAGS="-I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="-L$PREFIX/lib -R$PREFIX/lib"

gmake CC=gcc PREFIX="$PREFIX" curl=0 exif=0 xinerama=1 verscmp=0

gmake PREFIX="$PREFIX" DESTDIR="$PKGDIR" curl=0 exif=0 xinerama=1 verscmp=0 install
# feh - fast, lightweight image viewer (also used for wallpaper-setting)
# https://feh.finalrewind.org/

[package]
name = "feh"
version = "3.12.2"
release = 1
description = "Fast, lightweight X11 image viewer"
url = "https://feh.finalrewind.org/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["imlib2", "libX11", "libXinerama", "libpng"]
build = ["imlib2", "libX11", "libXinerama", "libpng"]

[[source]]
file = "feh-3.12.2.tar.bz2"
urls = ["https://feh.finalrewind.org/feh-3.12.2.tar.bz2"]
checksum = "7ce358b18a7f37bcc97a09b4efd89fdadd54cd8e7032db345f61e66dd04b1c3f"

[build]
parallel = true
#!/bin/sh
# Build script for font-util (autotools). No shared library output (build
# helpers + font metadata only) - confirmed zero libtool references in the
# release configure, so the Template A libtool hammerhead* sed does not
# apply here.
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -D__EXTENSIONS__"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR"

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# font-util - X font build helpers + encodings.dir/fonts.alias generation
# https://gitlab.freedesktop.org/xorg/font/util
# Direct xlibre-server DEPEND (media-fonts/font-util).

[package]
name = "font-util"
version = "1.4.2"
release = 1
description = "X.Org font build helpers and encodings"
url = "https://xorg.freedesktop.org/releases/individual/font/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = ["util-macros"]

[[source]]
file = "font-util-1.4.2.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/font/font-util-1.4.2.tar.xz"]
checksum = "02e4f8afdcf03cc8372ca9c37aa104b1e36b47722dbc79531be08f0a4c622999"

[build]
parallel = true
#!/bin/sh
# Build script for fontconfig (Meson, Template B).
# Uses libxml2 as the XML backend (PRESENT in base, /usr/lib) rather than
# expat, per the manifest's dependency line. gperf (devel/gperf) must be
# built/installed first - fontconfig's build uses it to generate perfect
# hash tables.
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -D__EXTENSIONS__"

# GOTCHA (Task 5): Meson does not set an rpath on the fc-cache/fc-list/
# fc-match consumer binaries by default, and /usr/local/lib is NOT on
# Hammerhead's default runtime ld.so search path (only /lib:/usr/lib -
# confirmed via `crle`). Without this, every installed binary fails at
# runtime with "libfontconfig.so.1: open failed". Force -R via LDFLAGS so
# meson's link step picks it up for all targets (libs + executables).
export LDFLAGS="${LDFLAGS} -Wl,-R,$PREFIX/lib"

meson setup build \
    --prefix="$PREFIX" \
    --libdir=lib \
    --sysconfdir="$SYSCONFDIR" \
    --buildtype=release \
    -Ddefault_library=shared \
    -Ddoc=disabled \
    -Dtests=disabled \
    -Dnls=disabled \
    -Dxml-backend=libxml2

ninja -C build -j${JOBS:-1}
DESTDIR="$PKGDIR" ninja -C build install
# fontconfig - font discovery and matching
# https://www.freedesktop.org/wiki/Software/fontconfig/

[package]
name = "fontconfig"
version = "2.16.0"
release = 1
description = "Font discovery and configuration library"
url = "https://www.freedesktop.org/wiki/Software/fontconfig/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["freetype"]
build = ["freetype", "gperf"]

[[source]]
file = "fontconfig-2.16.0.tar.xz"
urls = ["https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.16.0.tar.xz"]
checksum = "6a33dc555cc9ba8b10caf7695878ef134eeb36d0af366041f639b1da9b6ed220"

[build]
parallel = true
#!/bin/sh
# Build script for fox-toolkit / FOX 1.6.59 (autotools, Template A + C++).
# Older C++ codebase (pre-C++11 idioms) - watch illumos __EXTENSIONS__ /
# socket-header issues same as any client-stack C port, but this time also
# apply the flags to CXXFLAGS since FOX is a C++ library.
set -e
cd "$SRCDIR"

# MANDATORY libtool fix - see Template A.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

# GOTCHA #1: FOX's configure.ac does `CXXFLAGS=""` unconditionally near the
# top and rebuilds it from scratch with its own hardcoded flag set - any
# CXXFLAGS/CFLAGS we export before running configure is silently discarded
# (confirmed by inspecting configure.ac: "CXXFLAGS=\"\"" then a chain of
# CXXFLAGS="${CXXFLAGS} ..." appends, never re-adding a user value).
# GOTCHA #2: within that rebuild, `XFTCFLAGS="-I/usr/include/freetype2"` is
# hardcoded (no pkg-config/freetype-config probe), so <ft2build.h> is never
# found under our $PREFIX=/usr/local.
# WORKAROUND: src/Makefile.am declares `CXXFLAGS = @CXXFLAGS@ @X_CFLAGS@`
# with no explicit CPPFLAGS reference, but automake's generated compile
# rule ALWAYS appends $(CPPFLAGS) regardless (it's a standard AC_SUBST'd
# variable automake wires in implicitly) - and configure.ac never touches
# CPPFLAGS at all. So route our include path through CPPFLAGS instead of
# CXXFLAGS/CFLAGS - it survives the configure.ac reset untouched.
# GOTCHA #3: FOX's include/xincs.h has a ready-made
# `#ifdef HAVE_SYS_FILIO_H #include <sys/filio.h> #endif` (for FIONREAD on
# Solaris/illumos) but configure.ac never actually probes for
# sys/filio.h/AC_DEFINE's HAVE_SYS_FILIO_H - it's a dead branch upstream.
# illumos DOES have <sys/filio.h> (confirmed present on Hammerhead) so just
# define the macro ourselves; FXGUISignal.cpp otherwise fails with
# "'FIONREAD' was not declared in this scope".
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CPPFLAGS="${CPPFLAGS} -I$PREFIX/include -I$PREFIX/include/freetype2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS -DHAVE_SYS_FILIO_H"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

# No GL in this build (kernel has no DRM/KMS/GPU accel - see graphics
# capability baseline memory); tiff not ported, so disabled explicitly.
./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --with-opengl=no \
    --with-xft=yes \
    --with-xrandr=yes \
    --with-xcursor=yes \
    --with-xrender=yes \
    --with-xfixes=yes \
    --with-xshm=yes \
    --disable-tiff

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# fox-toolkit (FOX) - C++ GUI toolkit, backs the Xfe file manager
# https://fox-toolkit.org/

[package]
name = "fox-toolkit"
version = "1.6.59"
release = 1
description = "FOX C++ GUI toolkit"
url = "https://fox-toolkit.org/"
license = "LGPL-2.1-or-later"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11", "libXft", "freetype", "fontconfig", "libXext", "libXrandr", "libXcursor", "libpng", "libjpeg-turbo"]
build = ["libX11", "libXft", "freetype", "fontconfig", "libXext", "libXrandr", "libXcursor", "libpng", "libjpeg-turbo"]

[[source]]
file = "fox-1.6.59.tar.gz"
urls = ["http://fox-toolkit.org/ftp/fox-1.6.59.tar.gz"]
checksum = "48f33d2dd5371c2d48f6518297f0ef5bbf3fcd37719e99f815dc6fc6e0f928ae"

[build]
parallel = true
#!/bin/sh
# Build script for freetype (autotools, Template A).
# PASS 1: --without-harfbuzz --without-brotli - breaks the freetype<->
# harfbuzz circular dependency (see package.toml note) and avoids porting
# brotli (woff2 support, not needed). zlib is PRESENT in base.
set -e
cd "$SRCDIR"

# GOTCHA (Task 5): freetype's top-level "configure" is just a thin wrapper
# that shells out to "make setup unix", which in turn runs
# builds/unix/configure - THAT is the real libtool-driving script with the
# kopensolaris*-gnu dynamic-linker case block, not the top-level file (the
# top-level one has no such pattern at all - confirmed via grep, 0 hits).
# Patch builds/unix/configure or the shared .a-only fallback bites here too.
if [ -f builds/unix/configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/g' builds/unix/configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --with-zlib=yes \
    --with-png=yes \
    --with-bzip2=no \
    --with-harfbuzz=no \
    --with-brotli=no

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# freetype - glyph rasterizer / font rendering engine
# https://freetype.org/
#
# PASS 1 build: --without-harfbuzz --without-brotli. freetype and harfbuzz
# have a circular dependency upstream (freetype's autohinter can use
# harfbuzz for script-aware improvements, harfbuzz needs freetype to
# render); breaking the cycle by building freetype without harfbuzz/brotli
# first is the standard bootstrap sequence. brotli (woff2 support) is not
# needed for a basic desktop and is skipped to avoid porting it at all.

[package]
name = "freetype"
version = "2.14.3"
release = 1
description = "Freetype font rendering engine (built without harfbuzz/brotli)"
url = "https://freetype.org/"
license = "FTL"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libpng"]
build = ["libpng"]

[[source]]
file = "freetype-2.14.3.tar.xz"
urls = ["https://download.savannah.gnu.org/releases/freetype/freetype-2.14.3.tar.xz"]
checksum = "36bc4f1cc413335368ee656c42afca65c5a3987e8768cc28cf11ba775e785a5f"

[build]
parallel = true
#!/bin/sh
# Build script for fribidi (Meson, Template B). No deps.
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -D__EXTENSIONS__"
export LDFLAGS="${LDFLAGS} -Wl,-R,$PREFIX/lib"

meson setup build \
    --prefix="$PREFIX" \
    --libdir=lib \
    --buildtype=release \
    -Ddefault_library=shared \
    -Dtests=false \
    -Ddocs=false

ninja -C build -j${JOBS:-1}
DESTDIR="$PKGDIR" ninja -C build install
# fribidi - Unicode Bidirectional Algorithm implementation (pango dep)
# https://github.com/fribidi/fribidi

[package]
name = "fribidi"
version = "1.0.16"
release = 1
description = "Unicode Bidirectional Algorithm (BiDi) implementation"
url = "https://github.com/fribidi/fribidi"
license = "LGPL-2.1-or-later"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "fribidi-1.0.16.tar.xz"
urls = ["https://github.com/fribidi/fribidi/releases/download/v1.0.16/fribidi-1.0.16.tar.xz"]
checksum = "1b1cde5b235d40479e91be2f0e88a309e3214c8ab470ec8a2744d82a5a9ea05c"

[build]
parallel = true
#!/bin/bash
# Build script for GNU awk

set -e
cd "$SRCDIR"

# Fix illumos gnulib compatibility issues (if present)
# illumos declares getlocalename_l with const char* return type
for f in lib/localename-unsafe.c lib/localename.c gnulib-tests/localename.c support/localename.c; do
    if [ -f "$f" ]; then
        sed -i 's/extern char \* getlocalename_l/extern const char * getlocalename_l/' "$f"
    fi
done

./configure \
    --prefix=$PREFIX \
    --disable-nls

# Fix illumos memset_s false detection if present
for config in lib/config.h gnulib-tests/config.h support/config.h config.h; do
    if [ -f "$config" ]; then
        sed -i 's/#define HAVE_MEMSET_S 1/\/* #undef HAVE_MEMSET_S - illumos has it as macro only *\//' "$config"
    fi
done

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# GNU Awk - Pattern scanning and processing language
# https://www.gnu.org/software/gawk/

[package]
name = "gawk"
version = "5.3.0"
release = 1
description = "GNU awk pattern scanning and processing language"
url = "https://www.gnu.org/software/gawk/"
license = "GPL-3.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "gawk-5.3.0.tar.xz"
urls = ["https://ftp.gnu.org/gnu/gawk/gawk-5.3.0.tar.xz"]
checksum = "ca9c16d3d11d0ff8c69d79dc0b47267e1329a69b39b799895604ed447d3ca90b"


[build]
parallel = true
#!/bin/bash
# Build script for git

set -e
cd "$SRCDIR"

# Git uses its own Makefile (not autotools). `uname -s` on Hammerhead is
# 'Hammerhead', which config.mak.uname does not match — so it falls through
# to Linux-like defaults that miss illumos-isms (strings.h declarations,
# NEEDS_SOCKET, NEEDS_NSL, HAVE_ALLOCA_H, etc.). Force uname_S=SunOS to
# activate the existing Solaris block, then override the two assumptions
# Hammerhead doesn't satisfy: /usr/ucb/install and /usr/xpg6/bin.
gmake_common() {
    gmake \
        uname_S=SunOS \
        INSTALL=install \
        SANE_TOOL_PATH=/usr/xpg4/bin \
        prefix=$PREFIX \
        CFLAGS=-O2 \
        NO_TCLTK=1 \
        NO_GETTEXT=1 \
        NO_PERL=1 \
        NO_PYTHON=1 \
        NEEDS_SSL_WITH_CURL=1 \
        NEEDS_CRYPTO_WITH_SSL=1 \
        CURL_LDFLAGS="-lcurl -lssl -lcrypto -lz" \
        "$@"
}

gmake_common -j${JOBS:-1} all
gmake_common DESTDIR="$PKGDIR" install
# Git - Distributed version control system
# https://git-scm.com/

[package]
name = "git"
version = "2.48.1"
release = 1
description = "Distributed version control system"
url = "https://git-scm.com/"
license = "GPL-2.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["curl", "zlib"]
build = ["curl", "zlib"]

[[source]]
file = "git-2.48.1.tar.xz"
urls = [
    "https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.48.1.tar.xz",
    "https://www.kernel.org/pub/software/scm/git/git-2.48.1.tar.xz"
]
checksum = "1c5d545f5dc1eb51e95d2c50d98fdf88b1a36ba1fa30e9ae5d5385c6024f82ad"

[build]
parallel = true
#!/bin/sh
# Build script for glib2 (Meson, Template B).
# Deps: pcre2 (ported, above), libffi + zlib (PRESENT in base, /usr/lib -
# not ported; their .pc files are picked up via the /usr/lib/pkgconfig
# entry below). iconv is provided by illumos libc - meson's builtin
# dependency('iconv') probe finds it there with no extra flag needed.
#
# GOTCHA (Task 6): illumos ships a native Sun/illumos `msgfmt` at
# /usr/bin/msgfmt that is NOT command-line compatible with GNU gettext's
# msgfmt (confirmed on alpha9: `msgfmt --version` errors with "Cannot open
# file --version" - it treats every arg as a filename to open, not an
# option). glib's po/meson.build calls i18n.gettext(), which requires a
# GNU-compatible msgfmt/xgettext. glib's own `nls` option defaults to
# 'auto' and gates the entire po/ subdir behind `find_program('xgettext',
# required: get_option('nls'))`, so passing -Dnls=disabled skips that
# subdir entirely (no msgfmt/xgettext ever invoked) without touching any
# core (non-translation) functionality. No devel/gettext port needed for
# this port.
#
# GOTCHA (Task 6): meson's dtrace/systemtap options default to 'auto' and
# both probe-detect true because /usr/sbin/dtrace exists on Hammerhead
# (illumos DTrace). But glib's meson dtrace codegen step assumes the
# Linux/systemtap-style two-pass workflow (compile objects with probes
# first, THEN `dtrace -G` against those objects); it invokes
# `dtrace -G -s glib_probes.d -o glib_probes.o` with ONLY the .d script
# and no object files, which illumos dtrace rejects: "failed to link
# script ...: No probe sites found for declared provider" - not an
# illumos/dtrace bug, just glib's meson dtrace glue not matching how
# illumos's -G-only invocation needs objects present. Static USDT probes
# are optional instrumentation, not core functionality - disable
# dtrace/systemtap explicitly rather than relying on 'auto' probing.
set -e
cd "$SRCDIR"

# GOTCHA (Task 6): meson's host_machine.system() comes straight from
# Python's platform.system().lower() at configure time, which on
# Hammerhead reports 'hammerhead' (confirmed: `uname -s` => "Hammerhead"
# post-SYSNAME_PLATFORM_RENAME), not 'sunos'. glib's meson.build has
# several `host_system == 'sunos'` branches specifically for illumos/
# Solaris correctness - none of them fire for us. The one that bites at
# build time: "if host_system != 'sunos': functions += ['sysinfo']" -
# meson then probes cc.has_function('sysinfo') (true - illumos HAS a
# sysinfo(), just the unrelated SVR4 systeminfo(2) one, not Linux's
# struct-sysinfo RAM-stats one) and sets HAVE_SYSINFO, so
# gio/gmemorymonitorbase.c compiles the Linux `struct sysinfo`
# code path instead of its already-present Solaris sysconf(_SC_PHYS_PAGES)
# fallback. Patch the guard to also exclude 'hammerhead' rather than
# disabling memory-monitor functionality outright.
if [ -f meson.build ]; then
    sed -i "s/if host_system != 'sunos'/if host_system != 'sunos' and host_system != 'hammerhead'/" meson.build
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
# GOTCHA (Task 6): illumos libc's iconv(3) takes `const char **` for the
# input-buffer argument (POSIX-conformant), but glib/gconvert.c's g_iconv()
# wrapper takes plain `char **` and passes it straight through (glib has no
# configure-time ICONV_CONST detection - it assumes the glibc signature).
# GCC 14 promoted -Wincompatible-pointer-types from a warning to a hard
# error by default in C mode, so this one call site now fails the build.
# Rather than patching upstream glib source, demote it back to a warning.
# GOTCHA (Task 6): illumos's <pwd.h> (and <grp.h>) gate the POSIX.1c
# 5-arg reentrant getpwnam_r()/getpwuid_r() prototypes (returning int,
# via a 'struct passwd **' result out-param) behind
# `_POSIX_C_SOURCE >= 199506L || defined(_POSIX_PTHREAD_SEMANTICS)`.
# __EXTENSIONS__ alone is NOT enough - without one of those two also
# defined, the header falls back to the legacy SVR4 4-arg form (returning
# 'struct passwd *' directly), which is what glib/gutils.c's
# g_get_user_database_entry() gets miscompiled against ("too many
# arguments to function 'getpwnam_r'"). Define _POSIX_PTHREAD_SEMANTICS
# to select the POSIX form glib expects (also fixes the same class of
# issue for getgrnam_r/getgrgid_r if pango/harfbuzz/cairo ever probe them).
# GOTCHA (Task 6): glib's meson.build has a `host_system == 'sunos'`
# block (unreached here, same host_system-name mismatch as above) that
# probes and sets the highest working `_XOPEN_SOURCE` (800/700/600) plus
# __EXTENSIONS__ specifically so illumos's <sys/socket.h> exposes the
# XPG4v2 struct msghdr fields (msg_control/msg_controllen/msg_flags -
# gated behind `#if defined(_XPG4_2)`, which /usr/include/sys/
# feature_tests.h only #defines once _XOPEN_SOURCE is set to 500+).
# Without it, gio/gsocket.c's msghdr-based recvmsg/sendmsg ancillary-data
# code fails ("struct msghdr has no member named msg_control"). Set
# _XOPEN_SOURCE=700 directly (cascades to _XPG4_2 in feature_tests.h);
# __EXTENSIONS__ is still required alongside it so the XOPEN-strict mode
# doesn't hide the non-standard extensions glib also needs elsewhere.
export CFLAGS="${CFLAGS} -D__EXTENSIONS__ -D_XOPEN_SOURCE=700 -D_POSIX_PTHREAD_SEMANTICS -Wno-error=incompatible-pointer-types"
export LDFLAGS="${LDFLAGS} -Wl,-R,$PREFIX/lib"

meson setup build \
    --prefix="$PREFIX" \
    --libdir=lib \
    --sysconfdir="$SYSCONFDIR" \
    --buildtype=release \
    -Ddefault_library=shared \
    -Dtests=false \
    -Dselinux=disabled \
    -Dxattr=false \
    -Dman-pages=disabled \
    -Dintrospection=disabled \
    -Dnls=disabled \
    -Ddtrace=disabled \
    -Dsystemtap=disabled

ninja -C build -j${JOBS:-1}
DESTDIR="$PKGDIR" ninja -C build install
# glib2 - core low-level cross-platform library (Openbox render-stack dep)
# https://download.gnome.org/sources/glib/
#
# VERSION NOTE (Task 6): the phase1a manifest listed 2.89.2, but GNOME's
# glib versioning is even-minor=stable / odd-minor=development (2.89.x is
# the development cycle leading to 2.90). Verified against
# download.gnome.org/sources/glib/cache.json: the highest STABLE
# (even-minor) release is 2.88.2 (2.86.x and earlier are older stable
# lines). Using 2.88.2.

[package]
name = "glib2"
version = "2.88.2"
release = 1
description = "Core low-level cross-platform library (GLib/GObject/GIO)"
url = "https://www.gtk.org/"
license = "LGPL-2.1-or-later"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["pcre2"]
build = ["pcre2"]

[[source]]
file = "glib-2.88.2.tar.xz"
urls = ["https://download.gnome.org/sources/glib/2.88/glib-2.88.2.tar.xz"]
checksum = "cf3f215a640c8a4257f14317586b8f1fdd25a10a93cb4bdda147c0f9ad88e74f"

[build]
parallel = true
#!/bin/bash
# Build script for GNU gzip

set -e
cd "$SRCDIR"

./configure \
    --prefix=$PREFIX \
    --build=$BUILD_TRIPLE \
    --host=$BUILD_TRIPLE

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# GNU Gzip - Compression utility
# https://www.gnu.org/software/gzip/

[package]
name = "gzip"
version = "1.14"
release = 1
description = "GNU gzip compression utility"
url = "https://www.gnu.org/software/gzip/"
license = "GPL-3.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "gzip-1.14.tar.gz"
urls = ["https://ftpmirror.gnu.org/gzip/gzip-1.14.tar.gz"]
checksum = "613d6ea44f1248d7370c7ccdeee0dd0017a09e6c39de894b3c6f03f981191c6b"


[build]
parallel = true
#!/bin/sh
# Hammerhead Openbox autostart - Zygaena marine-dark identity.
# Idempotent: only launch a daemon if it isn't already running, so
# `openbox --restart` doesn't spawn duplicate panels.
running() { ps -ef | grep -v grep | grep -q "$1"; }
running "[p]icom" || picom --backend xrender -b 2>/dev/null &
# tint2 finds its config live via XDG_CONFIG_DIRS; conky does NOT honor
# XDG_CONFIG_DIRS, so give it the system config path explicitly (stays live).
running "[t]int2" || tint2 &
running "[c]onky" || conky -c @@PREFIX@@/etc/xdg/conky/conky.conf &
feh --bg-fill @@PREFIX@@/share/backgrounds/hammerhead.png 2>/dev/null &
#!/bin/sh
# Build script for hammerhead-desktop (Zygaena marine-dark branding config).
#
# No upstream tarball - all inputs are local files shipped alongside this
# script in the port directory. The only compiled artifact is the cairo
# wallpaper generator, built and run once here (its output PNG is what
# actually ships - the generator binary itself is not installed).
set -e

PORTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"

# --- Step 1: build + run the wallpaper generator ---
gcc "$PORTDIR/wallpaper-gen.c" $(pkg-config --cflags --libs cairo) -lm -o "$PORTDIR/wg"

mkdir -p "$PKGDIR$PREFIX/share/backgrounds"
"$PORTDIR/wg" "$PKGDIR$PREFIX/share/backgrounds/hammerhead.png"

# --- Step 2: Openbox theme ---
mkdir -p "$PKGDIR$PREFIX/share/themes/Hammerhead/openbox-3"
cp "$PORTDIR/themerc" "$PKGDIR$PREFIX/share/themes/Hammerhead/openbox-3/themerc"

# --- Step 3: tint2 panel config ---
# Matches the existing tint2 port's own default install location
# ($PREFIX/etc/xdg/tint2 - tint2's cmake build doesn't honor
# --sysconfdir), and what the integration step's XDG_CONFIG_DIRS
# ($PREFIX/etc/xdg) resolves against.
mkdir -p "$PKGDIR$PREFIX/etc/xdg/tint2"
cp "$PORTDIR/tint2rc" "$PKGDIR$PREFIX/etc/xdg/tint2/tint2rc"

# --- Step 4: conky config ---
mkdir -p "$PKGDIR$PREFIX/etc/xdg/conky"
cp "$PORTDIR/conky.conf" "$PKGDIR$PREFIX/etc/xdg/conky/conky.conf"

# --- Step 5: Openbox rc.xml + menu.xml ---
mkdir -p "$PKGDIR$PREFIX/etc/xdg/openbox"
cp "$PORTDIR/rc.xml" "$PKGDIR$PREFIX/etc/xdg/openbox/rc.xml"
cp "$PORTDIR/menu.xml" "$PKGDIR$PREFIX/etc/xdg/openbox/menu.xml"

# --- Step 6: autostart (substitute the real $PREFIX) ---
sed "s#@@PREFIX@@#$PREFIX#g" "$PORTDIR/autostart" \
    > "$PKGDIR$PREFIX/etc/xdg/openbox/autostart"
chmod 755 "$PKGDIR$PREFIX/etc/xdg/openbox/autostart"

# --- Step 7: screenshot tool (hh-grab XGetImage->PNG + hh-screenshot wrapper) ---
# Bound to Print in rc.xml; saves to ~/Pictures/hh-<timestamp>.png.
mkdir -p "$PKGDIR$PREFIX/bin"
gcc "$PORTDIR/hh-grab.c" -I"$PREFIX/include" -L"$PREFIX/lib" -R"$PREFIX/lib" -lX11 -lpng \
    -o "$PKGDIR$PREFIX/bin/hh-grab"
install -m 755 "$PORTDIR/hh-screenshot" "$PKGDIR$PREFIX/bin/hh-screenshot"

# --- Step 8: PDF/image launcher wrappers + branded welcome PDF ---
gcc "$PORTDIR/pdf-gen.c" $(pkg-config --cflags --libs cairo) -o "$PORTDIR/pdfgen"
mkdir -p "$PKGDIR$PREFIX/share/hammerhead"
"$PORTDIR/pdfgen" "$PKGDIR$PREFIX/share/hammerhead/welcome.pdf"
rm -f "$PORTDIR/pdfgen"
install -m 755 "$PORTDIR/hh-pdf" "$PKGDIR$PREFIX/bin/hh-pdf"
install -m 755 "$PORTDIR/hh-images" "$PKGDIR$PREFIX/bin/hh-images"

# --- Step 9: Openbox pipemenus (Places, Recent Files) ---
# GTK-free, POSIX-sh, pattern adapted from CrunchBang++'s
# cbpp-places-pipemenu / cbpp-recent-files-pipemenu; referenced from
# menu.xml via execute="hh-places-pipemenu" / "hh-recent-pipemenu".
install -m 755 "$PORTDIR/hh-places-pipemenu" "$PKGDIR$PREFIX/bin/hh-places-pipemenu"
install -m 755 "$PORTDIR/hh-recent-pipemenu" "$PKGDIR$PREFIX/bin/hh-recent-pipemenu"

# --- Step 10: branded tint2 launcher icons + .desktop entries ---
# The stock launcher was illegible: st ships no icon, xnedit's png was loose,
# and hicolor had no index.theme so name-lookup failed. We ship our own cairo
# glyphs and point each .desktop Icon= at an ABSOLUTE path, which tint2 loads
# directly (no icon theme required). tint2rc references these three by path.
gcc "$PORTDIR/icon-gen.c" $(pkg-config --cflags --libs cairo) -lm -o "$PORTDIR/ig"
mkdir -p "$PKGDIR$PREFIX/share/hammerhead-desktop/launcher"
"$PORTDIR/ig" "$PKGDIR$PREFIX/share/hammerhead-desktop/launcher"
rm -f "$PKGDIR$PREFIX/share/hammerhead-desktop/launcher/preview.png"  # review-only
rm -f "$PORTDIR/ig"
mkdir -p "$PKGDIR$PREFIX/share/applications"
cp "$PORTDIR/hh-terminal.desktop" "$PORTDIR/hh-files.desktop" \
   "$PORTDIR/hh-editor.desktop" "$PKGDIR$PREFIX/share/applications/"

# Clean up the transient build helper - not shipped.
rm -f "$PORTDIR/wg"

# --- Step 11: /etc/skel/.xsession (Task 4b) ---
# New users' home dirs are seeded from /etc/skel, so this makes a fresh
# account's X session default to the Openbox desktop without any manual
# ~/.xsession setup.
mkdir -p "$PKGDIR/etc/skel"
install -m 755 "$PORTDIR/dot-xsession" "$PKGDIR/etc/skel/.xsession"

# --- Step 12: hh-desktop-init (per-user ~/.config seed, CBPP-style) ---
# openbox-autostart only reads ~/.config or /etc/xdg (not our /usr/local/etc/xdg),
# so the X session entrypoints call this to seed ~/.config on login for new AND
# existing users (copy-if-missing).
install -m 755 "$PORTDIR/hh-desktop-init" "$PKGDIR$PREFIX/bin/hh-desktop-init"
-- Hammerhead conky config - Zygaena marine-dark identity
-- Installed to $PREFIX/etc/xdg/conky/conky.conf
-- Uses conky's native illumos/kstat stat backend (no ${exec} shellouts
-- needed for cpu/mem/fs/net - see task brief).
--
-- Typography/layout adapted from CrunchBang++'s signature right-side
-- conky (github.com/CBPP/cbpp-configs, simon-weber/crunchbang-conf):
-- monospace, right-aligned, uppercase section labels over hairline
-- rules, compact bars. Restyled teal-on-dark instead of CBPP's grey/red,
-- and kept our native kstat vars (no CBPP-style ${exec} shellouts).

conky.config = {
    own_window = true,
    own_window_type = 'desktop',
    own_window_transparent = true,
    own_window_argb_visual = true,
    own_window_argb_value = 200,
    own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',

    alignment = 'top_right',
    gap_x = 24,
    gap_y = 40,
    minimum_width = 260,
    maximum_width = 300,

    update_interval = 2.0,
    double_buffer = true,
    use_xft = true,
    font = 'monospace:size=9',

    default_color = 'cfe0e0',
    color1 = '1fb6b6',   -- headings / accents
    color2 = '5a7575',   -- muted / rules

    draw_shades = false,
    draw_outline = false,
    draw_borders = false,

    background = false,
}

conky.text = [[
${alignr}${color1}${font monospace:bold:size=14}HAMMERHEAD${font}${color}
${alignr}${color2}${nodename}${color}
${alignr}${color2}${hr 1}${color}

${alignr}${color1}SYSTEM${color}
${alignr}uptime  ${color1}${uptime}${color}
${alignr}load    ${color1}${loadavg}${color}

${alignr}${color1}CPU${color}
${alignr}${cpu}%${color}
${alignr}${cpubar 6,220}

${alignr}${color1}MEMORY${color}
${alignr}${mem} / ${memmax}${color}
${alignr}${membar 6,220}

${alignr}${color1}DISK (/)${color}
${alignr}${fs_used /} / ${fs_size /}${color}
${alignr}${fs_bar 6,220 /}

${alignr}${color1}NETWORK${color}
${alignr}down ${color1}${downspeed}${color} / up ${color1}${upspeed}${color}
]]
#!/bin/sh
# Hammerhead default X session - launch the Openbox desktop.
#
# Put the Hammerhead desktop config (/usr/local/etc/xdg) on the XDG search
# path so openbox/tint2/conky find the branded config without ~/.config.
# (xdm's Xsession also sets this; repeated here so `startx`/xinit users, who
# run ~/.xsession directly, get the branded desktop too.)
export XDG_CONFIG_DIRS="/usr/local/etc/xdg:${XDG_CONFIG_DIRS:-/etc/xdg}"
export XDG_DATA_DIRS="/usr/local/share:${XDG_DATA_DIRS:-/usr/share}"
# Seed ~/.config so openbox-autostart (which only reads ~/.config or /etc/xdg)
# runs our autostart -> tint2/conky/wallpaper. See hh-desktop-init.
/usr/local/bin/hh-desktop-init
exec /usr/local/bin/openbox-session
#!/bin/sh
# hh-desktop-init - point the user's openbox autostart at the LIVE system
# autostart so desktop-config updates ALWAYS take, with no per-user copies to
# go stale. Called from the X session entrypoint before openbox-session.
#
# Why only the autostart: openbox-autostart (run by openbox-session) reads only
# /etc/xdg/openbox/autostart or ~/.config/openbox/autostart -- NOT
# XDG_CONFIG_DIRS -- so the autostart is the single desktop file that must live
# under ~/.config. Everything else resolves live from /usr/local/etc/xdg via
# XDG_CONFIG_DIRS (set by the X session): openbox rc.xml/menu.xml and tint2rc;
# conky is launched by the autostart with an explicit -c path. So none of those
# need a per-user copy.
#
# We make ~/.config/openbox/autostart a SYMLINK to the system autostart (not a
# copy), so a package update to the autostart is picked up with no re-seed.
# A pre-existing non-symlink here is treated as legacy seeded state and migrated
# to the symlink.
SYS=/usr/local/etc/xdg/openbox/autostart
CFG="${XDG_CONFIG_HOME:-$HOME/.config}/openbox"

mkdir -p "$CFG" 2>/dev/null || exit 0
if [ "$(readlink "$CFG/autostart" 2>/dev/null)" != "$SYS" ]; then
	rm -f "$CFG/autostart" 2>/dev/null
	ln -sf "$SYS" "$CFG/autostart" 2>/dev/null
fi
exit 0
[Desktop Entry]
Type=Application
Name=Editor
Comment=XNEdit text editor
Exec=/usr/local/bin/xnc -tabbed %F
Icon=/usr/local/share/hammerhead-desktop/launcher/editor.png
Categories=Utility;TextEditor;
Terminal=false
[Desktop Entry]
Type=Application
Name=Files
Comment=Xfe file manager
Exec=xfe
Icon=/usr/local/share/hammerhead-desktop/launcher/files.png
Categories=System;FileManager;
Terminal=false
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <png.h>
#include <stdio.h>
#include <stdlib.h>
int main(int c,char**v){Display*d=XOpenDisplay(NULL);if(!d){fprintf(stderr,"no display\n");return 1;}
Window r=DefaultRootWindow(d);XWindowAttributes g;XGetWindowAttributes(d,r,&g);
XImage*im=XGetImage(d,r,0,0,g.width,g.height,AllPlanes,ZPixmap);if(!im)return 1;
FILE*f=fopen(c>1?v[1]:"screenshot.png","wb");png_structp p=png_create_write_struct(PNG_LIBPNG_VER_STRING,0,0,0);
png_infop i=png_create_info_struct(p);png_init_io(p,f);png_set_IHDR(p,i,g.width,g.height,8,PNG_COLOR_TYPE_RGB,0,0,0);
png_write_info(p,i);png_bytep row=malloc(3*g.width);for(int y=0;y<g.height;y++){for(int x=0;x<g.width;x++){
unsigned long px=XGetPixel(im,x,y);row[3*x]=(px>>16)&0xFF;row[3*x+1]=(px>>8)&0xFF;row[3*x+2]=px&0xFF;}png_write_row(p,row);}
png_write_end(p,i);fclose(f);return 0;}
#!/bin/sh
mkdir -p "$HOME/Pictures"
exec /usr/local/bin/feh --auto-zoom --scale-down --geometry 1000x720 "$HOME/Pictures" /usr/local/share/backgrounds
#!/bin/sh
[ -n "$1" ] && exec /usr/local/bin/mupdf-x11 "$@"
exec /usr/local/bin/mupdf-x11 /usr/local/share/hammerhead/welcome.pdf
#!/bin/sh
# hh-places-pipemenu - Openbox "Places" pipe menu (GTK-free)
#
# Pattern adapted from CrunchBang++'s cbpp-places-pipemenu
# (github.com/CBPP/cbpp-pipemenus, Copyright (C) 2010 John Crawley,
# ported to #!++ by Ben Young) - same idea (walk a directory, XML-escape
# names, emit an <openbox_pipe_menu>) but rewritten small/flat for our
# stack: no thunar/exo-open/geany, no recursive submenus. Every entry
# opens in xfe; a matching terminal entry opens st in that directory.
#
# Usage: <menu id="places-menu" label="Places" execute="hh-places-pipemenu"/>
# in menu.xml. Invoked with no arguments; always lists $HOME's immediate
# subdirectories (dotdirs skipped).
#
# NB: the shell, not bash - keep this POSIX sh / dash-fast per upstream.

files="xfe"

xml_escape() {
    # $1 -> escaped on stdout
    printf '%s' "$1" | sed \
        -e 's/&/\&amp;/g' \
        -e 's/</\&lt;/g' \
        -e 's/>/\&gt;/g' \
        -e 's/"/\&quot;/g'
}

home="${HOME:-/root}"

printf '<openbox_pipe_menu>\n'

printf '  <item label="~ Home">\n'
printf '    <action name="Execute"><command>%s %s</command></action>\n' "$files" "$(xml_escape "$home")"
printf '  </item>\n'
printf '  <item label="Terminal Here">\n'
printf '    <action name="Execute"><command>st -d %s</command></action>\n' "$(xml_escape "$home")"
printf '  </item>\n'
printf '  <separator/>\n'

# Immediate subdirectories of $HOME, skipping dotdirs, alphabetical.
for d in "$home"/*/; do
    [ -d "$d" ] || continue
    d="${d%/}"
    base="${d##*/}"
    case "$base" in
        .*) continue ;;
    esac
    label="$(xml_escape "$base")"
    path="$(xml_escape "$d")"
    printf '  <item label="%s">\n' "$label"
    printf '    <action name="Execute"><command>%s %s</command></action>\n' "$files" "$path"
    printf '  </item>\n'
    printf '  <item label="Terminal: %s">\n' "$label"
    printf '    <action name="Execute"><command>st -d %s</command></action>\n' "$path"
    printf '  </item>\n'
done

printf '</openbox_pipe_menu>\n'
#!/bin/sh
# hh-recent-pipemenu - Openbox "Recent Files" pipe menu (GTK-free)
#
# Loosely modeled on CrunchBang++'s cbpp-recent-files-pipemenu
# (github.com/CBPP/cbpp-pipemenus), but that one parses GTK's
# ~/.local/share/recently-used.xbel, which nothing on Hammerhead writes
# (no GTK). Instead: find(1) over $HOME for recently-modified
# docs/images, opened with the matching viewer.
#
# Usage: <menu id="recent-menu" label="Recent Files" execute="hh-recent-pipemenu"/>

max_entries=12
home="${HOME:-/root}"

xml_escape() {
    printf '%s' "$1" | sed \
        -e 's/&/\&amp;/g' \
        -e 's/</\&lt;/g' \
        -e 's/>/\&gt;/g' \
        -e 's/"/\&quot;/g'
}

viewer_for() {
    case "$1" in
        *.pdf) echo "hh-pdf" ;;
        *.png|*.jpg|*.jpeg|*.gif|*.bmp) echo "hh-images" ;;
        *) echo "xnedit" ;;
    esac
}

printf '<openbox_pipe_menu>\n'

count=0
find "$home" -maxdepth 3 -type f \
    \( -iname '*.pdf' -o -iname '*.txt' -o -iname '*.png' -o -iname '*.jpg' -o -iname '*.jpeg' \) \
    -mtime -14 -print 2>/dev/null | while IFS= read -r f; do
    viewer="$(viewer_for "$f")"
    label="$(xml_escape "${f##*/}")"
    path="$(xml_escape "$f")"
    printf '  <item label="%s">\n' "$label"
    printf '    <action name="Execute"><command>%s %s</command></action>\n' "$viewer" "$path"
    printf '  </item>\n'
    count=$((count + 1))
    [ "$count" -ge "$max_entries" ] && break
done

printf '</openbox_pipe_menu>\n'
#!/bin/sh
mkdir -p "$HOME/Pictures"
exec /usr/local/bin/hh-grab "$HOME/Pictures/hh-$(date +%Y%m%d-%H%M%S).png"
[Desktop Entry]
Type=Application
Name=Terminal
Comment=st terminal emulator
Exec=st
Icon=/usr/local/share/hammerhead-desktop/launcher/terminal.png
Categories=System;TerminalEmulator;
Terminal=false
/*
 * icon-gen.c - Zygaena marine-dark launcher icon generator.
 *
 * Renders three 48x48 ARGB launcher glyphs - terminal, files, editor - in
 * the Hammerhead teal palette (matching wallpaper-gen.c). tint2 loads these
 * by ABSOLUTE path (Icon=/usr/local/share/hammerhead-desktop/launcher/*.png),
 * so no freedesktop icon theme / hicolor index.theme is required - which is
 * exactly why the stock launcher was illegible (st shipped no icon, xnedit's
 * png was loose, hicolor had no index.theme).
 *
 * Build: gcc icon-gen.c $(pkg-config --cflags --libs cairo) -lm -o ig
 * Usage: ./ig /output/dir   (writes terminal.png, files.png, editor.png,
 *                            and preview.png for design review)
 */
#include <cairo.h>
#include <math.h>
#include <stdio.h>

#define S 48   /* icon canvas size */

/* palette - matches wallpaper-gen.c */
#define TILE_R   0x12/255.0
#define TILE_G   0x2e/255.0
#define TILE_B   0x34/255.0
#define TEAL_R   0x1f/255.0
#define TEAL_G   0xb6/255.0
#define TEAL_B   0xb6/255.0
#define TEALBR_R 0x54/255.0
#define TEALBR_G 0xe0/255.0
#define TEALBR_B 0xe0/255.0
#define TEXT_R   0xcf/255.0
#define TEXT_G   0xe0/255.0
#define TEXT_B   0xe0/255.0

static void
rrect(cairo_t *cr, double x, double y, double w, double h, double r)
{
    cairo_new_sub_path(cr);
    cairo_arc(cr, x + w - r, y + r,     r, -M_PI / 2, 0);
    cairo_arc(cr, x + w - r, y + h - r, r, 0, M_PI / 2);
    cairo_arc(cr, x + r,     y + h - r, r, M_PI / 2, M_PI);
    cairo_arc(cr, x + r,     y + r,     r, M_PI, 3 * M_PI / 2);
    cairo_close_path(cr);
}

/* subtle elevated chip so the three icons read as one branded set */
static void
tile(cairo_t *cr)
{
    rrect(cr, 2.5, 2.5, S - 5, S - 5, 10);
    cairo_set_source_rgb(cr, TILE_R, TILE_G, TILE_B);
    cairo_fill_preserve(cr);
    cairo_set_source_rgba(cr, TEAL_R, TEAL_G, TEAL_B, 0.40);
    cairo_set_line_width(cr, 1.5);
    cairo_stroke(cr);
}

/* Terminal: a prompt chevron ">" plus a cursor underscore "_". */
static void
draw_terminal(cairo_t *cr)
{
    tile(cr);
    cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
    cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND);

    cairo_set_source_rgb(cr, TEALBR_R, TEALBR_G, TEALBR_B);
    cairo_set_line_width(cr, 4.4);
    cairo_move_to(cr, 15, 16);
    cairo_line_to(cr, 25, 24);
    cairo_line_to(cr, 15, 32);
    cairo_stroke(cr);

    cairo_set_source_rgb(cr, TEXT_R, TEXT_G, TEXT_B);
    cairo_set_line_width(cr, 4.0);
    cairo_move_to(cr, 27, 33);
    cairo_line_to(cr, 34, 33);
    cairo_stroke(cr);
}

/* Files: a two-tone manila folder (tab + body). */
static void
draw_files(cairo_t *cr)
{
    tile(cr);
    cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND);

    /* tab peeking above the body's top-left */
    cairo_set_source_rgb(cr, TEAL_R, TEAL_G, TEAL_B);
    rrect(cr, 11, 14, 14, 8, 2.5);
    cairo_fill(cr);

    /* back body */
    rrect(cr, 11, 18, 26, 17, 3);
    cairo_fill(cr);

    /* front pocket, lighter, slightly inset - gives the folder depth */
    cairo_set_source_rgb(cr, TEALBR_R, TEALBR_G, TEALBR_B);
    rrect(cr, 13, 23, 22, 12, 2.5);
    cairo_fill(cr);
}

/* Editor: a pencil at 45 degrees (eraser, shaft, nib, tip). */
static void
draw_editor(cairo_t *cr)
{
    tile(cr);
    cairo_save(cr);
    cairo_translate(cr, 24, 24);
    cairo_rotate(cr, -M_PI / 4);

    double pw = 8, half = pw / 2;

    /* shaft */
    cairo_set_source_rgb(cr, TEAL_R, TEAL_G, TEAL_B);
    rrect(cr, -half, -13, pw, 19, 1.5);
    cairo_fill(cr);

    /* eraser (top) */
    cairo_set_source_rgb(cr, TEXT_R, TEXT_G, TEXT_B);
    rrect(cr, -half, -16.5, pw, 4, 1.2);
    cairo_fill(cr);

    /* nib (bottom), brighter teal */
    cairo_set_source_rgb(cr, TEALBR_R, TEALBR_G, TEALBR_B);
    cairo_move_to(cr, -half, 6);
    cairo_line_to(cr,  half, 6);
    cairo_line_to(cr,  0,   14);
    cairo_close_path(cr);
    cairo_fill(cr);

    /* graphite tip */
    cairo_set_source_rgb(cr, TILE_R, TILE_G, TILE_B);
    cairo_move_to(cr, -2.2, 10.5);
    cairo_line_to(cr,  2.2, 10.5);
    cairo_line_to(cr,  0,   14);
    cairo_close_path(cr);
    cairo_fill(cr);

    cairo_restore(cr);
}

typedef void (*drawfn)(cairo_t *);

static void
emit(const char *dir, const char *name, drawfn fn)
{
    char path[1024];
    cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, S, S);
    cairo_t *cr = cairo_create(s);
    fn(cr);
    snprintf(path, sizeof path, "%s/%s", dir, name);
    cairo_surface_write_to_png(s, path);
    printf("wrote %s\n", path);
    cairo_destroy(cr);
    cairo_surface_destroy(s);
}

/* Review sheet: each glyph at 3x (detail) over the same glyph at 22px
 * (real launcher size) on a panel-tone strip, so legibility is judged at
 * the size it will actually render. */
static void
emit_preview(const char *dir)
{
    drawfn fns[3] = { draw_terminal, draw_files, draw_editor };
    int cw = 160, W = cw * 3, H = 210;
    char path[1024];

    cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, W, H);
    cairo_t *cr = cairo_create(s);

    cairo_set_source_rgb(cr, 0x0d / 255.0, 0x11 / 255.0, 0x17 / 255.0);
    cairo_paint(cr);

    for (int i = 0; i < 3; i++) {
        cairo_save(cr);
        cairo_translate(cr, i * cw + (cw - 144) / 2.0, 8);
        cairo_scale(cr, 144.0 / S, 144.0 / S);
        fns[i](cr);
        cairo_restore(cr);
    }

    /* panel strip */
    cairo_set_source_rgb(cr, 0x0e / 255.0, 0x1c / 255.0, 0x1f / 255.0);
    cairo_rectangle(cr, 0, 168, W, 42);
    cairo_fill(cr);
    for (int i = 0; i < 3; i++) {
        cairo_save(cr);
        cairo_translate(cr, i * cw + (cw - 22) / 2.0, 178);
        cairo_scale(cr, 22.0 / S, 22.0 / S);
        fns[i](cr);
        cairo_restore(cr);
    }

    snprintf(path, sizeof path, "%s/preview.png", dir);
    cairo_surface_write_to_png(s, path);
    printf("wrote %s\n", path);
    cairo_destroy(cr);
    cairo_surface_destroy(s);
}

int
main(int argc, char **argv)
{
    const char *dir = (argc > 1) ? argv[1] : ".";
    emit(dir, "terminal.png", draw_terminal);
    emit(dir, "files.png",    draw_files);
    emit(dir, "editor.png",   draw_editor);
    emit_preview(dir);
    return 0;
}
<?xml version="1.0" encoding="UTF-8"?>
<!-- Hammerhead Openbox root menu - Zygaena marine-dark identity
     Installed to $PREFIX/etc/xdg/openbox/menu.xml

     Structure adapted from CrunchBang++'s categorized root menu
     (github.com/CBPP/cbpp-configs, simon-weber/crunchbang-conf) -
     Applications/Places submenus, quick launchers, an Openbox submenu,
     plain Exit (no GTK exit dialog). Rebuilt GTK-free for our real
     apps: st, xfe, xnedit, nvim (in st), hh-pdf, hh-images, dmenu_run. -->
<openbox_menu xmlns="http://openbox.org/3.4/menu">

  <menu id="root-menu" label="Hammerhead">

    <menu id="apps-menu" label="Applications">
      <menu id="apps-accessories-menu" label="Accessories">
        <item label="Text Editor (XNEdit)">
          <action name="Execute"><command>xnedit</command></action>
        </item>
        <item label="Vim (terminal)">
          <action name="Execute"><command>st -e nvim</command></action>
        </item>
        <item label="Files (Xfe)">
          <action name="Execute"><command>xfe</command></action>
        </item>
        <item label="Image Viewer">
          <action name="Execute"><command>hh-images</command></action>
        </item>
        <item label="PDF Viewer">
          <action name="Execute"><command>hh-pdf</command></action>
        </item>
      </menu>
      <menu id="apps-system-menu" label="System">
        <item label="Terminal">
          <action name="Execute"><command>st</command></action>
        </item>
      </menu>
    </menu>

    <menu id="places-menu" label="Places" execute="hh-places-pipemenu"/>

    <menu id="recent-menu" label="Recent Files" execute="hh-recent-pipemenu"/>

    <separator/>

    <item label="Terminal">
      <action name="Execute"><command>st</command></action>
    </item>
    <item label="Files">
      <action name="Execute"><command>xfe</command></action>
    </item>
    <item label="Run...">
      <action name="Execute"><command>dmenu_run</command></action>
    </item>

    <separator/>

    <menu id="openbox-menu" label="Openbox">
      <item label="Reconfigure">
        <action name="Reconfigure"/>
      </item>
      <item label="Restart">
        <action name="Restart"/>
      </item>
    </menu>

    <separator/>

    <!-- Power management. zygctl talks to the root-owned zyginit socket, so
         it needs root privilege; the desktop runs as zygaena (uid 1000).
         pfexec elevates via the "Hammerhead Power Management" RBAC profile
         (base config: rootfs/etc/security/{prof,exec}_attr.d/hammerhead +
         rootfs/etc/user_attr.d/hammerhead). Each has an Openbox confirm
         <prompt> so a stray click can't power off the machine. -->
    <item label="Reboot">
      <action name="Execute">
        <command>pfexec /sbin/zygctl reboot</command>
        <prompt>Reboot the system?</prompt>
      </action>
    </item>
    <item label="Shutdown">
      <action name="Execute">
        <command>pfexec /sbin/zygctl poweroff</command>
        <prompt>Shut down the system?</prompt>
      </action>
    </item>

    <item label="Log Out / Exit">
      <action name="Exit">
        <prompt>yes</prompt>
      </action>
    </item>
  </menu>

</openbox_menu>
# hammerhead-desktop - Zygaena marine-dark desktop branding/config
# (wallpaper, Openbox theme, tint2/conky configs, menu/keybinds, autostart)
#
# No upstream source - this port carries its own config files + a small
# cairo program (wallpaper-gen.c) that renders the branded wallpaper PNG
# at package-build time. See build.sh.

[package]
name = "hammerhead-desktop"
version = "1.7.0"
release = 1
description = "Zygaena marine-dark desktop branding: wallpaper, Openbox theme, tint2/conky configs, categorized menu w/ CBPP-style Places/Recent pipemenus + Shutdown/Reboot (pfexec zygctl), autostart"
url = "https://git.sharkos.one/zygaena/hammerhead"
license = "CDDL-1.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["openbox", "tint2", "conky", "picom", "feh", "dmenu", "st", "xfe", "mupdf", "xnedit", "cairo", "libpng"]
build = ["cairo", "libpng"]

[build]
parallel = false
#include <cairo.h>
#include <cairo-pdf.h>
int main(int c,char**v){
 cairo_surface_t*s=cairo_pdf_surface_create(c>1?v[1]:"welcome.pdf",612,792);
 cairo_t*cr=cairo_create(s);
 cairo_set_source_rgb(cr,0.02,0.035,0.06); cairo_paint(cr);
 cairo_set_source_rgb(cr,0.12,0.71,0.71); cairo_rectangle(cr,0,0,612,8); cairo_fill(cr);
 cairo_select_font_face(cr,"sans",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD);
 cairo_set_font_size(cr,40); cairo_set_source_rgb(cr,0.12,0.71,0.71);
 cairo_move_to(cr,60,120); cairo_show_text(cr,"HAMMERHEAD");
 cairo_select_font_face(cr,"sans",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL);
 cairo_set_font_size(cr,15); cairo_set_source_rgb(cr,0.55,0.68,0.68);
 cairo_move_to(cr,62,148); cairo_show_text(cr,"Zygaena Operating System");
 const char*L[]={"Welcome to your Hammerhead desktop.","",
  "This document is displayed by mupdf, built from source for",
  "Hammerhead - a 64-bit illumos-derived OS with a modern GNU",
  "toolchain running an XLibre + Openbox desktop, all GTK-free.","",
  "Keys:  Super+Return terminal   Super+f files   Super+e editor",
  "       Super+Space launcher    Right-click the desktop for the menu.",0};
 cairo_set_font_size(cr,14); double y=210;
 for(int i=0;L[i];i++){cairo_set_source_rgb(cr,0.82,0.9,0.9);cairo_move_to(cr,60,y);cairo_show_text(cr,L[i]);y+=26;}
 cairo_show_page(cr); cairo_destroy(cr); cairo_surface_destroy(s); return 0;}
<?xml version="1.0" encoding="UTF-8"?>
<!-- Hammerhead Openbox config - Zygaena marine-dark identity
     Installed to $PREFIX/etc/xdg/openbox/rc.xml -->
<openbox_config xmlns="http://openbox.org/3.4/rc">

  <resistance>
    <strength>10</strength>
    <screen_edge_strength>20</screen_edge_strength>
  </resistance>

  <focus>
    <focusNew>yes</focusNew>
    <followMouse>no</followMouse>
    <focusLast>yes</focusLast>
  </focus>

  <placement>
    <policy>Smart</policy>
    <center>yes</center>
  </placement>

  <theme>
    <name>Hammerhead</name>
    <titleLayout>NLIMC</titleLayout>
    <keepBorder>yes</keepBorder>
    <animateIconify>no</animateIconify>
    <font place="ActiveWindow">
      <name>sans</name>
      <size>9</size>
      <weight>Bold</weight>
      <slant>Normal</slant>
    </font>
    <font place="InactiveWindow">
      <name>sans</name>
      <size>9</size>
      <weight>Normal</weight>
      <slant>Normal</slant>
    </font>
  </theme>

  <desktops>
    <number>4</number>
    <firstdesk>1</firstdesk>
    <names>
      <name>1</name>
      <name>2</name>
      <name>3</name>
      <name>4</name>
    </names>
    <popupTime>500</popupTime>
  </desktops>

  <keyboard>
    <!-- Application launchers (Super) -->
    <keybind key="W-Return"><action name="Execute"><command>st</command></action></keybind>
    <keybind key="W-t"><action name="Execute"><command>st</command></action></keybind>
    <keybind key="W-f"><action name="Execute"><command>xfe</command></action></keybind>
    <keybind key="W-e"><action name="Execute"><command>xnedit</command></action></keybind>
    <keybind key="W-space"><action name="Execute"><command>dmenu_run</command></action></keybind>
    <keybind key="A-F2"><action name="Execute"><command>dmenu_run</command></action></keybind>
    <keybind key="A-F3"><action name="Execute"><command>dmenu_run</command></action></keybind>
    <!-- Menus -->
    <keybind key="W-m"><action name="ShowMenu"><menu>root-menu</menu></action></keybind>
    <keybind key="C-A-q"><action name="ShowMenu"><menu>root-menu</menu></action></keybind>
    <keybind key="W-Tab"><action name="ShowMenu"><menu>client-list-combined-menu</menu></action></keybind>
    <!-- Screenshot -->
    <keybind key="Print"><action name="Execute"><command>hh-screenshot</command></action></keybind>
    <!-- Window management -->
    <keybind key="A-F4"><action name="Close"/></keybind>
    <keybind key="W-q"><action name="Close"/></keybind>
    <keybind key="A-space"><action name="ShowMenu"><menu>client-menu</menu></action></keybind>
    <keybind key="A-Tab"><action name="NextWindow"/></keybind>
    <keybind key="A-S-Tab"><action name="PreviousWindow"/></keybind>
    <keybind key="W-A-f"><action name="ToggleMaximizeFull"/></keybind>
    <!-- Half-screen tiling -->
    <keybind key="W-Left"><action name="UnmaximizeFull"/><action name="MoveResizeTo"><x>0</x><y>0</y><width>50%</width><height>100%</height></action></keybind>
    <keybind key="W-Right"><action name="UnmaximizeFull"/><action name="MoveResizeTo"><x>-0</x><y>0</y><width>50%</width><height>100%</height></action></keybind>
    <keybind key="W-Up"><action name="ToggleMaximizeFull"/></keybind>
    <keybind key="W-Down"><action name="Iconify"/></keybind>
    <!-- Desktops -->
    <keybind key="C-A-Left"><action name="GoToDesktop"><to>left</to><wrap>no</wrap></action></keybind>
    <keybind key="C-A-Right"><action name="GoToDesktop"><to>right</to><wrap>no</wrap></action></keybind>
    <keybind key="W-F1"><action name="GoToDesktop"><to>1</to></action></keybind>
    <keybind key="W-F2"><action name="GoToDesktop"><to>2</to></action></keybind>
    <keybind key="W-d"><action name="ToggleShowDesktop"/></keybind>
    <keybind key="S-A-Left"><action name="SendToDesktop"><to>left</to><wrap>no</wrap></action></keybind>
    <keybind key="S-A-Right"><action name="SendToDesktop"><to>right</to><wrap>no</wrap></action></keybind>
  </keyboard>

  <mouse>
    <dragThreshold>1</dragThreshold>
    <doubleClickTime>300</doubleClickTime>
    <context name="Frame">
      <mousebind button="A-Left" action="Press"><action name="Focus"/><action name="Raise"/></mousebind>
      <mousebind button="A-Left" action="Drag"><action name="Move"/></mousebind>
      <mousebind button="A-Right" action="Press"><action name="Focus"/><action name="Raise"/></mousebind>
      <mousebind button="A-Right" action="Drag"><action name="Resize"/></mousebind>
      <mousebind button="A-Middle" action="Press"><action name="Lower"/><action name="FocusToBottom"/><action name="Unfocus"/></mousebind>
    </context>
    <context name="Titlebar">
      <mousebind button="Left" action="Press"><action name="Focus"/><action name="Raise"/></mousebind>
      <mousebind button="Left" action="Drag"><action name="Move"/></mousebind>
      <mousebind button="Left" action="DoubleClick"><action name="ToggleShade"/></mousebind>
      <mousebind button="Up" action="Click"><action name="Shade"/></mousebind>
      <mousebind button="Down" action="Click"><action name="Unshade"/></mousebind>
      <mousebind button="Middle" action="Press"><action name="Lower"/><action name="FocusToBottom"/><action name="Unfocus"/></mousebind>
      <mousebind button="Right" action="Press"><action name="Focus"/><action name="Raise"/><action name="ShowMenu"><menu>client-menu</menu></action></mousebind>
    </context>
    <context name="Top"><mousebind button="Left" action="Drag"><action name="Resize"><edge>top</edge></action></mousebind></context>
    <context name="Bottom"><mousebind button="Left" action="Drag"><action name="Resize"><edge>bottom</edge></action></mousebind></context>
    <context name="Left"><mousebind button="Left" action="Drag"><action name="Resize"><edge>left</edge></action></mousebind></context>
    <context name="Right"><mousebind button="Left" action="Drag"><action name="Resize"><edge>right</edge></action></mousebind></context>
    <context name="TLCorner TRCorner BLCorner BRCorner"><mousebind button="Left" action="Drag"><action name="Resize"/></mousebind></context>
    <context name="Client">
      <mousebind button="Left" action="Press"><action name="Focus"/><action name="Raise"/></mousebind>
      <mousebind button="Middle" action="Press"><action name="Focus"/><action name="Raise"/></mousebind>
      <mousebind button="Right" action="Press"><action name="Focus"/><action name="Raise"/></mousebind>
    </context>
    <context name="Icon">
      <mousebind button="Left" action="Press"><action name="Focus"/><action name="Raise"/><action name="ShowMenu"><menu>client-menu</menu></action></mousebind>
      <mousebind button="Right" action="Press"><action name="Focus"/><action name="Raise"/><action name="ShowMenu"><menu>client-menu</menu></action></mousebind>
    </context>
    <context name="Iconify"><mousebind button="Left" action="Click"><action name="Iconify"/></mousebind></context>
    <context name="Maximize">
      <mousebind button="Left" action="Click"><action name="ToggleMaximize"/></mousebind>
      <mousebind button="Middle" action="Click"><action name="ToggleMaximizeVertical"/></mousebind>
      <mousebind button="Right" action="Click"><action name="ToggleMaximizeHorizontal"/></mousebind>
    </context>
    <context name="Close"><mousebind button="Left" action="Click"><action name="Close"/></mousebind></context>
    <context name="Desktop">
      <mousebind button="Up" action="Click"><action name="GoToDesktop"><to>previous</to></action></mousebind>
      <mousebind button="Down" action="Click"><action name="GoToDesktop"><to>next</to></action></mousebind>
    </context>
    <context name="Root">
      <mousebind button="Middle" action="Press"><action name="ShowMenu"><menu>client-list-combined-menu</menu></action></mousebind>
      <mousebind button="Right" action="Press"><action name="ShowMenu"><menu>root-menu</menu></action></mousebind>
    </context>
  </mouse>

  <menu>
    <file>menu.xml</file>
    <hideDelay>200</hideDelay>
    <middle>no</middle>
    <submenuShowDelay>100</submenuShowDelay>
    <showIcons>yes</showIcons>
  </menu>

  <applications/>

</openbox_config>
# Hammerhead Openbox theme - Zygaena marine-dark identity
# Installed to $PREFIX/share/themes/Hammerhead/openbox-3/themerc

window.active.title.bg: flat solid
window.active.title.bg.color: #12303a

window.inactive.title.bg: flat solid
window.inactive.title.bg.color: #0d1117

window.active.label.bg: parentrelative
window.inactive.label.bg: parentrelative

window.active.label.text.color: #cfe0e0
window.inactive.label.text.color: #5a7575

window.active.title.separator.color: #1fb6b6
window.inactive.title.separator.color: #0d1117

window.active.border.color: #1fb6b6
window.inactive.border.color: #0d1117

window.active.handle.bg: flat solid
window.active.handle.bg.color: #12303a
window.inactive.handle.bg: flat solid
window.inactive.handle.bg.color: #0d1117

window.active.grip.bg: flat solid
window.active.grip.bg.color: #1fb6b6
window.inactive.grip.bg: flat solid
window.inactive.grip.bg.color: #0d1117

window.active.button.unpressed.bg: flat solid
window.active.button.unpressed.bg.color: #12303a
window.active.button.pressed.bg: flat solid
window.active.button.pressed.bg.color: #1fb6b6
window.active.button.disabled.bg: flat solid
window.active.button.disabled.bg.color: #0d1117
window.active.button.hover.bg: flat solid
window.active.button.hover.bg.color: #3fd0d0

window.inactive.button.unpressed.bg: flat solid
window.inactive.button.unpressed.bg.color: #0d1117
window.inactive.button.pressed.bg: flat solid
window.inactive.button.pressed.bg.color: #1fb6b6
window.inactive.button.disabled.bg: flat solid
window.inactive.button.disabled.bg.color: #0d1117
window.inactive.button.hover.bg: flat solid
window.inactive.button.hover.bg.color: #3fd0d0

window.active.button.unpressed.image.color: #cfe0e0
window.active.button.pressed.image.color: #05080d
window.active.button.disabled.image.color: #5a7575
window.active.button.hover.image.color: #05080d
window.inactive.button.unpressed.image.color: #5a7575
window.inactive.button.pressed.image.color: #05080d
window.inactive.button.disabled.image.color: #5a7575
window.inactive.button.hover.image.color: #05080d

border.width: 2
padding.width: 2
padding.height: 2
window.client.padding.width: 0
window.handle.width: 6
window.label.text.justify: left

menu.items.bg: flat solid
menu.items.bg.color: #0d1117
menu.items.text.color: #cfe0e0
menu.items.disabled.text.color: #5a7575
menu.items.active.bg: flat solid
menu.items.active.bg.color: #12303a
menu.items.active.text.color: #3fd0d0
menu.border.color: #1fb6b6
menu.border.width: 1
menu.separator.color: #1fb6b6
menu.separator.padding.width: 6
menu.separator.padding.height: 3

menu.title.bg: flat solid
menu.title.bg.color: #12303a
menu.title.text.color: #cfe0e0
menu.title.text.justify: left

osd.bg: flat solid
osd.bg.color: #0d1117
osd.border.color: #1fb6b6
osd.border.width: 1
osd.label.bg: parentrelative
osd.label.text.color: #cfe0e0

window.active.shadow: false
window.inactive.shadow: false

font: shadow=n
font: place=ActiveWindow
font: family=sans
font: size=9
font: weight=bold
font: slant=normal

font: place=InactiveWindow
font: family=sans
font: size=9
font: weight=normal
font: slant=normal

font: place=MenuHeader
font: family=sans
font: size=9
font: weight=bold

font: place=MenuItem
font: family=sans
font: size=9
font: weight=normal

font: place=OnScreenDisplay
font: family=sans
font: size=9
font: weight=bold
#---------------------------------------------
# Hammerhead tint2 panel - Zygaena marine-dark identity
# Installed to $PREFIX/etc/xdg/tint2/tint2rc
#
# Layout adapted from CrunchBang++'s tint2rc (github.com/CBPP/cbpp-configs,
# simon-weber/crunchbang-conf): bottom panel, left launcher block, centered
# taskbar, right-hand systray + two-line clock, teal active-task highlight.
# No battery/brightness applets (headless/Xvfb-safe). Restyled to our
# marine-dark palette, not CBPP's grey.
#---------------------------------------------

#-------------------------------------
# Backgrounds
# bg_color_0: panel background
rounded = 0
border_width = 0
background_color = #0d1117 88
border_color = #1fb6b6 0

rounded = 3
border_width = 1
background_color = #12303a 100
border_color = #1fb6b6 70

rounded = 3
border_width = 0
background_color = #1fb6b6 25
border_color = #1fb6b6 0

rounded = 0
border_width = 0
background_color = #0d1117 0
border_color = #1fb6b6 0

#-------------------------------------
# Panel
panel_items = LTSC
panel_size = 100% 30
panel_margin = 0 0
panel_padding = 6 0 8
panel_background_id = 1
panel_position = bottom center horizontal
panel_layer = top
panel_monitor = all
autohide = 0
strut_policy = follow_size
panel_dock = 0
wm_menu = 1
panel_window_name = tint2
disable_transparency = 0
mouse_effects = 1

#-------------------------------------
# Launcher
launcher_padding = 6 3 8
launcher_background_id = 4
launcher_icon_size = 22
launcher_icon_theme_override = 0
launcher_item_app = /usr/local/share/applications/hh-terminal.desktop
launcher_item_app = /usr/local/share/applications/hh-files.desktop
launcher_item_app = /usr/local/share/applications/hh-editor.desktop

#-------------------------------------
# Taskbar
taskbar_mode = multi_desktop
taskbar_hide_if_empty = 0
taskbar_padding = 4 2 4
taskbar_background_id = 0
taskbar_active_background_id = 0
taskbar_name = 1
taskbar_name_padding = 8 3
taskbar_name_background_id = 0
taskbar_name_active_background_id = 3
taskbar_name_font = sans bold 9
taskbar_name_font_color = #5a7575 100
taskbar_name_active_font_color = #1fb6b6 100
taskbar_distribute_size = 1
#-------------------------------------
# Task
task_text = 1
task_icon = 1
task_centered = 1
task_maximum_size = 180 28
task_padding = 6 2
task_background_id = 0
task_active_background_id = 2
task_urgent_background_id = 2
task_font = sans 9
task_font_color = #cfe0e0 100
task_active_font_color = #3fd0d0 100
task_urgent_font_color = #3fd0d0 100
task_tooltip = 1

#-------------------------------------
# Clock (two-line, CBPP-style: time over date)
time1_format = %H:%M
time2_format = %a %d %b
time1_font = sans bold 9
time2_font = sans 7
clock_font_color = #cfe0e0 100
clock_padding = 8 0
clock_background_id = 0
clock_tooltip = %A, %d %B %Y

#-------------------------------------
# System tray
systray_padding = 4 2 8
systray_background_id = 0
systray_sort = ascending
systray_icon_size = 18
systray_icon_asb = 100 0 0

#-------------------------------------
# Tooltips
tooltip_padding = 4 4
tooltip_show_timeout = 0.5
tooltip_hide_timeout = 0.1
tooltip_background_id = 1
tooltip_font_color = #cfe0e0 100
tooltip_font = sans 8
/*
 * wallpaper-gen.c - Zygaena marine-dark wallpaper generator.
 *
 * Renders a 1920x1080 PNG: deep-ocean vertical gradient, low-alpha
 * concentric sonar arcs from a lower-left origin, a low-alpha stylized
 * hammerhead-shark silhouette, and the HAMMERHEAD/ZYGAENA wordmark in
 * the lower-right corner.
 *
 * Build: gcc wallpaper-gen.c $(pkg-config --cflags --libs cairo) -lm -o wg
 * Usage: ./wg /path/to/output.png
 */
#include <cairo.h>
#include <math.h>
#include <stdio.h>

#define W 1920
#define H 1080

/* Zygaena marine-dark palette */
#define BG_TOP_R    0x05/255.0
#define BG_TOP_G    0x08/255.0
#define BG_TOP_B    0x0d/255.0
#define BG_BOT_R    0x0a/255.0
#define BG_BOT_G    0x27/255.0
#define BG_BOT_B    0x33/255.0
#define TEAL_R      0x1f/255.0
#define TEAL_G      0xb6/255.0
#define TEAL_B      0xb6/255.0
#define TEAL_BR_R   0x3f/255.0
#define TEAL_BR_G   0xd0/255.0
#define TEAL_BR_B   0xd0/255.0
#define MUTED_R     0x5a/255.0
#define MUTED_G     0x75/255.0
#define MUTED_B     0x75/255.0

static void
draw_background(cairo_t *cr)
{
    cairo_pattern_t *grad = cairo_pattern_create_linear(0, 0, 0, H);
    cairo_pattern_add_color_stop_rgb(grad, 0.0, BG_TOP_R, BG_TOP_G, BG_TOP_B);
    cairo_pattern_add_color_stop_rgb(grad, 1.0, BG_BOT_R, BG_BOT_G, BG_BOT_B);
    cairo_set_source(cr, grad);
    cairo_paint(cr);
    cairo_pattern_destroy(grad);
}

static void
draw_sonar_arcs(cairo_t *cr)
{
    /* Origin lower-left, off canvas a bit so rings sweep across the
     * bottom-left quadrant. */
    double cx = -80, cy = H + 80;
    int rings = 5;
    double base_r = 260;
    double step_r = 220;

    for (int i = 0; i < rings; i++) {
        double alpha = 0.12 - (i * (0.06 / (rings - 1)));
        if (alpha < 0.06) alpha = 0.06;
        cairo_set_source_rgba(cr, TEAL_R, TEAL_G, TEAL_B, alpha);
        cairo_set_line_width(cr, 2.0);
        cairo_arc(cr, cx, cy, base_r + i * step_r, -M_PI / 2.2, 0.15);
        cairo_stroke(cr);
    }
}

/*
 * Stylized hammerhead-shark silhouette: a wide flattened "hammer" head
 * bar with an eye-dot at each end, a tapering dorsal body, and a
 * crescent tail - all in one low-alpha teal fill, large and off-center
 * (upper-left-of-center so it doesn't collide with the wordmark).
 */
static void
draw_hammerhead_motif(cairo_t *cr)
{
    double ox = 560, oy = 430;   /* motif origin (center of the head bar) */
    double scale = 1.55;

    cairo_save(cr);
    cairo_translate(cr, ox, oy);
    cairo_scale(cr, scale, scale);
    cairo_set_source_rgba(cr, TEAL_R, TEAL_G, TEAL_B, 0.10);

    /* Hammer head: a wide, slightly bowed bar. */
    cairo_move_to(cr, -260, 0);
    cairo_curve_to(cr, -180, -34,  180, -34,  260, 0);
    cairo_curve_to(cr,  180,  34, -180,  34, -260, 0);
    cairo_close_path(cr);
    cairo_fill(cr);

    /* Tapering body/tail sweeping down-right from the head's center. */
    cairo_move_to(cr, -40, 18);
    cairo_curve_to(cr, 120, 60,  260, 160,  360, 340);
    cairo_curve_to(cr, 380, 380,  340, 400,  300, 380);
    cairo_curve_to(cr, 220, 220,  90, 100, -40, 54);
    cairo_close_path(cr);
    cairo_fill(cr);

    /* Tail fluke. */
    cairo_move_to(cr, 340, 320);
    cairo_curve_to(cr, 400, 330, 440, 300, 470, 250);
    cairo_curve_to(cr, 450, 310, 420, 360, 380, 400);
    cairo_curve_to(cr, 360, 370, 345, 345, 340, 320);
    cairo_close_path(cr);
    cairo_fill(cr);

    /* Eye-dots at each end of the hammer bar. */
    cairo_arc(cr, -235, 0, 10, 0, 2 * M_PI);
    cairo_fill(cr);
    cairo_arc(cr, 235, 0, 10, 0, 2 * M_PI);
    cairo_fill(cr);

    cairo_restore(cr);
}

/* Draw text with manual letter-spacing (cairo toy text API has no
 * built-in tracking control). */
static void
draw_tracked_text(cairo_t *cr, const char *s, double x, double y, double tracking)
{
    cairo_text_extents_t ext;
    double cx = x;
    char buf[2] = {0, 0};

    for (const char *p = s; *p; p++) {
        buf[0] = *p;
        cairo_text_extents(cr, buf, &ext);
        cairo_move_to(cr, cx, y);
        cairo_show_text(cr, buf);
        cx += ext.x_advance + tracking;
    }
}

static void
draw_wordmark(cairo_t *cr)
{
    cairo_text_extents_t ext;

    cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL,
        CAIRO_FONT_WEIGHT_BOLD);
    cairo_set_font_size(cr, 64);
    cairo_set_source_rgb(cr, TEAL_R, TEAL_G, TEAL_B);

    /* Measure full tracked width to right-align at x = W - 120. */
    const char *word = "HAMMERHEAD";
    double tracking = 8.0;
    double total_w = 0;
    char buf[2] = {0, 0};
    for (const char *p = word; *p; p++) {
        buf[0] = *p;
        cairo_text_extents(cr, buf, &ext);
        total_w += ext.x_advance + tracking;
    }
    total_w -= tracking;

    double x = W - 120 - total_w;
    double y = H - 150;
    draw_tracked_text(cr, word, x, y, tracking);

    /* Subtitle */
    cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL,
        CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_font_size(cr, 22);
    cairo_set_source_rgb(cr, MUTED_R, MUTED_G, MUTED_B);

    const char *sub = "ZYGAENA";
    double sub_tracking = 6.0;
    double sub_w = 0;
    for (const char *p = sub; *p; p++) {
        buf[0] = *p;
        cairo_text_extents(cr, buf, &ext);
        sub_w += ext.x_advance + sub_tracking;
    }
    sub_w -= sub_tracking;

    draw_tracked_text(cr, sub, W - 120 - sub_w, y + 40, sub_tracking);
}

int
main(int argc, char **argv)
{
    const char *outpath = (argc > 1) ? argv[1] : "/tmp/hammerhead.png";

    cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, W, H);
    cairo_t *cr = cairo_create(surface);

    draw_background(cr);
    draw_sonar_arcs(cr);
    draw_hammerhead_motif(cr);
    draw_wordmark(cr);

    cairo_status_t st = cairo_surface_write_to_png(surface, outpath);
    if (st != CAIRO_STATUS_SUCCESS) {
        fprintf(stderr, "write_to_png failed: %s\n", cairo_status_to_string(st));
        cairo_destroy(cr);
        cairo_surface_destroy(surface);
        return 1;
    }

    printf("wrote %s (%dx%d)\n", outpath, W, H);

    cairo_destroy(cr);
    cairo_surface_destroy(surface);
    return 0;
}
#!/bin/ksh93
# Build script for hammerhead-kernel
# Packages kernel modules, boot infrastructure, and CPU microcode from proto area
#
# Requires PROTO_AREA to be set to the hammerhead proto path, e.g.:
#   export PROTO_AREA=/usr/src/hammerhead-build/root_amd64
#
# Optional: ROOTFS_DIR for rootfs overlay (boot archive filelist, etc.)
#   export ROOTFS_DIR=/usr/src/hammerhead/rootfs

set -e

PROTO_AREA="${PROTO_AREA:?PROTO_AREA must be set to hammerhead proto path}"

# Validate required directories
for dir in kernel boot; do
    if [ ! -d "$PROTO_AREA/$dir" ]; then
        printf "ERROR: %s/%s does not exist\n" "$PROTO_AREA" "$dir"
        printf "Has the hammerhead build completed successfully?\n"
        exit 1
    fi
done

# Validate critical files
for f in kernel/genunix kernel/unix boot/loader64.efi; do
    if [ ! -f "$PROTO_AREA/$f" ]; then
        printf "ERROR: %s not found in proto area\n" "$f"
        exit 1
    fi
done

# --- Kernel modules (includes driver .conf files) ---
printf "Packaging kernel modules...\n"
mkdir -p "$PKGDIR/kernel"
(cd "$PROTO_AREA/kernel" && find . | cpio -pdm "$PKGDIR/kernel" 2>/dev/null)

# Set ownership: kernel modules are root:sys
chown -R root:sys "$PKGDIR/kernel"

# --- Boot infrastructure (loader, fonts, splash, forth scripts) ---
printf "Packaging boot files...\n"
mkdir -p "$PKGDIR/boot"
(cd "$PROTO_AREA/boot" && find . | cpio -pdm "$PKGDIR/boot" 2>/dev/null)

# Apply rootfs overlay for boot files (filelist.ramdisk, etc.)
if [ -n "$ROOTFS_DIR" ] && [ -d "$ROOTFS_DIR/boot" ]; then
    printf "Applying rootfs overlay for boot...\n"
    (cd "$ROOTFS_DIR/boot" && find . | cpio -pdm "$PKGDIR/boot" 2>/dev/null)
fi

chown -R root:sys "$PKGDIR/boot"

# --- CPU microcode ---
if [ -d "$PROTO_AREA/platform/amd64/ucode" ]; then
    printf "Packaging CPU microcode...\n"
    mkdir -p "$PKGDIR/platform/amd64/ucode"
    (cd "$PROTO_AREA/platform/amd64/ucode" && find . | cpio -pdm "$PKGDIR/platform/amd64/ucode" 2>/dev/null)
    chown -R root:sys "$PKGDIR/platform/amd64/ucode"
fi

# --- Post-install script ---
mkdir -p "$PKGDIR/.SCRIPTS"
cat > "$PKGDIR/.SCRIPTS/post-install.sh" << 'SCRIPT'
#!/bin/ksh93
# Update boot archive to include new kernel modules
# Only run if we're on a live system (not during initial install to altroot)
if [ -f /kernel/genunix ]; then
    # Generate boot archive using cpio method (not bootadm)
    if [ -f /boot/solaris/filelist.ramdisk ]; then
        printf "Regenerating boot archive...\n"
        tmpfilelist=/tmp/boot_archive_files.$$
        tmparchive=/tmp/boot_archive.$$
        (cd / && while IFS= read -r line; do
            [[ -z "$line" || "$line" = \#* ]] && continue
            [[ -e "$line" ]] && printf "%s\n" "$line"
        done < /boot/solaris/filelist.ramdisk) > "$tmpfilelist"
        (cd / && cpio -o -H odc < "$tmpfilelist" 2>/dev/null) > "$tmparchive"
        digest -a sha1 "$tmparchive" > /boot/boot_archive.hash
        gzip -9 -c "$tmparchive" > /boot/boot_archive
        rm -f "$tmpfilelist" "$tmparchive"
        printf "Boot archive updated.\n"
    fi
fi
printf "Kernel updated. A reboot is required to load the new kernel.\n"
SCRIPT
chmod 755 "$PKGDIR/.SCRIPTS/post-install.sh"

# --- Summary ---
MODULES=$(find "$PKGDIR/kernel" -type f | wc -l)
BOOT_FILES=$(find "$PKGDIR/boot" -type f | wc -l)
SIZE=$(du -sh "$PKGDIR" | cut -f1)
printf "Packaged %d kernel files, %d boot files (%s total)\n" "$MODULES" "$BOOT_FILES" "$SIZE"
# hammerhead-kernel - Kernel modules, boot infrastructure, and microcode
# https://git.sharkos.one/zygaena/hammerhead

[package]
name = "hammerhead-kernel"
version = "0.1.0"
release = 1
description = "Hammerhead kernel modules, boot loader, and CPU microcode"
url = "https://git.sharkos.one/zygaena/hammerhead"
license = "CDDL-1.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"
conflicts = ["illumos-kernel", "illumos-platform", "illumos-boot"]

[dependencies]
runtime = []
build = []

[build]
parallel = false
#!/bin/ksh93
# Build script for hammerhead-userland
# Packages commands, libraries, headers, and system configuration from proto area
#
# Requires PROTO_AREA to be set to the hammerhead proto path, e.g.:
#   export PROTO_AREA=/usr/src/hammerhead-build/root_amd64
#
# Optional: ROOTFS_DIR for rootfs overlay (config files, ownership manifest)
#   export ROOTFS_DIR=/usr/src/hammerhead/rootfs

set -e

PROTO_AREA="${PROTO_AREA:?PROTO_AREA must be set to hammerhead proto path}"

# Validate required directories
for dir in bin sbin lib usr etc var; do
    if [ ! -d "$PROTO_AREA/$dir" ]; then
        printf "ERROR: %s/%s does not exist\n" "$PROTO_AREA" "$dir"
        printf "Has the hammerhead build completed successfully?\n"
        exit 1
    fi
done

# Validate critical files
for f in lib/libc.so.1 lib/ld.so.1 sbin/init; do
    if [ ! -f "$PROTO_AREA/$f" ]; then
        printf "ERROR: %s not found in proto area\n" "$f"
        exit 1
    fi
done

# --- /bin (real directory with boot-essential commands) ---
printf "Packaging bin...\n"
mkdir -p "$PKGDIR/bin"
(cd "$PROTO_AREA/bin" && find . | cpio -pdm "$PKGDIR/bin" 2>/dev/null)

# --- /sbin (essential system commands) ---
printf "Packaging sbin...\n"
mkdir -p "$PKGDIR/sbin"
(cd "$PROTO_AREA/sbin" && find . | cpio -pdm "$PKGDIR/sbin" 2>/dev/null)

# --- /lib (essential libraries + SMF infrastructure) ---
printf "Packaging lib...\n"
mkdir -p "$PKGDIR/lib"
(cd "$PROTO_AREA/lib" && find . | cpio -pdm "$PKGDIR/lib" 2>/dev/null)

# --- /usr (commands, libraries, headers, man pages, data) ---
printf "Packaging usr...\n"
mkdir -p "$PKGDIR/usr"
(cd "$PROTO_AREA/usr" && find . | cpio -pdm "$PKGDIR/usr" 2>/dev/null)

# --- /etc (system configuration) ---
# Exclude system-specific runtime files that are populated at install time
# or by the kernel. These must NOT be overwritten on upgrade.
printf "Packaging etc...\n"
mkdir -p "$PKGDIR/etc"
(cd "$PROTO_AREA/etc" && find . \
    ! -name name_to_major \
    ! -name path_to_inst \
    ! -name driver_aliases \
    ! -name driver_classes \
    ! -name minor_perm \
    ! -name device.tab \
    ! -name devlink.tab \
    ! -name dacf.conf \
    ! -name iu.ap \
    ! -name mnttab \
    ! -name utmpx \
    ! -name wtmpx \
    | cpio -pdm "$PKGDIR/etc" 2>/dev/null)

# --- /var (state directories — mostly empty structure) ---
printf "Packaging var...\n"
mkdir -p "$PKGDIR/var"
(cd "$PROTO_AREA/var" && find . | cpio -pdm "$PKGDIR/var" 2>/dev/null)

# --- Apply rootfs overlay ---
# These are Hammerhead-specific config files that override proto defaults
if [ -n "$ROOTFS_DIR" ] && [ -d "$ROOTFS_DIR" ]; then
    printf "Applying rootfs overlay...\n"
    for overlay_dir in etc lib root; do
        if [ -d "$ROOTFS_DIR/$overlay_dir" ]; then
            (cd "$ROOTFS_DIR/$overlay_dir" && find . | cpio -pdm "$PKGDIR/$overlay_dir" 2>/dev/null)
        fi
    done
    # Copy .zshrc for root
    if [ -f "$ROOTFS_DIR/root/.zshrc" ]; then
        mkdir -p "$PKGDIR/root"
        cp "$ROOTFS_DIR/root/.zshrc" "$PKGDIR/root/.zshrc"
    fi
fi

# --- Remove items that should NOT be packaged ---
# Build tools
rm -rf "$PKGDIR/opt/onbld" 2>/dev/null || true
# Test suites (large, not needed on target)
rm -rf "$PKGDIR/opt/"*-tests 2>/dev/null || true
rm -rf "$PKGDIR/opt/test-runner" 2>/dev/null || true
# Build system remnants
rm -rf "$PKGDIR/usr/src" 2>/dev/null || true

# --- Apply ownership from manifest ---
if [ -n "$ROOTFS_DIR" ] && [ -f "$ROOTFS_DIR/ownership.manifest" ]; then
    printf "Applying ownership manifest...\n"

    # Phase 1: bulk defaults
    chown -R root:sys "$PKGDIR/"
    chown -R root:bin "$PKGDIR/bin" "$PKGDIR/sbin" \
        "$PKGDIR/usr/bin" "$PKGDIR/usr/sbin" \
        "$PKGDIR/usr/lib" "$PKGDIR/lib" 2>/dev/null || true

    # Phase 2: per-file overrides from manifest
    while IFS=' ' read -r path mode owner group; do
        # Skip comments and blank lines
        [[ -z "$path" || "$path" = \#* ]] && continue
        target="$PKGDIR$path"
        if [ -e "$target" ] || [ -L "$target" ]; then
            chmod "$mode" "$target" 2>/dev/null || true
            chown "$owner:$group" "$target" 2>/dev/null || true
        fi
    done < "$ROOTFS_DIR/ownership.manifest"
else
    # No manifest — apply bulk defaults only
    printf "WARNING: No ownership manifest found, applying bulk defaults\n"
    chown -R root:sys "$PKGDIR/"
    chown -R root:bin "$PKGDIR/bin" "$PKGDIR/sbin" \
        "$PKGDIR/usr/bin" "$PKGDIR/usr/sbin" \
        "$PKGDIR/usr/lib" "$PKGDIR/lib" 2>/dev/null || true
fi

# --- Create .CONFIG (config-protected files) ---
# These files will not be overwritten on upgrade if user has modified them.
# New versions are installed as <file>.pkg for manual merging.
cat > "$PKGDIR/.CONFIG" << 'EOF'
/etc/system
/etc/vfstab
/etc/passwd
/etc/shadow
/etc/group
/etc/hosts
/etc/inet/hosts
/etc/nsswitch.conf
/etc/resolv.conf
/etc/nodename
/etc/pam.conf
/etc/profile
/etc/zshenv
/etc/zshrc
/etc/zprofile
/etc/default/init
/etc/default/login
/etc/default/useradd
/etc/security/policy.conf
/etc/security/crypt.conf
/etc/crypto/pkcs11.conf
/etc/ssh/sshd_config
/etc/syslog.conf
/etc/sudoers.d/zygaena
/etc/svc/profile/site.xml
/etc/coral/coral.conf
EOF

# --- Post-install script ---
mkdir -p "$PKGDIR/.SCRIPTS"
cat > "$PKGDIR/.SCRIPTS/post-install.sh" << 'SCRIPT'
#!/bin/ksh93
# Refresh SMF repository if svc.configd is running (live system upgrade)
if [ -f /lib/svc/bin/svc.configd ]; then
    if pgrep -x svc.configd >/dev/null 2>&1; then
        printf "Refreshing SMF manifests...\n"
        svccfg import /lib/svc/manifest 2>/dev/null || true
    fi
fi
SCRIPT
chmod 755 "$PKGDIR/.SCRIPTS/post-install.sh"

# --- Summary ---
CMDS=0
for d in "$PKGDIR/bin" "$PKGDIR/sbin" "$PKGDIR/usr/bin" "$PKGDIR/usr/sbin"; do
    if [ -d "$d" ]; then
        n=$(find "$d" -type f | wc -l)
        CMDS=$((CMDS + n))
    fi
done
LIBS=$(find "$PKGDIR/lib" "$PKGDIR/usr/lib" -name "*.so.*" -type f 2>/dev/null | wc -l)
SIZE=$(du -sh "$PKGDIR" | cut -f1)
printf "Packaged %d commands, %d libraries (%s total)\n" "$CMDS" "$LIBS" "$SIZE"
# hammerhead-userland - Commands, libraries, headers, and system configuration
# https://git.sharkos.one/zygaena/hammerhead

[package]
name = "hammerhead-userland"
version = "0.1.0"
release = 1
description = "Hammerhead userland: commands, libraries, headers, and system configuration"
url = "https://git.sharkos.one/zygaena/hammerhead"
license = "CDDL-1.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"
conflicts = ["illumos-core", "illumos-libs", "illumos-utils", "illumos-config", "illumos-smf"]

[dependencies]
runtime = ["hammerhead-kernel"]
build = []

[build]
parallel = false
#!/bin/sh
# Xreset - runs as root at session end on display :0.
# Return console ownership to root (TakeConsole). Absolute paths.
/bin/chown root /dev/console
/bin/chmod 622 /dev/console
exit 0
Xcursor.theme: whiteglass

xlogin*login.translations: #override \
	Ctrl<Key>R: abort-display()\n\
	<Key>F1: set-session-argument(failsafe) finish-field()\n\
	<Key>Delete: delete-character()\n\
	<Key>Left: move-backward-character()\n\
	<Key>Right: move-forward-character()\n\
	<Key>Home: move-to-begining()\n\
	<Key>End: move-to-end()\n\
	Ctrl<Key>KP_Enter: set-session-argument(failsafe) finish-field()\n\
	<Key>KP_Enter: set-session-argument() finish-field()\n\
	Ctrl<Key>Return: set-session-argument(failsafe) finish-field()\n\
	<Key>Return: set-session-argument() finish-field()

! `CLIENTHOST` is an xdm token replaced with the system hostname at display
! time (dynamic per machine). Show ONLY the hostname -- deliberately NO
! "Welcome"/invitation language, which has been argued in unauthorized-access
! cases to imply an invitation. Branding lives on the wallpaper wordmark.
xlogin*greeting: CLIENTHOST
! The display IS access-controlled (start.sh starts Xorg with a MIT-MAGIC-COOKIE
! -auth file), but xdm does not track auth for a `foreign` display and would
! otherwise show its scary "This is an unsecure session". Use the same host text.
xlogin*unsecureGreeting: CLIENTHOST
xlogin*namePrompt: \040\040\040\040\040\040\040Login:
xlogin*passwdPrompt: \040\040\040\040Password:
! Mask the password with '*' (keystroke feedback; only exposes length).
xlogin*echoPasswd: true
xlogin*echoPasswdChar: *
xlogin*fail: Login incorrect or forbidden by policy

#if WIDTH > 800
xlogin*greetFont: -adobe-helvetica-bold-o-normal--24-240-75-75-p-138-iso8859-1
xlogin*font: -adobe-helvetica-medium-r-normal--18-180-75-75-p-98-iso8859-1
xlogin*promptFont: -adobe-helvetica-bold-r-normal--18-180-75-75-p-103-iso8859-1
xlogin*failFont: -adobe-helvetica-bold-r-normal--18-180-75-75-p-103-iso8859-1
xlogin*greetFace:	Serif-24:bold:italic
xlogin*face: 		Helvetica-18
xlogin*promptFace: 	Helvetica-18:bold
xlogin*failFace: 	Helvetica-18:bold
#else
xlogin*greetFont: -adobe-helvetica-bold-o-normal--17-120-100-100-p-92-iso8859-1
xlogin*font: -adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1
xlogin*promptFont: -adobe-helvetica-bold-r-normal--12-120-75-75-p-70-iso8859-1
xlogin*failFont: -adobe-helvetica-bold-o-normal--14-140-75-75-p-82-iso8859-1
xlogin*greetFace:	Serif-18:bold:italic
xlogin*face:		Helvetica-12
xlogin*promptFace:	Helvetica-12:bold
xlogin*failFace:	Helvetica-14:bold
#endif

#ifdef COLOR
! Zygaena marine-dark palette
!   bg      #0d1117  (deep marine)
!   text    #cfe0e0  (pale teal-grey)
!   accent  #1fb6b6  (teal - greeting/prompt/input)
!   input   #161b22  (slightly raised field)
!   fail    #ff5f56  (warning red)
xlogin*borderWidth: 1
xlogin*frameWidth: 4
xlogin*innerFramesWidth: 1
xlogin*shdColor:	#0a0d12
xlogin*hiColor:		#1c2530
xlogin*background:	#0d1117
xlogin*foreground:	#cfe0e0
xlogin*inpColor:	#161b22
xlogin*greetColor:	#1fb6b6
xlogin*promptColor:	#1fb6b6
xlogin*failColor:	#ff5f56
*Foreground:		#cfe0e0
*Background:		#0d1117
#else
xlogin*borderWidth: 3
xlogin*frameWidth: 0
xlogin*innerFramesWidth: 1
xlogin*shdColor: black
xlogin*hiColor: black
#endif
! Off-brand XLibre "X" logo hidden for now; a Zygaena mark (XPM) can be dropped
! in here later. No logoFileName => the greeter shows the login box only.
xlogin*useShape: true
xlogin*logoPadding: 10

! hh-greeter-power: Shutdown/Reboot button bar on the greeter (Zygaena teal).
HhGreeterPower*background:		#0d1117
HhGreeterPower*Box.background:		#0d1117
HhGreeterPower*Command.background:	#12303a
HhGreeterPower*Command.foreground:	#54e0e0
HhGreeterPower*Command.borderColor:	#1fb6b6
HhGreeterPower*Command.borderWidth:	1
HhGreeterPower*Command.internalWidth:	14
HhGreeterPower*Command.internalHeight:	8
HhGreeterPower*Command.font:		-*-helvetica-bold-r-normal-*-14-*-*-*-*-*-iso8859-1
! Confirmation dialog (Shut down? / Reboot?)
HhGreeterPower*Dialog.background:	#12303a
HhGreeterPower*Dialog.borderColor:	#1fb6b6
HhGreeterPower*Dialog.label.background:	#12303a
HhGreeterPower*Dialog.label.foreground:	#cfe0e0
HhGreeterPower*Dialog.label.font:	-*-helvetica-medium-r-normal-*-14-*-*-*-*-*-iso8859-1

XConsole.text.geometry:	480x130
XConsole.verbose:	true
XConsole*iconic:	true
XConsole*font:		fixed

Chooser*geometry:		700x500+300+200
Chooser*allowShellResize:	false
Chooser*viewport.forceBars:	true
Chooser*label.font:		*-new century schoolbook-bold-i-normal-*-240-*
Chooser*label.label:		XDMCP Host Menu from CLIENTHOST
Chooser*list.font:		-*-*-medium-r-normal-*-*-230-*-*-c-*-iso8859-1
Chooser*Command.font:		*-new century schoolbook-bold-r-normal-*-180-*
#
# Xservers file, Hammerhead workstation
#
# DECOUPLED: our zyginit start.sh launches Xorg itself (xdm-managed startup
# hangs on illumos VT acquisition). xdm therefore manages only the greeter +
# session on the already-running server, declared FOREIGN — xdm does not
# start or stop it. See DESKTOP_XLIBRE_XDM_GREETER_PLAN.md.
#
:0 foreign
#!/bin/sh
# Xsession - runs AS the authenticated user after login (xdm sets
# $USER/$HOME/$DISPLAY/$XAUTHORITY).
#
# Put the Hammerhead desktop config (shipped under /usr/local/etc/xdg) on the
# XDG search path so openbox/tint2/conky find the BRANDED config even for a
# fresh user with no ~/.config. Exported here so it is inherited by the whole
# session tree (including a user's own ~/.xsession, if any).
export XDG_CONFIG_DIRS="/usr/local/etc/xdg:${XDG_CONFIG_DIRS:-/etc/xdg}"
export XDG_DATA_DIRS="/usr/local/share:${XDG_DATA_DIRS:-/usr/share}"

# Seed ~/.config with the Hammerhead desktop defaults if absent, so the
# openbox autostart (tint2/conky/wallpaper) fires even for a fresh user.
/usr/local/bin/hh-desktop-init

# Prefer the user's own ~/.xsession; otherwise the Hammerhead Openbox session.
if [ -x "$HOME/.xsession" ]; then
	exec "$HOME/.xsession"
fi
exec /usr/local/bin/openbox-session
#!/bin/sh
# Xsetup_0 - branded backdrop drawn before the xlogin box appears.
# Runs as root on display :0. Absolute paths only.
#
# HOME: xdm's setup env is minimal; feh needs a HOME to read/write its config.
# XAUTHORITY: connect to the access-controlled (foreign) server started by
# the zyginit start.sh with our MIT-MAGIC-COOKIE.
export HOME=/root
export XAUTHORITY=/var/lib/xdm/authdir/authfiles/A:0

/usr/local/bin/xsetroot -solid "#0d1117"
[ -r /usr/local/share/backgrounds/hammerhead.png ] && \
	/usr/local/bin/feh --bg-fill /usr/local/share/backgrounds/hammerhead.png &

# Shutdown/Reboot button bar, bottom-right corner (no WM on the greeter).
# Killed by Xstartup on login so it never leaks into the user's session.
/usr/local/bin/hh-greeter-power -geometry -40-12 &
#!/bin/sh
# Xstartup - runs as root at session start on display :0.
# Give console ownership to the logging-in user (GiveConsole). Absolute paths.
/bin/chown "$USER" /dev/console
# Remove the greeter's Shutdown/Reboot button bar so it doesn't leak into the
# user's session (the foreign server is not reset on login).
/usr/bin/pkill -x hh-greeter-power 2>/dev/null
exit 0
#!/bin/sh
# Build script for hammerhead-xdm.
#
# No upstream tarball - all inputs are local files shipped alongside this
# script. This port overlays Hammerhead branding + X-server/session wiring
# onto the stock xdm defaults (installed under $PREFIX/lib/X11/xdm by the
# xdm port), and ships a DISABLED zyginit xdm service under /etc.
set -e

PORTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

# --- A. Config overlay -> $PREFIX/lib/X11/xdm/ ---
XDMDIR="$PKGDIR$PREFIX/lib/X11/xdm"
mkdir -p "$XDMDIR"

# Plain config files (mode 644).
install -m 644 "$PORTDIR/xdm-config" "$XDMDIR/xdm-config"
install -m 644 "$PORTDIR/Xservers"   "$XDMDIR/Xservers"
install -m 644 "$PORTDIR/Xresources" "$XDMDIR/Xresources"

# Executable X* hook scripts (mode 755).
install -m 755 "$PORTDIR/Xsetup_0" "$XDMDIR/Xsetup_0"
install -m 755 "$PORTDIR/Xsession" "$XDMDIR/Xsession"
install -m 755 "$PORTDIR/Xstartup" "$XDMDIR/Xstartup"
install -m 755 "$PORTDIR/Xreset"   "$XDMDIR/Xreset"

# --- A2. hh-greeter-power: Xaw Shutdown/Reboot button bar for the greeter ---
mkdir -p "$PKGDIR$PREFIX/bin"
gcc "$PORTDIR/hh-greeter-power.c" \
    -I"$PREFIX/include" -L"$PREFIX/lib" -R"$PREFIX/lib" \
    -lXaw7 -lXmu -lXt -lX11 \
    -o "$PKGDIR$PREFIX/bin/hh-greeter-power"

# --- B. zyginit service (shipped DISABLED) -> /etc/zyginit/services/xdm/ ---
# Absolute /etc, OUTSIDE $PREFIX. No enabled.d symlink is created.
SVCDIR="$PKGDIR/etc/zyginit/services/xdm"
mkdir -p "$SVCDIR"
install -m 644 "$PORTDIR/service.toml" "$SVCDIR/service.toml"
install -m 755 "$PORTDIR/start.sh"     "$SVCDIR/start.sh"
/*
 * hh-greeter-power.c - a tiny Athena (Xaw) button bar with Shutdown and
 * Reboot buttons for the xdm greeter, each guarded by a confirmation popup.
 *
 * xdm's classic xlogin greeter has no power buttons, and the greeter display
 * runs with no window manager. This standalone client is launched by
 * Xsetup_0 (as root, so `zygctl poweroff`/`reboot` have the privilege to run)
 * and killed by Xstartup when a session begins, so it never leaks into the
 * user's desktop. Styling comes from the HhGreeterPower* resources in
 * Xresources (loaded by xrdb); placement from the -geometry Xsetup_0 passes.
 *
 * Build: cc hh-greeter-power.c -I$PREFIX/include -L$PREFIX/lib -R$PREFIX/lib \
 *        -lXaw7 -lXmu -lXt -lX11 -o hh-greeter-power
 */
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
#include <X11/Xaw/Box.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/Dialog.h>
#include <stdlib.h>

static Widget toplevel;
static Widget confirm_popup = NULL;
static const char *pending_cmd = NULL;

static void
dismiss(void)
{
    if (confirm_popup != NULL) {
        XtPopdown(confirm_popup);
        XtDestroyWidget(confirm_popup);
        confirm_popup = NULL;
    }
}

static void
do_it(Widget w, XtPointer client, XtPointer call)
{
    (void) w; (void) client; (void) call;
    if (pending_cmd != NULL)
        (void) system(pending_cmd);   /* machine goes down; no return expected */
    dismiss();
}

static void
cancel(Widget w, XtPointer client, XtPointer call)
{
    (void) w; (void) client; (void) call;
    dismiss();
}

/* Pop a centered confirmation dialog for a power action. */
static void
confirm(const char *prompt, const char *cmd, const char *okLabel)
{
    Widget dlg;
    Dimension pw, ph;
    Position px, py;
    int sw, sh;

    dismiss();                 /* only one popup at a time */
    pending_cmd = cmd;

    confirm_popup = XtVaCreatePopupShell("confirm",
        transientShellWidgetClass, toplevel, (char *)NULL);
    dlg = XtVaCreateManagedWidget("dialog", dialogWidgetClass, confirm_popup,
        XtNlabel, prompt, (char *)NULL);
    XawDialogAddButton(dlg, okLabel, do_it, NULL);
    XawDialogAddButton(dlg, "Cancel", cancel, NULL);

    /* Center on screen (no window manager to place it). */
    XtRealizeWidget(confirm_popup);
    XtVaGetValues(confirm_popup, XtNwidth, &pw, XtNheight, &ph, (char *)NULL);
    sw = WidthOfScreen(XtScreen(toplevel));
    sh = HeightOfScreen(XtScreen(toplevel));
    px = (Position)((sw - (int)pw) / 2);
    py = (Position)((sh - (int)ph) / 2);
    XtVaSetValues(confirm_popup, XtNx, px, XtNy, py, (char *)NULL);
    XtPopup(confirm_popup, XtGrabExclusive);
}

static void
shutdown_cb(Widget w, XtPointer client, XtPointer call)
{
    (void) w; (void) client; (void) call;
    confirm("Shut down this system?", "/sbin/zygctl poweroff", "Shut down");
}

static void
reboot_cb(Widget w, XtPointer client, XtPointer call)
{
    (void) w; (void) client; (void) call;
    confirm("Reboot this system?", "/sbin/zygctl reboot", "Reboot");
}

int
main(int argc, char **argv)
{
    XtAppContext app;
    Widget box, sd, rb;

    toplevel = XtOpenApplication(&app, "HhGreeterPower", NULL, 0, &argc, argv,
        NULL, applicationShellWidgetClass, NULL, 0);

    box = XtVaCreateManagedWidget("box", boxWidgetClass, toplevel,
        XtNorientation, XtorientHorizontal, (char *)NULL);

    sd = XtVaCreateManagedWidget("Shutdown", commandWidgetClass, box,
        (char *)NULL);
    XtAddCallback(sd, XtNcallback, shutdown_cb, NULL);

    rb = XtVaCreateManagedWidget("Reboot", commandWidgetClass, box,
        (char *)NULL);
    XtAddCallback(rb, XtNcallback, reboot_cb, NULL);

    XtRealizeWidget(toplevel);
    XtAppMainLoop(app);
    return 0;
}
# hammerhead-xdm - Zygaena branding + X-server/session wiring overlaid onto
# xdm's installed default config, plus Hammerhead's first port-provided
# zyginit service (shipped DISABLED).
#
# No upstream source: all inputs are local config files shipped alongside
# build.sh. This port depends on xdm (which installs the stock defaults we
# overlay) and hammerhead-desktop (Openbox session + branded backdrop).
# See build.sh and docs/roadmap/DESKTOP_XLIBRE_XDM_GREETER_PLAN.md.

[package]
name = "hammerhead-xdm"
version = "1.0.0"
release = 12
description = "Zygaena marine-dark xdm greeter branding, system Xsession/Xservers wiring, and a disabled zyginit xdm service"
url = "https://git.sharkos.one/zygaena/hammerhead"
license = "CDDL-1.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
# xsetroot: Xsetup_0 paints a solid backdrop; xrdb: xdm loads the branded
# Xresources onto the greeter; xauth: start.sh sets the MIT-MAGIC-COOKIE for
# the decoupled (foreign) server (release 3).
runtime = ["xdm", "hammerhead-desktop", "xsetroot", "xrdb", "xauth"]
# libXaw/libXt/libXmu: to compile hh-greeter-power (the greeter's Xaw
# Shutdown/Reboot button bar).
build = ["libXaw", "libXt", "libXmu", "libX11"]

[build]
parallel = false
# Hammerhead's first port-provided zyginit service.
# Graphical login via xdm on the console framebuffer. Runs as ROOT (xdm
# itself drops privileges per session), so NO `user` field. Shipped
# DISABLED: this port creates no /etc/zyginit/enabled.d/xdm symlink.
#
# Coexists with console-login: the decoupled X server lives on its own VT
# (vtdaemon holds vt1, X gets vt2), so it does NOT contend for /dev/console.
# Ctrl-Alt-F# switches between the greeter (vt2) and the text consoles.
[service]
name = "xdm"
description = "Graphical login (xdm on the console framebuffer)"
type = "daemon"
[exec]
start = "/etc/zyginit/services/xdm/start.sh"
[dependencies]
# vtdaemon MUST be up first: it configures the kernel VT subsystem, without
# which Xorg's VT_WAITACTIVE bring-up hangs (started with no ctty by zyginit).
requires = ["utmpd", "filesystem", "vtdaemon"]
after = ["devfs"]
[contract]
param = ["inherit", "noorphan"]
fatal = ["hwerr"]
[restart]
on = "failure"
delay = 5
max_retries = 3
#!/bin/zsh
# zyginit start hook for the Hammerhead xdm graphical login.
#
# DECOUPLED server model: xdm-managed X-server startup hangs on illumos VT
# acquisition ("using VT number 2" never completes) — while a separately
# started server works fine. So we start our own Xorg here (the proven M2/M3
# launch), then run xdm against it as a FOREIGN display (xdm draws only the
# greeter + runs the session; it does not start/stop the server). See
# docs/roadmap/DESKTOP_XLIBRE_XDM_GREETER_PLAN.md.
#
# MIT-MAGIC-COOKIE-1 access control so the display is authorized (no
# "unsecure session" warning). Absolute paths only (zyginit convention).
set -u

XAUTHDIR=/var/lib/xdm/authdir/authfiles
XAUTH="$XAUTHDIR/A:0"

# Robustness: a crashed prior instance (or a zyginit restart whose
# backgrounded Xorg orphaned past the contract teardown) can leave a stale
# server, X lock, or xdm pid file. Clear them first so a restart does NOT
# accumulate X servers. We are still zsh here (xdm is exec'd at the end), so
# pkill xdm cannot hit this script.
/usr/bin/pkill -9 -x Xorg 2>/dev/null
/usr/bin/pkill -9 -x xdm 2>/dev/null
/bin/sleep 1

/bin/mkdir -p "$XAUTHDIR"
/bin/rm -f "$XAUTH" /var/run/xdm.pid /tmp/.X0-lock /tmp/.X11-unix/X0 2>/dev/null

# Fresh cookie, shared between the server (-auth) and every X client via
# XAUTHORITY (xdm greeter, Xsetup, and the user session all inherit it).
COOKIE=$(/usr/bin/openssl rand -hex 16)
/usr/local/bin/xauth -f "$XAUTH" add :0 . "$COOKIE"
export XAUTHORITY="$XAUTH"

# Start Xorg with auth, in the background (the launch that works on our console).
/usr/local/bin/Xorg :0 -nolisten tcp -auth "$XAUTH" -config /etc/X11/xorg.conf &

# Wait for the server socket (illumos has no seq/timeout(1)).
i=0
while [ ! -S /tmp/.X11-unix/X0 ] && [ "$i" -lt 60 ]; do /bin/sleep 0.25; i=$((i + 1)); done
/bin/sleep 1

# Run xdm on the foreign, authorized server. exec so zyginit supervises xdm;
# Xorg is in the same process contract and is torn down with the service.
exec /usr/local/bin/xdm -nodaemon -config /usr/local/lib/X11/xdm/xdm-config
!
! Hammerhead xdm-config: overlaid onto the stock xdm default. Only the
! display-:0 startup/reset hooks are re-pointed at our Xstartup/Xreset
! (GiveConsole/TakeConsole console-ownership handling); the setup, session,
! and resources hooks already reference the paths we ship. XDMCP stays OFF.
!
DisplayManager.authDir:	/var/lib/xdm
DisplayManager.errorLogFile:	/var/log/xdm.log
DisplayManager.pidFile:		/var/run/xdm.pid
DisplayManager.keyFile:		/usr/local/lib/X11/xdm/xdm-keys
DisplayManager.servers:		/usr/local/lib/X11/xdm/Xservers
DisplayManager.accessFile:	/usr/local/lib/X11/xdm/Xaccess
DisplayManager*resources:	/usr/local/lib/X11/xdm/Xresources
DisplayManager.willing:		su nobody -s /bin/sh -c /usr/local/lib/X11/xdm/Xwilling
! All displays should use authorization, but we cannot be sure
! X terminals may not be configured that way, so they will require
! individual resource settings.
DisplayManager*authorize:	true
!
DisplayManager*chooser:		/usr/local/lib/X11/xdm/chooser
DisplayManager*startup:		/usr/local/lib/X11/xdm/Xstartup
DisplayManager*session:		/usr/local/lib/X11/xdm/Xsession
DisplayManager*reset:		/usr/local/lib/X11/xdm/Xreset
DisplayManager*authComplain:	true
! The following resources set up display :0 as the console.
DisplayManager._0.setup:	/usr/local/lib/X11/xdm/Xsetup_0
DisplayManager._0.startup:	/usr/local/lib/X11/xdm/Xstartup
DisplayManager._0.reset:	/usr/local/lib/X11/xdm/Xreset
DisplayManager._0.session:	/usr/local/lib/X11/xdm/Xsession
DisplayManager*loginmoveInterval:	10
! SECURITY: do not listen for XDMCP or Chooser requests
! Comment out this line if you want to manage X terminals with xdm
DisplayManager.requestPort:	0
#!/bin/sh
# Build script for harfbuzz (Meson, Template B).
# Deps: freetype, glib2 (both ported). cairo/icu support disabled (cairo
# isn't built yet at this point in the order, and ICU isn't ported/needed).
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -D__EXTENSIONS__"
export LDFLAGS="${LDFLAGS} -Wl,-R,$PREFIX/lib"

meson setup build \
    --prefix="$PREFIX" \
    --libdir=lib \
    --buildtype=release \
    -Ddefault_library=shared \
    -Dtests=disabled \
    -Ddocs=disabled \
    -Dfreetype=enabled \
    -Dglib=enabled \
    -Dcairo=disabled \
    -Dicu=disabled

ninja -C build -j${JOBS:-1}
DESTDIR="$PKGDIR" ninja -C build install
# harfbuzz - text shaping engine (pango dep)
# https://github.com/harfbuzz/harfbuzz
#
# NOTE: freetype was built WITHOUT harfbuzz (Task 5, --with-harfbuzz=no)
# to break the freetype<->harfbuzz circular dependency at bootstrap.
# harfbuzz->freetype is the one-way edge here; do NOT rebuild freetype.

[package]
name = "harfbuzz"
version = "14.2.1"
release = 1
description = "Text shaping engine"
url = "https://harfbuzz.github.io/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["freetype", "glib2"]
build = ["freetype", "glib2"]

[[source]]
file = "harfbuzz-14.2.1.tar.xz"
urls = ["https://github.com/harfbuzz/harfbuzz/releases/download/14.2.1/harfbuzz-14.2.1.tar.xz"]
checksum = "a54a5d8e9380a41fbb762ce367bcbf7704792dfca0d93f1bbca86c5a57902e0e"

[build]
parallel = true
#!/bin/sh
# Build script for imlib2 (autotools, Template A).
# NOTE: imlib2's optional loaders (gif/tiff/webp/heif/jxl/...) are each
# auto-probed via AC_CHECK_LIB/pkg-config in configure.ac - there are no
# --without-<format> flags to pass. Since none of those libs are ported to
# Hammerhead yet, the loaders auto-disable and only png/jpeg (both present)
# get built.
#
# REVISED (Task 1b-3, 2026-07-22): originally built --without-x on the
# assumption that "X11 client apps link libX11 themselves" - WRONG. imlib2's
# X11 support (gated by AC_PATH_XTRA/BUILD_X11) is not just SHM plumbing; it
# ships the imlib_context_set_{display,visual,colormap,drawable}() /
# imlib_render_image_on_drawable*() / imlib_create_image_from_drawable() API
# that feh (wallpaper-setting) and other imlib2 consumers (tint2's
# IMLIB2>=1.4.2 dep) call directly. --without-x drops those symbols entirely,
# so feh failed to link ("undefined reference to imlib_context_set_drawable"
# etc). Enable X11 support instead (needs no explicit flag - AC_PATH_XTRA
# auto-detects libX11 under $PREFIX via the CFLAGS/LDFLAGS -I/-L already
# exported below).
set -e
cd "$SRCDIR"

# MANDATORY libtool fix - see Template A comment in DESKTOP_XLIBRE_PHASE1A_PLAN.md.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --with-x

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# imlib2 - image loading/rendering library (tint2, feh, conky)
# https://docs.enlightenment.org/api/imlib2/html/

[package]
name = "imlib2"
version = "1.12.6"
release = 1
description = "Image loading, saving, rendering and manipulation library"
url = "https://sourceforge.net/projects/enlightenment/files/imlib2-src/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libpng", "libjpeg-turbo", "freetype"]
build = ["libpng", "libjpeg-turbo", "freetype"]

[[source]]
file = "imlib2-1.12.6.tar.xz"
urls = ["https://downloads.sourceforge.net/enlightenment/imlib2-1.12.6.tar.xz"]
checksum = "250f9752f69dc522e529a81aaa9395705f7fc312ff2453e5de59ac2ba1f2858f"

[build]
parallel = true
#!/bin/sh
set -e
cd "$SRCDIR"

export CFLAGS="${CFLAGS} -I/usr/local/include"
export LDFLAGS="${LDFLAGS} -L/usr/local/lib -R/usr/local/lib"

./configure \
    --prefix=$PREFIX \
    --build=$BUILD_TRIPLE \
    --host=$BUILD_TRIPLE \
    --sysconfdir=$SYSCONFDIR \
    --with-regex=posix

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# less - Terminal pager program
# https://www.greenwoodsoftware.com/less/

[package]
name = "less"
version = "692"
release = 1
description = "Terminal pager program similar to more"
url = "https://www.greenwoodsoftware.com/less/"
license = "GPL-3.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["ncurses"]
build = ["ncurses"]

[[source]]
file = "less-692.tar.gz"
urls = ["https://greenwoodsoftware.com/less/less-692.tar.gz"]
checksum = "61300f603798ecf1d7786570789f0ff3f5a1acf075a6fb9f756837d166e37d14"


[build]
parallel = true
#!/bin/sh
# Build script for libICE (autotools, Template A + custom).
# illumos note (brief/manifest): if configure/link fails on socket symbols
# (socket/connect/etc.), add -lsocket -lnsl to LDFLAGS. Added defensively
# up front (same pattern as libX11's build.sh in Task 4a) since ICE opens
# raw sockets directly.
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib -lsocket -lnsl"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libICE - Inter-Client Exchange library
# https://gitlab.freedesktop.org/xorg/lib/libice

[package]
name = "libICE"
version = "1.1.2"
release = 1
description = "Inter-Client Exchange library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = ["xorgproto", "util-macros"]

[[source]]
file = "libICE-1.1.2.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libICE-1.1.2.tar.xz"]
checksum = "974e4ed414225eb3c716985df9709f4da8d22a67a2890066bc6dfc89ad298625"

[build]
parallel = true
#!/bin/sh
# Build script for libSM (autotools, Template A).
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libSM - Session Management library
# https://gitlab.freedesktop.org/xorg/lib/libsm

[package]
name = "libSM"
version = "1.2.6"
release = 1
description = "Session Management library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libICE"]
build = ["libICE", "xorgproto", "util-macros"]

[[source]]
file = "libSM-1.2.6.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libSM-1.2.6.tar.xz"]
checksum = "be7c0abdb15cbfd29ac62573c1c82e877f9d4047ad15321e7ea97d1e43d835be"

[build]
parallel = true
#!/bin/sh
# Build script for libX11 (autotools, Template A + custom). LARGE build.
# Needs python3 (xcb-proto's xcbgen) for some codegen paths; --enable-xcms
# --enable-xkb per Task 4a brief. illumos socket symbols (Xtrans) may need
# -lsocket -lnsl - added defensively; harmless no-op if unused.
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib -lsocket -lnsl"
export PYTHON=/usr/local/bin/python3

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --enable-xcms \
    --enable-xkb

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libX11 - Core X11 protocol client library
# https://gitlab.freedesktop.org/xorg/lib/libx11

[package]
name = "libX11"
version = "1.8.13"
release = 1
description = "Core X11 protocol client library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libxcb", "libXau", "libXdmcp"]
build = ["libxcb", "libXau", "libXdmcp", "xtrans", "xorgproto", "xcb-proto"]

[[source]]
file = "libX11-1.8.13.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libX11-1.8.13.tar.xz"]
checksum = "69606f485c2c07c14ef64f75b7bb326d48587af33795d9ab3e607c0b5f94f11c"

[build]
parallel = true
#!/bin/sh
# Build script for libXau (autotools, Template A).
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies). Verified this
# alone flips "checking if libtool supports shared libraries" from no to
# yes and produces a real libFoo.so.N.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXau - X Authority database library
# https://gitlab.freedesktop.org/xorg/lib/libxau

[package]
name = "libXau"
version = "1.0.12"
release = 1
description = "X Authority database library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = ["xorgproto", "util-macros"]

[[source]]
file = "libXau-1.0.12.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXau-1.0.12.tar.xz"]
checksum = "74d0e4dfa3d39ad8939e99bda37f5967aba528211076828464d2777d477fc0fb"

[build]
parallel = true
#!/bin/sh
# Build script for libXaw (autotools, Template A).
set -e
cd "$SRCDIR"

# GOTCHA (see libXmu build.sh, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXaw - X Athena Widget library
# https://gitlab.freedesktop.org/xorg/lib/libxaw

[package]
name = "libXaw"
version = "1.0.16"
release = 1
description = "X Athena Widget library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libXt", "libXmu", "libXpm", "libX11", "libXext"]
build = ["libXt", "libXmu", "libXpm", "libX11", "libXext", "xorgproto", "util-macros"]

[[source]]
file = "libXaw-1.0.16.tar.xz"
urls = ["https://xorg.freedesktop.org/archive/individual/lib/libXaw-1.0.16.tar.xz"]
checksum = "731d572b54c708f81e197a6afa8016918e2e06dfd3025e066ca642a5b8c39c8f"

[build]
parallel = true
#!/bin/sh
# Build script for libXcomposite (autotools, Template A).
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXcomposite - X Composite extension client library
# https://gitlab.freedesktop.org/xorg/lib/libxcomposite

[package]
name = "libXcomposite"
version = "0.4.7"
release = 1
description = "X Composite extension client library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libXfixes", "libX11"]
build = ["libXfixes", "libX11", "xorgproto", "util-macros"]

[[source]]
file = "libXcomposite-0.4.7.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXcomposite-0.4.7.tar.xz"]
checksum = "8bdf310967f484503fa51714cf97bff0723d9b673e0eecbf92b3f97c060c8ccb"

[build]
parallel = true
#!/bin/sh
# Build script for libXcursor (autotools, Template A).
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXcursor - X client-side cursor loading library
# https://gitlab.freedesktop.org/xorg/lib/libxcursor

[package]
name = "libXcursor"
version = "1.2.3"
release = 1
description = "X client-side cursor loading library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libXrender", "libXfixes", "libX11"]
build = ["libXrender", "libXfixes", "libX11", "xorgproto", "util-macros"]

[[source]]
file = "libXcursor-1.2.3.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXcursor-1.2.3.tar.xz"]
checksum = "fde9402dd4cfe79da71e2d96bb980afc5e6ff4f8a7d74c159e1966afb2b2c2c0"

[build]
parallel = true
#!/bin/sh
# Build script for libXdamage (autotools, Template A).
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXdamage - X Damage extension client library
# https://gitlab.freedesktop.org/xorg/lib/libxdamage

[package]
name = "libXdamage"
version = "1.1.7"
release = 1
description = "X Damage extension client library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11", "libXfixes"]
build = ["libX11", "libXfixes", "xorgproto", "util-macros"]

[[source]]
file = "libXdamage-1.1.7.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXdamage-1.1.7.tar.xz"]
checksum = "127067f521d3ee467b97bcb145aeba1078e2454d448e8748eb984d5b397bde24"

[build]
parallel = true
#!/bin/sh
# Build script for libXdmcp (autotools, Template A).
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXdmcp - X Display Manager Control Protocol library
# https://gitlab.freedesktop.org/xorg/lib/libxdmcp

[package]
name = "libXdmcp"
version = "1.1.5"
release = 1
description = "X Display Manager Control Protocol library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = ["xorgproto", "util-macros"]

[[source]]
file = "libXdmcp-1.1.5.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXdmcp-1.1.5.tar.xz"]
checksum = "d8a5222828c3adab70adf69a5583f1d32eb5ece04304f7f8392b6a353aa2228c"

[build]
parallel = true
#!/bin/sh
# Build script for libXext (autotools, Template A).
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXext - X11 miscellaneous extension library
# https://gitlab.freedesktop.org/xorg/lib/libxext

[package]
name = "libXext"
version = "1.3.7"
release = 1
description = "X11 miscellaneous extension library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11"]
build = ["libX11", "xorgproto", "xtrans", "util-macros"]

[[source]]
file = "libXext-1.3.7.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXext-1.3.7.tar.xz"]
checksum = "6c643c7035cdacf67afd68f25d01b90ef889d546c9fcd7c0adf7c2cf91e3a32d"

[build]
parallel = true
#!/bin/sh
# Build script for libXfixes (autotools, Template A).
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXfixes - X Fixes extension client library
# https://gitlab.freedesktop.org/xorg/lib/libxfixes

[package]
name = "libXfixes"
version = "6.0.2"
release = 1
description = "X Fixes extension client library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11"]
build = ["libX11", "xorgproto", "util-macros"]

[[source]]
file = "libXfixes-6.0.2.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXfixes-6.0.2.tar.xz"]
checksum = "39f115d72d9c5f8111e4684164d3d68cc1fd21f9b27ff2401b08fddfc0f409ba"

[build]
parallel = true
#!/bin/sh
# Build script for libXfont2 (autotools, Template A).
set -e
cd "$SRCDIR"

if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXfont2 - X font rasterization library (xlibre-server CDEPEND >=2.0.1)
# https://gitlab.freedesktop.org/xorg/lib/libxfont

[package]
name = "libXfont2"
version = "2.0.8"
release = 1
description = "X font rasterization library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["freetype", "libfontenc"]
build = ["freetype", "libfontenc", "xtrans", "xorgproto", "util-macros"]

[[source]]
file = "libXfont2-2.0.8.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXfont2-2.0.8.tar.xz"]
checksum = "f556c0e1093a4e6911cc90bc4b106d201902ee187fd74af206ff162f7e6a24d5"

[build]
parallel = true
#!/bin/sh
# Build script for libXft (autotools, Template A).
set -e
cd "$SRCDIR"

if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXft - client-side font rendering (Xft) for X11
# https://gitlab.freedesktop.org/xorg/lib/libxft

[package]
name = "libXft"
version = "2.3.9"
release = 1
description = "Xft client-side font rendering library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11", "libXrender", "freetype", "fontconfig"]
build = ["libX11", "libXrender", "freetype", "fontconfig", "xorgproto", "util-macros"]

[[source]]
file = "libXft-2.3.9.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXft-2.3.9.tar.xz"]
checksum = "60a25b78945ed6932635b3bb1899a517d31df7456e69867ffba27f89ff3976f5"

[build]
parallel = true
#!/bin/sh
# Build script for libXi (autotools, Template A).
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXi - X Input extension client library
# https://gitlab.freedesktop.org/xorg/lib/libxi

[package]
name = "libXi"
version = "1.8.3"
release = 1
description = "X Input extension client library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libXext", "libXfixes", "libX11"]
build = ["libXext", "libXfixes", "libX11", "xorgproto", "util-macros"]

[[source]]
file = "libXi-1.8.3.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXi-1.8.3.tar.xz"]
checksum = "7ad60056f01af4f786cfe93b3a7707447711626fc8da2637bec71a90409babe5"

[build]
parallel = true
#!/bin/sh
# Build script for libXinerama (autotools, Template A).
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXinerama - Xinerama extension client library
# https://gitlab.freedesktop.org/xorg/lib/libxinerama

[package]
name = "libXinerama"
version = "1.1.6"
release = 1
description = "Xinerama extension client library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libXext", "libX11"]
build = ["libXext", "libX11", "xorgproto", "util-macros"]

[[source]]
file = "libXinerama-1.1.6.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXinerama-1.1.6.tar.xz"]
checksum = "d00fc1599c303dc5cbc122b8068bdc7405d6fcb19060f4597fc51bd3a8be51d7"

[build]
parallel = true
#!/bin/sh
# Build script for libXmu (autotools, Template A).
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXmu - X miscellaneous utility library
# https://gitlab.freedesktop.org/xorg/lib/libxmu

[package]
name = "libXmu"
version = "1.3.1"
release = 1
description = "X miscellaneous utility library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libXt", "libXext", "libX11"]
build = ["libXt", "libXext", "libX11", "xorgproto", "util-macros"]

[[source]]
file = "libXmu-1.3.1.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXmu-1.3.1.tar.xz"]
checksum = "81a99e94c4501e81c427cbaa4a11748b584933e94b7a156830c3621256857bc4"

[build]
parallel = true
#!/bin/sh
# Build script for libXpm (autotools, Template A + custom).
# --disable-open-zfile per brief: avoids a gzip-helper-path probe in
# configure that has tripped on non-Linux hosts.
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --disable-open-zfile

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXpm - X Pixmap library (Openbox theme/icon support)
# https://gitlab.freedesktop.org/xorg/lib/libxpm

[package]
name = "libXpm"
version = "3.5.19"
release = 1
description = "X Pixmap library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11", "libXt", "libXext"]
build = ["libX11", "libXt", "libXext", "xorgproto", "util-macros"]

[[source]]
file = "libXpm-3.5.19.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXpm-3.5.19.tar.xz"]
checksum = "ad3576d689221a39dc728f0e0dc02ca7bb6a0d724c9a77fd1bfa1e9af83be900"

[build]
parallel = true
#!/bin/sh
# Build script for libXrandr (autotools, Template A).
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXrandr - X Resize, Rotate and Reflection extension client library
# https://gitlab.freedesktop.org/xorg/lib/libxrandr

[package]
name = "libXrandr"
version = "1.5.5"
release = 1
description = "X Resize, Rotate and Reflection extension client library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libXrender", "libXext", "libX11"]
build = ["libXrender", "libXext", "libX11", "xorgproto", "util-macros"]

[[source]]
file = "libXrandr-1.5.5.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXrandr-1.5.5.tar.xz"]
checksum = "72b922c2e765434e9e9f0960148070bd4504b288263e2868a4ccce1b7cf2767a"

[build]
parallel = true
#!/bin/sh
# Build script for libXrender (autotools, Template A).
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXrender - X Rendering Extension client library
# https://gitlab.freedesktop.org/xorg/lib/libxrender

[package]
name = "libXrender"
version = "0.9.12"
release = 1
description = "X Rendering Extension client library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11"]
build = ["libX11", "xorgproto", "util-macros"]

[[source]]
file = "libXrender-0.9.12.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXrender-0.9.12.tar.xz"]
checksum = "b832128da48b39c8d608224481743403ad1691bf4e554e4be9c174df171d1b97"

[build]
parallel = true
#!/bin/sh
# Build script for libXt (autotools, Template A).
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXt - X Toolkit Intrinsics library
# https://gitlab.freedesktop.org/xorg/lib/libxt

[package]
name = "libXt"
version = "1.3.1"
release = 1
description = "X Toolkit Intrinsics library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libSM", "libICE", "libX11"]
build = ["libSM", "libICE", "libX11", "xorgproto", "util-macros"]

[[source]]
file = "libXt-1.3.1.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXt-1.3.1.tar.xz"]
checksum = "e0a774b33324f4d4c05b199ea45050f87206586d81655f8bef4dba434d931288"

[build]
parallel = true
#!/bin/sh
# Build script for libXtst (autotools, Template A).
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libXtst - X Test extension client library (input injection, used by x11vnc)
# https://gitlab.freedesktop.org/xorg/lib/libxtst

[package]
name = "libXtst"
version = "1.2.5"
release = 1
description = "X Test extension client library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libXi", "libXext", "libX11"]
build = ["libXi", "libXext", "libX11", "xorgproto", "util-macros"]

[[source]]
file = "libXtst-1.2.5.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libXtst-1.2.5.tar.xz"]
checksum = "b50d4c25b97009a744706c1039c598f4d8e64910c9fde381994e1cae235d9242"

[build]
parallel = true
#!/bin/sh
# Build script for libconfig (autotools, Template A). No deps.
set -e
cd "$SRCDIR"

if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libconfig - C/C++ library for structured configuration files (picom)
# https://hyperrealm.github.io/libconfig/

[package]
name = "libconfig"
version = "1.7.3"
release = 1
description = "C/C++ library for processing structured configuration files"
url = "https://hyperrealm.github.io/libconfig/"
license = "LGPL-2.1-or-later"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "libconfig-1.7.3.tar.gz"
urls = ["https://github.com/hyperrealm/libconfig/releases/download/v1.7.3/libconfig-1.7.3.tar.gz"]
checksum = "545166d6cac037744381d1e9cc5a5405094e7bfad16a411699bcff40bbb31ee7"

[build]
parallel = true
#!/bin/bash
# Build script for libedit

set -e
cd "$SRCDIR"

./configure \
    --prefix=$PREFIX \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libedit - BSD editline library
# https://thrysoee.dk/editline/

[package]
name = "libedit"
version = "20240808-3.1"
release = 1
description = "BSD editline and history libraries"
url = "https://thrysoee.dk/editline/"
license = "BSD-3-Clause"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["ncurses"]
build = ["ncurses"]

[[source]]
file = "libedit-20240808-3.1.tar.gz"
urls = ["https://thrysoee.dk/editline/libedit-20240808-3.1.tar.gz"]
checksum = "5f0573349d77c4a48967191cdd6634dd7aa5f6398c6a57fe037cc02696d6099f"

[build]
parallel = true
#!/bin/sh
# Build script for libev (autotools, Template A). No deps. Ships no .pc
# upstream - picom and other consumers locate it via ev.h/-lev directly.
set -e
cd "$SRCDIR"

if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libev - high-performance event loop library (picom)
# http://software.schmorp.de/pkg/libev.html

[package]
name = "libev"
version = "4.33"
release = 1
description = "High-performance full-featured event loop"
url = "http://software.schmorp.de/pkg/libev.html"
license = "BSD-2-Clause OR GPL-2.0-or-later"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "libev-4.33.tar.gz"
urls = ["http://dist.schmorp.de/libev/Attic/libev-4.33.tar.gz"]
checksum = "507eb7b8d1015fbec5b935f34ebed15bf346bed04a11ab82b8eee848c4205aea"

[build]
parallel = true
#!/bin/zsh
# Build script for libevent
set -e
cd "$SRCDIR"

./configure \
    --prefix=$PREFIX \
    --disable-samples \
    --disable-openssl

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libevent - Event notification library
# https://libevent.org/

[package]
name = "libevent"
version = "2.1.12"
release = 1
description = "Event notification library for developing scalable network servers"
url = "https://libevent.org/"
license = "BSD-3-Clause"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "libevent-2.1.12-stable.tar.gz"
urls = ["https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz"]
checksum = "92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb"


[build]
parallel = true
#!/bin/bash
# Build script for libffi

set -e
cd "$SRCDIR"

./configure \
    --prefix=$PREFIX \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libffi - Foreign Function Interface library
# https://sourceware.org/libffi/

[package]
name = "libffi"
version = "3.4.7"
release = 1
description = "Portable foreign function interface library"
url = "https://sourceware.org/libffi/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "libffi-3.4.7.tar.gz"
urls = [
    "https://github.com/libffi/libffi/releases/download/v3.4.7/libffi-3.4.7.tar.gz",
    "https://sourceware.org/pub/libffi/libffi-3.4.7.tar.gz"
]
checksum = "138607dee268bdecf374adf9144c00e839e38541f75f24a1fcf18b78fda48b2d"

[build]
parallel = true
#!/bin/sh
# Build script for libfontenc (autotools, Template A). zlib is PRESENT
# in base.
set -e
cd "$SRCDIR"

if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libfontenc - X font encoding library
# https://gitlab.freedesktop.org/xorg/lib/libfontenc

[package]
name = "libfontenc"
version = "1.1.9"
release = 1
description = "X font encoding library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = ["xorgproto", "util-macros"]

[[source]]
file = "libfontenc-1.1.9.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libfontenc-1.1.9.tar.xz"]
checksum = "9d8392705cb10803d5fe1d27d236cbab3f664e26841ce01916bbbe430cf273e2"

[build]
parallel = true
#!/bin/sh
# Build script for libjpeg-turbo (CMake, Ninja generator). CMake doesn't
# recognize Hammerhead and won't set UNIX=TRUE / pick the right shared-lib
# conventions without a Platform module (same gotcha as base/neovim's
# cmake build) - map it to the SunOS platform module.
set -e
cd "$SRCDIR"

mkdir -p "$SRCDIR/.cmake/Platform"
echo 'include(Platform/SunOS)' > "$SRCDIR/.cmake/Platform/Hammerhead.cmake"

cmake -B build -G Ninja \
    -DCMAKE_MODULE_PATH="$SRCDIR/.cmake" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX="$PREFIX" \
    -DCMAKE_INSTALL_RPATH="$PREFIX/lib" \
    -DCMAKE_C_FLAGS="-D__EXTENSIONS__" \
    -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
    -DCMAKE_ASM_NASM_COMPILER=/usr/local/bin/nasm \
    -DENABLE_STATIC=OFF \
    -DWITH_TURBOJPEG=ON

cmake --build build -j${JOBS:-1}
DESTDIR="$PKGDIR" cmake --install build
# libjpeg-turbo - JPEG image codec with SIMD acceleration
# https://libjpeg-turbo.org/

[package]
name = "libjpeg-turbo"
version = "3.2.0"
release = 1
description = "JPEG image codec with SIMD acceleration"
url = "https://libjpeg-turbo.org/"
license = "IJG AND BSD-3-Clause AND zlib"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "libjpeg-turbo-3.2.0.tar.gz"
urls = ["https://github.com/libjpeg-turbo/libjpeg-turbo/archive/refs/tags/3.2.0.tar.gz"]
checksum = "980dd81f425082aa6d7c9e47fef27554ce7a9ffc8e2f6e863b97d263c5c50858"

[build]
parallel = true
#!/bin/sh
# Build script for libpng (autotools, Template A). zlib dependency is
# PRESENT in base (/usr/lib) - not ported separately.
set -e
cd "$SRCDIR"

# Mandatory libtool hammerhead* dynamic-linker fix (see libXrender/Task 4a
# gotcha): unmatched host_os falls through to "dynamic_linker=no", forcing
# static-only output without this.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libpng - PNG reference library (freetype dependency)
# http://www.libpng.org/pub/png/libpng.html

[package]
name = "libpng"
version = "1.6.58"
release = 1
description = "PNG reference library"
url = "http://www.libpng.org/pub/png/libpng.html"
license = "libpng-2.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "libpng-1.6.58.tar.xz"
urls = ["https://downloads.sourceforge.net/project/libpng/libpng16/1.6.58/libpng-1.6.58.tar.xz"]
checksum = "28eb403f51f0f7405249132cecfe82ea5c0ef97f1b32c5a65828814ae0d34775"

[build]
parallel = true
#!/bin/sh
# Build script for libpthread-stubs (autotools, Template A).
# NOTE: the 0.5 release tarball ships only Makefile.am/configure.ac (no
# meson.build) despite some packaging docs describing it as a Meson port -
# verified 2026-07-22 by inspecting the actual distfile. Header/.pc only,
# no compiled library content - just satisfies libxcb's pkg-config check.
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libpthread-stubs - weak aliases for pthread functions (pkg-config-only stub)
# https://gitlab.freedesktop.org/xorg/lib/libpthread-stubs
#
# Confirmed needed on Hammerhead 2026-07-22 (Task 4a): even though illumos
# has native pthreads, libxcb's configure hard-requires the pthread-stubs
# pkg-config module unconditionally (`xau >= 0.99.2 pthread-stubs`). Not a
# skip candidate here.
#
# Build system note: the 0.5 distfile is autotools-only (Makefile.am +
# configure.ac, no meson.build) - built with Template A, not Meson.

[package]
name = "libpthread-stubs"
version = "0.5"
release = 1
description = "Weak aliases for pthread functions not provided by all libc/libpthread implementations"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = ["util-macros"]

[[source]]
file = "libpthread-stubs-0.5.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libpthread-stubs-0.5.tar.xz"]
checksum = "59da566decceba7c2a7970a4a03b48d9905f1262ff94410a649224e33d2442bc"

[build]
parallel = true
#!/bin/sh
# Build script for libtermkey (plain Makefile, uses the system GNU libtool
# binary directly - not a generated per-project libtool script). Needs
# base/unibilium built + installed first; the Makefile locates it via
# pkg-config ($(call pkgconfig, ...)), so PKG_CONFIG_PATH must reach
# $PREFIX/lib/pkgconfig.
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

gmake -j${JOBS:-1} PREFIX="$PREFIX"
gmake install PREFIX="$PREFIX" DESTDIR="$PKGDIR"
# libtermkey - terminal keyboard entry reading library (neovim TUI input)
# http://www.leonerd.org.uk/code/libtermkey/

[package]
name = "libtermkey"
version = "0.22"
release = 1
description = "Terminal keypress reading library"
url = "http://www.leonerd.org.uk/code/libtermkey/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["unibilium"]
build = ["unibilium"]

[[source]]
file = "libtermkey-0.22.tar.gz"
urls = ["http://www.leonerd.org.uk/code/libtermkey/libtermkey-0.22.tar.gz"]
checksum = "6945bd3c4aaa83da83d80a045c5563da4edd7d0374c62c0d35aec09eb3014600"

[build]
parallel = true
#!/bin/sh
# Build script for libuv (autotools, Template A variant + autogen.sh).
#
# GOTCHA (1b-2): the release tarball ships NO pre-generated `configure`
# (only configure.ac/Makefile.am + autogen.sh) - must autogen before the
# usual libtool-fix + configure steps. Same shape as base/x11vnc's
# autoreconf gotcha.
#
# GOTCHA (1b-2): libuv's configure.ac gates its illumos backend
# (src/unix/sunos.c, `AM_CONDITIONAL([SUNOS], ...)`) on `$host_os` matching
# the literal pattern `solaris*`. Our BUILD_TRIPLE's OS component is
# "hammerhead" (x86_64-zygaena-hammerhead), which doesn't match, so
# unpatched the port silently builds without the SunOS backend at all
# (missing symbols / broken kqueue-less unix core). Patch the
# AM_CONDITIONAL pattern to also match hammerhead* before autogen.sh runs
# (configure.ac -> configure, so this must happen pre-generation, not as
# a `sed` on the generated `configure` like the libtool fix below).
set -e
cd "$SRCDIR"

sed -i -E '/AM_CONDITIONAL\(\[SUNOS\]/ s/\[solaris\*\]/[solaris*|hammerhead*]/' configure.ac

export AUTOCONF=/usr/bin/autoconf
export AUTOHEADER=/usr/bin/autoheader
export ACLOCAL=/usr/bin/aclocal
export AUTOMAKE=/usr/bin/automake
export LIBTOOLIZE=/usr/bin/libtoolize

./autogen.sh

# GOTCHA (1b-2): autogen.sh's libtoolize --install pulls in its OWN fresh
# config.sub/config.guess, which do NOT carry the hammerhead patch (coral's
# pre-build copy is a no-op here since neither file existed in $SRCDIR
# before autogen ran). Re-copy the patched versions now, post-autogen,
# same fix as base/x11vnc.
cp -f /usr/share/autoconf/build-aux/config.sub config.sub 2>/dev/null || true
cp -f /usr/share/autoconf/build-aux/config.guess config.guess 2>/dev/null || true

# MANDATORY libtool fix (Template A): unmatched OS in libtool's
# dynamic-linker case falls through to static-only.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libuv - multi-platform asynchronous I/O library (neovim's event loop)
# https://libuv.org/

[package]
name = "libuv"
version = "1.52.1"
release = 1
description = "Multi-platform support library with a focus on asynchronous I/O"
url = "https://libuv.org/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "libuv-1.52.1.tar.gz"
urls = ["https://github.com/libuv/libuv/archive/refs/tags/v1.52.1.tar.gz"]
checksum = "478baf2599bfbc882c355288c9cb6f92e0e7dda435fa04031fa5b607cf3f414c"

[build]
parallel = true
#!/bin/sh
# Build script for libvncserver (CMake + Ninja) - undocumented dependency
# of x11vnc, see package.toml header for why this port exists.
#
# Deliberately keep the feature surface minimal / no-GTK (project toolkit
# rule): no SDL/GTK/Qt example clients, no systemd, no GnuTLS/gcrypt/SASL/
# FFmpeg/websockets/libsshtunnel. zlib comes from base (/usr/lib); jpeg +
# png come from the Task-5 (M3a) ports already installed at $PREFIX.
#
# illumos socket gotcha (per Task-7a brief + gotcha checklist): sockets.c
# calls socket()/bind()/listen()/accept()/gethostbyname() unconditionally.
# CMake's check_function_exists(socket ...) probe does NOT itself add
# -lsocket/-lnsl to the link line the way autoconf's AC_CHECK_LIB does, so
# without forcing them into the linker flags the final `ninja` link step
# fails with undefined references to socket()/gethostbyname(). Force via
# CMAKE_EXE_LINKER_FLAGS/CMAKE_SHARED_LINKER_FLAGS cache vars.
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"

mkdir -p build && cd build
cmake -G Ninja \
    -DCMAKE_INSTALL_PREFIX="$PREFIX" \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_C_FLAGS="-D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS -I$PREFIX/include" \
    -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
    -DCMAKE_EXE_LINKER_FLAGS="-L$PREFIX/lib -R$PREFIX/lib -lsocket -lnsl" \
    -DCMAKE_SHARED_LINKER_FLAGS="-L$PREFIX/lib -R$PREFIX/lib -lsocket -lnsl" \
    -DBUILD_SHARED_LIBS=ON \
    -DWITH_ZLIB=ON \
    -DWITH_LZO=OFF \
    -DWITH_JPEG=ON \
    -DWITH_PNG=ON \
    -DWITH_SDL=OFF \
    -DWITH_GTK=OFF \
    -DWITH_QT=OFF \
    -DWITH_LIBSSHTUNNEL=OFF \
    -DWITH_THREADS=ON \
    -DWITH_GNUTLS=OFF \
    -DWITH_OPENSSL=ON \
    -DWITH_SYSTEMD=OFF \
    -DWITH_GCRYPT=OFF \
    -DWITH_FFMPEG=OFF \
    -DWITH_TIGHTVNC_FILETRANSFER=ON \
    -DWITH_24BPP=ON \
    -DWITH_IPv6=ON \
    -DWITH_WEBSOCKETS=OFF \
    -DWITH_SASL=OFF \
    -DWITH_XCB=ON \
    -DWITH_EXAMPLES=OFF \
    -DWITH_TESTS=OFF \
    ..
ninja -j${JOBS:-1}
DESTDIR="$PKGDIR" ninja install
# libvncserver - VNC server/client protocol library (VNC/RFB implementation)
#
# NOT in the Task-0/xlibre-phase1a-manifest.md port table. Discovered as a
# hard build dependency of x11vnc during Task 7a (2026-07-22): x11vnc split
# off from the LibVNCServer project in 2016 and its configure.ac now does
# PKG_CHECK_MODULES(LIBVNCSERVER, libvncserver >= 0.9.8) +
# PKG_CHECK_MODULES(LIBVNCCLIENT, libvncclient >= 0.9.8) unconditionally -
# it is no longer a standalone/bundled-source VNC implementation. Added
# here as a manifest gap fix so x11vnc can build at all.
# https://github.com/LibVNC/libvncserver

[package]
name = "libvncserver"
version = "0.9.15"
release = 1
description = "VNC server/client protocol library (used by x11vnc)"
url = "https://github.com/LibVNC/libvncserver"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libjpeg-turbo", "libpng"]
build = ["libjpeg-turbo", "libpng"]

[[source]]
file = "libvncserver-0.9.15.tar.gz"
urls = ["https://github.com/LibVNC/libvncserver/archive/refs/tags/LibVNCServer-0.9.15.tar.gz"]
checksum = "62352c7795e231dfce044beb96156065a05a05c974e5de9e023d688d8ff675d7"

[build]
parallel = true
#!/bin/sh
# Build script for libvterm (plain Makefile, uses the system GNU libtool
# binary directly). No deps.
#
# libvterm's own Makefile only adds -D__EXTENSIONS__ -D_XPG6
# -D__XOPEN_OR_POSIX when `uname` == "SunOS"; Hammerhead's uname is
# "Hammerhead" so that branch never fires - add the same flags manually
# (same shape as base/libconfig/base/libev's Template A CFLAGS export).
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS -D_XPG6 -D__XOPEN_OR_POSIX"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

gmake -j${JOBS:-1} PREFIX="$PREFIX"
gmake install PREFIX="$PREFIX" DESTDIR="$PKGDIR"
# libvterm - abstract terminal emulator library (neovim's embedded terminal)
# http://www.leonerd.org.uk/code/libvterm/

[package]
name = "libvterm"
version = "0.3.3"
release = 1
description = "Abstract library implementation of a terminal emulator"
url = "http://www.leonerd.org.uk/code/libvterm/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "libvterm-0.3.3.tar.gz"
urls = ["http://www.leonerd.org.uk/code/libvterm/libvterm-0.3.3.tar.gz"]
checksum = "09156f43dd2128bd347cbeebe50d9a571d32c64e0cf18d211197946aff7226e0"

[build]
parallel = true
#!/bin/sh
# Build script for libxcb (autotools, Template A + custom).
# Needs python3 (xcb-proto's xcbgen module) to generate C sources from XML.
# Verified 2026-07-22: configure hard-requires the pthread-stubs pkg-config
# module unconditionally (`xau >= 0.99.2 pthread-stubs`), even on illumos
# with native pthreads. libpthread-stubs is therefore a required build dep
# (see base/libpthread-stubs).
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22, Task 4a): this release's libtool-generated
# `configure` has no solaris/illumos/hammerhead arm in its dynamic-linker
# detection `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"
export PYTHON=/usr/local/bin/python3

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --enable-xkb

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# libxcb - X protocol C-language Binding
# https://gitlab.freedesktop.org/xorg/lib/libxcb

[package]
name = "libxcb"
version = "1.17.0"
release = 1
description = "X protocol C-language Binding (XCB)"
url = "https://xorg.freedesktop.org/releases/individual/xcb/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libXau", "libXdmcp"]
build = ["xcb-proto", "libXau", "libXdmcp", "libpthread-stubs"]

[[source]]
file = "libxcb-1.17.0.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/xcb/libxcb-1.17.0.tar.xz"]
checksum = "599ebf9996710fea71622e6e184f3a8ad5b43d0e5fa8c4e407123c88a59a6d55"

[build]
parallel = true
#!/bin/sh
# Build script for libxcvt (Meson, Template B). Dependency of
# xlibre-xserver-xorg. Pure C library + `cvt` binary; no patches needed.
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
# __EXTENSIONS__ + _POSIX_PTHREAD_SEMANTICS: unlock hidden POSIX/SysV prototypes
# on illumos headers (meson has_function() falsely reports them present).
export CFLAGS="${CFLAGS} -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
# rpath: Meson strips rpath on install and /usr/local/lib is not on the default
# ld.so path; bake -R$PREFIX/lib so installed artifacts are self-contained.
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -Wl,-R,$PREFIX/lib"

meson setup build \
    --prefix="$PREFIX" \
    --libdir=lib \
    --buildtype=release \
    -Ddefault_library=shared

ninja -C build -j${JOBS:-1}
DESTDIR="$PKGDIR" ninja -C build install
# libxcvt - VESA CVT standard timing modelines generator library
# Small standalone library split out of the X server; xlibre-xserver-xorg
# hard-requires it (meson.build: dependency('libxcvt', required: build_xorg)).
# Pure C, no illumos-isms - a plain Meson library + the `cvt` helper binary.
# https://gitlab.freedesktop.org/xorg/lib/libxcvt

[package]
name = "libxcvt"
version = "0.1.3"
release = 1
description = "Library providing VESA CVT standard timing modelines"
url = "https://gitlab.freedesktop.org/xorg/lib/libxcvt"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "libxcvt-0.1.3.tar.xz"
urls = ["https://www.x.org/releases/individual/lib/libxcvt-0.1.3.tar.xz"]
checksum = "a929998a8767de7dfa36d6da4751cdbeef34ed630714f2f4a767b351f2442e01"

[build]
parallel = true
#!/bin/sh
# Build script for libxkbfile (Meson, Template B).
# NOTE (Task 4b, 2026-07-22): the 1.2.0 release tarball ships ONLY
# meson.build - no configure script (autotools support was dropped
# upstream by this release, despite the phase1a manifest listing
# "autotools/meson" for it). Confirmed via `tar tf` on the fetched
# tarball: no configure.ac/configure anywhere in the tree. Using
# Template B; no libtool fix needed (Meson doesn't hit the libtool
# dynamic-linker case-arm bug at all).
#
# GOTCHA (Task 4b, 2026-07-22): meson's cc.has_function() probe reported
# flockfile/getc_unlocked/funlockfile as present (they exist in libc), so
# config.h's HAVE_UNLOCKED_STDIO got set - but src/maprules.c then fails
# with "implicit declaration" because illumos's stdio.h only exposes those
# POSIX.1c prototypes when __EXTENSIONS__ (PLURAL - not the single-S
# __EXTENSION__ used by some other illumos headers) or _REENTRANT or
# _POSIX_C_SOURCE>=199506L is defined (confirmed by reading
# /usr/include/stdio.h's guard directly on alpha9). Define __EXTENSIONS__.
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -D__EXTENSIONS__"

meson setup build \
    --prefix="$PREFIX" \
    --libdir=lib \
    --buildtype=release \
    -Ddefault_library=shared

ninja -C build -j${JOBS:-1}
DESTDIR="$PKGDIR" ninja -C build install
# libxkbfile - XKB file parsing library (xlibre-server CDEPEND >=1.0.4)
# https://gitlab.freedesktop.org/xorg/lib/libxkbfile

[package]
name = "libxkbfile"
version = "1.2.0"
release = 1
description = "XKB file parsing library"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11"]
build = ["libX11", "xorgproto", "util-macros"]

[[source]]
file = "libxkbfile-1.2.0.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/libxkbfile-1.2.0.tar.xz"]
checksum = "7f71884e5faf56fb0e823f3848599cf9b5a9afce51c90982baeb64f635233ebf"

[build]
parallel = true
#!/bin/sh
# Build script for Lua 5.4 (plain uname-keyed Makefile - NOT autotools).
#
# Lua's src/Makefile only has a "guess"/named-platform target dispatch (no
# dedicated Hammerhead/illumos entry) and its "posix"/"solaris" targets only
# ever produce a STATIC liblua.a - there is no shared-library target at all
# upstream, on any platform. So this build.sh does two passes:
#   1. `gmake posix` - the generic POSIX target (illumos has no dedicated
#      target; "solaris"/"SunOS" exists but drags in Solaris-specific
#      readline assumptions we don't want) - gives us liblua.a + lua/luac
#      binaries, and validates the objects build cleanly.
#   2. Manually recompile the library objects -fPIC and link them into a
#      real liblua.so.5.4 - conky/neovim need a *shared* liblua, which
#      upstream never ships, so this has to be done by hand.
# Finally we write a lua.pc by hand (upstream Lua ships NO pkg-config file
# at all) so consumers (conky, neovim) can find it via pkg-config.
set -e
cd "$SRCDIR/src"

export CC=gcc

# --- Pass 1: static build (also produces the lua/luac binaries) ---
gmake MYCFLAGS="-D__EXTENSIONS__ -DLUA_USE_POSIX -DLUA_USE_DLOPEN -fPIC" \
      MYLIBS="-ldl" \
      CC="$CC" \
      posix

# --- Pass 2: shared liblua.so.5.4 ---
# CORE_O/LIB_O objects were already compiled -fPIC above (MYCFLAGS carried
# -fPIC into SYSCFLAGS via MYCFLAGS), so relink into a shared object rather
# than recompiling. lua.o/luac.o are excluded (those are the standalone
# interpreter/compiler mains, not part of the library).
# NOTE: coral invokes build.sh via `zsh script.sh` (not `sh script.sh`), so
# the shebang is not honored and zsh's default (no word-splitting on
# unquoted variable expansion) applies - an "$CORE_O $LIB_O" variable
# reference collapses to a single argument and breaks the link. Inline the
# object list literally (plain script tokens, not a variable) to sidestep
# the shell-dependent splitting behavior entirely.
gcc -shared -Wl,-soname,liblua.so.5 -o liblua.so.5.4 \
    lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
    lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
    ltm.o lundump.o lvm.o lzio.o \
    lauxlib.o lbaselib.o lcorolib.o ldblib.o liolib.o lmathlib.o \
    loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o linit.o \
    -lm -ldl
ln -sf liblua.so.5.4 liblua.so.5
ln -sf liblua.so.5   liblua.so

# --- Install (static lib + binaries + headers via upstream install target) ---
cd "$SRCDIR"
gmake install INSTALL_TOP="$PKGDIR$PREFIX"

# --- Stage the shared lib alongside the static one ---
# NOTE: illumos cp(1) has no GNU/BSD-style -P (no-dereference) flag - copy
# only the real regular file, then recreate the two symlinks in place with
# ln -sf so they land as symlinks (not dereferenced copies).
mkdir -p "$PKGDIR$PREFIX/lib"
cp -f src/liblua.so.5.4 "$PKGDIR$PREFIX/lib/"
( cd "$PKGDIR$PREFIX/lib" && ln -sf liblua.so.5.4 liblua.so.5 && ln -sf liblua.so.5 liblua.so )

# --- Write lua.pc (upstream ships none) ---
mkdir -p "$PKGDIR$PREFIX/lib/pkgconfig"
cat > "$PKGDIR$PREFIX/lib/pkgconfig/lua.pc" <<EOF
prefix=$PREFIX
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include

Name: lua
Description: Lua embeddable scripting language
Version: 5.4.8
Libs: -L\${libdir} -llua -lm -ldl
Cflags: -I\${includedir}
EOF
# Also provide the lua5.4 alias name some consumers probe for.
ln -sf lua.pc "$PKGDIR$PREFIX/lib/pkgconfig/lua5.4.pc"
# Lua - embeddable scripting language (conky, neovim)
# https://www.lua.org/

[package]
name = "lua"
version = "5.4.8"
release = 1
description = "Lua embeddable scripting language interpreter/library"
url = "https://www.lua.org/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "lua-5.4.8.tar.gz"
urls = ["https://www.lua.org/ftp/lua-5.4.8.tar.gz"]
checksum = "4f18ddae154e793e46eeab727c59ef1c0c0c2b744e7b94219710d76f530629ae"

[build]
parallel = true
#!/bin/sh
# Build script for motif / OpenMotif 2.3.8 (autotools, Template A).
# Older codebase - config.sub/libtool/__EXTENSIONS__ gotchas expected.
# CORRECTION (2026-07-23): motif's own configure.ac only references its
# in-tree bitmaps/Makefile, but lib/Xm/I18List.c has a *hardcoded*
# `#include <X11/bitmaps/gray>` - a real X.Org bitmap from the standalone
# xbitmaps package, NOT one of motif's own bitmaps/. Needs base/xbitmaps
# built+installed to $PREFIX/include first (see zports base/xbitmaps).
set -e

# Resolve the port dir (holds patches/) BEFORE cd'ing into the extracted source.
PORTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

cd "$SRCDIR"

# MANDATORY libtool fix - see Template A (confirmed 4 kopensolaris hits
# in this configure).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

# GOTCHA: lib/Xm/Xmfuncs.h #defines bcopy/bzero/bcmp as function-like
# macros (for pre-ANSI systems) BEFORE illumos's X11/Xos.h later does its
# own (normally-safe, guarded) `#include <strings.h>`. Since strings.h
# hasn't been seen yet at that point, its `extern int bcmp(const void *,
# ...)` etc. prototypes get macro-substituted into invalid syntax
# ("expected declaration specifiers ... before '(' token"). Fixed by
# patching Xmfuncs.h to pull in <strings.h> itself before defining the
# macros, so strings.h's own include guard makes Xos.h's later include a
# no-op. See patches/0001-xmfuncs-strings-h-macro-mangling.patch.
for p in "$PORTDIR"/patches/*.patch; do
    [ -f "$p" ] || continue
    echo "==> Applying patch: $(basename "$p")"
    patch -p1 < "$p"
done

# GOTCHA: ResEncod.c casts its iconv() 2nd arg to (char **) - matching
# illumos's non-POSIX-conformant iconv(3C) prototype, which /usr/include/
# iconv.h only exposes when _XPG6 is defined (otherwise it exposes the
# `const char **` prototype instead, and the explicit (char **) cast in the
# old motif source becomes an incompatible-pointer-type error under GCC 14's
# now-stricter default). Define _XPG6 to select the signature the existing
# cast already expects, rather than patching upstream source.
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS -D_XPG6 -fpermissive -fcommon"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

# GOTCHA: ac_find_xft.m4's Xrender probe does
# `XRENDER_LIBS="-L$x_libraries -lXft -lXrender"` unconditionally once
# $have_x=yes, with NO fallback if $x_libraries came back empty (which it
# does here since AC_PATH_XTRA never needed to search - X11 is already on
# the default $PREFIX/lib path) - producing a malformed literal "-L -lXft"
# that trips libtool ("require no space between '-L' and '-lXft'").
# Force --x-libraries/--x-includes explicitly so $x_libraries is non-empty.
./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --enable-xft \
    --disable-printing \
    --x-includes="$PREFIX/include" \
    --x-libraries="$PREFIX/lib"

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# motif (OpenMotif) - X11 widget toolkit, backs the XNEdit editor
# https://sourceforge.net/projects/motif/

[package]
name = "motif"
version = "2.3.8"
release = 1
description = "OpenMotif X11 widget toolkit"
url = "https://sourceforge.net/projects/motif/"
license = "LGPL-2.1-or-later"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11", "libXext", "libXt", "libXft", "libXpm", "freetype"]
build = ["libX11", "libXext", "libXt", "libXft", "libXpm", "freetype", "xbitmaps"]

[[source]]
file = "motif-2.3.8.tar.gz"
urls = ["https://downloads.sourceforge.net/project/motif/Motif%202.3.8%20Source%20Code/motif-2.3.8.tar.gz"]
checksum = "859b723666eeac7df018209d66045c9853b50b4218cecadb794e2359619ebce7"

[build]
parallel = true
--- a/lib/Xm/Xmfuncs.h
+++ b/lib/Xm/Xmfuncs.h
@@ -41,6 +41,16 @@
 #else
 #if (__STDC__ && !defined(X_NOT_STDC_ENV) && !defined(sun) && !defined(macII) && !defined(apollo)) || defined(SVR4) || defined(hpux) || defined(_IBMR2) || defined(_SEQUENT_)
 #include <string.h>
+/* HAMMERHEAD: pull in <strings.h> here, BEFORE bcopy/bzero/bcmp become
+ * function-like macros below. Otherwise X11/Xos.h's later (guarded, so
+ * normally a no-op) `#include <strings.h>` is the FIRST time these
+ * prototypes are seen, and the macro substitution mangles the illumos
+ * `extern int bcmp(const void *, const void *, size_t);` declarations
+ * into invalid syntax ("expected declaration specifiers ... before '('
+ * token"). Pre-including here means strings.h's own guard (_STRINGS_H)
+ * makes X11/Xos.h's later include a safe no-op.
+ */
+#include <strings.h>
 #define _XFUNCS_H_INCLUDED_STRING_H
 #define bcopy(b1,b2,len) memmove(b2, b1, (size_t)(len))
 #define bzero(b,len) memset(b, 0, (size_t)(len))
#!/bin/sh
# Build script for msgpack-c (CMake, Ninja generator). CMake doesn't
# recognize Hammerhead and won't set UNIX=TRUE / pick the right shared-lib
# conventions without a Platform module (same gotcha as base/neovim's and
# base/libjpeg-turbo's cmake builds) - map it to the SunOS platform module.
#
# This is the C-only "c-<ver>" release tag (NOT the C++ "cpp-" tag), so
# there is no MSGPACK_ENABLE_CXX option to disable here.
set -e
cd "$SRCDIR"

mkdir -p "$SRCDIR/.cmake/Platform"
echo 'include(Platform/SunOS)' > "$SRCDIR/.cmake/Platform/Hammerhead.cmake"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"

cmake -B build -G Ninja \
    -DCMAKE_MODULE_PATH="$SRCDIR/.cmake" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX="$PREFIX" \
    -DCMAKE_INSTALL_RPATH="$PREFIX/lib" \
    -DCMAKE_C_FLAGS="-D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS" \
    -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
    -DMSGPACK_BUILD_TESTS=OFF \
    -DMSGPACK_BUILD_EXAMPLES=OFF

cmake --build build -j${JOBS:-1}
DESTDIR="$PKGDIR" cmake --install build
# msgpack-c - MessagePack binary serialization, C library (neovim RPC)
# https://github.com/msgpack/msgpack-c

[package]
name = "msgpack-c"
version = "7.0.1"
release = 1
description = "MessagePack binary-based object serialization library for C"
url = "https://github.com/msgpack/msgpack-c"
license = "BSL-1.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "msgpack-c-7.0.1.tar.gz"
urls = ["https://github.com/msgpack/msgpack-c/archive/refs/tags/c-7.0.1.tar.gz"]
checksum = "1a8f85d21418d118af953043146f727b9b08d78ad85ed17cd6aa0b568f60f1d7"

[build]
parallel = true
#!/bin/sh
# Build script for mupdf 1.28.0 (plain uname-keyed GNU Makefile, bundled
# thirdparty). NOT Template A/B - mupdf ships its own Makerules that
# selects behavior off `$(OS)` (defaulting to `uname`, which reports
# "Hammerhead" - matches none of mupdf's Darwin/Linux/OpenBSD/wasm arms),
# so force OS=Linux explicitly to pick up the Linux-shaped defaults
# (HAVE_OBJCOPY, LIB_LDFLAGS -shared -Wl,-soname, etc.) which line up with
# our GNU-ld/binutils toolchain.
#
# Use the BUNDLED thirdparty/ (freetype, harfbuzz, jbig2dec, openjpeg,
# mujs, zlib-alt) rather than USE_SYSTEM_LIBS=yes - avoids a large,
# fragile dependency reconciliation against our own freetype/harfbuzz
# ports for a single consumer. Only the X11 viewer libs (libX11/libXext/
# libXrandr/libXcursor) come from the system via pkg-config.
#
# Old (pre-2015-idiom-heavy in thirdparty/) C - GCC 14 promotes implicit-
# decl/incompatible-pointer-type/int-conversion to hard errors by default;
# -fpermissive demotes them back to warnings, -fcommon undoes GCC10+'s
# -fno-common default (tentative-definition multiple-definition errors).
set -e

PORTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

cd "$SRCDIR"

for p in "$PORTDIR"/patches/*.patch; do
    [ -f "$p" ] || continue
    echo "==> Applying patch: $(basename "$p")"
    patch -p1 < "$p"
done

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"

# Build only first (no install target) - DESTDIR must be a make ARG on the
# install step, never exported/used on a plain build, and never omitted -
# an install-apps run without DESTDIR would write straight into the live
# $PREFIX on the build host.
gmake -j${JOBS:-1} \
    OS=Linux \
    build=release \
    HAVE_X11=yes \
    HAVE_GLUT=no \
    HAVE_OBJCOPY=yes \
    prefix="$PREFIX" \
    XCFLAGS="-fpermissive -fcommon -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS" \
    apps libs

# install-apps installs mutool + the view apps (incl. mupdf-x11);
# install-libs additionally ships libmupdf + headers for any future consumer.
gmake \
    OS=Linux \
    build=release \
    HAVE_X11=yes \
    HAVE_GLUT=no \
    HAVE_OBJCOPY=yes \
    prefix="$PREFIX" \
    DESTDIR="$PKGDIR" \
    XCFLAGS="-fpermissive -fcommon -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS" \
    install-apps install-libs
# mupdf - lightweight PDF/XPS/EPUB viewer and library
# https://mupdf.com/

[package]
name = "mupdf"
version = "1.28.0"
release = 1
description = "Lightweight PDF/XPS/EPUB viewer and library (X11 viewer)"
url = "https://mupdf.com/"
license = "AGPL-3.0-or-later"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11", "libXext", "libXrandr", "libXcursor", "zlib"]
build = ["libX11", "libXext", "libXrandr", "libXcursor", "zlib"]

[[source]]
file = "mupdf-1.28.0-source.tar.gz"
urls = ["https://mupdf.com/downloads/archive/mupdf-1.28.0-source.tar.gz"]
checksum = "21c7f064903154f1c3a7458bee81f130fc36f9b5147ea13328f9980e02d2dea2"

[build]
parallel = true
From: Chris Tusa <chris.tusa@leafscale.com>
Subject: fitz/deskew: rename index_t (clashes with illumos sys/types.h)

illumos's <sys/types.h> already typedefs index_t as 'short' (an
SVR4 STREAMS-era type), which conflicts with deskew.c's own struct
index_t typedef (transitively included via mupdf/fitz.h ->
mupdf/memento.h -> stdlib.h -> sys/wait.h -> sys/types.h). Rename
mupdf's local type to fz_deskew_index_t (deskew.c/.h only - no
other file in the tree uses this name) to remove the collision
rather than fighting illumos's system header.

diff --git a/source/fitz/deskew.c b/source/fitz/deskew.c
--- a/source/fitz/deskew.c	2026-06-25 14:05:09.000000000 -0500
+++ b/source/fitz/deskew.c	2026-07-22 21:04:17.710448696 -0500
@@ -261,7 +261,7 @@
 	uint8_t  slow;		/* Flag */
 	int32_t  first_pixel;	/* offset of first value in source data */
 	int32_t  last_pixel;	/* last pixel number */
-} index_t;
+} fz_deskew_index_t;
 
 #if ARCH_HAS_NEON
 typedef int16_t weight_t;
@@ -271,7 +271,7 @@
 
 typedef void (zoom_y_fn)(uint8_t        *            dst,
 			const uint8_t  * __restrict tmp,
-			const index_t  * __restrict index,
+			const fz_deskew_index_t  * __restrict index,
 			const weight_t * __restrict weights,
 			uint32_t                    width,
 			uint32_t                    channels,
@@ -279,7 +279,7 @@
 			int32_t                     y);
 typedef void (zoom_x_fn)(uint8_t        * __restrict tmp,
 			const uint8_t  * __restrict src,
-			const index_t  * __restrict index,
+			const fz_deskew_index_t  * __restrict index,
 			const weight_t * __restrict weights,
 			uint32_t                    dst_w,
 			uint32_t                    src_w,
@@ -317,9 +317,9 @@
 	uint32_t      dst_h_borderless;
 	uint32_t      skip_l;
 	uint32_t      skip_t;
-	index_t      *index_x[SUB_PIX_X];
+	fz_deskew_index_t      *index_x[SUB_PIX_X];
 	weight_t     *weights_x[SUB_PIX_X];
-	index_t      *index_y[SUB_PIX_Y];
+	fz_deskew_index_t      *index_y[SUB_PIX_Y];
 	weight_t     *weights_y[SUB_PIX_Y];
 	uint32_t      max_y_weights[SUB_PIX_Y];
 	uint8_t       bg[FZ_MAX_COLORS];
@@ -381,7 +381,7 @@
 
 static void
 make_x_weights(fz_context *ctx,
-		index_t **indexp,
+		fz_deskew_index_t **indexp,
 		weight_t **weightsp,
 		uint32_t src_w,
 		uint32_t dst_w,
@@ -391,7 +391,7 @@
 		int sse_slow)
 {
 	double squeeze;
-	index_t  *index;
+	fz_deskew_index_t  *index;
 	weight_t *weights;
 	uint32_t i;
 	double offset = ((double)offset_f)/offset_n;
@@ -419,7 +419,7 @@
 	weights = (weight_t *)fz_malloc_aligned(ctx, sizeof(*weights) * max_weights * dst_w + SSE_SLOP, sizeof(weight_t) * 4);
 	memset(weights, 0, sizeof(*weights) * max_weights * dst_w);
 	fz_try(ctx)
-		index = (index_t *)fz_malloc(ctx, sizeof(*index) * dst_w + SSE_SLOP);
+		index = (fz_deskew_index_t *)fz_malloc(ctx, sizeof(*index) * dst_w + SSE_SLOP);
 	fz_catch(ctx)
 	{
 		fz_free_aligned(ctx, weights);
@@ -497,7 +497,7 @@
  */
 static void
 make_y_weights(fz_context *ctx,
-		index_t **indexp,
+		fz_deskew_index_t **indexp,
 		weight_t **weightsp,
 		uint32_t *max_weightsp,
 		uint32_t dst_w,
@@ -508,7 +508,7 @@
 		uint32_t h)
 {
 	double squeeze;
-	index_t  *index;
+	fz_deskew_index_t  *index;
 	weight_t *weights;
 	uint32_t i;
 	double   offset = ((double)offset_f)/offset_n;
@@ -538,7 +538,7 @@
 
 	weights = (weight_t *)fz_malloc_aligned(ctx, sizeof(*weights) * max_weights * dst_w, sizeof(weight_t) * 4);
 	fz_try(ctx)
-		index = (index_t *)fz_malloc(ctx, sizeof(*index) * dst_w);
+		index = (fz_deskew_index_t *)fz_malloc(ctx, sizeof(*index) * dst_w);
 	fz_catch(ctx)
 	{
 		fz_free_aligned(ctx, weights);
@@ -587,7 +587,7 @@
 
 #ifdef DEBUG_DESKEWER
 static void
-dump_weights(const index_t *index,
+dump_weights(const fz_deskew_index_t *index,
 		const weight_t *weights,
 		uint32_t w,
 		const char *str)
@@ -623,7 +623,7 @@
 		uint32_t  num_w = deskewer->dst_w;
 		weight_t *new_weights = fz_malloc_aligned(ctx, num_w *  deskewer->max_y_weights[i] *
 							sizeof(weight_t) * 4, sizeof(weight_t) * 4);
-		index_t  *index;
+		fz_deskew_index_t  *index;
 		weight_t *weights;
 
 		index = deskewer->index_y[i];

diff --git a/source/fitz/deskew_c.h b/source/fitz/deskew_c.h
--- a/source/fitz/deskew_c.h	2026-06-25 14:05:09.000000000 -0500
+++ b/source/fitz/deskew_c.h	2026-07-22 21:04:17.710702010 -0500
@@ -25,7 +25,7 @@
 static void
 zoom_x(uint8_t * FZ_RESTRICT tmp,
 	const uint8_t * FZ_RESTRICT src,
-	const index_t * FZ_RESTRICT index,
+	const fz_deskew_index_t * FZ_RESTRICT index,
 	const weight_t * FZ_RESTRICT weights,
 	uint32_t dst_w,
 	uint32_t src_w,
@@ -109,7 +109,7 @@
 static void
 zoom_x1(uint8_t * FZ_RESTRICT tmp,
 	const uint8_t * FZ_RESTRICT src,
-	const index_t * FZ_RESTRICT index,
+	const fz_deskew_index_t * FZ_RESTRICT index,
 	const weight_t * FZ_RESTRICT weights,
 	uint32_t dst_w,
 	uint32_t src_w,
@@ -183,7 +183,7 @@
 static void
 zoom_x3(uint8_t * FZ_RESTRICT tmp,
 	const uint8_t * FZ_RESTRICT src,
-	const index_t * FZ_RESTRICT index,
+	const fz_deskew_index_t * FZ_RESTRICT index,
 	const weight_t * FZ_RESTRICT weights,
 	uint32_t dst_w,
 	uint32_t src_w,
@@ -280,7 +280,7 @@
 static void
 zoom_x4(uint8_t * FZ_RESTRICT tmp,
 	const uint8_t * FZ_RESTRICT src,
-	const index_t * FZ_RESTRICT index,
+	const fz_deskew_index_t * FZ_RESTRICT index,
 	const weight_t * FZ_RESTRICT weights,
 	uint32_t dst_w,
 	uint32_t src_w,
@@ -388,7 +388,7 @@
 static void
 zoom_y(uint8_t * dst,
 	const uint8_t * FZ_RESTRICT tmp,
-	const index_t * FZ_RESTRICT index,
+	const fz_deskew_index_t * FZ_RESTRICT index,
 	const weight_t * FZ_RESTRICT weights,
 	uint32_t width,
 	uint32_t channels,
@@ -431,7 +431,7 @@
 static void
 zoom_y1(uint8_t * dst,
 		const uint8_t * FZ_RESTRICT tmp,
-		const index_t * FZ_RESTRICT index,
+		const fz_deskew_index_t * FZ_RESTRICT index,
 		const weight_t * FZ_RESTRICT weights,
 		uint32_t width,
 		uint32_t channels,
@@ -471,7 +471,7 @@
 static void
 zoom_y3(uint8_t * dst,
 		const uint8_t * FZ_RESTRICT tmp,
-		const index_t * FZ_RESTRICT index,
+		const fz_deskew_index_t * FZ_RESTRICT index,
 		const weight_t * FZ_RESTRICT weights,
 		uint32_t width,
 		uint32_t channels,
@@ -520,7 +520,7 @@
 static void
 zoom_y4(uint8_t * dst,
 	const uint8_t * FZ_RESTRICT tmp,
-	const index_t * FZ_RESTRICT index,
+	const fz_deskew_index_t * FZ_RESTRICT index,
 	const weight_t * FZ_RESTRICT weights,
 	uint32_t width,
 	uint32_t channels,
--- a/source/fitz/subset-cff.c
+++ b/source/fitz/subset-cff.c
@@ -24,6 +24,11 @@
 
 #include <math.h>
 
+/* illumos <sys/types.h> already typedefs index_t (SVR4 STREAMS-era
+ * short). Rename ours to avoid the redefinition conflict - see the
+ * same fix in deskew.c. */
+#define index_t mu_index_t
+
 /*
 	For the purposes of this code, and to save my tiny brain from
 	overload, we will adopt the following notation:
#!/bin/zsh
# Build script for GNU nano
set -e
cd "$SRCDIR"

# ncurses .pc files are in $PREFIX/lib/pkgconfig
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:${PKG_CONFIG_PATH:-}"

# Fix illumos gnulib compatibility issues
for f in lib/localename.c gnulib-tests/localename.c; do
    if [ -f "$f" ]; then
        sed -i 's/extern char \* getlocalename_l/extern const char * getlocalename_l/' "$f"
    fi
done

./configure --build=$BUILD_TRIPLE \
    --prefix=$PREFIX \
    --sysconfdir=$SYSCONFDIR \
    --disable-nls

# Fix illumos memset_s false detection if present
for config in lib/config.h gnulib-tests/config.h config.h; do
    if [ -f "$config" ]; then
        sed -i 's/#define HAVE_MEMSET_S 1/\/* #undef HAVE_MEMSET_S - illumos has it as macro only *\//' "$config"
    fi
done

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# GNU nano - Simple text editor
# https://www.nano-editor.org/

[package]
name = "nano"
version = "8.2"
release = 1
description = "GNU nano - Simple text editor"
url = "https://www.nano-editor.org/"
license = "GPL-3.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["ncurses"]
build = ["ncurses"]

[[source]]
file = "nano-8.2.tar.xz"
urls = ["https://www.nano-editor.org/dist/v8/nano-8.2.tar.xz"]
checksum = "d5ad07dd862facae03051c54c6535e54c7ed7407318783fcad1ad2d7076fffeb"


[build]
parallel = true
#!/bin/zsh
set -e
cd "$SRCDIR"

./configure \
    --prefix=$PREFIX \
    --build=$BUILD_TRIPLE \
    --host=$BUILD_TRIPLE \
    --with-shared \
    --with-cxx-shared \
    --without-debug \
    --without-ada \
    --enable-widec \
    --enable-pc-files \
    --with-pkg-config-libdir=$PREFIX/lib/pkgconfig \
    --with-termlib \
    --with-ticlib

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"

# Create non-wide symlinks (libncurses.so -> libncursesw.so etc.)
# Many programs look for -lncurses not -lncursesw
cd "$PKGDIR$PREFIX/lib"
for lib in ncurses form panel menu tinfo tic; do
    if [ -f "lib${lib}w.so" ]; then
        ln -sf "lib${lib}w.so" "lib${lib}.so"
    fi
    # Also link the .a files
    if [ -f "lib${lib}w.a" ]; then
        ln -sf "lib${lib}w.a" "lib${lib}.a"
    fi
done

# Symlink ncursesw headers as ncurses headers
cd "$PKGDIR$PREFIX/include"
if [ -d ncursesw ]; then
    ln -sf ncursesw ncurses
    # Also link headers directly for programs that use -I$PREFIX/include
    for h in ncursesw/*.h; do
        ln -sf "$h" .
    done
fi
--- configure.orig
+++ configure
@@ -6457,7 +6457,7 @@
 	(osf*|mls+*)
 		LD_RPATH_OPT="-rpath "
 		;;
-	(solaris2*)
+	(solaris2*|hammerhead*)
 		LD_RPATH_OPT="-R"
 		;;
 	(*)
@@ -7066,7 +7066,7 @@
 		MK_SHARED_LIB='${LD} ${LDFLAGS} -assert pure-text -o $@'
 		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
 		;;
-	(solaris2*)
+	(solaris2*|hammerhead*)
 		# tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
 		# tested with SunOS 5.10 (solaris 10) and gcc 3.4.3
 		if test "$DFT_LWR_MODEL" = "shared" ; then
@@ -26948,7 +26948,7 @@
 	(sco3.2v5*)
 	    CXXLDFLAGS="-u main"
 	    ;;
-	(solaris2*)
+	(solaris2*|hammerhead*)
 	    if test "$GXX" != yes ; then
 		CXX_AR='$(CXX)'
 		CXX_ARFLAGS='-xar -o'
@@ -28833,7 +28833,7 @@
 		LDFLAGS_STATIC=-noso
 		LDFLAGS_SHARED=-so_archive
 		;;
-	(solaris2*)
+	(solaris2*|hammerhead*)
 		LDFLAGS_STATIC=-Bstatic
 		LDFLAGS_SHARED=-Bdynamic
 		;;
@@ -29284,7 +29284,7 @@

 # workaround for g++ versus Solaris (20131116)
 case "$cf_cv_system_name" in
-(solaris2*)
+(solaris2*|hammerhead*)
 	case "x$CPPFLAGS" in
 	(*-D_XOPEN_SOURCE_EXTENDED*)
 		test -n "$verbose" && echo "	moving _XOPEN_SOURCE_EXTENDED to work around g++ problem" 1>&6
# ncurses - Terminal handling library
# https://invisible-island.net/ncurses/

[package]
name = "ncurses"
version = "6.5"
release = 1
description = "Terminal handling library with terminfo support"
url = "https://invisible-island.net/ncurses/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "ncurses-6.5.tar.gz"
urls = ["https://invisible-island.net/archives/ncurses/ncurses-6.5.tar.gz"]
checksum = "136d91bc269a9a5785e5f9e980bc76ab57428f604ce3e5a5a90cebc767971cc6"

[patches]
files = ["hammerhead-solaris-compat.patch"]
strip = 0

[build]
parallel = true
#!/bin/zsh
# Build script for neovim
#
# Task 1b-4 (M2): attempted USE_BUNDLED=OFF + PREFER_LUA=ON (consume our
# system libuv/msgpack-c/unibilium/libtermkey/libvterm/tree-sitter + lua).
# That failed: neovim's cmake.deps subproject requires an EXACT Lua 5.1
# (find_package(Lua 5.1 EXACT)) to link against for either the "prefer lua"
# path (real PUC Lua 5.1) OR the default LuaJIT path - and our system `lua`
# port is 5.4.8 (no 5.1-ABI package exists in zports). Per task brief
# fallback: keep USE_BUNDLED=ON (neovim builds its own private copies of
# these deps, using the bundled LuaJIT engine) rather than sink more time
# chasing a Lua 5.1 system package that doesn't exist yet. tree-sitter
# parsers were already being pre-staged this way regardless of the flag.
#
# cmake on Hammerhead has no HTTPS support, so every ExternalProject source
# tarball cmake.deps would otherwise fetch itself must be pre-staged with
# curl into .deps/build/downloads/<subdir>/<file> first.

set -e

PORTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

cd "$SRCDIR"

# LuaJIT's own Makefile probes whether $(TARGET_CC) emits eh_frame/
# __unwind_info sections in a bare test compile (no -funwind-tables) to
# decide whether to auto-define -DLUAJIT_UNWIND_EXTERNAL. GCC 14 on
# Hammerhead doesn't default to -fasynchronous-unwind-tables the way
# glibc/Linux x86_64 GCC does, so the probe comes back empty and
# lj_err.c's LJ_TARGET_X64 unwind path hits its
# "#error Broken build system" guard. Patch cmake.deps' BuildLuajit.cmake
# to force -DLUAJIT_UNWIND_EXTERNAL directly instead of relying on the
# probe.
for p in "$PORTDIR"/patches/*.patch; do
    [ -f "$p" ] || continue
    echo "==> Applying patch: $(basename "$p")"
    patch -p1 < "$p"
done

# Create cmake Platform module for Hammerhead (illumos derivative)
# cmake doesn't recognize Hammerhead and won't set UNIX=TRUE without this
mkdir -p "$SRCDIR/.cmake/Platform"
echo 'include(Platform/SunOS)' > "$SRCDIR/.cmake/Platform/Hammerhead.cmake"

MODPATH="$SRCDIR/.cmake"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CMAKE_PREFIX_PATH="$PREFIX:$CMAKE_PREFIX_PATH"

# -D__illumos__: bundled tree-sitter (and possibly other deps) gate their
# <endian.h> #include on __linux__/__illumos__/*BSD/etc; our GCC 14
# toolchain defines __sun/__SVR4 but not __illumos__, tripping
# "#error platform not supported" even though Hammerhead's libc DOES ship
# a POSIX-style <endian.h> with le16toh/be16toh (verified at
# /usr/include/endian.h). Each dep in cmake.deps is its own fresh
# ExternalProject_Add cmake invocation (only CMAKE_BUILD_TYPE is
# propagated via DEPS_CMAKE_ARGS - CMAKE_C_FLAGS passed to the outer
# `cmake -S cmake.deps -B .deps` configure does NOT flow down to
# sub-projects), so export it via the CFLAGS env var instead: cmake's
# project() seeds CMAKE_C_FLAGS from $CFLAGS on first configure, and
# ExternalProject_Add's cmake subprocess inherits our environment.
export CFLAGS="${CFLAGS:-} -D__illumos__"

# coral's build wrapper exports DESTDIR=$PKGDIR globally so a package's
# own `make install`/`cmake --install` stages into the pkg dir. That
# environment variable bleeds into cmake.deps's bundled sub-builds too
# (e.g. LuaJIT's Makefile does `DPREFIX = $(DESTDIR)$(PREFIX)`), so
# instead of installing into .deps/usr as intended, luajit/libuv/etc were
# silently installing under $PKGDIR/<absolute .deps/usr path> - meaning
# .deps/usr never got populated and every downstream dep
# (lpeg/luv - "lua.h: No such file", "missing LUAJIT_LIBRARIES") failed to
# find them. Unset it for the whole cmake.deps phase; it gets re-exported
# below just before neovim's own `cmake --install build`, which is the
# only step that should honor it.
unset DESTDIR

# Pre-download every bundled dependency cmake.deps will build with
# USE_BUNDLED=ON (default LuaJIT engine): libuv, luajit, lpeg, unibilium,
# luv, utf8proc, plus the tree-sitter runtime + parsers used for
# :checkhealth/help/runtime syntax. GETTEXT/LIBICONV are MSVC-only and
# WASMTIME/UNCRUSTIFY/LUA_DEV_DEPS/XXD/WIN32YANK are Windows- or
# lint/test-only - not needed for a plain Unix build, so they are skipped.
DLDIR="$SRCDIR/.deps/build/downloads"

echo "Pre-downloading bundled dependencies..."
while IFS=' ' read -r name url; do
    [[ -z "$name" || -z "$url" ]] && continue
    local subdir=""
    case "$name" in
        LIBUV_URL)               subdir="libuv" ;;
        LUAJIT_URL)               subdir="luajit" ;;
        LPEG_URL)                 subdir="lpeg" ;;
        UNIBILIUM_URL)            subdir="unibilium" ;;
        LUV_URL)                  subdir="luv" ;;
        LUA_COMPAT53_URL)         subdir="lua_compat53" ;;
        UTF8PROC_URL)             subdir="utf8proc" ;;
        TREESITTER_URL)           subdir="treesitter" ;;
        TREESITTER_C_URL)         subdir="treesitter_c" ;;
        TREESITTER_LUA_URL)       subdir="treesitter_lua" ;;
        TREESITTER_VIM_URL)       subdir="treesitter_vim" ;;
        TREESITTER_VIMDOC_URL)    subdir="treesitter_vimdoc" ;;
        TREESITTER_QUERY_URL)     subdir="treesitter_query" ;;
        TREESITTER_MARKDOWN_URL)  subdir="treesitter_markdown" ;;
        *)                        continue ;;
    esac
    local fname="${url##*/}"
    mkdir -p "$DLDIR/$subdir"
    if [[ ! -f "$DLDIR/$subdir/$fname" ]]; then
        echo "  Downloading $subdir/$fname ..."
        curl -fsSL -o "$DLDIR/$subdir/$fname" "$url"
    fi
done < cmake.deps/deps.txt

# Build the cmake.deps subproject with the default USE_BUNDLED=ON (private
# copies of libuv/luajit/lpeg/unibilium/luv/utf8proc/tree-sitter, all
# statically linked into nvim - no system Lua 5.1 required).
# -D__illumos__: bundled tree-sitter's portable/endian.h gates its
# `#include <endian.h>` branch on __linux__/__illumos__/*BSD/etc; our GCC
# 14 toolchain defines __sun/__SVR4 but not __illumos__, so it falls
# through to "#error platform not supported" even though Hammerhead's
# libc DOES ship a POSIX-style <endian.h> with le16toh/be16toh (verified
# at /usr/include/endian.h). Define the macro ourselves rather than patch
# every upstream file that checks for it.
cmake -S cmake.deps -B .deps -G Ninja \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_MODULE_PATH="$MODPATH" \
    -DCMAKE_C_COMPILER=/usr/bin/cc \
    -DCMAKE_C_FLAGS="-D__illumos__"

cmake --build .deps

# Build neovim against the bundled deps just built above.
cmake -B build -G Ninja \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DCMAKE_MODULE_PATH="$MODPATH" \
    -DCMAKE_C_COMPILER=/usr/bin/cc \
    -DCMAKE_C_FLAGS="-D__illumos__" \
    -DCMAKE_INSTALL_PREFIX=$PREFIX \
    -DCMAKE_INSTALL_RPATH=$PREFIX/lib \
    -DENABLE_JEMALLOC=OFF

cmake --build build

# Install - restore DESTDIR (unset above for the cmake.deps phase) so this
# final install stages into $PKGDIR as coral expects.
export DESTDIR="$PKGDIR"
cmake --install build

# Create vi/vim symlinks
ln -sf nvim "$PKGDIR$PREFIX/bin/vim"
ln -sf nvim "$PKGDIR$PREFIX/bin/vi"
[package]
name = "neovim"
version = "0.11.6"
release = 1
description = "Hyperextensible Vim-based text editor"
url = "https://neovim.io/"
license = "Apache-2.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["ncurses"]
build = ["ninja"]

[[source]]
file = "neovim-0.11.6.tar.gz"
urls = ["https://github.com/neovim/neovim/archive/refs/tags/v0.11.6.tar.gz"]
checksum = "d1c8e3f484ed1e231fd5f48f53b7345b628e52263d5eef489bb8b73ca8d90fca"

[build]
parallel = true
--- a/cmake.deps/cmake/BuildLuajit.cmake
+++ b/cmake.deps/cmake/BuildLuajit.cmake
@@ -30,6 +30,8 @@
 set(BUILDCMD_UNIX ${MAKE_PRG} -j CFLAGS=-fPIC
                               CFLAGS+=-DLUA_USE_APICHECK
                               CFLAGS+=-funwind-tables
+                              CFLAGS+=-DLUAJIT_UNWIND_EXTERNAL
+                              BUILDMODE=static
                               ${NO_STACK_CHECK}
                               ${AMD64_ABI}
                               CCDEBUG+=-g
--- a/src/nvim/lib/queue_defs.h
+++ b/src/nvim/lib/queue_defs.h
@@ -21,9 +21,9 @@
 
 #include <stddef.h>
 
-typedef struct queue {
-  struct queue *next;
-  struct queue *prev;
+typedef struct nvim_queue {
+  struct nvim_queue *next;
+  struct nvim_queue *prev;
 } QUEUE;
 
 #ifdef INCLUDE_GENERATED_DECLARATIONS
#!/bin/sh
# Build script for openbox (autotools, Template A).
# Deps: glib2, pango, cairo, libxml2 (BASE - /usr/lib), libX11, libXext,
# libXrender, libXrandr, libXinerama, libXcursor, libSM, libICE.
# Optionals disabled to stay minimal (no imlib2/librsvg/startup-notification
# ports exist).
set -e
cd "$SRCDIR"

# GOTCHA (Template A, standard): this release's libtool-generated `configure`
# has no solaris/illumos/hammerhead arm in its dynamic-linker detection
# `case $host_os in ...` block - unmatched OS falls through to
# `*) dynamic_linker=no ;;` which forces can_build_shared=no (static-only
# .a, no .so). Patch the case arm to add hammerhead* alongside the generic
# glibc/ELF branch (same SONAME/.so.N convention applies).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

# libxml2 ships in base (/usr/lib), not under $PREFIX - make sure its .pc
# is on the search path alongside the usual $PREFIX locations.
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -Wl,-R,$PREFIX/lib -lsocket -lnsl"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --disable-nls \
    --disable-imlib2 \
    --disable-librsvg \
    --disable-startup-notification

gmake -j${JOBS:-1}

# GOTCHA: openbox's automake-generated install-recursive races under a
# parallel MAKEFLAGS inherited from the environment - two subdirectory
# installs both `install-sh -c -d .../libexec` at once and the loser's
# mkdir sees EEXIST as a hard error (not the usual -p tolerant case).
# Force the install step serial regardless of inherited -j.
gmake -j1 install DESTDIR="$PKGDIR"
# openbox - lightweight, standards-compliant X11 window manager
# https://openbox.org/

[package]
name = "openbox"
version = "3.6.1"
release = 1
description = "Lightweight X11 window manager"
url = "http://openbox.org/"
license = "GPL-2.0-or-later"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["glib2", "pango", "cairo", "libxml2", "libX11", "libXext", "libXrender", "libXrandr", "libXinerama", "libXcursor", "libSM", "libICE"]
build = ["glib2", "pango", "cairo", "libxml2", "libX11", "libXext", "libXrender", "libXrandr", "libXinerama", "libXcursor", "libSM", "libICE", "xorgproto", "util-macros"]

[[source]]
file = "openbox-3.6.1.tar.gz"
urls = ["http://openbox.org/dist/openbox/openbox-3.6.1.tar.gz"]
checksum = "8b4ac0760018c77c0044fab06a4f0c510ba87eae934d9983b10878483bde7ef7"

[build]
parallel = true
#!/bin/sh
# Build script for pango (Meson, Template B).
# Deps: glib2, harfbuzz, fribidi, cairo, fontconfig, freetype (all ported).
# No gettext/nls dependency - confirmed via source inspection (no
# meson.build/meson.options reference to nls, gettext, or msgfmt anywhere
# in the 1.58.0 tree).
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -D__EXTENSIONS__"
export LDFLAGS="${LDFLAGS} -Wl,-R,$PREFIX/lib"

meson setup build \
    --prefix="$PREFIX" \
    --libdir=lib \
    --buildtype=release \
    -Ddefault_library=shared \
    -Dintrospection=disabled \
    -Dgtk_doc=false \
    -Dbuild-testsuite=false

ninja -C build -j${JOBS:-1}
DESTDIR="$PKGDIR" ninja -C build install
# pango - text layout and rendering (Openbox dep)
# https://download.gnome.org/sources/pango/

[package]
name = "pango"
version = "1.58.0"
release = 1
description = "Text layout and rendering library"
url = "https://www.pango.org/"
license = "LGPL-2.1-or-later"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["glib2", "harfbuzz", "fribidi", "cairo", "fontconfig", "freetype"]
build = ["glib2", "harfbuzz", "fribidi", "cairo", "fontconfig", "freetype"]

[[source]]
file = "pango-1.58.0.tar.xz"
urls = ["https://download.gnome.org/sources/pango/1.58/pango-1.58.0.tar.xz"]
checksum = "bc5bad6213ad4886a47d1e80292fd850b64159b50db67917a43d9ea80ee2298a"

[build]
parallel = true
#!/bin/bash
# Build script for GNU patch

set -e
cd "$SRCDIR"

# Fix illumos gnulib compatibility issues
for f in lib/localename.c gnulib-tests/localename.c; do
    if [ -f "$f" ]; then
        sed -i 's/extern char \* getlocalename_l/extern const char * getlocalename_l/' "$f"
    fi
done

./configure \
    --build=$BUILD_TRIPLE \
    --host=$BUILD_TRIPLE \
    --prefix=$PREFIX

# Fix illumos memset_s false detection if present
for config in lib/config.h gnulib-tests/config.h config.h; do
    if [ -f "$config" ]; then
        sed -i 's/#define HAVE_MEMSET_S 1/\/* #undef HAVE_MEMSET_S - illumos has it as macro only *\//' "$config"
    fi
done

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# GNU patch - Apply diff files
# https://www.gnu.org/software/patch/

[package]
name = "patch"
version = "2.7.6"
release = 1
description = "GNU patch - Apply diff files to originals"
url = "https://www.gnu.org/software/patch/"
license = "GPL-3.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "patch-2.7.6.tar.xz"
urls = ["https://ftp.gnu.org/gnu/patch/patch-2.7.6.tar.xz"]
checksum = "ac610bda97abe0d9f6b7c963255a11dcb196c25e337c61f94e4778d632f1d8fd"


[build]
parallel = true
#!/bin/sh
# Build script for pcre2 (autotools, Template A). No deps (zlib/bz2 not
# needed - pcre2grep's compressed-file support is optional and skipped).
set -e
cd "$SRCDIR"

# Mandatory libtool hammerhead* dynamic-linker fix (see libXrender/Task 4a
# gotcha): unmatched host_os falls through to "dynamic_linker=no", forcing
# static-only output without this.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --enable-pcre2-16 \
    --enable-pcre2-32

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# pcre2 - Perl Compatible Regular Expressions (glib2 dependency)
# https://github.com/PCRE2Project/pcre2
#
# glib requires libpcre2-8 >= 10.32 and probes for the 16/32-bit-code
# variants too (pcre2-16, pcre2-32) even though it only links libpcre2-8 -
# build all three widths so no glib feature silently degrades.

[package]
name = "pcre2"
version = "10.47"
release = 1
description = "Perl Compatible Regular Expressions library, version 2"
url = "https://github.com/PCRE2Project/pcre2"
license = "BSD-3-Clause"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "pcre2-10.47.tar.gz"
urls = ["https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.47/pcre2-10.47.tar.gz"]
checksum = "c08ae2388ef333e8403e670ad70c0a11f1eed021fd88308d7e02f596fcd9dc16"

[build]
parallel = true
#!/bin/sh
# Build script for picom (Meson, Template B). RISKY per task brief.
#
# xrender backend ONLY: -Dopengl=false (no Mesa/GL on Hammerhead) skips the
# epoxy dependency entirely (src/meson.build only calls
# `dependency('epoxy')` inside `if get_option('opengl')`). -Ddbus=false
# skips dbus-1 (not needed for a plain compositor).
#
# picom's src/meson.build unconditionally requires several xcb-util family
# pkg-config modules that were NOT yet in zports: xcb-image, xcb-renderutil,
# xcb-util (base). Added as base/xcb-util, base/xcb-util-image,
# base/xcb-util-renderutil (small fd.o autotools ports, built first).
# It also does `cc.has_header('uthash.h')` - not shipped anywhere in the
# tree, so added base/uthash (header-only, build-dep only).
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -Wl,-R,$PREFIX/lib"

meson setup build \
    --prefix="$PREFIX" \
    --libdir=lib \
    --buildtype=release \
    -Ddefault_library=shared \
    -Dopengl=false \
    -Ddbus=false \
    -Dwith_docs=false \
    -Dunittest=false

ninja -C build -j${JOBS:-1}
DESTDIR="$PKGDIR" ninja -C build install
# picom - X11 compositor (xrender backend only - no OpenGL/Mesa on Hammerhead)
# https://github.com/yshui/picom

[package]
name = "picom"
version = "13"
release = 1
description = "X11 compositor (xrender backend)"
url = "https://github.com/yshui/picom"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libconfig", "libev", "pcre2", "pixman", "libX11", "libxcb", "xcb-util", "xcb-util-image", "xcb-util-renderutil", "libXext", "libXrender", "libXfixes", "libXdamage", "libXcomposite", "libXrandr"]
build = ["libconfig", "libev", "pcre2", "pixman", "libX11", "libxcb", "xcb-util", "xcb-util-image", "xcb-util-renderutil", "libXext", "libXrender", "libXfixes", "libXdamage", "libXcomposite", "libXrandr", "uthash"]

[[source]]
file = "picom-13.tar.gz"
urls = ["https://github.com/yshui/picom/archive/refs/tags/v13.tar.gz"]
checksum = "db9791a54255742c924ef82a6a882042636d61de0fa61bc14c5e56279cf5791c"

[build]
parallel = true
#!/bin/sh
# Build script for pixman (Meson, Template B). No X deps; no libtool fix
# needed (Meson doesn't use libtool's dynamic-linker case block).
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"

meson setup build \
    --prefix="$PREFIX" \
    --libdir=lib \
    --buildtype=release \
    -Ddefault_library=shared \
    -Dtests=disabled

ninja -C build -j${JOBS:-1}
DESTDIR="$PKGDIR" ninja -C build install
# pixman - low-level pixel manipulation library (cairo + Xvfb rasterizer dep)
# https://www.cairographics.org/releases/ (also mirrored on xorg.freedesktop.org)

[package]
name = "pixman"
version = "0.46.4"
release = 1
description = "Low-level pixel manipulation library"
url = "https://www.cairographics.org/releases/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "pixman-0.46.4.tar.gz"
urls = ["https://www.cairographics.org/releases/pixman-0.46.4.tar.gz"]
checksum = "d09c44ebc3bd5bee7021c79f922fe8fb2fb57f7320f55e97ff9914d2346a591c"

[build]
parallel = true
#!/bin/bash
# Build script for readline
# GNU readline library for command line editing

set -e

cd "$SRCDIR"

# Set library path for ncurses (installed under $PREFIX, not /usr)
# Note: no tputs cast needed — readline depends on ncurses (build dep), which
# uses `int(*)(int)`, matching _rl_output_character_function's signature.
export LDFLAGS="-L$PREFIX/lib -R$PREFIX/lib -lncurses"
export CPPFLAGS="-I$PREFIX/include -I$PREFIX/include/ncurses"
export SHLIB_LIBS="-L$PREFIX/lib -lncursesw"

# Configure readline with shared library support
./configure \
    --build=$BUILD_TRIPLE \
    --host=$BUILD_TRIPLE \
    --prefix=$PREFIX \
    --libdir=$PREFIX/lib \
    --with-curses \
    --enable-shared

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"

# readline's shobj-conf for illumos installs only libreadline.so.8 with no
# libreadline.so symlink, so `-lreadline` falls through to the static archive
# (which then needs explicit -lncurses/-ltermcap to resolve tputs/tgetent).
# Add the canonical .so → .so.8 symlinks so consumers link dynamically.
ln -sf libreadline.so.8 "$PKGDIR$PREFIX/lib/libreadline.so"
ln -sf libhistory.so.8  "$PKGDIR$PREFIX/lib/libhistory.so"
# readline - GNU readline library
# https://tiswww.case.edu/php/chet/readline/rltop.html

[package]
name = "readline"
version = "8.2"
release = 1
description = "GNU readline library for command line editing"
url = "https://tiswww.case.edu/php/chet/readline/rltop.html"
license = "GPL-3.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["ncurses"]
build = ["ncurses"]

[[source]]
file = "readline-8.2.tar.gz"
urls = ["https://ftp.gnu.org/gnu/readline/readline-8.2.tar.gz"]
checksum = "3feb7171f16a84ee82ca18a36d7b9be109a52c04f492a053331d7d1095007c35"


[build]
parallel = true
jobs = 0
#!/bin/sh
# Build script for st (suckless, plain Makefile - NO configure, NOT a
# template build). Deps: libX11, libXft, fontconfig, freetype.
#
# st's shipped config.mk hardcodes X11INC/X11LIB to /usr/X11R6 (doesn't
# exist on Hammerhead) and links -lX11/-lXft directly instead of going
# through pkg-config. Rewrite config.mk to resolve everything via
# pkg-config against $PREFIX (falls back cleanly since x11/xft/
# fontconfig/freetype2 .pc files all live under $PREFIX/lib/pkgconfig).
set -e
cd "$SRCDIR"

# GOTCHA: st.c's openpty() header selection is an #if/#elif chain keyed on
# __linux / __OpenBSD__ / __NetBSD__ / __APPLE__ / __FreeBSD__ /
# __DragonFly__ - none of which match illumos-derived GCC (which defines
# __sun / __SVR4 instead), so no header gets included at all and openpty()
# is an implicit (and on this GCC, fatal-by-default) declaration. openpty()
# lives in libutil.h on illumos, same as the FreeBSD/DragonFly branch -
# add a __sun arm alongside it.
sed -i \
    -e 's/#elif defined(__FreeBSD__) || defined(__DragonFly__)/#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__sun)/' \
    st.c

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"

sed -i \
    -e "s#^PREFIX = .*#PREFIX = $PREFIX#" \
    -e '/^X11INC/d' -e '/^X11LIB/d' \
    -e 's#^INCS = .*#INCS = `$(PKG_CONFIG) --cflags x11 xft fontconfig freetype2`#' \
    -e '/PKG_CONFIG.*--cflags fontconfig/d' \
    -e '/PKG_CONFIG.*--cflags freetype2/d' \
    -e 's#^LIBS = .*#LIBS = -lm -lrt -lutil `$(PKG_CONFIG) --libs x11 xft fontconfig freetype2`#' \
    -e '/PKG_CONFIG.*--libs fontconfig/d' \
    -e '/PKG_CONFIG.*--libs freetype2/d' \
    config.mk

# Hidden POSIX prototypes (readv/writev/etc.) on illumos-derived headers -
# same __EXTENSIONS__ gotcha as every other X11 port here. Add rpath too
# since /usr/local/lib is not on Hammerhead's default ld.so search path.
sed -i \
    -e 's#^STCFLAGS = .*#STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS) -D__EXTENSIONS__#' \
    -e "s#^STLDFLAGS = .*#STLDFLAGS = \$(LIBS) \$(LDFLAGS) -Wl,-R,$PREFIX/lib#" \
    config.mk

# st's Makefile defaults CC to `c99`, which doesn't exist on Hammerhead
# (GCC 14 toolchain only) - the shipped config.mk has this commented out
# expecting the user to override it, but we're non-interactive so force
# it on the make command line too (belt-and-suspenders with the sed above).
gmake CC=gcc PREFIX="$PREFIX"

# GOTCHA: the Makefile's `install` target ends with `tic -sx st.info` to
# register st's terminfo entry. That's GNU-ncurses tic syntax; Hammerhead
# only ships illumos' native SVR4 /usr/bin/tic, which doesn't understand
# -s/-x and errors out ("Unknown option"), taking `gmake install` down
# with it even though the binary+man install (the two steps before it)
# already succeeded. Do the bin/man install ourselves and treat terminfo
# registration as best-effort (harmless if it's a no-op - st still runs
# fine falling back to $TERM=xterm-compatible entries already present).
mkdir -p "$PKGDIR$PREFIX/bin"
cp -f st "$PKGDIR$PREFIX/bin/st"
chmod 755 "$PKGDIR$PREFIX/bin/st"
mkdir -p "$PKGDIR$PREFIX/share/man/man1"
sed "s/VERSION/0.9.3/g" < st.1 > "$PKGDIR$PREFIX/share/man/man1/st.1"
chmod 644 "$PKGDIR$PREFIX/share/man/man1/st.1"
tic st.info 2>/dev/null || true
# st - simple suckless terminal emulator for X
# https://st.suckless.org/

[package]
name = "st"
version = "0.9.3"
release = 1
description = "Simple suckless terminal emulator for X"
url = "https://st.suckless.org/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11", "libXft", "fontconfig", "freetype"]
build = ["libX11", "libXft", "fontconfig", "freetype"]

[[source]]
file = "st-0.9.3.tar.gz"
urls = ["https://dl.suckless.org/st/st-0.9.3.tar.gz"]
checksum = "9ed9feabcded713d4ded38c8cebf36a3b08f0042ef7934a0e2b2409da56e649b"

[build]
parallel = true
#!/bin/bash
# Build script for GNU tar

set -e
cd "$SRCDIR"

# GNU tar configure refuses to run as root by default
export FORCE_UNSAFE_CONFIGURE=1

./configure \
    --build=$BUILD_TRIPLE \
    --host=$BUILD_TRIPLE \
    --prefix=$PREFIX \
    --disable-nls

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# GNU Tar - Tape archiver
# https://www.gnu.org/software/tar/

[package]
name = "tar"
version = "1.35"
release = 1
description = "GNU tar archiving utility"
url = "https://www.gnu.org/software/tar/"
license = "GPL-3.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "tar-1.35.tar.xz"
urls = ["https://ftp.gnu.org/gnu/tar/tar-1.35.tar.xz"]
checksum = "4d62ff37342ec7aed748535323930c7cf94acf71c3591882b26a7ea50f3edc16"


[build]
parallel = true
#!/bin/sh
# Build script for tint2 (CMake, Ninja generator).
# Deps: cairo, pango, glib2, libX11, libXinerama, libXrandr, libXrender,
# libXcomposite, libXdamage, imlib2 (all ported).
#
# CMake doesn't recognize Hammerhead and won't set UNIX=TRUE / pick the
# right shared-lib conventions without a Platform module (same gotcha as
# base/libjpeg-turbo's cmake build) - map it to the SunOS platform module.
#
# ENABLE_BATTERY=OFF: no battery in a VM (task brief).
# ENABLE_TINT2CONF=OFF: tint2conf is a GTK+2 theme configurator - NO GTK
# anywhere per the toolkit-durability decision, and GTK+2 isn't ported.
# ENABLE_RSVG=OFF / ENABLE_SN=OFF: librsvg / libstartup-notification are
# not ported; both are optional (launcher SVG icons / startup-notification
# only) and tint2's CMakeLists gates them cleanly behind these options.
set -e
cd "$SRCDIR"

# GOTCHA (found 2026-07-22): src/util/window.c and src/util/timer.c use the
# BSD u_int32_t/u_int64_t typedefs, which illumos's <sys/types.h> does NOT
# provide (unlike glibc, which defines them unconditionally) - not even
# behind __EXTENSIONS__. window.c already includes <stdint.h>, so just
# swap the type names to their POSIX/C99 uintNN_t equivalents; timer.c
# needs the #include added too.
sed -i -e 's/u_int64_t/uint64_t/g' -e 's/u_int32_t/uint32_t/g' src/util/window.c
sed -i -e 's/u_int64_t/uint64_t/g' src/util/timer.c
{ printf '#include <stdint.h>\n'; cat src/util/timer.c; } > src/util/timer.c.new
mv src/util/timer.c.new src/util/timer.c

# bzero() lives in illumos's <strings.h> (BSD legacy function, not
# <string.h>) - several tint2 files call it without including that header,
# an implicit-declaration error under GCC 14. Prepend the include to every
# file that uses bzero() but doesn't already pull in strings.h.
for f in src/util/common.c src/util/area.c src/util/timer.c \
         src/util/gradient.c src/battery/battery.c; do
    if grep -q 'bzero(' "$f" && ! grep -q 'strings\.h' "$f"; then
        { printf '#include <strings.h>\n'; cat "$f"; } > "$f.new"
        mv "$f.new" "$f"
    fi
done

mkdir -p "$SRCDIR/.cmake/Platform"
echo 'include(Platform/SunOS)' > "$SRCDIR/.cmake/Platform/Hammerhead.cmake"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"

cmake -B build -G Ninja \
    -DCMAKE_MODULE_PATH="$SRCDIR/.cmake" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX="$PREFIX" \
    -DCMAKE_INSTALL_RPATH="$PREFIX/lib" \
    -DCMAKE_C_FLAGS="-D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS" \
    -DENABLE_BATTERY=OFF \
    -DENABLE_TINT2CONF=OFF \
    -DENABLE_RSVG=OFF \
    -DENABLE_SN=OFF

cmake --build build -j${JOBS:-1}
DESTDIR="$PKGDIR" cmake --install build
# tint2 - lightweight X11 panel/taskbar/systray
# https://gitlab.com/o9000/tint2 (mirror: https://github.com/o9000/tint2)

[package]
name = "tint2"
version = "16.2"
release = 1
description = "Lightweight panel/taskbar for X11 window managers"
url = "https://github.com/o9000/tint2"
license = "GPL-2.0-or-later"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["cairo", "pango", "glib2", "libX11", "libXinerama", "libXrandr", "libXrender", "libXcomposite", "libXdamage", "imlib2"]
build = ["cairo", "pango", "glib2", "libX11", "libXinerama", "libXrandr", "libXrender", "libXcomposite", "libXdamage", "imlib2"]

[[source]]
file = "tint2-16.2.tar.gz"
urls = ["https://github.com/o9000/tint2/archive/refs/tags/v16.2.tar.gz"]
checksum = "a95c8a22d4cc117335b3157c7de48da91c8721fc97f86d0353c545eed2598ce8"

[build]
parallel = true
#!/bin/zsh
# Build script for tmux
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
export CPPFLAGS="-I$PREFIX/include"
export LDFLAGS="-L$PREFIX/lib -R$PREFIX/lib"
export LIBS="-lsendfile"

./configure \
    --prefix=$PREFIX

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# tmux - Terminal multiplexer
# https://github.com/tmux/tmux

[package]
name = "tmux"
version = "3.3a"
release = 1
description = "Terminal multiplexer allowing multiple terminals in a single window"
url = "https://github.com/tmux/tmux"
license = "ISC"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libevent", "ncurses"]
build = ["libevent", "ncurses"]

[[source]]
file = "tmux-3.3a.tar.gz"
urls = ["https://github.com/tmux/tmux/releases/download/3.3a/tmux-3.3a.tar.gz"]
checksum = "e4fd347843bd0772c4f48d6dde625b0b109b7a380ff15db21e97c11a4dcdf93f"


[build]
parallel = true
#!/bin/sh
# Build script for tree-sitter (plain Makefile, no deps, no libtool - links
# the shared object directly via $(CC) -shared, gated on `$(CC) -dumpmachine`
# rather than `uname`, so it already falls through cleanly to the generic
# ELF .so branch on Hammerhead).
#
# GOTCHA (1b-2): lib/src/portable/endian.h picks its `#include <endian.h>`
# branch only when __illumos__ (or __linux__/etc) is defined; Hammerhead's
# GCC predefines __sun/__sun__, not __illumos__, so unpatched it falls to
# the final `#error platform not supported`. illumos's own
# /usr/include/endian.h already declares htobe16/le16toh/etc as libc
# externs (confirmed present) - just needs the macro to select that arm.
set -e
cd "$SRCDIR"

export CFLAGS="${CFLAGS} -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS -D__illumos__"

gmake -j${JOBS:-1} PREFIX="$PREFIX"
gmake install PREFIX="$PREFIX" DESTDIR="$PKGDIR"
# tree-sitter - incremental parsing library (neovim's syntax/highlight engine)
# https://tree-sitter.github.io/tree-sitter/

[package]
name = "tree-sitter"
version = "0.26.11"
release = 1
description = "An incremental parsing system for programming tools"
url = "https://tree-sitter.github.io/tree-sitter/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "tree-sitter-0.26.11.tar.gz"
urls = ["https://github.com/tree-sitter/tree-sitter/archive/refs/tags/v0.26.11.tar.gz"]
checksum = "1bab01ed21464f3272665b9c60e39ee79f68da1333e80b23f2c9356569d06971"

[build]
parallel = true
#!/bin/bash
# Build script for tree
# Directory listing utility - no external dependencies

set -e

cd "$SRCDIR"

# illumos fix: rename 'struct comment' to avoid conflict with /usr/include/pwd.h
# which also defines struct comment
for f in *.h *.c; do
    sed -i 's/struct comment/struct tree_comment/g' "$f"
done

# tree uses a simple Makefile, needs some adjustments for illumos
# Override Linux-specific flags

gmake -j${JOBS:-1} \
    CC=gcc \
    CFLAGS="-O2 -Wall -fomit-frame-pointer -DSOLARIS" \
    LDFLAGS="" \
    prefix=$PREFIX \
    MANDIR=$PREFIX/share/man

# Manual install since Makefile doesn't properly support DESTDIR
mkdir -p "$PKGDIR$PREFIX/bin"
mkdir -p "$PKGDIR$PREFIX/share/man/man1"
install -m 755 tree "$PKGDIR$PREFIX/bin/tree"
install -m 644 doc/tree.1 "$PKGDIR$PREFIX/share/man/man1/tree.1"
# tree - List directory contents in a tree-like format
# https://oldmanprogrammer.net/source.php?dir=projects/tree

[package]
name = "tree"
version = "2.1.1"
release = 1
description = "List directory contents in a tree-like format"
url = "https://oldmanprogrammer.net/source.php?dir=projects/tree"
license = "GPL-2.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "2.1.1.tar.gz"
urls = ["https://github.com/Old-Man-Programmer/tree/archive/refs/tags/2.1.1.tar.gz"]
checksum = "1b70253994dca48a59d6ed99390132f4d55c486bf0658468f8520e7e63666a06"


[build]
parallel = true
jobs = 0
--- a/tree.h	2023-11-12 00:00:00.000000000 +0000
+++ b/tree.h	2024-01-24 00:00:00.000000000 +0000
@@ -173,12 +173,12 @@
 #define SORT_SIZE	8192

 /* Comment file parsing (via .info files) */
-struct comment {
+struct tree_comment {
   char *filename;
   int isdir;
-  struct comment *next;
+  struct tree_comment *next;
 };
 struct _info {
-  struct comment *comments;
+  struct tree_comment *comments;
 };

 /* For ANSI terminals */
@@ -300,7 +300,7 @@
 void htmldir(char *dirname, int level, char *newdir);
 void html_encode(FILE *fd, char *s);

-struct comment *infocheck(char *path, char *name, int top, int isdir);
+struct tree_comment *infocheck(char *path, char *name, int top, int isdir);
 struct _info *getinfo(char *name, struct _info *dir);
 void switch_on(char *opt);
 void switch_off(char *opt);
--- a/info.c	2023-11-12 00:00:00.000000000 +0000
+++ b/info.c	2024-01-24 00:00:00.000000000 +0000
@@ -31,7 +31,7 @@
  * Returns NULL if path/name is not found in the .info file.
  * The returned comment structure is in the given cwd _info structure.
  */
-struct comment *infocheck(char *path, char *name, int top, int isdir)
+struct tree_comment *infocheck(char *path, char *name, int top, int isdir)
 {
   static struct _info cwd = {NULL};
   static char *cpath = NULL;
@@ -39,7 +39,7 @@
   char *file, *ptr, *ent;
   FILE *fp;
   size_t flen = 0;
-  struct comment *com, *cp, *cpprev = NULL;
+  struct tree_comment *com, *cp, *cpprev = NULL;
   bool iscomment = false;

   if (cwd.comments != NULL && cpath != NULL && strcmp(path, cpath) == 0) {
@@ -68,7 +68,7 @@
   while (getdelim(&file, &flen, '\n', fp) > 0) {
     ptr = trim(file);
     if (!ptr[0]) continue;
-    if (ptr[0] == '#') { if (com) com = (struct comment *)1; continue; }
+    if (ptr[0] == '#') { if (com) com = (struct tree_comment *)1; continue; }
     if (ptr[0] == '[') {
       char *q = strchr(ptr,']');
       if (q) {
@@ -85,7 +85,7 @@
 	}
 	com = NULL;
       }
-    } else if (com == (struct comment *)1) {
+    } else if (com == (struct tree_comment *)1) {
       com = xmalloc(sizeof(*com));
       com->filename = scopy(ent);
       com->isdir = (*ent && ent[strlen(ent)-1] == '/');
#!/bin/sh
# Build script for unibilium (autotools, Template A variant + autoreconf).
#
# GOTCHA (1b-2): the release tarball ships configure.ac + a hand-written
# Makefile.in (no Makefile.am, no pre-generated `configure`) - must
# autoreconf before the usual libtool-fix + configure steps, same shape as
# base/x11vnc's autoreconf gotcha. autoreconf pulls in its OWN fresh
# config.sub/config.guess (coral's pre-build copy is a no-op here since
# neither file existed in $SRCDIR yet), so they must be re-copied
# post-autoreconf.
set -e
cd "$SRCDIR"

export AUTOCONF=/usr/bin/autoconf
export AUTOHEADER=/usr/bin/autoheader
export ACLOCAL=/usr/bin/aclocal
export AUTOM4TE=/usr/bin/autom4te
export LIBTOOLIZE=/usr/bin/libtoolize

autoreconf -v --install

cp -f /usr/share/autoconf/build-aux/config.sub config.sub 2>/dev/null || true
cp -f /usr/share/autoconf/build-aux/config.guess config.guess 2>/dev/null || true

# MANDATORY libtool fix (Template A): unmatched OS in libtool's
# dynamic-linker case falls through to static-only.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# unibilium - terminfo parser and utility functions (neovim/libtermkey)
# https://github.com/neovim/unibilium

[package]
name = "unibilium"
version = "2.1.2"
release = 1
description = "Terminfo parser library, without any curses dependencies"
url = "https://github.com/neovim/unibilium"
license = "LGPL-3.0-or-later"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "unibilium-2.1.2.tar.gz"
urls = ["https://github.com/neovim/unibilium/archive/refs/tags/v2.1.2.tar.gz"]
checksum = "370ecb07fbbc20d91d1b350c55f1c806b06bf86797e164081ccc977fc9b3af7a"

[build]
parallel = true
#!/bin/sh
# Build script for uthash (header-only, no build system - just stage headers).
# NOTE: headers live under src/, not the tarball root (verified 2026-07-22).
set -e
cd "$SRCDIR/src"

mkdir -p "$PKGDIR$PREFIX/include"
cp -f *.h "$PKGDIR$PREFIX/include/"
# uthash - header-only C hash table / list / array macros (picom build dep)
# https://troydhanson.github.io/uthash/

[package]
name = "uthash"
version = "2.4.0"
release = 1
description = "Header-only C macros for hash tables, lists, arrays and strings"
url = "https://troydhanson.github.io/uthash/"
license = "BSD-1-Clause"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "uthash-2.4.0.tar.gz"
urls = ["https://github.com/troydhanson/uthash/archive/refs/tags/v2.4.0.tar.gz"]
checksum = "387ba027946d7c64e9aa19cc53b2edcd714f8f9dca9fa8e3aaef17e0e8e3d736"

[build]
parallel = true
#!/bin/sh
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR"

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# util-macros - X.Org autoconf macros
# https://gitlab.freedesktop.org/xorg/util/macros

[package]
name = "util-macros"
version = "1.20.2"
release = 1
description = "Autoconf macros used by the X.Org build system"
url = "https://xorg.freedesktop.org/releases/individual/util/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "util-macros-1.20.2.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/util/util-macros-1.20.2.tar.xz"]
checksum = "9ac269eba24f672d7d7b3574e4be5f333d13f04a7712303b1821b2a51ac82e8e"

[build]
parallel = true
#!/bin/bash
# Build script for vim
# Vi IMproved text editor

set -e

cd "$SRCDIR"

# Go directly into src/ to bypass the wrapper script
# (ksh93 has a built-in SRCDIR that causes infinite loops with the wrapper)
cd src

# Configure vim - minimal build, disable NLS to avoid locale issues on illumos
# Use bash explicitly due to ksh93 compatibility issues
CONFIG_SHELL=/usr/bin/bash /usr/bin/bash ./configure \
    --prefix=$PREFIX \
    --with-features=huge \
    --enable-multibyte \
    --disable-gui \
    --without-x \
    --disable-gpm \
    --disable-sysmouse \
    --disable-nls

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"

# Create vi symlink
ln -sf vim "$PKGDIR$PREFIX/bin/vi"
# vim - Vi IMproved text editor
# https://www.vim.org/

[package]
name = "vim"
version = "9.1.0"
release = 1
description = "Vi IMproved - highly configurable text editor"
url = "https://www.vim.org/"
license = "Vim"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["ncurses"]
build = ["ncurses"]

[[source]]
file = "v9.1.0.tar.gz"
urls = ["https://github.com/vim/vim/archive/refs/tags/v9.1.0.tar.gz"]
checksum = "SKIP"


[build]
parallel = true
jobs = 0
#!/bin/bash
# Build script for GNU wget

set -e
cd "$SRCDIR"

# Fix illumos gnulib compatibility issues
for f in lib/localename.c gnulib-tests/localename.c; do
    if [ -f "$f" ]; then
        sed -i 's/extern char \* getlocalename_l/extern const char * getlocalename_l/' "$f"
    fi
done

./configure \
    --prefix=$PREFIX \
    --sysconfdir=$SYSCONFDIR \
    --with-ssl=openssl \
    --disable-nls \
    --disable-pcre2

# Fix illumos memset_s false detection if present
for config in lib/config.h gnulib-tests/config.h config.h; do
    if [ -f "$config" ]; then
        sed -i 's/#define HAVE_MEMSET_S 1/\/* #undef HAVE_MEMSET_S - illumos has it as macro only *\//' "$config"
    fi
done

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# GNU Wget - Network downloader
# https://www.gnu.org/software/wget/

[package]
name = "wget"
version = "1.25.0"
release = 1
description = "GNU Wget - Network downloader supporting HTTP, HTTPS and FTP"
url = "https://www.gnu.org/software/wget/"
license = "GPL-3.0"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["zlib"]
build = ["zlib"]

[[source]]
file = "wget-1.25.0.tar.gz"
urls = ["https://mirrors.kernel.org/gnu/wget/wget-1.25.0.tar.gz"]
checksum = "766e48423e79359ea31e41db9e5c289675947a7fcf2efdcedb726ac9d0da3784"


[build]
parallel = true
#!/bin/sh
# Build script for x11vnc (autotools, Template A variant).
#
# GOTCHA (Task 7a, 2026-07-22): the GitHub tag tarball ships ONLY
# configure.ac/Makefile.am - no pre-generated `configure` at all (confirmed
# via `tar tf`: configure.ac + autogen.sh present, no top-level `configure`,
# no Makefile.in). Must autoreconf before the usual libtool-fix + configure
# steps; the libtool `kopensolaris*-gnu` sed fix is applied to the
# autoreconf-GENERATED configure, same as every other port.
#
# GOTCHA (Task 7a): x11vnc's own configure.ac hard PKG_CHECK_MODULES()s for
# `libvncserver >= 0.9.8` and `libvncclient >= 0.9.8` - this project split
# off the LibVNCServer repo in 2016 and is no longer a bundled/standalone
# VNC codebase (see base/libvncserver/package.toml header). Both must be
# built+installed first (base/libvncserver, this task).
#
# illumos socket libs: configure.ac already does
# AC_CHECK_LIB(nsl,gethostbyname) / AC_CHECK_LIB(socket,socket)
# unconditionally, so -lsocket/-lnsl get added to LIBS automatically by
# autoconf's own probe - no manual LDFLAGS needed for those (unlike the
# CMake-based libvncserver, which required them explicitly).
#
# No --with-jpeg option exists in this x11vnc release's configure.ac (only
# libvncserver's own jpeg support matters - already baked in via
# WITH_JPEG=ON there); the brief's "--with-jpeg=/usr/local" suggestion does
# not apply here and is intentionally omitted.
#
# GOTCHA (Task 7a): autoreconf's internal `automake --add-missing --copy
# --no-force` step reads autoconf's macro trace via `$ENV{AUTOCONF} ||
# 'true'` (automake's scan_autoconf_traces, /usr/bin/automake ~line 5308)
# - when run non-interactively over ssh AUTOCONF is unset, so automake
# silently traces with the no-op `true` command instead of real autoconf,
# sees zero AM_INIT_AUTOMAKE/AC_CONFIG_FILES hits, and fails with the
# misleading "no proper invocation of AM_INIT_AUTOMAKE was found" /
# "no Makefile.am found for any configure output" errors - even though
# configure.ac is completely correct. Fix: export AUTOCONF explicitly
# before autoreconf so it propagates to automake's sub-invocation.
set -e
cd "$SRCDIR"

export AUTOCONF=/usr/bin/autoconf
export AUTOHEADER=/usr/bin/autoheader
export ACLOCAL=/usr/bin/aclocal
export AUTOM4TE=/usr/bin/autom4te

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

test -d m4 || mkdir m4
autoreconf -v --install

# GOTCHA (Task 7a): coral's pre-build step copies the hammerhead-patched
# config.sub/config.guess into any config.sub/config.guess ALREADY present
# in $SRCDIR before build.sh runs - but this port ships NEITHER file (no
# pre-generated configure at all), so that copy is a no-op. autoreconf
# --install then generates its OWN fresh config.sub/config.guess (pulled
# from automake's install-missing machinery), which do NOT carry the
# hammerhead patch, causing `configure: error: ... OS 'hammerhead' not
# recognized`. Re-copy the patched versions here, post-autoreconf.
cp -f /usr/share/autoconf/build-aux/config.sub config.sub 2>/dev/null || true
cp -f /usr/share/autoconf/build-aux/config.guess config.guess 2>/dev/null || true

if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --with-x \
    --x-includes="$PREFIX/include" \
    --x-libraries="$PREFIX/lib" \
    --without-avahi \
    --with-ssl="/usr"

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# x11vnc - VNC server for real (or virtual/Xvfb) X displays
# THE VNC bridge for the headless XLibre/Xvfb desktop.
# https://github.com/LibVNC/x11vnc

[package]
name = "x11vnc"
version = "0.9.17"
release = 1
description = "VNC server for X11 displays"
url = "https://github.com/LibVNC/x11vnc"
license = "GPL-2.0-or-later"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11", "libXext", "libXtst", "libXdamage", "libXfixes", "libXrandr", "libXinerama", "libjpeg-turbo", "libvncserver"]
build = ["libX11", "libXext", "libXtst", "libXdamage", "libXfixes", "libXrandr", "libXinerama", "libjpeg-turbo", "libvncserver", "xorgproto", "util-macros"]

[[source]]
file = "x11vnc-0.9.17.tar.gz"
urls = ["https://github.com/LibVNC/x11vnc/archive/refs/tags/0.9.17.tar.gz"]
checksum = "3ab47c042bc1c33f00c7e9273ab674665b85ab10592a8e0425589fe7f3eb1a69"

[build]
parallel = true
#!/bin/sh
# Build script for xauth (autotools, Template A verbatim).
# Note: configure.ac's PKG_CHECK_MODULES(XAUTH, x11 xau xext xmuu ...) wants
# the "xmuu" pkg-config module, which the libXmu port already ships
# alongside libXmu itself (upstream libXmu builds both libXmu.so and the
# thinner libXmuu.so + xmuu.pc) - no extra dependency needed.
set -e
cd "$SRCDIR"

if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# xauth - X authority file (cookie) manipulation tool
# Direct xlibre-server CDEPEND (>=x11-apps/xauth-1.0.3)
# https://gitlab.freedesktop.org/xorg/app/xauth

[package]
name = "xauth"
version = "1.1.5"
release = 1
description = "X authority file utility"
url = "https://xorg.freedesktop.org/releases/individual/app/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11", "libXau", "libXext", "libXmu"]
build = ["libX11", "libXau", "libXext", "libXmu", "xorgproto", "util-macros"]

[[source]]
file = "xauth-1.1.5.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/app/xauth-1.1.5.tar.xz"]
checksum = "a4000e2f441facebf569026bedecc23ba262cc6927be52070abe0002625cfbe0"

[build]
parallel = true
#!/bin/sh
# Build script for xbitmaps (autotools, Template A). Data-only (X11/bitmaps/*
# bitmap files) - no compiled code, just install(1) via the generated
# Makefile. Ships a pre-generated ./configure, so no xorg-macros/autoreconf
# needed. Pulled in as a motif build dependency: lib/Xm/I18List.c does
# `#include <X11/bitmaps/gray>` (a real X.Org bitmap, unrelated to motif's
# own in-tree bitmaps/ subdir).
set -e
cd "$SRCDIR"

# MANDATORY libtool/config.sub fix - see Template A.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR"

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# xbitmaps - X.Org bitmaps (legacy X11 bitmap data), needed by motif's lib/Xm
# https://gitlab.freedesktop.org/xorg/data/bitmaps

[package]
name = "xbitmaps"
version = "1.1.2"
release = 1
description = "X.Org bitmaps (X11/bitmaps/* data files)"
url = "https://xorg.freedesktop.org/releases/individual/data/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "xbitmaps-1.1.2.tar.gz"
urls = ["https://xorg.freedesktop.org/releases/individual/data/xbitmaps-1.1.2.tar.gz"]
checksum = "27e700e8ee02c43f7206f4eca8f1953ad15236cac95d7a0f08505c3f7d99c265"

[build]
parallel = true
#!/bin/sh
# Build script for xcb-proto (autotools + python, Template A).
# Installs XML protocol descriptions + the xcbgen python module libxcb needs.
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export PYTHON=/usr/local/bin/python3

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR"

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# xcb-proto - XCB protocol descriptions (XML) + xcbgen python codegen module
# https://gitlab.freedesktop.org/xorg/proto/xcbproto

[package]
name = "xcb-proto"
version = "1.17.0"
release = 1
description = "XML-XCB protocol descriptions and the xcbgen Python code generator used by libxcb"
url = "https://xorg.freedesktop.org/releases/individual/xcb/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["python"]
build = ["python"]

[[source]]
file = "xcb-proto-1.17.0.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/xcb/xcb-proto-1.17.0.tar.xz"]
checksum = "2c1bacd2110f4799f74de6ebb714b94cf6f80fb112316b1219480fd22562148c"

[build]
parallel = true
#!/bin/sh
# Build script for xcb-util-image (autotools, Template A).
# Needs xcb-shm (part of libxcb's default extension set) + xcb-util (base module).
set -e
cd "$SRCDIR"

if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# xcb-util-image - port of Xlib's XImage and XShmImage functions to XCB
# https://xcb.freedesktop.org/

[package]
name = "xcb-util-image"
version = "0.4.1"
release = 1
description = "XCB port of Xlib's XImage and XShmImage functions"
url = "https://xcb.freedesktop.org/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libxcb", "xcb-util"]
build = ["libxcb", "xcb-util", "xorgproto"]

[[source]]
file = "xcb-util-image-0.4.1.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/xcb/xcb-util-image-0.4.1.tar.xz"]
checksum = "ccad8ee5dadb1271fd4727ad14d9bd77a64e505608766c4e98267d9aede40d3d"

[build]
parallel = true
#!/bin/sh
# Build script for xcb-util-renderutil (autotools, Template A).
set -e
cd "$SRCDIR"

if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# xcb-util-renderutil - convenience functions for the Render extension
# https://xcb.freedesktop.org/

[package]
name = "xcb-util-renderutil"
version = "0.3.10"
release = 1
description = "Convenience functions for the Render extension (XCB)"
url = "https://xcb.freedesktop.org/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libxcb"]
build = ["libxcb", "xorgproto"]

[[source]]
file = "xcb-util-renderutil-0.3.10.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/xcb/xcb-util-renderutil-0.3.10.tar.xz"]
checksum = "3e15d4f0e22d8ddbfbb9f5d77db43eacd7a304029bf25a6166cc63caa96d04ba"

[build]
parallel = true
#!/bin/sh
# Build script for xcb-util (autotools, Template A).
set -e
cd "$SRCDIR"

# MANDATORY libtool fix - see Template A comment in DESKTOP_XLIBRE_PHASE1A_PLAN.md.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# xcb-util - base XCB utility functions (atom cache, etc.)
# https://xcb.freedesktop.org/

[package]
name = "xcb-util"
version = "0.4.1"
release = 1
description = "Utility libraries for the XCB library (base module)"
url = "https://xcb.freedesktop.org/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libxcb"]
build = ["libxcb", "xorgproto"]

[[source]]
file = "xcb-util-0.4.1.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/xcb/xcb-util-0.4.1.tar.xz"]
checksum = "5abe3bbbd8e54f0fa3ec945291b7e8fa8cfd3cccc43718f8758430f94126e512"

[build]
parallel = true
#!/bin/sh
# Build script for xdm (autotools, Template A).
#
# xdm authenticates via PAM (illumos <security/pam_appl.h> + -lpam, both in
# base). configure autodetects PAM but we pass --with-pam to make it a hard
# requirement (fail loudly rather than silently building a crypt(3)-only xdm).
#
# XDMCP: no --without-xdmcp exists in 1.1.17 (PKG_CHECK_MODULES(DMCP, xdmcp)
# is unconditional). The UDP listener is disabled at runtime instead via the
# shipped config's `DisplayManager.requestPort: 0` (see package.toml).
#
# Patches (patches/, applied -p1 below): illumos portability fixes discovered
# during the alpha10 build. See each patch header for the specific reason.
set -e

# Resolve the port dir (holds patches/) BEFORE cd'ing into the extracted source.
PORTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

cd "$SRCDIR"

# --- Hammerhead/illumos portability patches ---
# coral runs this script under zsh; an unmatched glob is a hard error there,
# so enable NULL_GLOB (empty expansion) when running under zsh. The [ -f ]
# guard covers the /bin/sh case (glob stays literal).
if [ -n "$ZSH_VERSION" ]; then setopt NULL_GLOB 2>/dev/null || true; fi
for p in "$PORTDIR"/patches/*.patch; do
    [ -f "$p" ] || continue
    echo "==> Applying patch: $(basename "$p")"
    patch -p1 < "$p"
done

# MANDATORY libtool fix (Task 4a): this release's libtool-generated
# `configure` has no illumos/hammerhead arm in its dynamic-linker detection
# `case $host_os in ...` block; unmatched OS falls through to
# `*) dynamic_linker=no ;;` forcing static-only. Piggyback hammerhead onto
# the kopensolaris arm.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --with-pam \
    --with-xdmconfigdir="$PREFIX/lib/X11/xdm"

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# xdm - X Display Manager (X.Org)
# The classic X11 display manager: starts a local X server on the console
# VT and presents a graphical Xaw login greeter, authenticating via PAM.
# Second task of the XLibre/xdm greeter plan
# (docs/roadmap/DESKTOP_XLIBRE_XDM_GREETER_PLAN.md).
#
# XDMCP note: this release has no --without-xdmcp configure toggle
# (PKG_CHECK_MODULES(DMCP, xdmcp) is unconditional, so libXdmcp is a hard
# build dep). The remote-login/chooser UDP listener is instead disabled at
# runtime by the shipped default config: config/xdm-config sets
# `DisplayManager.requestPort: 0`, so xdm does not open the XDMCP socket.
#
# https://gitlab.freedesktop.org/xorg/app/xdm

[package]
name = "xdm"
version = "1.1.17"
release = 1
description = "X Display Manager (login greeter, PAM auth)"
url = "https://xorg.freedesktop.org/releases/individual/app/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libXaw", "libXt", "libXmu", "libXpm", "libX11", "libXdmcp", "libXau", "libXext", "libXinerama"]
build = ["libXaw", "libXt", "libXmu", "libXpm", "libX11", "libXdmcp", "libXau", "libXext", "libXinerama", "xorgproto", "util-macros"]

[[source]]
file = "xdm-1.1.17.tar.xz"
urls = ["https://xorg.freedesktop.org/archive/individual/app/xdm-1.1.17.tar.xz"]
checksum = "9494aef0911a031c53670725b5c8c9bb9d3f7c5ea7318b1f72ddd9dcbbeceb6a"

[build]
parallel = true
Fix PAM const-qualifier detection for Hammerhead/illumos.

xdm keys the `XDM_PAM_QUAL` const qualifier (used on the pam_conv callback
and pam_get_item() arguments) on `#ifdef __sun`, assuming any __sun target
uses the classic Solaris non-const PAM prototypes. Hammerhead's GCC defines
__sun, but its <security/pam_appl.h> defaults to the CONST-qualified form
(int (*conv)(int, const struct pam_message **, ...) and pam_get_item(...,
const void **)) unless _PAM_LEGACY_NONCONST is defined. With __sun alone,
XDM_PAM_QUAL expands empty (non-const) and greet.c fails to compile under
GCC 14 with -Wincompatible-pointer-types (now a hard error):

  greet.c:496: initialization of 'int (*)(int, const struct pam_message **,...)'
               from incompatible pointer type 'int (*)(int, struct pam_message **,...)'
  greet.c:588/613/735: passing argument 3 of 'pam_get_item' from incompatible
               pointer type

Gate the non-const branch on _PAM_LEGACY_NONCONST as well, so the qualifier
matches whichever prototype form the PAM headers actually present. On
Hammerhead this selects `const`, matching the default headers; on a legacy
Solaris that defines _PAM_LEGACY_NONCONST it stays empty as before.

--- a/greeter/greet.c
+++ b/greeter/greet.c
@@ -152,9 +152,13 @@ static XtIntervalId	pingTimeout;

 #ifdef USE_PAM

-#ifdef __sun
-/* Solaris does not const qualify arguments to pam_get_item() or the
-   PAM conversation function that Linux-PAM and others do. */
+#if defined(__sun) && defined(_PAM_LEGACY_NONCONST)
+/* Classic Solaris did not const qualify arguments to pam_get_item() or the
+   PAM conversation function that Linux-PAM and others do. Hammerhead's
+   <security/pam_appl.h> defaults to the const-qualified (non-legacy) form
+   unless _PAM_LEGACY_NONCONST is defined, and Hammerhead's GCC also defines
+   __sun, so key the qualifier on _PAM_LEGACY_NONCONST rather than on __sun
+   alone. */
 # define XDM_PAM_QUAL /**/
 #else
 # define XDM_PAM_QUAL const
#!/bin/sh
# Build script for xf86-input-keyboard (autotools, Template A).
#
# Phase 2 Task 4 (M3). Ships a pre-generated `configure` (standard fd.o
# release tarball, unlike xf86-video-illumosfb's git-commit-archive), so no
# autogen.sh/autoreconf step is needed - straight Template A.
#
# Patches (patches/, applied below):
#   01-sun-kbd-headers.patch - add sys/param.h, unistd.h, stropts.h includes
#                              to src/sun_kbd.c (missing-header compile fix
#                              on GCC 14 / illumos headers). Equivalent of
#                              OI's 01-sun-kbd.patch.
#
# Module install dir: like xf86-video-illumosfb, this driver's configure.ac
# computes inputdir=${moduledir}/input, and moduledir defaults from
# --with-xorg-module-dir. The XLibre Xorg server (base/xlibre-xserver-xorg)
# advertises input_drivers_dir=${exec_prefix}/lib/xorg/modules/xlibre-25/drivers/input
# in its xorg-server.pc, so pass
# --with-xorg-module-dir="$PREFIX/lib/xorg/modules/xlibre-25/drivers"
# (NOT ".../xlibre-25" as the video driver used - video's own Makefile.am
# appends "/drivers" itself, whereas ours appends "/input" directly) so the
# built .../input subdir lines up with where Xorg actually looks.
set -e

# Resolve the port dir (holds patches/) BEFORE cd'ing into the extracted source.
PORTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

cd "$SRCDIR"

# --- Hammerhead/illumos portability patches ---
for p in "$PORTDIR"/patches/*.patch; do
    [ -f "$p" ] || continue
    echo "==> Applying patch: $(basename "$p")"
    patch -p1 < "$p"
done

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

# MANDATORY libtool fix (Template A) - piggyback hammerhead onto the
# kopensolaris arm in configure's dynamic-linker case block.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

# OS-detection fix: sun_kbd.c (the VUID /dev/kbd backend) is only selected
# when configure's `case $host_os in ... solaris*) IS_SOLARIS="yes" ;;`
# matches - our host_os is "hammerhead", not "solaris*", so the generated
# configure's unmatched `*)` arm hard-errors with "Your operating system is
# not supported by the kbd driver." Piggyback hammerhead* onto the solaris*
# arm (same VUID/STREAMS ioctl convention) in the *generated* configure
# (this tarball ships one; there is no configure.ac regen step here).
if [ -f configure ]; then
    sed -i -E 's/^  solaris\*\)$/  solaris* | hammerhead*)/' configure
fi

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --with-xorg-module-dir="$PREFIX/lib/xorg/modules/xlibre-25/drivers"

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# xf86-input-keyboard - X.Org keyboard input driver
#
# Phase 2 Task 4 (M3): the VUID /dev/kbd STREAMS backend (src/sun_kbd.c) is
# already upstream (uses sys/vuid_event.h, sys/kbd.h). One local patch adds
# a few missing header includes needed to compile against GCC 14 / illumos
# headers (see patches/01-sun-kbd-headers.patch).

[package]
name = "xf86-input-keyboard"
version = "1.9.0"
release = 1
description = "X.Org keyboard input driver (illumos /dev/kbd VUID backend)"
url = "https://gitlab.freedesktop.org/xorg/driver/xf86-input-keyboard"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["xlibre-xserver-xorg"]
build = ["xlibre-xserver-xorg", "util-macros"]

[[source]]
file = "xf86-input-keyboard-1.9.0.tar.gz"
urls = ["https://www.x.org/archive/individual/driver/xf86-input-keyboard-1.9.0.tar.gz"]
checksum = "407cf742246708843126617feee85b30a8b7b7567b3bc507a6cfda7443a8d9ac"
extract = true

[build]
parallel = true
--- a/src/sun_kbd.c	2026-07-23 13:55:22.652012681 -0500
+++ b/src/sun_kbd.c	2026-07-23 13:59:47.345032786 -0500
@@ -56,9 +56,21 @@
 #include "xf86OSKbd.h"
 #include "sun_kbd.h"
 
-#include <sys/stropts.h>
+/* OI fix (missing-header build failure on illumos/GCC 14): pull in
+ * sys/param.h, unistd.h, stropts.h explicitly - sun_kbd.c uses
+ * usleep()/ioctl() and STREAMS ioctl constants (I_PUSH/I_POP/I_FIND)
+ * that are not reliably pulled in transitively on this toolchain.
+ * sys/kbio.h is ALSO required (not just sys/kbd.h): Hammerhead's
+ * <sys/kbd.h> does not transitively include it, and it is the header
+ * that actually defines the KIOC* keyboard ioctl constants
+ * (KIOCSLED/KIOCGLED/KIOCTYPE/KIOCLAYOUT/KIOCGDIRECT/KIOCSDIRECT/
+ * KIOCCMD/KIOCMKTONE/...) this driver uses throughout. */
+#include <sys/param.h>
+#include <unistd.h>
+#include <stropts.h>
 #include <sys/vuid_event.h>
 #include <sys/kbd.h>
+#include <sys/kbio.h>
 #include <sys/note.h>	/* needed before including older versions of hid.h */
 #include <sys/usb/clients/hid/hid.h>
 
#!/bin/sh
# Build script for xf86-input-mouse (autotools, Template A).
#
# Phase 2 Task 4 (M3). Ships a pre-generated `configure` - straight Template A,
# same shape as xf86-input-keyboard.
#
# Patches (patches/, applied below):
#   01-6892799-mouse-fd-persist.patch - reorder DEVICE_ON/DEVICE_OFF/
#     DEVICE_CLOSE in src/mouse.c so the /dev/mouse fd (+ Xisb buffer) is
#     opened once and closed only at DEVICE_CLOSE, surviving console mode
#     switches (VT enter/leave otherwise churns close()/open() on the VUID
#     stream on every switch). Equivalent of OI's 01-6892799.patch.
#
# Module install dir: same reasoning as xf86-input-keyboard - configure.ac
# computes inputdir=${moduledir}/input, so pass --with-xorg-module-dir
# pointing at .../xlibre-25/drivers so the result lands at
# .../xlibre-25/drivers/input, matching xorg-server.pc's input_drivers_dir.
set -e

# Resolve the port dir (holds patches/) BEFORE cd'ing into the extracted source.
PORTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

cd "$SRCDIR"

# --- Hammerhead/illumos portability patches ---
for p in "$PORTDIR"/patches/*.patch; do
    [ -f "$p" ] || continue
    echo "==> Applying patch: $(basename "$p")"
    patch -p1 < "$p"
done

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"
# sun_mouse.c's CheckRelToAbs() calls libdevinfo's di_init()/di_walk_node()
# under HAVE_ABSOLUTE_MOUSE_SCALING (on by default), but neither
# configure.ac nor src/Makefile.am declares the libdevinfo dependency
# anywhere - a genuine upstream build-system gap for the Solaris/illumos
# path, not something a source patch fixes. automake's generated link line
# includes $(LIBS), so just set it before configure so it gets baked into
# mouse_drv.la's link command. Found at Xorg startup (ld.so.1 relocation
# error: symbol di_init not found), not at compile time - configure/gmake
# both succeed without this; only actually loading the .so into Xorg fails.
export LIBS="${LIBS} -ldevinfo"

# MANDATORY libtool fix (Template A) - piggyback hammerhead onto the
# kopensolaris arm in configure's dynamic-linker case block.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

# OS-detection fix: the generated configure picks the source file to build
# via `case $host_os in ... solaris*) OS_MOUSE_NAME=sun ;; ... esac`, then
# src/Makefile.am uses @OS_MOUSE_NAME@_mouse.c. Our host_os is "hammerhead",
# not "solaris*", so OS_MOUSE_NAME is left empty and the build tries to
# compile a literal "_mouse.c" (missing file). Piggyback hammerhead* onto
# the solaris* arm so OS_MOUSE_NAME=sun selects sun_mouse.c (the VUID
# /dev/mouse backend this task is porting).
if [ -f configure ]; then
    sed -i -E 's/^  solaris\*\)$/  solaris* | hammerhead*)/' configure
fi

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --with-xorg-module-dir="$PREFIX/lib/xorg/modules/xlibre-25/drivers"

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# xf86-input-mouse - X.Org mouse input driver
#
# Phase 2 Task 4 (M3): the VUID /dev/mouse backend (src/mouse.c /
# src/sun_mouse.c) is already upstream. One local patch reorders the
# DEVICE_ON/DEVICE_OFF/DEVICE_CLOSE handling in src/mouse.c so the
# /dev/mouse fd is opened once (at first DEVICE_ON) and closed only at
# DEVICE_CLOSE, instead of being closed/reopened on every console mode
# switch (see patches/01-6892799-mouse-fd-persist.patch). That same patch
# also defines a local `sign()` macro fallback in src/mouse.c: this old
# (2019-era) driver relies on the X server's misc.h `sign()` macro, which
# the XLibre 25.1.8 SDK no longer provides - an SDK-drift build failure
# unrelated to the VUID port itself, found on first alpha10 build attempt.

[package]
name = "xf86-input-mouse"
version = "1.9.5"
release = 1
description = "X.Org mouse input driver (illumos /dev/mouse VUID backend)"
url = "https://gitlab.freedesktop.org/xorg/driver/xf86-input-mouse"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["xlibre-xserver-xorg"]
build = ["xlibre-xserver-xorg", "util-macros"]

[[source]]
file = "xf86-input-mouse-1.9.5.tar.gz"
urls = ["https://www.x.org/archive/individual/driver/xf86-input-mouse-1.9.5.tar.gz"]
checksum = "dc75c9e97f269b5edf80b3bb17ecac7f31c093cd27f74b5220b9d07ee63e0b25"
extract = true

[build]
parallel = true
--- a/src/mouse.c	2026-07-23 13:55:22.649216163 -0500
+++ b/src/mouse.c	2026-07-23 14:01:32.777853582 -0500
@@ -1772,6 +1772,26 @@
         break;
 
     case DEVICE_ON:
+        /*
+         * illumos/Solaris CR 6892799 fix: the VUID /dev/mouse stream
+         * (unlike a plain serial line) does not tolerate being closed
+         * and reopened across every console mode switch (X VT
+         * enter/leave toggles DEVICE_OFF/DEVICE_ON around each
+         * switch). Keep the fd + Xisb buffer alive once opened; only
+         * (re)open here on the very first DEVICE_ON, or if a prior
+         * open attempt failed. DEVICE_OFF no longer closes the fd -
+         * the real close now happens once, in DEVICE_CLOSE.
+         */
+        if (pInfo->fd != -1) {
+            /* Already open from a previous DEVICE_ON - just re-enable. */
+            xf86FlushInput(pInfo->fd);
+            xf86AddEnabledDevice(pInfo);
+            if (pMse->emulate3Buttons || pMse->emulate3ButtonsSoft) {
+                RegisterBlockAndWakeupHandlers (MouseBlockHandler,
+                                                MouseWakeupHandler,
+                                                (pointer) pInfo);
+            }
+        } else {
         pInfo->fd = xf86OpenSerial(pInfo->options);
         if (pInfo->fd == -1)
             xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
@@ -1820,6 +1840,7 @@
                 }
             }
         }
+        }
         pMse->lastButtons = 0;
         pMse->lastMappedButtons = 0;
         pMse->emulateState = 0;
@@ -1832,12 +1853,11 @@
     case DEVICE_OFF:
         if (pInfo->fd != -1) {
             xf86RemoveEnabledDevice(pInfo);
-            if (pMse->buffer) {
-                XisbFree(pMse->buffer);
-                pMse->buffer = NULL;
-            }
-            xf86CloseSerial(pInfo->fd);
-            pInfo->fd = -1;
+            /*
+             * 6892799: do NOT close/free the buffer or fd here - the
+             * VUID /dev/mouse stream must survive the mode switch.
+             * Actual teardown is deferred to DEVICE_CLOSE.
+             */
             if (pMse->emulate3Buttons || pMse->emulate3ButtonsSoft)
             {
                 RemoveBlockAndWakeupHandlers (MouseBlockHandler,
@@ -1848,6 +1868,16 @@
         device->public.on = FALSE;
         break;
     case DEVICE_CLOSE:
+        /* 6892799: the fd/buffer were kept open across DEVICE_OFF/ON
+         * cycles; do the real close here, once, at final teardown. */
+        if (pInfo->fd != -1) {
+            if (pMse->buffer) {
+                XisbFree(pMse->buffer);
+                pMse->buffer = NULL;
+            }
+            xf86CloseSerial(pInfo->fd);
+            pInfo->fd = -1;
+        }
         free(pMse->mousePriv);
         pMse->mousePriv = NULL;
         break;
@@ -3738,6 +3768,16 @@
 #define VAL_THRESHOLD 40
 
 /*
+ * SDK-drift compat fix: mouse.c relies on the X server's misc.h `sign()`
+ * macro, which the XLibre 25.1.8 SDK this port builds against no longer
+ * provides (dropped upstream). Define the historical semantics locally if
+ * it is not already defined by the SDK.
+ */
+#ifndef sign
+#define sign(x) ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0))
+#endif
+
+/*
  * checkForErraticMovements() -- check if mouse 'jumps around'.
  */
 static void
#!/bin/sh
# Build script for xf86-video-illumosfb (autotools, Template A variant).
#
# Phase 2 Task 3 (M2). This port ships NO pre-generated `configure` - only
# configure.ac/Makefile.am + its own autogen.sh (confirmed via `tar tf` on the
# git-commit-archive tarball). Must run `NOCONFIGURE=1 ./autogen.sh` (which is
# just `autoreconf -v --install` under the hood) before the usual
# libtool/config.sub fix + configure, same shape as base/x11vnc (Task 7a).
#
# configure.ac requires xorg-macros (XORG_MACROS_VERSION/XORG_DEFAULT_OPTIONS)
# at aclocal time. base/util-macros installs xorg-macros.m4 under
# $PREFIX/share/aclocal (/usr/local/share/aclocal), which is NOT on aclocal's
# default search path (/usr/share/aclocal) - export ACLOCAL_PATH so the
# autoreconf inside autogen.sh finds it.
#
# Module install dir: configure.ac defaults --with-xorg-module-dir to
# "$libdir/xorg/modules", but this XLibre build (base/xlibre-xserver-xorg)
# uses a versioned moduledir, $libdir/xorg/modules/xlibre-25 (see that port's
# xorg-server.pc: moduledir=${exec_prefix}/lib/xorg/modules/xlibre-25). The
# driver's own Makefile.am appends "/drivers" to @moduledir@, so pass
# --with-xorg-module-dir="$PREFIX/lib/xorg/modules/xlibre-25" here to land
# illumosfb_drv.so where Xorg's video_drivers_dir actually points.
#
# ABI: illumosfb_driver.c's XF86ModuleVersionInfo uses the SDK's
# ABI_VIDEODRV_VERSION macro directly (no hardcoded ABI number) - building
# against xorg-server.pc's SDK headers means the ABI always matches the
# server it's paired with. No ABI patch expected/needed.
set -e
cd "$SRCDIR"

export AUTOCONF=/usr/bin/autoconf
export AUTOHEADER=/usr/bin/autoheader
export ACLOCAL=/usr/bin/aclocal
export AUTOM4TE=/usr/bin/autom4te
export ACLOCAL_PATH="$PREFIX/share/aclocal:$ACLOCAL_PATH"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

NOCONFIGURE=1 ./autogen.sh

# GOTCHA (same as x11vnc, Task 7a): autoreconf --install generates its OWN
# fresh config.sub/config.guess which do NOT carry the hammerhead patch.
# Re-copy the patched versions post-autoreconf, before configure runs.
cp -f /usr/share/autoconf/build-aux/config.sub config.sub 2>/dev/null || true
cp -f /usr/share/autoconf/build-aux/config.guess config.guess 2>/dev/null || true

# MANDATORY libtool fix (Template A) - piggyback hammerhead onto the
# kopensolaris arm in the generated configure's dynamic-linker case block.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --with-xorg-module-dir="$PREFIX/lib/xorg/modules/xlibre-25"

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# xf86-video-illumosfb - illumos native framebuffer video driver for XLibre/Xorg
# https://github.com/LuminousMonkey/xf86-video-illumosfb
#
# Phase 2 Task 3 (M2): the DDX driver that makes the XLibre Xorg server
# (base/xlibre-xserver-xorg, M1) render on Hammerhead's console framebuffer.
# Opens /dev/fb0, validates VIS_GETIDENTIFIER == "illumos_fb", FBIOGATTR +
# mmap + KDSETMODE(KD_GRAPHICS) — the exact path M0's fbtest proved works.
#
# Pinned at git commit 8ad57812ca2e99be6281f5142101811482026c55 (upstream tag
# v0.5, matches the version oi-userland ships). No release tarball exists
# upstream, so the source is a GitHub commit-archive tarball.

[package]
name = "xf86-video-illumosfb"
version = "0.5"
release = 1
description = "illumos native framebuffer video driver for the XLibre/Xorg X server"
url = "https://github.com/LuminousMonkey/xf86-video-illumosfb"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["xlibre-xserver-xorg"]
build = ["xlibre-xserver-xorg", "pixman", "util-macros"]

[[source]]
file = "xf86-video-illumosfb-8ad57812ca2e99be6281f5142101811482026c55.tar.gz"
urls = ["https://github.com/LuminousMonkey/xf86-video-illumosfb/archive/8ad57812ca2e99be6281f5142101811482026c55.tar.gz"]
checksum = "f601e824c7a08189656d77515d9df0c302b669e79f990684527b5e75865c3355"
extract = true

[build]
parallel = true
#!/bin/sh
# Build script for Xfe 2.1.8 (autotools, Template A + CXXFLAGS - C++ port).
# Consumes fox-toolkit via pkg-config (fox.pc, installed to $PREFIX by
# base/fox-toolkit). startup-notification is not ported, so it's disabled.
set -e

PORTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

cd "$SRCDIR"

for p in "$PORTDIR"/patches/*.patch; do
    [ -f "$p" ] || continue
    echo "==> Applying patch: $(basename "$p")"
    patch -p1 < "$p"
done

# MANDATORY libtool fix - see Template A.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
# Xfe's configure finds FOX via `pkg-config fox` (fox.pc) and also probes
# fox-config as a fallback - make sure both resolve under $PREFIX.
export PATH="$PREFIX/bin:$PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export CXXFLAGS="${CXXFLAGS} -I$PREFIX/include -I$PREFIX/include/fox-1.6 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

# GOTCHA: --disable-nls (tried first) has a bad side effect - it makes
# configure skip probing MSGFMT entirely and hardcode it to ":", which
# ALSO breaks `xfe.desktop: xfe.desktop.in` (Makefile.am's rule is
# literally `$(MSGFMT) --desktop -d po --template $< -o $@` - msgfmt has
# a `--desktop` mode used for both translation AND desktop-file
# generation). msgfmt itself IS present on Hammerhead and works fine;
# it's msgmerge (used only inside po/'s own stamp-po recipe, to refresh
# each lang's .po against the .pot before compiling it to .gmo) that's
# missing from our gettext install. So: leave NLS enabled (MSGFMT stays
# real) and instead drop `po` out of SUBDIRS post-configure, skipping
# recursion into the one directory that actually needs msgmerge - the
# top-level `xfe.desktop` rule doesn't need po/ built, it reads the raw
# .po files directly.
sed -i -E 's/^(SUBDIRS[[:space:]]*=[[:space:]]*)po /\1/' Makefile

# GOTCHA #2: turns out moot - Hammerhead's /usr/bin/msgfmt is itself
# non-functional (`msgfmt --version` -> "Cannot open file --version",
# i.e. not real GNU gettext), so configure's own functional probe
# resolves MSGFMT to ":" regardless of NLS/SUBDIRS. Not something to fix
# from this port (system gettext bug, not in scope for xfe/mupdf/neovim/
# XNEdit) - work around it here: since we have no translations to merge
# anyway (po/ excluded above), `msgfmt --desktop`/`--xml` on an
# untranslated build is equivalent to a plain copy of the .in template.
sed -i -E 's#\$\(MSGFMT\) --(desktop|xml) -d \$\(top_srcdir\)/po --template \$< -o \$@#cp $< $@#' Makefile

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# Xfe - X File Explorer, a lightweight file manager built on FOX
# https://sourceforge.net/projects/xfe/

[package]
name = "xfe"
version = "2.1.8"
release = 1
description = "X File Explorer - lightweight file manager (FOX toolkit)"
url = "https://sourceforge.net/projects/xfe/"
license = "GPL-2.0-or-later"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["fox-toolkit", "libX11", "libXft", "freetype", "fontconfig"]
build = ["fox-toolkit", "libX11", "libXft", "freetype", "fontconfig"]

[[source]]
file = "xfe-2.1.8.tar.xz"
urls = ["https://sourceforge.net/projects/xfe/files/xfe/2.1.8/xfe-2.1.8.tar.xz/download"]
checksum = "f539dd333296d91bd318ba62403bc7bee4069262df23f518e4453c80273b82be"

[build]
parallel = true
From: Chris Tusa <chris.tusa@leafscale.com>
Subject: pkg_format/OTHER_PKG: declare on non-Linux/FreeBSD (Hammerhead)

Both pkg_format (main.cpp) and the OTHER_PKG constant it's
initialized to (xfedefs.h) are gated behind #if defined(__FreeBSD__)
or #if defined(linux) (used later, unconditionally, to seed the
"package_format" registry entry read by Xfe's open-with/install-package
UI). GCC on Hammerhead (illumos derivative) predefines neither macro,
so neither the constant nor the variable exist and the
writeUnsignedEntry(..., pkg_format) call fails to compile. Add a
Hammerhead/generic-illumos fallback in both files that just defaults
to OTHER_PKG (we have no deb/rpm-equivalent to autodetect and don't
want one guessed).

diff --git a/src/xfedefs.h b/src/xfedefs.h
--- a/src/xfedefs.h	2026-02-08 05:02:51.000000000 -0600
+++ b/src/xfedefs.h	2026-07-22 20:50:35.798811328 -0500
@@ -426,3 +426,7 @@
 #define OTHER_PKG    2
 
 #endif
+
+#if !defined(__FreeBSD__) && !defined(linux)
+#define OTHER_PKG    2
+#endif

diff --git a/src/main.cpp b/src/main.cpp
--- a/src/main.cpp	2026-01-17 10:07:41.000000000 -0600
+++ b/src/main.cpp	2026-07-22 20:50:35.798910014 -0500
@@ -423,6 +423,10 @@
     }
 #endif
 
+#if !defined(__FreeBSD__) && !defined(linux)
+    FXuint pkg_format = OTHER_PKG;
+#endif
+
     // Parse basic arguments
     for (i = 1; i < argc; ++i)
     {
From: Chris Tusa <chris.tusa@leafscale.com>
Subject: st/st.c: openpty() header include for Hammerhead

The bundled st (simple terminal) code's openpty() include is gated on
__linux / BSD-family / __APPLE__ macros only. GCC on Hammerhead
(illumos derivative) predefines none of these, so <libutil.h> (the
header illumos itself ships openpty() in - confirmed present at
/usr/include/libutil.h) never gets included and openpty() is an
implicit (and, under GCC14, error-level) declaration. Add a fallback
#else including the same illumos-native libutil.h.

diff --git a/st/st.c b/st/st.c
--- a/st/st.c	2026-01-17 10:07:39.000000000 -0600
+++ b/st/st.c	2026-07-22 20:52:24.005607327 -0500
@@ -31,6 +31,8 @@
 #include <util.h>
 #elif defined(__FreeBSD__) || defined(__DragonFly__)
 #include <libutil.h>
+#else
+#include <libutil.h>
 #endif
 
 /* Arbitrary sizes */
#!/bin/sh
# Build script for xinit (autotools, Template A verbatim).
# Not strictly required for the headless Xvfb+x11vnc launch path but it's
# the standard X launcher (xinit + startx) and cheap to build.
set -e
cd "$SRCDIR"

if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# xinit - X Window System initializer (xinit + startx)
# https://gitlab.freedesktop.org/xorg/app/xinit

[package]
name = "xinit"
version = "1.4.4"
release = 1
description = "X Window System initializer (xinit/startx)"
url = "https://xorg.freedesktop.org/releases/individual/app/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11"]
build = ["libX11", "xorgproto", "util-macros"]

[[source]]
file = "xinit-1.4.4.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/app/xinit-1.4.4.tar.xz"]
checksum = "40a47c7a164c7f981ce3787b4b37f7e411fb43231dcde543d70094075dacfef9"

[build]
parallel = true
#!/bin/sh
# Build script for xkbcomp (autotools, Template A verbatim).
set -e
cd "$SRCDIR"

# MANDATORY libtool fix (Task 4a, 2026-07-22): see libXau/build.sh for the
# full explanation. Piggyback hammerhead onto the kopensolaris arm.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# xkbcomp - X keyboard description compiler
# Direct xlibre-server CDEPEND (x11-apps/xkbcomp, unconditional) - the
# server execs xkbcomp to compile keymaps at runtime.
# https://gitlab.freedesktop.org/xorg/app/xkbcomp

[package]
name = "xkbcomp"
version = "1.5.0"
release = 1
description = "X keyboard description compiler"
url = "https://xorg.freedesktop.org/releases/individual/app/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11", "libxkbfile"]
build = ["libX11", "libxkbfile", "xorgproto", "util-macros"]

[[source]]
file = "xkbcomp-1.5.0.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/app/xkbcomp-1.5.0.tar.xz"]
checksum = "2ac31f26600776db6d9cd79b3fcd272263faebac7eb85fb2f33c7141b8486060"

[build]
parallel = true
#!/bin/sh
# Build script for xkeyboard-config (Meson, Template B variant, DATA-only port).
#
# No shared library ships from this port - it's the keymap XML/rules
# database the XLibre server (and xkbcomp) load/compile at runtime under
# $PREFIX/share/X11/xkb (legacy path) and $PREFIX/share/xkeyboard-config-2/
# (canonical path, meson.build's dir_xkb_base).
#
# gettext/NLS decision (Task 7a, 2026-07-22): meson.build's po/meson.build
# only runs i18n.gettext() when -Dnls is true (default true). alpha9's
# /usr/bin/msgfmt is illumos-native SVR4 msgfmt, NOT GNU-gettext compatible
# (same finding as Task 6's glib2 -Dnls=disabled decision - see memory
# glib2 gettext prereq). Pass -Dnls=false explicitly so meson's i18n
# module never invokes msgfmt/xgettext; this only disables translated
# rules/model descriptions, not keymap functionality itself.
#
# xsltproc (man page generation) is absent on alpha9; meson.build's
# find_program('xsltproc', required: false) already makes that optional,
# so no flag needed - the man page subdir is silently skipped.
#
# rules/meson.build requires python3 >= 3.11 (alpha9 has 3.13.2, built
# Task 2/M0) to run `python3 -m rules.generator` for the base/evdev rules
# files, plus the in-tree rules/xml2lst.pl perl script (perl present in
# base) - both resolved automatically by meson's find_program/pymod.
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -Wl,-R,$PREFIX/lib"

meson setup build \
    --prefix="$PREFIX" \
    --libdir=lib \
    --buildtype=release \
    -Dcompat-rules=true \
    -Dnls=false

ninja -C build -j${JOBS:-1}
DESTDIR="$PKGDIR" ninja -C build install
# xkeyboard-config - X keyboard configuration database (keymap XML/rules)
# Direct xlibre-server CDEPEND (>=x11-misc/xkeyboard-config-2.4.1-r3)
# https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config

[package]
name = "xkeyboard-config"
version = "2.48"
release = 1
description = "X keyboard configuration database"
url = "https://xorg.freedesktop.org/releases/individual/data/xkeyboard-config/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = ["util-macros"]

[[source]]
file = "xkeyboard-config-2.48.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/data/xkeyboard-config/xkeyboard-config-2.48.tar.xz"]
checksum = "b77041324f0109f77161ee43743fe04baa485866af8460d31e476ad3f7648fd5"

[build]
parallel = true
#!/bin/sh
# Build script for xlibre-xserver-xorg (Meson, Template B) — the Xorg DDX.
#
# Sibling of base/xlibre-xserver (Xvfb-only). Same XLibre 25.1.8 source, same
# os-layer portability patches, but -Dxorg=true so it produces
# /usr/local/bin/Xorg — the server xf86-video-illumosfb (Phase-2 M2) plugs into.
#
# Patches (patches/, applied below):
#   0001 os/meson.build       - Solaris socket defines under Hammerhead sysname
#   0002 os/ospoll.c          - illumos event-ports listener re-arm fix
#   0003 os-support/meson.build - select the solaris console backend for
#                                 Hammerhead (else it falls to the no-op stub;
#                                 the solaris arm is the load-bearing
#                                 /dev/console + VT_SETDISPINFO layer)
#
# Meson option notes (verified against this tree's meson_options.txt):
#   * -Dgbm / -Dxf86-input-null are NOT options in 25.1.8 (dropped, same as the
#     Xvfb port). glamor_egl is gated on gbm_dep.found(); with no gbm on
#     Hammerhead it's skipped. Intent preserved: Xorg on; DRM/GL/udev/hal off.
#   * -Dpciaccess=false: illumosfb does no PCI probing. hw/xfree86/meson.build
#     and os-support/meson.build gate all pciaccess use on get_option('pciaccess'),
#     so bus/Pci.c and the pciaccess dependency are skipped cleanly. If the DDX
#     turns out to hard-require it, build base/libpciaccess and flip to true.
#   * -Dsha1=libcrypto uses base OpenSSL libcrypto (as the Xvfb port).
#   * -Dglx=false: glx/meson.build hard-requires the 'gl' (libGL/Mesa) dep,
#     which Hammerhead has no port of. GLX is server-side OpenGL indirect
#     rendering; the framebuffer illumosfb driver (M2) does no GL, so GLX is
#     dead weight. Disabled (matches the Xvfb port). Revisit if/when Mesa lands.
#   * linker_export_flags: on Hammerhead host_machine.system() != 'sunos', so
#     hw/xfree86/meson.build falls to the GNU-ld `-Wl,--export-dynamic` branch —
#     which is exactly what we want so Xorg modules resolve xf86* symbols back
#     into the server. (The 'sunos' branch sets empty flags for the illumos ld;
#     we use GNU ld, so we deliberately do NOT match it here.)
set -e

# Resolve the port dir (holds patches/) BEFORE cd'ing into the extracted source.
PORTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

cd "$SRCDIR"

# --- Hammerhead/illumos portability patches (rationale in each patch header) ---
for p in "$PORTDIR"/patches/*.patch; do
    [ -f "$p" ] || continue
    echo "==> Applying patch: $(basename "$p")"
    patch -p1 < "$p"
done

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
# Template B illumos flags: __EXTENSIONS__ + _POSIX_PTHREAD_SEMANTICS select the
# XPG/POSIX prototypes (msg_control, *_r, etc.). coral's default CFLAGS is only
# "-O2 -pipe" and its LDFLAGS is just "-R$PREFIX/lib", so add the rest here.
export CFLAGS="${CFLAGS} -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -Wl,-R,$PREFIX/lib"

meson setup build \
    --prefix="$PREFIX" \
    --libdir=lib \
    --buildtype=release \
    -Dxorg=true -Dxvfb=true \
    -Dxephyr=false -Dxnest=false -Dxfbdev=false -Dxwin=false -Dxquartz=false \
    -Dglamor=false -Dglx=false -Dglx_dri=false \
    -Ddri1=false -Ddri2=false -Ddri3=false -Ddrm=false \
    -Dudev=false -Dudev_kms=false -Dhal=false \
    -Dsystemd_logind=false -Dsystemd_notify=false -Dseatd_libseat=false \
    -Dsuid_wrapper=false -Dxcsecurity=false -Dxselinux=false \
    -Dpciaccess=false -Dagp=false -Dint10=false -Dvgahw=false \
    -Dxf86bigfont=false -Dtests=false \
    -Ddocs=false -Ddevel-docs=false -Ddocs-pdf=false \
    -Dxf86-input-inputtest=false \
    -Ddtrace=false -Dlinux_acpi=false -Dlinux_apm=false \
    -Dsha1=libcrypto \
    -Dxkb_dir=/usr/local/share/X11/xkb \
    -Dxkb_bin_dir=/usr/local/bin \
    -Dxkb_output_dir=/var/lib/xkb

ninja -C build -j${JOBS:-1}
DESTDIR="$PKGDIR" ninja -C build install
# xlibre-xserver-xorg - XLibre Xorg DDX (the full hardware-driver X server)
# Sibling of base/xlibre-xserver (the Xvfb-only headless build). Same XLibre
# 25.1.8 source tree + the same os-layer portability patches, but built with
# -Dxorg=true so it produces /usr/local/bin/Xorg. This is the server the
# native framebuffer driver (xf86-video-illumosfb, Phase-2 M2) plugs into.
# XLibre retains hw/xfree86/os-support/solaris/ (sun_init.c: /dev/console +
# VT_SETDISPINFO) - the illumos console backend, selected via patch 0003.
# https://github.com/X11Libre/xserver

[package]
name = "xlibre-xserver-xorg"
version = "25.1.8"
release = 1
description = "XLibre X server (Xorg DDX for the native framebuffer console)"
url = "https://github.com/X11Libre/xserver"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["pixman", "libX11", "libXfont2", "libxkbfile", "libXau", "libXdmcp", "libXext", "font-util", "xkeyboard-config", "xkbcomp", "xauth", "libxcvt"]
build = ["pixman", "xorgproto", "xtrans", "libXfont2", "libxkbfile", "font-util", "util-macros", "libX11", "libXau", "libXdmcp", "libXext", "libXfixes", "libxcvt"]

[[source]]
file = "xlibre-xserver-25.1.8.tar.gz"
urls = ["https://github.com/X11Libre/xserver/archive/refs/tags/xlibre-xserver-25.1.8.tar.gz"]
checksum = "18091f53e8700801b61f0d20c30d850d1060cb31f6a0d2046249bb413809ae16"

[build]
parallel = true
Treat Hammerhead like Solaris/illumos in the os-layer meson build.

Meson derives host_machine.system() from uname sysname, which on Hammerhead
is "hammerhead", not "sunos". The os/ static library's Solaris branch (which
adds -lsocket/-lnsl and the _XOPEN_SOURCE/__EXTENSIONS__ defines needed for
struct msghdr.msg_control and the XPG socket API) therefore never fires,
producing undefined socket()/gethostbyname() symbols at link time. Hammerhead
IS illumos, so extend the guard to match its sysname.

--- a/os/meson.build
+++ b/os/meson.build
@@ -63,7 +63,7 @@
 os_c_args = []
 
 # eg. struct msghdr -> msg_control 
-if host_machine.system() == 'sunos'
+if host_machine.system() == 'sunos' or host_machine.system() == 'hammerhead'
     os_c_args += '-D_XOPEN_SOURCE=1'
     os_c_args += '-D_XOPEN_SOURCE_EXTENDED=1'
     os_c_args += '-D__EXTENSIONS__'
Fix inverted re-arm check in the illumos event-ports (PORT_SOURCE_FD) ospoll
backend - the listening socket only ever accepted exactly one client for the
lifetime of the server.

Root cause (found 2026-07-22, hh-alpha9, Task 8 M5 integration test):
illumos event ports are one-shot per delivered event - once port_getn()
returns an event for a PORT_SOURCE_FD object, that fd is automatically
dissociated from the port and MUST be re-associated (port_associate() again,
done here via epoll_mod()) to keep receiving further events on it.

ospoll_wait()'s PORT-backend dispatch loop re-arms level-triggered fds with:

    if (osfd->trigger == ospoll_trigger_level &&
        !xorg_list_is_empty(&osfd->deleted)) {
        epoll_mod(ospoll, osfd);
    }

osfd->deleted is the intrusive list node ospoll_remove() links onto
ospoll->deleted when an fd is torn down (see the xorg_list_add call right
after port_dissociate() in ospoll_remove()). So xorg_list_is_empty(&osfd->deleted)
is true exactly when this specific fd has NOT just been removed by its own
callback - i.e. it's still a live, valid fd safe to re-arm.

The listening socket is a level-triggered fd that lives for the entire
server lifetime and is never removed, so its deleted node is always empty.
With the `!` in front, the condition only fires when the fd HAS just been
deleted (backwards - re-arming an fd that's about to be freed), and never
fires for the common "still alive" case. Net effect: the listen socket's
single initial port_associate() (done at ospoll_add time) gets consumed by
the first accept() event and is never renewed, so every connection after
the first sits unnoticed in the kernel accept backlog forever.

Confirmed via truss -p <Xvfb pid>: after the first client's full connection
setup, port_getn() goes back to sleeping and no further accept(4, ...) call
is ever made, even though a second client's connect() has already completed
at the socket layer (visible in `netstat -f unix` as a live but un-accepted
pair). Fix: drop the negation so accepting fds get re-armed, and only skip
fds that were actually just torn down.

--- a/os/ospoll.c
+++ b/os/ospoll.c
@@ -638,7 +638,7 @@
             osfd->callback(osfd->fd, xevents, osfd->data);

         if (osfd->trigger == ospoll_trigger_level &&
-            !xorg_list_is_empty(&osfd->deleted)) {
+            xorg_list_is_empty(&osfd->deleted)) {
             epoll_mod(ospoll, osfd);
         }
     }
Select the Solaris/illumos os-support backend for Hammerhead in the Xorg DDX.

hw/xfree86/os-support/meson.build picks the per-OS console backend from
host_machine.system(). On Hammerhead uname sysname is "hammerhead", not
"sunos", so the `elif host_machine.system() == 'sunos'` arm never fires and
the build silently falls through to the generic *stub* backend (stub_init.c,
VTsw_noop, etc.). That stub is a no-op: xf86OpenConsole() does nothing, so the
server never touches /dev/console / VT_SETDISPINFO and can't drive the
framebuffer console the M2 illumosfb driver targets.

Hammerhead IS illumos, so the solaris arm (sun_init.c: /dev/console +
VT_SETDISPINFO, sun_vid.c, sun_apm/bell, solaris-amd64.S port I/O) is exactly
the load-bearing console layer we need. Extend the guard to match Hammerhead's
sysname, mirroring the os/meson.build sunos-sysname patch (0001).

--- a/hw/xfree86/os-support/meson.build
+++ b/hw/xfree86/os-support/meson.build
@@ -62,7 +62,7 @@ if host_machine.system() == 'linux'
         srcs_xorg_os_support += 'shared/pm_noop.c'
     endif

-elif host_machine.system() == 'sunos'
+elif host_machine.system() == 'sunos' or host_machine.system() == 'hammerhead'
     srcs_xorg_os_support += [
         'solaris/sun_apm.c',
         'solaris/sun_bell.c',
Fix build of the Solaris APM os-support file: include xf86_priv.h.

XLibre moved the power-management hook declarations
    extern int (*xf86PMGetEventFromOs)(...);
    extern pmWait (*xf86PMConfirmEventToOs)(...);
    void xf86HandlePMEvents(int fd, void *data);
into hw/xfree86/common/xf86_priv.h (lowercase-underscore), and updated the
Linux backend (lnx_apm.c / lnx_acpi.c include "xf86_priv.h") but NOT the
Solaris backend. hw/xfree86/os-support/solaris/sun_apm.c still includes only
"xf86Priv.h" (capital-P, a different header), so on Hammerhead/illumos - the
only platform that still compiles sun_apm.c - xf86OSPMOpen() fails with
"xf86PMGetEventFromOs undeclared" (GCC 14 hard error). This never surfaced
upstream because XLibre's CI has no illumos target. Add the missing include,
matching lnx_apm.c.

--- a/hw/xfree86/os-support/solaris/sun_apm.c
+++ b/hw/xfree86/os-support/solaris/sun_apm.c
@@ -58,6 +58,7 @@

 #include "os.h"
 #include "xf86.h"
+#include "xf86_priv.h"
 #include "xf86Priv.h"
 #include "xf86_os_support.h"
 #include "xf86_OSproc.h"
Disable the X server input thread by default on Hammerhead/illumos.

XLibre's threaded input (INPUTTHREAD, default on for non-Windows) runs a
separate input thread whose ospoll uses the Solaris event-ports backend
(port_getn / portfs). On illumos the input->main wakeup self-pipe fd is
re-armed reporting POLLIN "ready" every cycle with nothing to deliver, so
the input thread and the main thread ping-pong on that pipe as fast as the
CPU allows: measured ~340k portfs+write/s on [InputThread] and ~225k
portfs+read/s on [MainThread] = TWO fully pegged cores at idle (conky read
CPU 247%, load avg 2.0), and a sluggish pointer because the saturated main
thread services real motion late. The kbd/consms device fds themselves were
fine (no repeated reads, errno 0) - it is purely the threaded-input wakeup
pipe. Xvfb never hit this (no real input devices, no input thread).

XLibre REMOVED the historic `-noThreadedInput` command-line flag (only
`-dumbSched` still sets InputThreadEnable = FALSE, but that also disables the
smart scheduler). Rather than depend on a launch flag that a boot service or
.xinitrc could forget - reintroducing a 200%-CPU mystery - flip the compiled
default so a plain `Xorg` invocation is correct. Input is then serviced in
the main dispatch loop (the pre-2016 default; fully functional). The smart
scheduler is left untouched. All InputThread machinery stays compiled in, so
`-dumbSched`/future flags could still toggle it.

This is an illumos/Solaris-specific XLibre defect (event-ports ospoll re-arm
vs. the threaded-input self-pipe); XLibre CI has no illumos target. Worth
filing upstream. Complements 0002-ospoll-port-listener-rearm.

--- a/os/inputthread.c
+++ b/os/inputthread.c
@@ -44,7 +44,7 @@

 #if INPUTTHREAD

-Bool InputThreadEnable = TRUE;
+Bool InputThreadEnable = FALSE;

 /**
  * An input device as seen by the threaded input facility
#!/bin/sh
# Build script for xlibre-xserver (Meson, Template B) — Xvfb-only headless build.
#
# THE crux port of the desktop initiative. Builds ONLY the Xvfb DDX (headless
# software framebuffer): no hardware/DRM/GL, no udev/logind, no xorg/xephyr/etc.
# x11vnc (Task 7a) later bridges the Xvfb display to VNC.
#
# XLibre has BSD CI but no illumos/Hammerhead target, so this port carries
# Hammerhead portability patches in patches/ (applied below).
#
# Meson option notes (verified against this tree's meson_options.txt):
#   * -Dgbm / -Dxf86-input-null from the original manifest capture do NOT
#     exist as options in 25.1.8 and are intentionally dropped (gbm is only
#     ever probed as required:false, and the null input driver isn't an
#     option here). Intent preserved: Xvfb on, all hardware/GL/DRM off.
#   * -Dsha1=libcrypto uses base OpenSSL's libcrypto (find_library('crypto')
#     resolves /usr/lib/libcrypto.so; <openssl/sha.h> in base /usr/include).
#   * libdrm/pciaccess/epoxy/gbm are all probed required:false in meson.build,
#     so the -D*=false switches don't trip a hard missing-dependency error on
#     Hammerhead (none of those libs exist here). Verified by source read.
set -e

# Resolve the port dir (holds patches/) BEFORE cd'ing into the extracted source.
PORTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

cd "$SRCDIR"

# --- Hammerhead/illumos portability patches (rationale in each patch header) ---
for p in "$PORTDIR"/patches/*.patch; do
    [ -f "$p" ] || continue
    echo "==> Applying patch: $(basename "$p")"
    patch -p1 < "$p"
done

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
# Template B illumos flags: __EXTENSIONS__ + _POSIX_PTHREAD_SEMANTICS select the
# XPG/POSIX prototypes (msg_control, *_r, etc.). coral's default CFLAGS is only
# "-O2 -pipe" and its LDFLAGS is just "-R$PREFIX/lib", so add the rest here.
export CFLAGS="${CFLAGS} -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -Wl,-R,$PREFIX/lib"

meson setup build \
    --prefix="$PREFIX" \
    --libdir=lib \
    --buildtype=release \
    -Dxvfb=true \
    -Dxorg=false -Dxephyr=false -Dxnest=false -Dxfbdev=false -Dxwin=false -Dxquartz=false \
    -Dglamor=false -Dglx=false -Dglx_dri=false \
    -Ddri1=false -Ddri2=false -Ddri3=false -Ddrm=false \
    -Dudev=false -Dudev_kms=false -Dhal=false \
    -Dsystemd_logind=false -Dsystemd_notify=false -Dseatd_libseat=false \
    -Dsuid_wrapper=false -Dxcsecurity=false -Dxselinux=false \
    -Dpciaccess=false -Dagp=false -Dint10=false -Dvgahw=false \
    -Dxf86bigfont=false -Dtests=false \
    -Ddocs=false -Ddevel-docs=false -Ddocs-pdf=false \
    -Dxf86-input-inputtest=false \
    -Ddtrace=false -Dlinux_acpi=false -Dlinux_apm=false \
    -Dsha1=libcrypto \
    -Dxkb_dir=/usr/local/share/X11/xkb \
    -Dxkb_bin_dir=/usr/local/bin \
    -Dxkb_output_dir=/var/lib/xkb

ninja -C build -j${JOBS:-1}
DESTDIR="$PKGDIR" ninja -C build install
# xlibre-xserver - XLibre X server, built Xvfb-only (headless software framebuffer)
# THE crux port of the desktop initiative. No hardware/DRM/GL DDX - just Xvfb,
# which x11vnc then bridges to VNC. XLibre has no illumos upstream target, so
# this port carries Hammerhead/illumos portability patches (see patches/).
# https://github.com/X11Libre/xserver

[package]
name = "xlibre-xserver"
version = "25.1.8"
release = 1
description = "XLibre X server (Xvfb-only headless build)"
url = "https://github.com/X11Libre/xserver"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["pixman", "libX11", "libXfont2", "libxkbfile", "libXau", "libXdmcp", "libXext", "font-util", "xkeyboard-config", "xkbcomp", "xauth"]
build = ["pixman", "xorgproto", "xtrans", "libXfont2", "libxkbfile", "font-util", "util-macros", "libX11", "libXau", "libXdmcp", "libXext", "libXfixes"]

[[source]]
file = "xlibre-xserver-25.1.8.tar.gz"
urls = ["https://github.com/X11Libre/xserver/archive/refs/tags/xlibre-xserver-25.1.8.tar.gz"]
checksum = "18091f53e8700801b61f0d20c30d850d1060cb31f6a0d2046249bb413809ae16"

[build]
parallel = true
Treat Hammerhead like Solaris/illumos in the os-layer meson build.

Meson derives host_machine.system() from uname sysname, which on Hammerhead
is "hammerhead", not "sunos". The os/ static library's Solaris branch (which
adds -lsocket/-lnsl and the _XOPEN_SOURCE/__EXTENSIONS__ defines needed for
struct msghdr.msg_control and the XPG socket API) therefore never fires,
producing undefined socket()/gethostbyname() symbols at link time. Hammerhead
IS illumos, so extend the guard to match its sysname.

--- a/os/meson.build
+++ b/os/meson.build
@@ -63,7 +63,7 @@
 os_c_args = []
 
 # eg. struct msghdr -> msg_control 
-if host_machine.system() == 'sunos'
+if host_machine.system() == 'sunos' or host_machine.system() == 'hammerhead'
     os_c_args += '-D_XOPEN_SOURCE=1'
     os_c_args += '-D_XOPEN_SOURCE_EXTENDED=1'
     os_c_args += '-D__EXTENSIONS__'
Fix inverted re-arm check in the illumos event-ports (PORT_SOURCE_FD) ospoll
backend - the listening socket only ever accepted exactly one client for the
lifetime of the server.

Root cause (found 2026-07-22, hh-alpha9, Task 8 M5 integration test):
illumos event ports are one-shot per delivered event - once port_getn()
returns an event for a PORT_SOURCE_FD object, that fd is automatically
dissociated from the port and MUST be re-associated (port_associate() again,
done here via epoll_mod()) to keep receiving further events on it.

ospoll_wait()'s PORT-backend dispatch loop re-arms level-triggered fds with:

    if (osfd->trigger == ospoll_trigger_level &&
        !xorg_list_is_empty(&osfd->deleted)) {
        epoll_mod(ospoll, osfd);
    }

osfd->deleted is the intrusive list node ospoll_remove() links onto
ospoll->deleted when an fd is torn down (see the xorg_list_add call right
after port_dissociate() in ospoll_remove()). So xorg_list_is_empty(&osfd->deleted)
is true exactly when this specific fd has NOT just been removed by its own
callback - i.e. it's still a live, valid fd safe to re-arm.

The listening socket is a level-triggered fd that lives for the entire
server lifetime and is never removed, so its deleted node is always empty.
With the `!` in front, the condition only fires when the fd HAS just been
deleted (backwards - re-arming an fd that's about to be freed), and never
fires for the common "still alive" case. Net effect: the listen socket's
single initial port_associate() (done at ospoll_add time) gets consumed by
the first accept() event and is never renewed, so every connection after
the first sits unnoticed in the kernel accept backlog forever.

Confirmed via truss -p <Xvfb pid>: after the first client's full connection
setup, port_getn() goes back to sleeping and no further accept(4, ...) call
is ever made, even though a second client's connect() has already completed
at the socket layer (visible in `netstat -f unix` as a live but un-accepted
pair). Fix: drop the negation so accepting fds get re-armed, and only skip
fds that were actually just torn down.

--- a/os/ospoll.c
+++ b/os/ospoll.c
@@ -638,7 +638,7 @@
             osfd->callback(osfd->fd, xevents, osfd->data);

         if (osfd->trigger == ospoll_trigger_level &&
-            !xorg_list_is_empty(&osfd->deleted)) {
+            xorg_list_is_empty(&osfd->deleted)) {
             epoll_mod(ospoll, osfd);
         }
     }
#!/bin/sh
# Build script for XNEdit 1.6.3 (classic NEdit-style, target-keyed plain
# Makefile - NOT Template A/autotools). The top-level Makefile has no
# uname-autodetect: it dispatches on an explicit `make <target>` name to
# `makefiles/Makefile.<target>`, so we add our own
# makefiles/Makefile.hammerhead (patches/0001-add-makefile-hammerhead.patch)
# rather than adapting an existing OS's file in place.
set -e

PORTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

cd "$SRCDIR"

for p in "$PORTDIR"/patches/*.patch; do
    [ -f "$p" ] || continue
    echo "==> Applying patch: $(basename "$p")"
    patch -p1 < "$p"
done

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"

gmake -j${JOBS:-1} hammerhead

# `install:` target respects PREFIX/DESTDIR as make ARGs (not env) -
# see the openssl-vendor-wrapper DESTDIR gotcha.
gmake install PREFIX="$PREFIX" DESTDIR="$PKGDIR"
# XNEdit - classic NEdit-style Motif text editor
# https://github.com/unixwork/xnedit

[package]
name = "xnedit"
version = "1.6.3"
release = 1
description = "NEdit-style plain text editor (Motif)"
url = "https://github.com/unixwork/xnedit"
license = "GPL-2.0-or-later"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["motif", "libXt", "libX11", "libXext", "libXft", "fontconfig"]
build = ["motif", "libXt", "libX11", "libXext", "libXft", "fontconfig"]

[[source]]
file = "xnedit-1.6.3.tar.gz"
urls = ["https://github.com/unixwork/xnedit/archive/refs/tags/v1.6.3.tar.gz"]
checksum = "069f4d40445ef5db636975e0f268ca11ec828bbc62bf4e6d7343d57b0697ecb0"

[build]
parallel = false
From: Chris Tusa <chris.tusa@leafscale.com>
Subject: Add makefiles/Makefile.hammerhead

XNEdit's top-level Makefile is target-based (`make <platform>`, matching
a file `makefiles/Makefile.<platform>`) - there is no uname-autodetect
path to adapt, only per-platform templates to add to. None of the
shipped templates fit Hammerhead: Makefile.solaris hardcodes illumos
paths that don't exist here (/usr/openwin/include, /usr/sfw/lib/64) and
links -lsocket -lnsl (not used/needed on Hammerhead's libc); the
`:sh=`-based pkg-config assignment it uses is also not portable GNU
make syntax. Base this instead on the shape of Makefile.linux, pointed
at /usr/local (our port prefix) and using $(shell pkg-config ...)
throughout, plus the GCC14 old-C flags (-fpermissive -fcommon) and the
usual illumos header-gating defines.

diff --git a/makefiles/Makefile.hammerhead b/makefiles/Makefile.hammerhead
new file mode 100644
index 0000000..0000000
--- /dev/null
+++ b/makefiles/Makefile.hammerhead
@@ -0,0 +1,26 @@
+# Makefile.hammerhead - Hammerhead (illumos-derivative, GNU toolchain) port.
+# Modeled on Makefile.linux: Motif/X11/Xft/fontconfig all live under
+# /usr/local (our $PREFIX) rather than /usr/X11R6 or illumos's
+# /usr/openwin - use pkg-config throughout instead of hardcoded paths.
+#
+# GCC14 old-C compat: XNEdit/Xlt/Microline are classic pre-2015-idiom C -
+# -fpermissive demotes GCC14's new implicit-decl/incompatible-pointer/
+# int-conversion errors back to warnings; -fcommon undoes GCC10+'s
+# -fno-common default (tentative-definition multiple-definition errors).
+# -D__EXTENSIONS__ / -D_POSIX_PTHREAD_SEMANTICS unlock the usual
+# illumos-hidden POSIX/SysV prototypes and _r signatures.
+CC=gcc
+AR=ar
+
+C_OPT_FLAGS?=-O
+
+CFLAGS=$(C_OPT_FLAGS) -std=gnu99 -I/usr/local/include -DUSE_LPR_PRINT_CMD \
+    -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS -fpermissive -fcommon \
+    $(shell pkg-config --cflags xft fontconfig)
+
+ARFLAGS=-urs
+
+LIBS=$(LD_OPT_FLAGS) -L/usr/local/lib -R/usr/local/lib -lXm -lXt -lX11 \
+    -lXext -lXrender -lm -lpthread $(shell pkg-config --libs xft fontconfig)
+
+include Makefile.common
#!/bin/sh
# Build script for xorgproto (Meson, Template B). Headers/pkgconfig only.
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"

meson setup build \
    --prefix="$PREFIX" \
    --libdir=lib \
    --buildtype=release \
    -Ddefault_library=shared

ninja -C build -j${JOBS:-1}
DESTDIR="$PKGDIR" ninja -C build install
# xorgproto - X.Org protocol headers (all X protocol/extension headers)
# https://gitlab.freedesktop.org/xorg/proto/xorgproto

[package]
name = "xorgproto"
version = "2025.1"
release = 1
description = "X.Org protocol headers (xproto and all extension protocol headers)"
url = "https://xorg.freedesktop.org/releases/individual/proto/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = ["util-macros"]

[[source]]
file = "xorgproto-2025.1.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/proto/xorgproto-2025.1.tar.xz"]
checksum = "56898c716c0578df8a2d828c9c3e5c528277705c0484381a81960fe1a67668e8"

[build]
parallel = true
#!/bin/sh
# Build script for xrdb (autotools, Template A + runtime cpp pin).
set -e
cd "$SRCDIR"

# MANDATORY libtool fix (Task 4a, 2026-07-22): see libXau/build.sh for the
# full explanation. Piggyback hammerhead onto the kopensolaris arm.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

# xrdb pipes resource files through cpp at RUNTIME, not just build time.
# configure's AC_PATH_PROG probe would find Hammerhead's /usr/bin/cpp via
# PATH anyway, but pin it explicitly so the result doesn't depend on PATH
# search order across build hosts.
./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --with-cpp=/usr/bin/cpp

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# xrdb - X server resource database utility
# https://gitlab.freedesktop.org/xorg/app/xrdb
#
# hammerhead-xdm's Xsession/greeter uses xrdb to load
# /usr/local/lib/X11/xdm/Xresources onto the X server's RESOURCE_MANAGER so
# the xlogin greeter picks up the Zygaena teal branding + greeting instead of
# the default white box. See docs/roadmap/DESKTOP_XLIBRE_XDM_GREETER_PLAN.md.
#
# xrdb pipes resource files through a C preprocessor at RUNTIME (not just
# build time). configure's AC_PATH_PROG cpp probe searches
# $PATH:/bin:/usr/bin:/usr/lib:/usr/libexec:/usr/ccs/lib:/usr/ccs/lbin:/lib,
# which would find Hammerhead's /usr/bin/cpp anyway, but build.sh pins
# --with-cpp=/usr/bin/cpp explicitly for a deterministic, host-independent
# result rather than relying on PATH search order.

[package]
name = "xrdb"
version = "1.2.3"
release = 1
description = "X server resource database utility (xdm greeter branding)"
url = "https://xorg.freedesktop.org/releases/individual/app/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11", "libXmu"]
build = ["libX11", "libXmu", "xorgproto", "util-macros"]

[[source]]
file = "xrdb-1.2.3.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/app/xrdb-1.2.3.tar.xz"]
checksum = "c88f560243278c896ce4fc92ae5a45a2b505a316ffa427fe55b02e5d5914c4e4"

[build]
parallel = true
#!/bin/sh
# Build script for xsetroot (autotools, Template A verbatim).
set -e
cd "$SRCDIR"

# MANDATORY libtool fix (Task 4a, 2026-07-22): see libXau/build.sh for the
# full explanation. Piggyback hammerhead onto the kopensolaris arm.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# xsetroot - X.Org root window utility (solid color / bitmap / cursor)
# https://gitlab.freedesktop.org/xorg/app/xsetroot
#
# hammerhead-xdm's Xsetup_0 execs /usr/local/bin/xsetroot to paint a solid
# backdrop before the xlogin greeter appears (Task 4 finding: binary was
# referenced but never ported). See docs/roadmap/DESKTOP_XLIBRE_XDM_GREETER_PLAN.md.

[package]
name = "xsetroot"
version = "1.1.4"
release = 1
description = "X.Org root window utility (solid color / bitmap / cursor)"
url = "https://xorg.freedesktop.org/releases/individual/app/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11", "libXmu", "libXcursor"]
build = ["libX11", "libXmu", "libXcursor", "xbitmaps", "xorgproto", "util-macros"]

[[source]]
file = "xsetroot-1.1.4.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/app/xsetroot-1.1.4.tar.xz"]
checksum = "1315a3f7e9abe06357363b93461e272601f67225ce0bc075c430cce35073362b"

[build]
parallel = true
#!/bin/sh
# Build script for xtrans (autotools, Template A). Header/source only, no shared lib.
set -e
cd "$SRCDIR"

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# xtrans - X transport library (header/source only, no compiled shared lib)
# https://gitlab.freedesktop.org/xorg/lib/libxtrans

[package]
name = "xtrans"
version = "1.6.0"
release = 1
description = "X transport library headers used by X libs/server for network transport"
url = "https://xorg.freedesktop.org/releases/individual/lib/"
license = "MIT"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = ["util-macros"]

[[source]]
file = "xtrans-1.6.0.tar.xz"
urls = ["https://xorg.freedesktop.org/releases/individual/lib/xtrans-1.6.0.tar.xz"]
checksum = "faafea166bf2451a173d9d593352940ec6404145c5d1da5c213423ce4d359e92"

[build]
parallel = true
#!/bin/bash
# Build script for XZ Utils

set -e
cd "$SRCDIR"

# Fix illumos gnulib compatibility issues (if present)
for f in lib/localename-unsafe.c lib/localename.c; do
    if [ -f "$f" ]; then
        sed -i 's/extern char \* getlocalename_l/extern const char * getlocalename_l/' "$f"
    fi
done

./configure \
    --prefix=$PREFIX \
    --build=$BUILD_TRIPLE \
    --host=$BUILD_TRIPLE \
    --disable-nls

# Fix illumos memset_s false detection if present
for config in lib/config.h config.h; do
    if [ -f "$config" ]; then
        sed -i 's/#define HAVE_MEMSET_S 1/\/* #undef HAVE_MEMSET_S - illumos has it as macro only *\//' "$config"
    fi
done

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"
# XZ Utils - LZMA compression utility
# https://tukaani.org/xz/

[package]
name = "xz"
version = "5.8.2"
release = 1
description = "XZ Utils - LZMA compression utility"
url = "https://tukaani.org/xz/"
license = "LGPL-2.1"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "xz-5.8.2.tar.gz"
urls = ["https://github.com/tukaani-project/xz/releases/download/v5.8.2/xz-5.8.2.tar.gz"]
checksum = "ce09c50a5962786b83e5da389c90dd2c15ecd0980a258dd01f70f9e7ce58a8f1"


[build]
parallel = true
#!/bin/bash
# Build script for zlib
# Compression library - no external dependencies

set -e

cd "$SRCDIR"

# zlib uses a custom configure script, not autoconf
./configure --prefix=$PREFIX --shared

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"

# Remove static library to save space (optional)
# rm -f "$PKGDIR$PREFIX/lib/libz.a"
# zlib - General-purpose compression library
# https://zlib.net

[package]
name = "zlib"
version = "1.3.1"
release = 1
description = "General-purpose lossless data compression library"
url = "https://zlib.net"
license = "Zlib"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = []
build = []

[[source]]
file = "zlib-1.3.1.tar.gz"
urls = ["https://zlib.net/zlib-1.3.1.tar.gz"]
checksum = "9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23"


[build]
parallel = true
jobs = 0