Source

ooo340 / set_soenv.in

   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
#!@PERL@ -w
#
# Program:     set_soenv.in
# Version:     $Revision: 1.201 $
# Date:        $Date: 2008-09-05 14:14:29 $
# Author:      Willem van Dorp, Ross Nicholson, Oisin Boydell - Sun Microsystems, Ireland.
#
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# Description:
# set_soenv generates a file that contains all necessary 
# environment variables for the build proces of OpenOffice
# on Linux, NetBSD, Solaris, Windows NT and Mac OS X/Darwin.
#
# Program steps.
#
# I.    Checking the command-line arguments.
# IIa.  Declaring variables for the system commands, etc.
# IIb.  Declaring the environment variables.
# III.  Initialising the variables for the system commands, etc.
# IV.   Print out some important messages etc.
# V.    Initialising the environment variables.
# VI.   Open the output file.
# VII.  Writing the data to the output file.
# VIII. Closing output file.
# IX.   Sourcing the output file.
# X.    Set up the build environment.
# XI.   Moving the output file to the build home directory.
#
#---------------------------------------------------------------------------
#
use strict;                        # pragma
use File::Basename;


#
#--------------------------------------------------------
# IIa. Declaring variables for the system commands, etc.
#--------------------------------------------------------
#
my ( $outfile, $outfile_sh, $bootfile, $newline, $comment,
     $compiler, $unsetenv, $setenv, $unset, $set, $ds, $ps,
     $wps, $cur_dir, $par_dir, $I, $L, $D, $buildenv, $answer, $tmp, $MINGW,
     $USE_MINGW, $platform,
     $cygwinver, $empty, $no_ant, $no_stl, $no_gcc_include, 
     $no_gxx_include, $warnfile, $Warning, $result, $unsetvars, $unsetvarssh, $unsetvarsbat, $exportvars, $win_format_var, $perl_os, @mingw_lib_include_paths, $mingw_lib_include_path);
#
#-------------------------------------------------
# IIb. Declaring environment values (constants).
#-------------------------------------------------
#
# Platform independent constant values.
my @DICTIONARIES = ("DADK", "DEDE", "ENGB", "ENUS", "HUHU", "ITIT", "RURU", "THTH", "SWTZ" );
my ( $CALL_CDECL, $COMMON_OUTDIR, $BMP_WRITES_FLAG, 
     $common_build, $NO_REC_RES, $SO3, $SOLAR_JAVA, 
     $SOLAR_PLUGIN, $UPDATER, $BUILD_DELIVER, $VCL, 
     $CC, $CXX,
     $BUILD_SOSL, $ENABLEUNICODE, $NEW_JAR_PACK, $NO_BSYMBOLIC, 
     $BUILD_SOSL_RELEASE, $RSC_ONCE );
#
# Platform dependent constant values.
my ( $BIG_SVX, $COM, $ARCH, $CPU, $CPUNAME, $CVER, $GLIBC, $GUI, $GUIBASE,
      $GVER, $OS, $OSVERSION, $OUTPATH, $INPATH, $PATH_SEPERATOR,
      $DYNAMIC_CRT, $SET_EXCEPTIONS, $use_shl_versions, $CDPATHx, $JRELIBDIR,
      $JRETOOLKITDIR, $JRETHREADDIR,
      $FLIPCMD );
#
#-------------------------------------------
# IIc. Declaring the environment variables.
#-------------------------------------------
#
# Help variables.
my ( $USR, $ETC, $BIN, $LIB, $LIB64, $INC, $INCLUDE, $DEV, $OPT, $LOCAL, $SOLENV, $SOLVER, $CONFIG, 
     $USR_BIN, $USR_LIB, $USR_LOCAL, $USR_CCS, $JAVA_BIN, $JAVA_LIB, $JAVA_INCLUDE,
     $SOLARENVINC, $USR_DT, $USR_OPENWIN, $SHELL_PATH, $XLIB, $XINC,
     $CYGWIN_PATH, $language, $dict, $ASM_PATH, $NSIS_PATH, $ps_STLPORT_LIB, $L_STLPORT_LIB,
     $STLPORT_stlport, $STLPORT_inc_stlport, $PERL_PATH );

# Environment variables.
my ( $oldPATH, $SRC_ROOT, $SO_HOME, $JAVA_HOME, $JDK, $JAVAFLAGS, $SHELL,
     $UPD, $WORK_STAMP, $SOURCE_ROOT_DIR ,
     $SOLARSRC, $DEVROOT, $SOLARVER, $SOLARVERSION, $SOLARENV, 
     $STAR_INIROOT, $STAR_INIROOTOLD, $STAR_STANDLST, $STAR_SSCOMMON, $STAR_SSOLARINI, 
     $DMAKEROOT, $CLASSPATH, $XCLASSPATH, $COMPATH,
     $MSPDB_PATH, $MIDL_PATH, $CSC_PATH,
     $PATH, $SOLAREXTRAINC, $SOLAREXTRALIB, $SOLARLIB, 
     $SOLARINC, $LOCALINI, $FRAMEWORKSHOME, $COMEX, $PERL, 
     $COMP_ENV, $ILIB, $JAVAHOME, $PSDK_HOME, $DIRECTXSDK_LIB, $USE_NEW_SDK, $FRAME_HOME, 
     $USE_DIRECTX5, $ATL_LIB, $ATL_INCLUDE, $MFC_LIB, $MFC_INCLUDE, $NO_HIDS, $TMPDIR,
     $COMMON_BUILD_TOOLS, $WIN_GREP, $WIN_FIND, $WIN_LS,
     $WIN_GNUCOPY, $WIN_TOUCH, $STLPORT4, $MOZILLA_VERSION, $MOZILLA_TOOLKIT, $PREBUILD_MOZAB, $MOZILLABUILD,
	 $PROEXT,
     $SYSTEM_PYTHON, $SYSTEM_MOZILLA, $EPM_FLAGS);
#
#-------------------------------------------
# IId. Declaring the aliases.
#-------------------------------------------
#
my ( $dmake, $build, $build_client, $nmake, $mkout, $deliver, $zipdep );
#

#-------------------------------------------------------------
# IIIa. Initialising constants.
#-------------------------------------------------------------
#
# $platform is needed for PathFormat()
#
$platform          = `./config.guess`;
chomp( $platform );

$UPD            = '@UPD@';          # the project's UPD
$newline        = "\n";             # Perl newline character
$unsetenv       = "unsetenv";       # c-shell command
$setenv         = "setenv";         # c-shell command
$unset          = "unset";          # msdos batch file command
$set            = "set";            # msdos batch file command
$ds             = "/";              # directory separator
$ps             = ":";              # path separator
$wps            = ":";              # path separator, will be set to ';' for windows later.
$cur_dir        = ".";              # current directory
$par_dir        = "..";             # parrent directory
$I              = " -I";            # include search path
$L              = " -L";            # library search path
$D              = " -D";            # define search path
$empty          = "";               # used as argument
$no_stl         = "NO_STLPORT4";    # possible argument
$warnfile       = "warn";           # logfile configure warnings.
$Warning        = "";               # container for warning messages
$STLPORT4       = '@STLPORT4@';     # Location of STLport4
$SYSTEM_PYTHON	= '@SYSTEM_PYTHON@';
$SYSTEM_MOZILLA = '@SYSTEM_MOZILLA@';
$JDK 		= '@JDK@';
$JAVAFLAGS 		= '@JAVAFLAGS@';
$MINGW          = '@WITH_MINGWIN@'; # use MinGW for Windows build
$USE_MINGW      = '@USE_MINGW@';     # use MinGW in cygwin or pure-mingw
if ( $MINGW eq "yes" )
{ $CC             = '@CC@';           # C compiler
  $CXX            = '@CXX@'; }        # C++ compiler
else
{ $CC             = PathFormat('@CC@');           # C compiler
  $CXX            = PathFormat('@CXX@'); }        # C++ compiler
$MOZILLA_VERSION	= '@MOZILLA_VERSION@'; # mozilla version to use to build mozilla
$MOZILLA_TOOLKIT	= '@MOZILLA_TOOLKIT@'; # GUI toolkit to use to build mozilla
$FLIPCMD        = "";               # Flip '/' to '\' wrapper (only for winnt)
$GLIBC          = "";               # Whether the platform uses glibc
$PROEXT         = "@PROEXT@";
$EPM_FLAGS	= "";

#
#--------------------------------------------------------------------
# IV. Initialise the warning container and print a note to the user.
#--------------------------------------------------------------------
#
# Add the configure (pre-requisite) warnings to the warning container
# , $Warning.
AddWarning( "configure", "" );
#
print ("Setting up the environment for building OpenOffice.org $newline");
#
#--------------------------------------------------
# V. Setting the environment variables/values.
#--------------------------------------------------
#
# A. Checking the platform first.
#
# get perls idea for OS
# needed to differentiate cygwin/native perl on windows
$perl_os = $^O;

#
# B. Gathering information from the system.
#
# 1. Path
$oldPATH = $ENV{"PATH"};
chomp( $oldPATH );                  # cut off new line
#
# C. Setting the constant values.
#
# Setting platform independent constant values.
print "Setting platform independent values... ";
# NB: Language options now set at 'ToFile' stage. 
$BMP_WRITES_FLAG      = "TRUE";
$BUILD_SOSL_RELEASE   = "TRUE";
$RSC_ONCE             = "TRUE";
$CALL_CDECL           = "TRUE";
$COMMON_OUTDIR        = "";
$common_build         = "";
$NO_REC_RES           = "TRUE";
$SO3                  = "TRUE";
$SOLAR_JAVA           = "@SOLAR_JAVA@";
$SOLAR_PLUGIN         = "TRUE";
$UPDATER              = "YES";
$BUILD_DELIVER        = "true";
$VCL                  = "TRUE";
$BUILD_SOSL           = "true";
$ENABLEUNICODE        = "TRUE";
$NEW_JAR_PACK         = "TRUE";
$NO_BSYMBOLIC         = "TRUE";
$comment              = "#";           # UNIX script comment character

# Setting platform dependent constant values.
if ( $platform =~ m/solaris/ ) 
{     print "Setting Solaris specific values... ";
   if ($platform =~ m/^i[3456]86/)
   {  
      if ( $CC =~ "gcc") {
         $outfile        = "SolarisX86GccEnv.Set";
         $OUTPATH        = "unxsogi";
      } else {
         $outfile        = "SolarisX86Env.Set";
         $OUTPATH        = "unxsoli4";
      }
      $CPU            = "I";
      $CPUNAME        = "INTEL";
	  $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386";
	  $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."motif21";
	  $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."native_threads";

   }
   else
   {
      if ( $CC =~ "gcc") {
         $outfile        = "SolarisSparcGccEnv.Set"; 
         $OUTPATH        = "unxsogs";
      } else {
         $outfile        = "SolarisSparcEnv.Set"; 
         $OUTPATH        = "unxsols4";
      }
      $CPU            = "S";
      $CPUNAME        = "SPARC";
	  $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc";
	  $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc".$ds."motif21";
	  $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc".$ds."native_threads";
   }

   if ( $CC =~ "gcc") {
       $COM            = "GCC";
       $CVER           = "C300";
   } else {
       $COM            = "C52";
       $CVER           = "C52";
       $COMEX          = 4;
   }
   $BIG_SVX        = "TRUE";
   $COMPATH        = '@COMPATH@'; 
   $GUI            = "UNX";
   $GUIBASE        = "unx";
   $GVER           = "VCL";
   $INPATH         = $OUTPATH.$PROEXT;
   $OS             = "SOLARIS";
   $PATH_SEPERATOR = $ps;
}
elsif ( $platform =~ m/netbsd/ ) 
{
#Set platform specific values: 
   if ($platform =~ m/^i[3456]86/)
   {  print "Setting NetBSD x86 specific values... ";
      $outfile        = "NetBSDX86Env.Set"; 
      $CPU            = "I";
      $CPUNAME        = "INTEL";
      $OUTPATH        = "unxbsdi";
      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386";
      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."client";
      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."native_threads";
   }
   elsif ($platform =~ m/^sparc/)
   {  print "Setting NetBSD Sparc specific values... ";
      $outfile        = "NetBSDSparcEnv.Set"; 
      $CPU            = "S";
      $CPUNAME        = "SPARC";
      $OUTPATH        = "unxbsds";
      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc";
      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc".$ds."client";
      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc".$ds."native_threads";
   }
   elsif ($platform =~ m/powerpc/)
   {  print "Setting NetBSD PPC specific values... ";
      $outfile        = "NetBSDPPCEnv.Set"; 
      $CPU            = "P";
      $CPUNAME        = "POWERPC";
      $OUTPATH        = "unxbsdppc";
      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."classic";
      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."native_threads";
   }
   else
   { print "Unsupported NetBSD architecture: $platform \n";
     exit 1;
   }
   #Conditional setting depending on gcc3:
      $CVER           = "C300";
      $OUTPATH        = $OUTPATH."2";
   # General NetBSD settings:
      $BIG_SVX        = "TRUE";
      $COM            = "GCC";
      $COMPATH        = '@COMPATH@'; 
      $GUI            = "UNX";
      $GUIBASE        = "unx";
      $GVER           = "VCL";
      $INPATH         = $OUTPATH.$PROEXT;
      $OS             = "NETBSD";
      $PATH_SEPERATOR = $ps;
}
elsif ( $platform =~ m/freebsd/ ) 
{     $BIG_SVX        = "TRUE";
      $COM            = "GCC";
      $COMPATH        = '@COMPATH@'; 
      $CVER           = "C300";
      $GUI            = "UNX";
      $GUIBASE        = "unx";
      $GVER           = "VCL";
      $OS             = "FREEBSD";
      $PATH_SEPERATOR = $ps;
      $OSVERSION      = '@OSVERSION@';
   if ($platform =~ m/^amd64/)
   {  my ( $JAVA_OS );
      print "Setting FreeBSD AMD64 specific values... ";
      $outfile        = "FreeBSDAMDEnv.Set";
      $CPU            = "X";
      $CPUNAME        = "X86_64";
      $OUTPATH        = "unxfbsdx";
      $JAVA_OS        = '@JAVA_HOME@';
      $JAVA_OS        =~ s/.*\///;
      if ($JAVA_OS =~ m/^linux/)
      {  $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386";
         $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."client";
         $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."native_threads";
      }
      else
      {  $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."amd64";
         $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."amd64".$ds."server";
         $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."amd64".$ds."native_threads";
      }
   }
   elsif ($platform =~ m/^i386/)
   {  print "Setting FreeBSD x86 specific values... ";
      $outfile        = "FreeBSDX86Env.Set";
      $CPU            = "I";
      $CPUNAME        = "INTEL";
      $OUTPATH        = "unxfbsdi";
      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386";
      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."client";
      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."native_threads";
   }
   else
   {  print "Unsupported FreeBSD architecture: $platform \n";
         exit 1;
   }
   if( @GCCVER@ >= 30401 ) {
      $CVER        = "C341";
   }
      $INPATH         = $OUTPATH.$PROEXT;
} 
elsif ( $platform =~ m/linux/ ) 
{
# General Linux settings:
      $CVER           = "C341";
      $BIG_SVX        = "TRUE";
      $COM            = "GCC";
      $COMPATH        = '@COMPATH@'; 
      $GLIBC          = "2REDHAT60";
      $GUI            = "UNX";
      $GUIBASE        = "unx";
      $GVER           = "VCL";
      $OS             = "LINUX";
      $PATH_SEPERATOR = $ps;

#Set platform specific values: 
   if ($platform =~ m/^i[3456]86/)
   {  print "Setting Linux x86 specific values... ";
      $outfile        = "LinuxX86Env.Set"; 
      $CPU            = "I";
      $CPUNAME        = "INTEL";
      
      if ($JDK =~ m/^[Ii][Bb][Mm]/)
      { $JRELIBDIR     = '$JAVA_HOME'.$ds."jre".$ds."bin";
        $JRETOOLKITDIR = '$JAVA_HOME'.$ds."jre".$ds."bin".$ds."classic";
        $JRETHREADDIR  = '$JAVA_HOME'.$ds."jre".$ds."bin"; }

      elsif ($JDK =~ m/^[Bb][Ee][Aa]/)
      { $JRELIBDIR     = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386";
        $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."jrockit";
        $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."native_threads"; }

      else {      
      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386";
      # has both server and client
      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."client";
      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."i386".$ds."native_threads";
      }

      $OUTPATH     = "unxlngi6";
   }
   elsif ($platform =~ m/^x86_64/)
   {  print "Setting Linux x86-64 specific values... ";
      $outfile        = "LinuxX86-64Env.Set";
      $CPU            = "X";
      $CPUNAME        = "X86_64";
      $OUTPATH        = "unxlngx6";
      # Blackdown.org JDK porting project uses `amd64' and `server' in JDK 1.4.2 RC1
      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."amd64";
      # has both server and client
      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."amd64".$ds."server";
      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."amd64".$ds."native_threads";
   }
   elsif ($platform =~ m/^ia64/)
   {  print "Setting Linux ia64 specific values... ";
      $outfile        = "LinuxIA64Env.Set";
      $CPU            = "A";
      $CPUNAME        = "IA64";
      $OUTPATH        = "unxlnga";
      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ia64";
      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ia64".$ds."server";
      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ia64".$ds."native_threads";
   }
   elsif ($platform =~ m/^sparc/)
 
   {  print "Setting Linux Sparc specific values... ";
      $outfile        = "LinuxSparcEnv.Set"; 
      $CPU            = "S";
      $CPUNAME        = "SPARC";
      $OUTPATH        = "unxlngs";
      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc";
      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc".$ds."server";
      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."sparc".$ds."native_threads";
   }
   elsif ($platform =~ m/^powerpc/)
   {
      if (($platform =~ m/^powerpc64/) && ('@SIZEOF_LONG@' eq '8')) {
         print "Setting Linux PPC64 specific values... ";
         $outfile = "LinuxPPC64Env.Set"; 
         $OUTPATH = "unxlngppc64";
         $CPUNAME = "POWERPC64";

         if ( $JDK eq "gcj" ) {
            $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc64";
            $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc64".$ds."client";
            $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc64".$ds."native_threads";
         }
      }
      else {
         print "Setting Linux PPC specific values... ";
         $outfile = "LinuxPPCEnv.Set"; 
         $OUTPATH = "unxlngppc";
         $CPUNAME = "POWERPC";

         if ( $JDK eq "gcj" ) {
            $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
            $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."client";
            $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."native_threads"; }
         elsif ($JDK =~ m/^[Ii][Bb][Mm]/)
         {  $JRELIBDIR     = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
            $JRETOOLKITDIR = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."classic";
            $JRETHREADDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
         }
	 # OpenJDK
	 elsif ($JDK =~ m/sun/) {
	    $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
	    $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."server";
	    $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."native_threads";
	 }
      }

      $CPU            = "P";

   }
   elsif ($platform =~ m/^s390/)
   {
      if (($platform =~ m/^s390x/) && ('@SIZEOF_LONG@' eq '8')) {
         print "Setting Linux zSeries specific values... ";
         $outfile        = "LinuxS390XEnv.Set";
         $CPUNAME        = "S390X";
	 $ARCH           = "s390x";
         $OUTPATH        = "unxlngs390x";
      }
      else {
         print "Setting Linux S/390 specific values... ";
         $outfile        = "LinuxS390Env.Set";
         $CPUNAME        = "S390";
	 $ARCH           = "s390";
         $OUTPATH        = "unxlngs390";
      }
      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds.$ARCH;
      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds.$ARCH.$ds."server";
      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds.$ARCH.$ds."native_threads";
      $CPU            = "3";
   }
   elsif ($platform =~ m/^m68k/)
   {  print "Setting Linux m68k specific values... ";
      $outfile        = "LinuxM68KEnv.Set";
      $CPU            = "6";
      $CPUNAME        = "M68K";
      $OUTPATH        = "unxlngm68k";
      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."m68k";
      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."m68k".$ds."server";
      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."m68k".$ds."native_threads";
   }
   elsif ($platform =~ m/^hppa/)
   {  print "Setting Linux hppa specific values... ";
      $outfile        = "LinuxHPPAEnv.Set";
      $CPU            = "H";
      $CPUNAME        = "HPPA";
      $OUTPATH        = "unxlnghppa";
      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."hppa";
      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."hppa".$ds."server";
      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."hppa".$ds."native_threads";
      $EPM_FLAGS      = "-a hppa";
   }
   elsif ($platform =~ m/^alpha/) 
   {  print "Setting Linux Alpha specific values... ";
      $outfile        = "LinuxAlphaEnv.Set"; 
      $CPU            = "A";
      $CPUNAME        = "ALPHA_";
      $OUTPATH        = "unxlnga";
      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."alpha";
      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."alpha".$ds."server";
      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."alpha".$ds."native_threads";
   }
   elsif ($platform =~ m/^arm.*?l-/)
   {  print "Setting Linux ARM specific values... ";
      $outfile        = "LinuxARMEnv.Set"; 
      $CPU            = "R";
      $CPUNAME        = "ARM";
      $OUTPATH        = "unxlngr";
      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."arm";
      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."arm".$ds."server";
      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."arm".$ds."native_threads";
      $EPM_FLAGS      = "-a arm";
   }
   elsif ($platform =~ m/^mips/)
   {  print "Setting Linux MIPS specific values... ";
      $outfile        = "LinuxMIPSEnv.Set"; 
      $CPU            = "M";
      $CPUNAME        = "GODSON";
      $OUTPATH        = "unxlngmips";

      if ('@SIZEOF_LONG@' eq '8') {
        if ('@WORDS_BIGENDIAN@' ne 'yes') {
          $EPM_FLAGS = "-a mips64el";
          if ( $JDK eq "gcj" ) {
	    $ARCH = "mips64el";
          }
        }
        else {
          $ARCH = "mips64";
        }
      }
      else {
        if ('@WORDS_BIGENDIAN@' ne 'yes') {
          $EPM_FLAGS = "-a mipsel";
	  if ( $JDK =~ m/sun/ && -d "@JAVA_HOME@".$ds."jre".$ds."lib".$ds."mips32" ) {
	   $ARCH = "mips32"; # Lemote
	  } else {
	   $ARCH = "mipsel";
 	  }
        }
        else {
          $ARCH = "mips";
        }
      }

      $JRELIBDIR      = '$JAVA_HOME'.$ds."lib".$ds.$ARCH;
      if ( $JDK =~ m/sun/ && -d "@JAVA_HOME@".$ds."jre".$ds."lib".$ds."mips32" ) {
      	$JRETOOLKITDIR  = '$JAVA_HOME'.$ds."lib".$ds.$ARCH.$ds."client"; # Lemote
      } else {
      	$JRETOOLKITDIR  = '$JAVA_HOME'.$ds."lib".$ds.$ARCH.$ds."server";
      }  
      $JRETHREADDIR   = '$JAVA_HOME'.$ds."lib".$ds.$ARCH.$ds."native_threads";
   }


   $INPATH         = $OUTPATH.$PROEXT;
}
elsif ( $platform =~ m/osf1/ ) 
{     print "Setting Tru64 specific values... ";
      $outfile        = "Tru64AlphaEnv.Set"; 
      $BIG_SVX        = "TRUE";
      $COM            = "CXX";
      $COMPATH        = '@COMPATH@'; 
      $CPU            = "A";
      $CPUNAME        = "ALPHA_";
      $CVER           = "C62";
      $GUI            = "UNX";
      $GUIBASE        = "unx";
      $GVER           = "VCL";
      $OUTPATH        = "unxt64";
      $INPATH         = $OUTPATH.$PROEXT;
      $OS             = "TRU64";
      $PATH_SEPERATOR = $ps;
      $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."alpha";
      $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."alpha".$ds."client";
      $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."alpha".$ds."native_threads";
} 
elsif ( $platform =~ m/cygwin/ ) 
{
      $MSPDB_PATH     = PathFormat('@MSPDB_PATH@');
      $MIDL_PATH      = PathFormat('@MIDL_PATH@');
      $CSC_PATH       = PathFormat('@CSC_PATH@');
      $PSDK_HOME      = PathFormat('@PSDK_HOME@');
      $DIRECTXSDK_LIB = PathFormat('@DIRECTXSDK_LIB@');
      $USE_DIRECTX5   = "";
      $FRAME_HOME     = PathFormat('@FRAME_HOME@');
      $USE_NEW_SDK    = "TRUE";
      $CPUNAME        = "INTEL";
      $CPU            = "I";
      $GUI            = "WNT";
      $GUIBASE        = "WIN";
      $GVER           = "NT351";
      $OS             = "WNT";
      $DYNAMIC_CRT    = "TRUE";
      $SET_EXCEPTIONS = "TRUE";
      $use_shl_versions = "TRUE";
      $wps = ';'; # Windows style path seperator
  if ( $MINGW eq "yes" )
  {   # At the moment this implies the use of tcsh
      print "Setting Windows NT cygwin MinGW specific values... ";
      $FLIPCMD        = "slfl.pl";
      $PATH_SEPERATOR = ';';
      $outfile        = "winmingw.set"; 
      $COMPATH        = PathFormat('@COMPATH@/bin');
      $COMPATH        =~ s/\/bin$//i;
      $COM            = "GCC";
      $CVER           = "C341";
      $OUTPATH        = "wntgcci";
      $INPATH         = $OUTPATH.$PROEXT;
      $ATL_INCLUDE = '$SOLARVER'.$ds.'$INPATH'.$ds."inc".$ds."external".$ds."mingw".$ds."include".$ds."atl". " ".'$PSDK_HOME'.$ds."include".$ds."atl";
  }
  else # The MSVC section starts here
  {   $outfile        = "winenv.set";
      $COMPATH        = PathFormat('@COMPATH@');
      $COM            = "MSC";
      $OUTPATH        = "wntmsci@COMEX@";
      $INPATH         = $OUTPATH.$PROEXT;
      $COMEX          = '@COMEX@';
      if ( "@COMEX@" eq "10" ) { # .NET 2003 needs M1310
          $CVER        = "M1310";
          $ATL_LIB     = $COMPATH.$ds."atlmfc".$ds."lib";
          $ATL_INCLUDE = $COMPATH.$ds."atlmfc".$ds."include";
          $MFC_LIB     = "";
          $MFC_INCLUDE = "";
      } elsif ( "@COMEX@" ge "11" ) { # .NET 2005 needs M1400
	  if ( "@COMEX@" eq "11" ) {
	      $CVER        = "M1400";
	  } elsif ( "@COMEX@" eq "12" ) {
	      $CVER        = "M1500";
	  } else {                   # Unsupported
	      die "Unsupported value for COMEX variable.\n";
	  }
          if ( "@DISABLE_ACTIVEX@" ) {
              $ATL_LIB     = $PSDK_HOME.$ds."lib"; # Doesn't exist for VSE
              $ATL_INCLUDE = $PSDK_HOME.$ds."include".$ds."atl";
              $MFC_LIB     = $PSDK_HOME.$ds."lib"; # Doesn't exist for VSE
              $MFC_INCLUDE = $PSDK_HOME.$ds."include".$ds."mfc";
          } else {
              $ATL_LIB     = $COMPATH.$ds."atlmfc".$ds."lib";
              $ATL_INCLUDE = $COMPATH.$ds."atlmfc".$ds."include";
              $MFC_LIB     = $COMPATH.$ds."atlmfc".$ds."lib";
              $MFC_INCLUDE = $PSDK_HOME.$ds."include".$ds."mfc";
          }
      }
	  print "Setting W32 build with bash shell specific values... ";
	  # No speacial treatment for CC an CXX anymore.
	  $FLIPCMD        = "slfl.pl";
	  $PATH_SEPERATOR = ';';
  }
}
elsif ( $platform =~ m/os2/ ) 
{ 
      $COMPATH        = PathFormat('@COMPATH@');
      $MSPDB_PATH     = PathFormat('@MSPDB_PATH@');
      $MIDL_PATH      = PathFormat('@MIDL_PATH@');
      $CSC_PATH       = PathFormat('@CSC_PATH@');
      $PSDK_HOME      = PathFormat('@PSDK_HOME@');
      $FRAME_HOME     = PathFormat('@FRAME_HOME@');
      $USE_NEW_SDK    = "TRUE";
      $CPUNAME        = "INTEL";
      $CPU            = "I";
      $GUI            = "OS2";
      $GUIBASE        = "os2";
      $GVER           = "VCL";
      $OS             = "OS2";
      $DYNAMIC_CRT    = "TRUE";
      $SET_EXCEPTIONS = "TRUE";
      $use_shl_versions = "TRUE";
  {
      print "Setting OS/2 gcc 3.3.5 specific values... \n";
      $outfile        = "os2env.set";
      $COM            = "GCC";
      $CVER           = "C300";
      $OUTPATH        = "os2gcci";
      $INPATH         = $OUTPATH.$PROEXT;
      $COMEX          = '@COMEX@';

  {   print "Setting OS/2 with 4OS2 specific values... ";
      # Change path to lower case.
      $COMPATH        = lc $COMPATH;
      $PATH_SEPERATOR = ';';
      $ps = ';';
      $wps = ';'; # Windows style path seperator
  }

  }
}
elsif ( $platform =~ m/darwin/ ) 
{     print "Setting Mac OS X/Darwin specific values... ";
      $BIG_SVX        = "TRUE";
      $COM            = "GCC";
      $COMPATH        = '@COMPATH@'; 
      if ($platform =~ m/^i[3456]86/)
      {
          print "Setting values for Mac OS X/Darwin on x86... ";
          $outfile        = "MacOSXX86Env.Set"; 
          $CPU            = "I";
          $CPUNAME        = "INTEL";
          $OUTPATH        = "unxmacxi";
      }
      elsif ($platform =~ m/^powerpc/)
      {
          print "Setting values for Mac OS X/Darwin on PowerPC... ";
          $outfile        = "MacOSXPPCEnv.Set"; 
          $CPU            = "P";
          $CPUNAME        = "POWERPC";
          $OUTPATH        = "unxmacxp";
      }
      if (@GCCVER@ >= 30401) {
	  $CVER           = "C341";
      } else {
	  $CVER           = "C300";
      }
      $GUI            = "UNX";
      $GVER           = "VCL";
      $INPATH         = $OUTPATH.$PROEXT;
      $OS             = "MACOSX";
      $PATH_SEPERATOR = $ps;
      # GUIBASE is set below; may be "aqua" or "unx".
}
elsif ( $platform =~ m/aix/ )
{
   if( $platform !~ m/^powerpc/ )
   {
	print "\nAIX has only been ported and tested on powerpc\n";
	AddWarning( "set_soenv", "Platform $platform has not been tested");
   }
   print "Setting AIX PPC specific values... ";
   $outfile        = "aixPPCEnv.Set"; 
   $CPU            = "P";
   $CPUNAME        = "POWERPC";
   $OUTPATH        = "unxlngppc";
   $JRELIBDIR      = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc";
   $JRETOOLKITDIR  = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."classic";
   $JRETHREADDIR   = '$JAVA_HOME'.$ds."jre".$ds."lib".$ds."ppc".$ds."native_threads";
   $BIG_SVX        = "TRUE";
   $COM            = "GCC";
   $CVER           = "C300";
   $COMPATH        = '@COMPATH@'; 
   $GUI            = "UNX";
   $GUIBASE        = "unx";
   $GVER           = "VCL";
   $INPATH         = $OUTPATH.$PROEXT;
   $OS             = "AIX";
   $PATH_SEPERATOR = $ps;
}
else {
	print "\nset_soenv:  Cannot figure out what platform you are running\n";
	print "For $platform.\n";
	exit 1;
}
print "done\n";

#
# D. Gathering directory information from the user.
#
# If the directory does not exist something is strange.
# 1. OpenOffice.org build home directory.
chomp($SRC_ROOT  = `pwd`);
$SRC_ROOT =~ s/\/config_office//;
$SRC_ROOT = PathFormat($SRC_ROOT);
CheckPathExist( $SRC_ROOT );


#-----------------------------------------------------------------------------------------------------
# Copy top level makefile from config_office/ to $SRC_ROOT
#-----------------------------------------------------------------------------------------------------
if (! -e "makefile.rc")
{  AddWarning( "set_soenv", "makefile.rc not found in config_office/. Could not copy to SRC_ROOT." );
}
else
{  `cp -f makefile.rc $SRC_ROOT/makefile.mk`;
}

# 2. Java home directory.
# JAVA_HOME as argument from autoconf.
$JAVA_HOME = PathFormat('@JAVA_HOME@') ;

if ( $platform =~ m/cygwin|os2/ ) {
   $JAVA_HOME =~ s/[\s\/]+$//;	# remove trailing \n or \/ if there is any.
}
# 3. shell path.
# Check whether autoconf found a valid shell path.
if ("@USE_SHELL@" eq "tcsh")
{  # SHELL as argument from autoconf.
   $SHELL_PATH = '@SHELLPATH@';
   $SHELL = '@SHELLPATH@'."\/tcsh";
}
elsif ("@USE_SHELL@" eq "bash")
{
   $SHELL_PATH = '@SHELLPATH@';
   $SHELL = '@SHELLPATH@'."\/bash";
}
else {
   die "Not a recognized shell: @USE_SHELL@ !";
}


if ( '@STLPORT4@' eq $no_stl )
{
   $STLPORT4 = "$no_stl";
}

# ml.exe assembler path for Windows users.
if ($platform =~ m/cygwin/)
{  $ASM_PATH = PathFormat('@ASM_HOME@');
}

# Check for prebuild mozab libraries if we don't build them # ourselves
# and we're also not using the external system mozilla installation.
#
# FIXME! This check should be done in configure and not here, but
# the $OS, $COM, $CPU variables are not yet present there.
#
if ( "@WITH_MOZILLA@" eq "YES" and "@BUILD_MOZAB@" ne "TRUE" and "@SYSTEM_MOZILLA@" ne "YES" )
{  print("\nChecking for prebuilt Mozilla libraries ...");
   my $mozbinfile = $SRC_ROOT."/moz/zipped/";
   if ( $^O eq 'MSWin32' ) {
       chomp( $mozbinfile = qx{cygpath -d "$mozbinfile"} );
   }
   $mozbinfile .= $OS.$COM.$CPU;
   if ( -e $mozbinfile."inc.zip"
        and -e $mozbinfile."lib.zip"
        and -e $mozbinfile."runtime.zip" )
   {   print " found.\n";
       $PREBUILD_MOZAB = "YES";
   }
   else
   {   print " not found!\n\n";
       print "If you don\'t use the system mozilla and also not build the needed\n";
       print "mozilla libraries yourself you have to provide the needed files\n";
       print "$OS$COM$CPU\{inc,lib,runtime\}.zip in moz/zipped/ .\n";
       print "These files can be found here:\n";
       print "  <http://tools.openoffice.org/moz_prebuild/680/>.\n\n";
       die;
   }
}
else
{
   $PREBUILD_MOZAB = "";
}

#
# E. Determining the envionment values based on the information
#    that was gathered earlier on.
#
print "Setting the environment variables... ";
$USR                  = $ds."usr";
$ETC                  = $ds."etc";
$BIN                  = $ds."bin";
$LIB                  = $ds."lib";
$LIB64                = $ds."lib";
$LIB64               .= "64"
if ($platform =~ m/x86_64-.*-linux/);
$LIB64               .= "64" 
if (($platform =~ m/powerpc64-.*-linux/) && ('@SIZEOF_LONG@' eq '8'));
$LIB64               .= "64" 
if (($platform =~ m/s390x-.*-linux/) && ('@SIZEOF_LONG@' eq '8'));
$INC                  = $ds."inc";
$INCLUDE              = $ds."include";
$DEV                  = $ds."dev";
$OPT                  = $ds."opt";
$LOCAL                = $ds."local";
$SOLENV               = $ds."solenv";
$SOLVER               = $ds."solver";
$CONFIG               = $ds."config";
$USR_BIN              = $USR.$BIN;
$USR_LIB              = $USR.$LIB64;
$USR_LOCAL            = $USR.$ds."local";
$USR_CCS              = $USR.$ds."ccs";
$USR_OPENWIN          = $USR.$ds."openwin";
$USR_DT               = $USR.$ds."dt";
$COMMON_BUILD_TOOLS   = '$SRC_ROOT'.$ds."external".$ds."common";

# Generate alternate output file for sh?
$outfile_sh = $outfile.".sh";

if ($STLPORT4 ne $no_stl) {
	$ps_STLPORT_LIB		= $ps.'$STLPORT4'.$LIB64;
	$L_STLPORT_LIB		= $L.'$STLPORT4'.$LIB64;
	$STLPORT_stlport 	= $I.'$STLPORT4'.$ds.'stlport';
	$STLPORT_inc_stlport	= $I.'$STLPORT4'.$ds.'include'.$ds.'stlport';
} else {
        $ps_STLPORT_LIB         = "";
        $L_STLPORT_LIB          = "";
        $STLPORT_stlport        = $I.$SRC_ROOT.$SOLVER.$ds.$UPD.$ds.$INPATH.$INC.$ds."stl";
        $STLPORT_inc_stlport    = "";
}


# Windows NT only variables
if ($platform =~ m/cygwin/)
{  
   if ( $JAVA_HOME ne "" )
   {
      $JAVA_LIB             = $JAVA_HOME.$LIB;
   }
   # Import SystemDrive enviroment variable
   use Env qw(SYSTEMDRIVE);
   # Change $SYSTEMDRIVE to lower case.
   $SYSTEMDRIVE          = lc $SYSTEMDRIVE;
   use Env qw(SYSTEMROOT);
   $CYGWIN_PATH          = PathFormat('@CYGWIN_PATH@'); # Windows bash path
   $WIN_GREP             = '$CYGWIN_PATH'.$ds."grep.exe";
   $WIN_FIND             = '$CYGWIN_PATH'.$ds."find.exe";
   $WIN_LS               = '$CYGWIN_PATH'.$ds."ls.exe";
   $WIN_GNUCOPY          = '$CYGWIN_PATH'.$ds."cp.exe";
   $WIN_TOUCH            = '$CYGWIN_PATH'.$ds."touch.exe";
}

if ( $JAVA_HOME ne "" )
{
   $JAVA_BIN             = $JAVA_HOME.$BIN;
   $JAVA_INCLUDE         = $JAVA_HOME.$ds."include";
}


$PERL                 = PathFormat('@PERL@'); # Perl program
$PERL_PATH            = dirname('@PERL@'); # Perl Path 
$XLIB                 = PathFormat('@XLIB@'); # X11 libraries
$XINC                 = PathFormat('@XINC@'); # X11 includes


# Mac OS X/Darwin only variables.
if ( $platform =~ m/darwin/ )
{  $FRAMEWORKSHOME       = $ds."System".$ds."Library".$ds."Frameworks";
   if ( $XLIB eq "no_x_libraries" ) {
      $GUIBASE  = "aqua";
   } else {
      $GUIBASE  = "unx";
   }
}

# The project's workstamp.
$WORK_STAMP            = "@SOURCEVERSION@";
# Location of the source.
$SOLARSRC             = '$SRC_ROOT';
# Location of the repository.
my @splitlist = split( /\//, $SRC_ROOT );
pop @splitlist;
$SOURCE_ROOT_DIR      = join("/", @splitlist);
#
$DEVROOT              = '$SRC_ROOT';
# Set solenv and solver to given or default values. 
# Location of the solenv tree.
if ('@LOCAL_SOLENV@' eq "DEFAULT")
{  $SOLARENV          = $SRC_ROOT.$SOLENV;
}
else
{  $SOLARENV          =  PathFormat('@LOCAL_SOLENV@');
}
# Location of the solver tree.
if ('@LOCAL_SOLVER@' eq "DEFAULT")
{  $SOLARVER          = $SRC_ROOT.$SOLVER.$ds.$UPD;
}
else
{  $SOLARVER          = PathFormat('@LOCAL_SOLVER@').$ds.$UPD;
}
#Location of Solar version.
$SOLARVERSION         = '$SOLARVER';

$SOLARENVINC          = '$SOLARENV'.$INC;
# Location of 
$LOCALINI             = '$SOLARENV'.$CONFIG;
# Location of 
$STAR_INIROOT         = '$SOLARENV'.$CONFIG;
# Location of 
$STAR_INIROOTOLD      = '$SOLARENV'.$CONFIG;
# Location of 
$STAR_STANDLST        = '$SOLARENV'.$CONFIG.$ds."stand.lst";
# Location of 
$STAR_SSCOMMON        = '$SOLARENV'.$CONFIG.$ds."ssolar.cmn";
# Location of 
$STAR_SSOLARINI       = '$SOLARENV'.$CONFIG.$ds."ssolar.ini";
# Location of dmake resource. 
$DMAKEROOT            = '$SOLARENVINC'.$ds."startup";
# Location of JDK classes .zip file.
# but in jdk 1.2 it is called rt.jar and it lives in jre/lib
$CLASSPATH            = '$JAVA_HOME'.$ds.'jre'.$LIB.$ds."rt.jar".$wps.'.';
# Location of the JDK supported standard classes.zip file.
# see above for why the change
$XCLASSPATH           = '$JAVA_HOME'.$ds.'jre'.$LIB.$ds."rt.jar".$wps.'.';

# Location used by the linker to create libraries.
if ($platform =~ m/solaris/) 
{  $SOLAREXTRALIB     = $L.$par_dir.$LIB.
                        $L.'$SOLARENV'.$ds.'$OUTPATH'.$ds."lib.solaris.2.6".
                        $L.$LIB.
                        $L.$USR.$LIB.
                        $L.$USR.$LOCAL.$LIB.
                        $L.$USR_DT.$LIB.
                        $L.$USR_OPENWIN.$LIB;
}
elsif ($platform =~ m/linux|netbsd|osf1|freebsd|aix/)
{
   $SOLAREXTRALIB     = $L.$par_dir.$LIB64;
}
elsif ($platform =~ m/darwin/) 
{  $SOLAREXTRALIB     = $L.$LIB.
                        $L.$USR.$LIB;
}
elsif ($platform !~ m/cygwin|os2/ )
{  AddWarning( "set_soenv", "$platform not configured for linkage create libraries" );
}

# Windows NT only variables
if ($platform =~ m/cygwin|os2/)
{  $COMP_ENV          = $OUTPATH;

   $JAVAHOME          = '$JAVA_HOME';

   $ILIB             = $cur_dir;

   if ($STLPORT4 ne $no_stl) {
       $ILIB      .=   $wps.$STLPORT4.$LIB64;
   }

   # Mingw is different
   if ( $COM eq "MSC" )
   {  $ILIB       .=    $wps.$SOLARVER.$ds.$INPATH.$LIB.
                        $wps.$JAVA_HOME.$LIB.
                        $wps.$PSDK_HOME.$LIB.
                        $wps.$FRAME_HOME.$LIB.
                        $wps.$COMPATH.$LIB;
      if ( '@ENABLE_DIRECTX@' ne "" ) {
          $ILIB   .= $wps.$DIRECTXSDK_LIB;
          if ( '@COMEX@' eq "10" ) {
              # .NET2003 provides and compiles against DirectX 5 libraries and is
              # hereby still Win9x compatible.
              $ILIB .= $wps.'$COMPATH'.$ds.'PlatformSDK'.$LIB;
              $USE_DIRECTX5 = "YES";
          }
      }
      # ILIB needs to use '\' directory seperators;
      $ILIB = WinPath( $ILIB, ";" );
   }
   elsif ( $COM eq "GCC" )
   {  $ILIB       .=    $wps.$SOLARVER.$ds.$INPATH.$LIB.
                        $wps.$SOLARVER.$ds.$INPATH.$BIN.
                        $wps.$JAVA_HOME.$LIB;
      if ( $USE_MINGW eq "cygwin" )
      {  $ILIB    .= $wps.PathFormat($USR.$LIB.$ds."mingw").
                     $wps.PathFormat($USR.$LIB.$ds."w32api");
      }
      else
      {  $ILIB       .= $wps.$COMPATH.$LIB;
      }
      $ILIB       .= $wps.PathFormat("@MINGW_CLIB_DIR@").
                     $wps.$PSDK_HOME.$LIB;
      if ( '@ENABLE_DIRETX@' )
      {   $ILIB   .= $wps.PathFormat("@DIRECTXSDK_LIB@");
      }
   }

   $JAVAHOME          = '$JAVA_HOME';

}
     
# The general environment path.
if ($platform =~ m/linux|netbsd|odf1|freebsd|aix|solaris/)
{  $PATH              = $cur_dir.
#                        $ps.'$SOLARVER'.$ds.'$INPATH'.$BIN.
                        $ps.'$SOLARENV'.$ds.'$OUTPATH'.$BIN.
                        $ps.'$SOLARENV'.$BIN;

   if ($platform =~ m/solaris/) {
	$PATH .= $ps.$USR_CCS.$BIN;
   }

   $PATH             .= $ps.$oldPATH;

   my @javaBits;
   if (( $JAVA_HOME ne "" ) && ( $JDK ne "gcj" )) {
      @javaBits = ( '$JAVA_HOME'.$BIN, 'javac' );
   } else {
      @javaBits = (); 
   }
   $PATH              = GetCorrectPath ($PATH,
                                        $COMPATH, $CC,
                                        $PERL_PATH, 'perl',
                                        $SHELL_PATH, '@USE_SHELL@',
                                        @javaBits);
}

elsif ($platform =~ m/cygwin/)
{  # The PATH variable is completely created from scratch. Elements
   # from oldPATH that are not yet included are appended to PATH at
   # the end.

   my ( $tmppath );

   $PATH              = $cur_dir.
#                        $ps.CygFormat($SOLARVER).$ds.$INPATH.$BIN.
                        $ps.CygFormat($SOLARENV).$ds."bin".
                        $ps.CygFormat($SOLARENV).$ds.$OUTPATH.$BIN;

   if ( $JAVA_HOME ne "" )
   {
      # hack either "hotspot" or "client" should be used, depending on the jdk version:
      # 1.2.x   -   no such directory, unsupported 
      # 1.3.x   -   hotspot, client missing
      # 1.4.x   -   client, hotspot missing
      
      $PATH .= $ps.CygFormat($JAVA_HOME).$BIN;
	  if ( -d $JAVA_HOME.$ds."jre".$ds."bin".$ds."hotspot" ) {
		  $PATH .= $ps.CygFormat($JAVA_HOME).$ds."jre".$ds."bin".$ds."hotspot";
	  }
	  if ( -d $JAVA_HOME.$ds."jre".$ds."bin".$ds."client" ) {
		  $PATH .= $ps.CygFormat($JAVA_HOME).$ds."jre".$ds."bin".$ds."client";
	  }
   }

   # Add path to compiler
   $tmppath = CygFormat($COMPATH).$BIN;
   $tmppath =~ s/^\/\//\//;
   $PATH .= $ps.$tmppath;

   if ( $COM eq "MSC" ) {
       $tmppath = CygFormat($MSPDB_PATH);
	   # for .NET to find mspdb71.dll (needed by CL.EXE C/C++ Compiler)
	   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
		   $PATH .= $ps.$tmppath;
	   }
	   if ( ( $COMEX ge "10" ) ) {
		   # .NET needs midl.exe
               $tmppath = CygFormat($MIDL_PATH);
		   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
			   $PATH .= $ps.$tmppath;
		   }
		   # .NET needs csc.exe
               $tmppath = CygFormat($CSC_PATH);
		   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
			   $PATH .= $ps.$tmppath;
		   }
		   # Native installer needs some files if the Windows Installer SDK
               $tmppath = CygFormat($PSDK_HOME);
		   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath\/bin)(?:[:]|\Z)/i ) {
			   $PATH .= $ps.$tmppath.$BIN;
		   }
	   }
   } else { # Mingw is different
	   # Native installer needs some files if the Windows Installer SDK
               $tmppath = CygFormat($PSDK_HOME);
	   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath\/bin)(?:[:]|\Z)/i ) {
		   $PATH .= $ps.$tmppath.$BIN;
	   }
   }

   if ( $ASM_PATH ne "ASM_IN_PATH" )
   {   $PATH          .= $ps.CygFormat($ASM_PATH);
   } 
   # zip.exe / unzip.exe path for Windows users.
   my $zip_home_path = PathFormat('@ZIP_HOME@');
   $tmppath = CygFormat($zip_home_path);
   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
       $PATH          .= $ps.$tmppath;
   }

   # Possible cygwin paths must follow behind the OOo and MS paths

   # Check if $PERL_PATH is already set in PATH
   $tmppath = CygFormat($PERL_PATH);
   if ( ! ( $PATH =~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) )
   {
      $PATH          .= $ps.$tmppath;
   }
   # Check if $SHELL_PATH is already set in PATH
   $tmppath = CygFormat($SHELL_PATH);
   if ( ( $PATH !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) )
   {   $PATH          .= $ps.$tmppath;
   }
   # Check if $CYGWIN_PATH is already set in PATH
   $tmppath = CygFormat($CYGWIN_PATH);
   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
      $PATH           .= $ps.$tmppath;
   }
   $PATH              .= $ps_STLPORT_LIB;
   # nsis path for Windows users.
   $NSIS_PATH = PathFormat('@NSIS_PATH@');
   $tmppath = CygFormat($NSIS_PATH);
   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
       $PATH          .= $ps.$tmppath;
   }
   # path to sn.exe (signing) for Windows users.
   my $sn_path = PathFormat('@FRAME_HOME@/bin');
   $tmppath = CygFormat($sn_path);
   if ( $PATH !~ /(?:[:]|\A)(?:$tmppath)(?:[:]|\Z)/ ) {
       $PATH          .= $ps.$tmppath;
   }


   # Add the rest of the original path if it is still missing.
   if (($^O eq "cygwin")) { # Not for ActiveState perl
       my $expandedPATH = $PATH;
       $expandedPATH =~ s/(\$\w+)/$1/eeg;

       # fix situations where PATH may look like /bin:"C:\blah\bleh":/ugh
       my $fixedPATH = $oldPATH;
       if ( $oldPATH =~ /"/ ) {
	   $fixedPATH = "";
	   foreach my $pathentry ( split( '"',$oldPATH ) ) {
	       if ( ( $pathentry =~ /^$ps/ ) || ( $pathentry =~ /$ps$/ ) ) {
		   $fixedPATH .= $pathentry;
	       } else {
		   chomp( $pathentry = qx{cygpath -d "$pathentry"} ) ;
		   chomp( $pathentry = qx{cygpath -u "$pathentry"} ) ;
		   $fixedPATH .= $pathentry;
	       }
	   }
       }

       foreach my $pathentry (split($ps,$fixedPATH)) {
           if ( ! ( $expandedPATH =~ /(?:$ps|\A)(?:$pathentry)(?:$ps|\Z)/ ) ) {
               $PATH .= $ps.$pathentry;
               $expandedPATH .= $ps.$pathentry;
           }
       }
   } else {
       $PATH          .= $ps.$oldPATH;
   }

   # The path now is in cygwin posix format

}

elsif ($platform =~ m/os2/)
{  # The PATH variable is completely created from scratch. Everything that is not
   # needed is appended to the end.

   $PATH              = $cur_dir.
#                        $ps.'$SOLARVER'.$ds.'$INPATH'.$BIN.
                        $ps.'$SOLARENV'.$ds."bin".
                        $ps.'$SOLARENV'.$ds.'$OUTPATH'.$BIN;

   if ( $JAVA_HOME ne "" )
   {
      # hack either "hotspot" or "client" should be used, depending on the jdk version:
      # 1.2.x   -   no such directory, unsupported 
      # 1.3.x   -   hotspot, client missing
      # 1.4.x   -   client, hotspot missing
      
      $PATH .= $ps.$JAVA_HOME.$BIN;
	  if ( -d $JAVA_HOME.$ds."jre".$ds."bin".$ds."hotspot" ) {
		  $PATH .= $ps.$JAVA_HOME.$ds."jre".$ds."bin".$ds."hotspot";
	  }
	  if ( -d $JAVA_HOME.$ds."jre".$ds."bin".$ds."client" ) {
		  $PATH .= $ps.$JAVA_HOME.$ds."jre".$ds."bin".$ds."client";
	  }
   }

  # Append old PATH
  my $temp = $oldPATH;
  $temp =~ s/\\/\//g ;
  $PATH             .= $ps.$temp;
}

elsif ($platform =~ m/darwin/)
{  $PATH              = $cur_dir.
#                        $ps.'$SOLARVER'.$ds.'$INPATH'.$BIN.
                        $ps.'$SOLARENV'.$ds.'$OUTPATH'.$BIN.
                        $ps.'$SOLARENV'.$BIN;

  # Append old PATH
  $PATH             .= $ps.$oldPATH;
}
else
{  AddWarning( "set_soenv", "$platform not configured for general environment paths" );
}

# Linker library search directory paths. 
if ($platform =~ m/solaris/) 
{  $SOLARLIB          = $L.$par_dir.$LIB.
                        $L.'$SOLARENV'.$ds.'$OUTPATH'.$LIB.
                        $L.'$SOLARVER'.$ds.'$INPATH'.$LIB.
                        $L.'$SOLARENV'.$ds.'$OUTPATH'.$LIB.
                        $L.'$SOLARENV'.$ds.'$OUTPATH'.$LIB."solaris.2.6".
                        $L.$LIB.
                        $L.$USR_LIB;
   if ( $CC =~ "gcc" ) {
      $SOLARLIB      .= $L.$COMPATH.$LIB;
   }
   $SOLARLIB         .= $L.$USR_LOCAL.$LIB.
                        $L.$USR_DT.$LIB.
                        $L.$USR_OPENWIN.$LIB.
                        $L.'$JAVA_HOME'.$LIB.
                        $L.$JRELIBDIR.
                        $L.$JRETOOLKITDIR.
                        $L.$JRETHREADDIR.
                        $L_STLPORT_LIB.
                        $L.$XLIB;
}
elsif ($platform =~ m/linux|netbasd|osf1|aix|freebsd/)
{  $SOLARLIB          = $L.$par_dir.$LIB.
                        $L.'$SOLARENV'.$ds.'$OUTPATH'.$LIB.
                        $L.'$SOLARVER'.$ds.'$INPATH'.$LIB.
                        $L.'$SOLARENV'.$ds.'$OUTPATH'.$LIB.
                        $L.'$JAVA_HOME'.$LIB64.
                        $L.$JRELIBDIR.
                        $L.$JRETOOLKITDIR.
                        $L.$JRETHREADDIR.
                        $L_STLPORT_LIB.
                        $L.$XLIB;
}
elsif ($platform =~ m/cygwin|os2/)
{  $SOLARLIB          = $L.'$SOLARVER'.$ds.'$INPATH'.$LIB.
                        $L.$par_dir.$LIB.
                        $L_STLPORT_LIB.
                        $L.'$SOLARENV'.$ds.'$OUTPATH'.$LIB;
} 
elsif ($platform =~ m/darwin/) 
{  $SOLARLIB          = $L.'$SOLARVER'.$ds.'$INPATH'.$LIB.
                        $L_STLPORT_LIB.
                        $L.$USR_LIB;
    # [ed] 6/15/02 Add in X11 libraries onto the library path
    if ($GUIBASE eq "unx") {
       $SOLARLIB      .= $L.$XLIB;
    }

}

if ($SYSTEM_MOZILLA eq "YES")
{
       $SOLARLIB .= $L."@MOZ_LIB@"
}

# Location of the compiler include search directory paths.
$SOLARINC             = $I.$cur_dir.
                        $I.'$SOLARVER'.$ds.'$INPATH'.$INC.$ds."stl".
                        $I.'$SOLARVER'.$ds.'$INPATH'.$INC.$ds."external".
                        $I.'$SOLARVER'.$ds.'$INPATH'.$INC.
                        $I.'$SOLARENV'.$ds.'$OUTPATH'.$INC.
                        $I.'$SOLARENV'.$INC.
                        $I.'$SRC_ROOT'.$ds."res";

if ($platform =~ m/solaris|linux|osf1|freebsd|netbsd/)
{
$SOLARINC	     .= $STLPORT_stlport;
if ($platform =~ m/linux|freebsd|netbsd/)
{
# This simply adds an include path, so even cases that break the FHS work
$SOLARINC            .= $STLPORT_inc_stlport;
}
if ($platform =~ m/solaris/ && $CC !=~ "gcc")
{
$SOLARINC            .= '/SC5 ';
}
# Platform dependent include path at the top of this list of include paths
if ($platform =~ m/solaris/)
{   
    $SOLARINC         .= $I.$COMPATH.$ds."include";
}
if ($platform =~ m/linux/)
{
# This simply adds an include path, so even cases that break the FHS work
   $SOLARINC         .= $STLPORT_inc_stlport;
}


   	$SOLARINC      .= $I.'$SOLARENV'.$INC.$ds."Xp31".
                     $I.'$JAVA_HOME'.$INCLUDE;

	#include system dependent Java include directory
	if (!($JDK eq "gcj"))
	{
   		if ($platform =~ m/solaris/)
   		{  $SOLARINC   .=$I.'$JAVA_HOME'.$INCLUDE.$ds."solaris";
   		}
   		elsif  ($platform =~ m/linux|osf1/)
   		{  $SOLARINC   .=$I.'$JAVA_HOME'.$INCLUDE.$ds."linux";
   		}
   		elsif ($platform =~ m/freebsd/)
   		{
      		$SOLARINC   .=$I.'$JAVA_HOME'.$INCLUDE.$ds."freebsd";
      		$SOLARINC   .=$I.'$JAVA_HOME'.$INCLUDE.$ds."bsd";
      		$SOLARINC   .=$I.'$JAVA_HOME'.$INCLUDE.$ds."linux";
   		}
   		elsif ($platform =~ m/netbsd/)
   		{  $SOLARINC   .=$I.'$JAVA_HOME'.$INCLUDE.$ds."netbsd";
   		}

   		#java threads include path

   		$SOLARINC .=$I.'$JAVA_HOME'.$INCLUDE.$ds."native_threads".$ds."include";
	}
    #The tail, if needed
    if ($platform =~ m/linux|freebsd|netbsd/)
    {  $SOLARINC  .= $I.$XINC;
    }
    elsif ($platform =~ m/osf1/)
    {  $SOLARINC  .= $I.$XINC.
                     $I.$USR.$INCLUDE;
    }
}
elsif ($platform =~ m/cygwin/)
{  $SOLARINC         .= $STLPORT_stlport.
                        $I.'$JAVA_HOME'.$ds."include".$ds."win32".
                        $I.'$JAVA_HOME'.$ds."include";
   # Mingw is different
   if ( $COM eq "MSC" )
   {  $SOLARINC       .= $I.'$PSDK_HOME'.$INCLUDE.
                         $I.'$COMPATH'.$ds."include";
      if ( '@ENABLE_DIRECTX@' ne "" ) {
          $SOLARINC   .= $I.PathFormat('@DIRECTXSDK_HOME@').$INCLUDE;
          if ( '@COMEX@' eq "10" ) {
              # .NET2003 provides and compiles against DirectX 5 libraries and is
              # hereby still Win9x compatible.
              $SOLARINC .= $I.'$COMPATH'.$ds.'PlatformSDK'.$ds."include";
          }
      }
   }
   elsif ( $COM eq "GCC" )
   {  $SOLARINC       .= $I.'$SOLARVER'.$ds.'$INPATH'.$INC.$ds."external".$ds."mingw".$ds."include";
     if ( $USE_MINGW eq "cygwin" )
     {  $SOLARINC    .= $I.PathFormat($USR.$ds."include".$ds."mingw").
                        $I.PathFormat($USR.$ds."include".$ds."w32api").
                        $I.PathFormat($USR.$ds."include"); }
     else
     {  $SOLARINC    .= $I.'$COMPATH'.$ds."include"; }
     @mingw_lib_include_paths = split( / /, "@MINGW_LIB_INCLUDE_PATH@" );
     $SOLARINC .= $I.PathFormat("@MINGW_BACKWARD_INCLUDE_PATH@");
     foreach $mingw_lib_include_path (@mingw_lib_include_paths)
       {   chomp $mingw_lib_include_path;
           if ( $mingw_lib_include_path ne $COMPATH.$ds."include" && $mingw_lib_include_path ne "" )
           {
              $SOLARINC   .= $I.PathFormat($mingw_lib_include_path);
           }
       }
     $SOLARINC .= $I.PathFormat("@GXX_INCLUDE_PATH@").$I.PathFormat("@GXX_INCLUDE_PATH@".$ds."mingw32").
                  $I.'$PSDK_HOME'.$INCLUDE;
   }
   if ( '@ENABLE_DIRECTX@' ne "" ) {
       $SOLARINC   .= $I.PathFormat('@DIRECTXSDK_HOME@').$INCLUDE;
   }
}
elsif ($platform =~ m/darwin/)
{  $SOLARINC         .= $STLPORT_stlport.
						$I.$FRAMEWORKSHOME.$ds."JavaVM.framework".$ds."Versions".$ds."Current".$ds."Headers".
                        $I.$FRAMEWORKSHOME.$ds."JavaVM.framework".$ds."Headers";
   # [ed] 6/15/02 Add in X11 headers as appropriate for the build
   if ($GUIBASE eq "unx") {
      $SOLARINC      .= $I.$XINC.
                        $I.$XINC.$ds."freetype2";
   }
}
else
{  AddWarning( "set_soenv", "$platform not configured for system dependant include dir" );
}

#
print "done\n";

#
# F. Setting the different aliases.
#
print "Setting the aliases... ";
# 1. alias for a full product make. 
	$mkout           = '"perl $SOLARENV/bin/mkout.pl"';
	$deliver         = '"perl $SOLARENV/bin/deliver.pl"';
	$build           = '"perl $SOLARENV/bin/build.pl"';
	$build_client    = '"perl $SOLARENV/bin/build_client.pl"';
	$zipdep          = '"perl $SOLARENV/bin/zipdep.pl"';
# 3. alias for a full product make
$nmake           = '"dmake"';
print "done\n";
#
#--------------------------
# VI. Open the output file.
#--------------------------
#
open( OUT, ">$outfile" ) ||
   die "Cannot open $outfile: $!\n";

# Create sh environment file
open( OUT_SH, ">$outfile_sh" ) ||
  die "Cannot open $outfile_sh: $!\n";

#
#------------------------------------------
# VII. Writing the data to the output file.
#------------------------------------------
#
# Write file header.
CreateFileHeader( *OUT, $UPD, $platform, "(t)csh", "#" );
CreateFileHeader( *OUT_SH, $UPD, $platform, "sh/bash/ksh", "#" );

ToFile( "SRC_ROOT",	     $SRC_ROOT,          "e" );
ToFile( "SHELL",             $SHELL,             "e" );
ToFile( "JAVA_HOME",         $JAVA_HOME,         "e" );
ToFile( "ANT_HOME",          PathFormat("@ANT_HOME@"), "e" );
ToFile( "ANT_LIB",           PathFormat("@ANT_LIB@"), "e" );
ToFile( "ANT",               PathFormat("@ANT@"), "e" );
ToFile( "JDKLIB",            $JAVA_LIB,          "e" );
ToFile( "STLPORT4",          $STLPORT4,          "e" );
ToFile( "STLPORT_VER",       "@STLPORT_VER@",    "e" );
ToFile( "ASM_PATH",          $ASM_PATH,          "e" );
ToFile( "BUILD_SOSL",        $BUILD_SOSL,        "e" );
ToFile( "FRAMEWORKSHOME",    $FRAMEWORKSHOME,    "e" );
ToFile( "Empty",             $empty,             "n" );

#
# Writing the platform independent constant values to file.
# (c = comment, e = environment variable, a = alias )
ToFile( "Platform independent constant values.", $empty, "c" );
# dictionaries
if ('@WITH_DICT@' =~ m/ALL,/s)
{
   foreach $dict (@DICTIONARIES)
   {
      ToFile( "DIC_$dict",     "TRUE",          "e" );
   }
   ToFile( "DIC_ALL",          "TRUE",          "e" );
}
else
{	
   foreach $dict (@DICTIONARIES)
   {   if ('@WITH_DICT@' =~ m/$dict,/s)
       {   my $val="TRUE";
           ToFile( "DIC_$dict",     $val,          "e" );
       }
       else
       {   my $val;
           undef $val;
           ToFile( "DIC_$dict",     $val,          "e" );
       }
   }
}
# Languages
ToFile( "WITH_LANG",         "@WITH_LANG@",      "e" );
ToFile( "INTRO_BITMAPS",     "@INTRO_BITMAPS@",  "e" );
ToFile( "ABOUT_BITMAPS",     "@ABOUT_BITMAPS@",  "e" );
ToFile( "OOO_VENDOR",        "@OOO_VENDOR@",     "e" );
ToFile( "OOODMAKEMODE",      "YES",              "e" );
ToFile( "WITH_POOR_HELP_LOCALIZATIONS", "@WITH_POOR_HELP_LOCALIZATIONS@", "e" );

ToFile( "CALL_CDECL",        $CALL_CDECL,        "e" );
ToFile( "COMMON_OUTDIR",     $COMMON_OUTDIR,     "e" );
ToFile( "common_build",      $common_build,      "e" );
ToFile( "BMP_WRITES_FLAG",   $BMP_WRITES_FLAG,   "e" );
ToFile( "BUILD_SOSL_RELEASE", $BUILD_SOSL_RELEASE, "e" );
ToFile( "NO_REC_RES",        $NO_REC_RES,        "e" );
ToFile( "SO3",               $SO3,               "e" );
ToFile( "SOLAR_PLUGIN",      $SOLAR_PLUGIN,      "e" );
ToFile( "UPDATER",           $UPDATER,           "e" );
ToFile( "build_deliver",     $BUILD_DELIVER,     "e" );
ToFile( "VCL",               $VCL,               "e" );
ToFile( "ENABLEUNICODE",     $ENABLEUNICODE,     "e" );
ToFile( "NEW_JAR_PACK",      $NEW_JAR_PACK,      "e" );
ToFile( "NO_BSYMBOLIC",      $NO_BSYMBOLIC,      "e" );
ToFile( "TF_FILTER",         "TRUE",             "e" );
if ("@ENABLE_DEBUG@" eq "TRUE") {
ToFile( "debug",             "true",             "e" );
}
if ("@ENABLE_WERROR@" eq "FALSE") {
ToFile( "EXTERNAL_WARNINGS_NOT_ERRORS", "TRUE",  "e" );
}
ToFile( "PRODUCT",           "@PRODUCT@",        "e" );
ToFile( "PROFULLSWITCH",     "@PROFULLSWITCH@",  "e" );
ToFile( "PROEXT",            $PROEXT,            "e" );
ToFile( "UNIXWRAPPERNAME",   "@UNIXWRAPPERNAME@","e" );
ToFile( "BUILD_MOZAB",       "@BUILD_MOZAB@",    "e" );
ToFile( "PREBUILD_MOZAB",    $PREBUILD_MOZAB,    "e" );
ToFile( "MOZILLA_VERSION",   $MOZILLA_VERSION,   "e" );
ToFile( "DEFAULT_MOZILLA_TOOLKIT", $MOZILLA_TOOLKIT, "e" );
ToFile( "ENABLE_NSS_MODULE",  "@ENABLE_NSS_MODULE@", "e" );
ToFile( "MOZILLABUILD",  "@MOZILLABUILD@", "e" );
ToFile( "BUILD_VER_STRING",  "@BUILD_VER_STRING@", "e" );
ToFile( "ENABLE_VBA",  "@ENABLE_VBA@", "e" );
ToFile( "VBA_EXTENSION",  "@VBA_EXTENSION@", "e" );
if ($platform =~ m/linux/ && $platform =~ m/powerpc/) {
ToFile( "JITC_PROCESSOR_TYPE","6",                 "e" );
}
ToFile( "DEFAULT_TO_ENGLISH_FOR_PACKING",  "yes", "e" );
ToFile( "ENABLE_GTK",        "@ENABLE_GTK@",       "e" );
ToFile( "GTK_CFLAGS",        "@GTK_CFLAGS@",       "e" );
ToFile( "GTK_LIBS",          "@GTK_LIBS@",         "e" );
ToFile( "ENABLE_SYSTRAY_GTK", "@ENABLE_SYSTRAY_GTK@", "e" );
ToFile( "ENABLE_STATIC_GTK", "@ENABLE_STATIC_GTK@", "e" );
ToFile( "ENABLE_CAIRO",      "@ENABLE_CAIRO@",     "e" );
ToFile( "ENABLE_OPENGL",     "@ENABLE_OPENGL@",    "e" );
ToFile( "ENABLE_PDFIMPORT",  "@ENABLE_PDFIMPORT@", "e" );
ToFile( "ENABLE_PRESENTER_EXTRA_UI","@ENABLE_PRESENTER_EXTRA_UI@","e" );
ToFile( "ENABLE_MINIMIZER",   "@ENABLE_MINIMIZER@","e" );
ToFile( "ENABLE_PRESENTER_SCREEN","@ENABLE_PRESENTER_SCREEN@","e" );
ToFile( "ENABLE_REPORTBUILDER","@ENABLE_REPORTBUILDER@","e" );
ToFile( "SYSTEM_JFREEREPORT","@SYSTEM_JFREEREPORT@","e" );
ToFile( "SAC_JAR",           "@SAC_JAR@",          "e" );
ToFile( "LIBXML_JAR",        "@LIBXML_JAR@",       "e" );
ToFile( "FLUTE_JAR",         "@FLUTE_JAR@",        "e" );
ToFile( "JFREEREPORT_JAR",   "@JFREEREPORT_JAR@",  "e" );
ToFile( "LIBLAYOUT_JAR",     "@LIBLAYOUT_JAR@",    "e" );
ToFile( "LIBLOADER_JAR",     "@LIBLOADER_JAR@",    "e" );
ToFile( "LIBFORMULA_JAR",    "@LIBFORMULA_JAR@",   "e" );
ToFile( "LIBREPOSITORY_JAR", "@LIBREPOSITORY_JAR@","e" );
ToFile( "LIBBASE_JAR",       "@LIBBASE_JAR@",      "e" );
ToFile( "LIBFONTS_JAR",      "@LIBFONTS_JAR@",     "e" );
ToFile( "LIBSERIALIZER_JAR", "@LIBSERIALIZER_JAR@","e" );
ToFile( "ENABLE_MEDIAWIKI",  "@ENABLE_MEDIAWIKI@", "e" );
ToFile( "SYSTEM_APACHE_COMMONS","@SYSTEM_APACHE_COMMONS@","e" );
ToFile( "COMMONS_CODEC_JAR", "@COMMONS_CODEC_JAR@","e" );
ToFile( "COMMONS_LANG_JAR",  "@COMMONS_LANG_JAR@", "e" );
ToFile( "COMMONS_HTTPCLIENT_JAR","@COMMONS_HTTPCLIENT_JAR@","e" );
ToFile( "COMMONS_LOGGING_JAR","@COMMONS_LOGGING_JAR@","e" );
ToFile( "SYSTEM_SERVLETAPI", "@SYSTEM_SERVLETAPI@", "e" );
ToFile( "SERVLETAPI_JAR",    "@SERVLETAPI_JAR@",   "e" );
ToFile( "ENABLE_DBUS",       "@ENABLE_DBUS@",      "e" );
ToFile( "ENABLE_GCONF",      "@ENABLE_GCONF@",     "e" );
ToFile( "ENABLE_GNOMEVFS",   "@ENABLE_GNOMEVFS@",  "e" );
ToFile( "ENABLE_GIO",        "@ENABLE_GIO@",       "e" );
ToFile( "ENABLE_KDE",        "@ENABLE_KDE@",       "e" );
ToFile( "KDE_CFLAGS",        "@KDE_CFLAGS@",       "e" );
ToFile( "KDE_LIBS",          "@KDE_LIBS@",         "e" );
ToFile( "MOC",               "@MOC@",              "e" );
ToFile( "ENABLE_KDE4",       "@ENABLE_KDE4@",      "e" );
ToFile( "KDE4_CFLAGS",       "@KDE4_CFLAGS@",      "e" );
ToFile( "KDE4_LIBS",         "@KDE4_LIBS@",        "e" );
ToFile( "MOC4",              "@MOC4@",             "e" );
ToFile( "ENABLE_KAB",        "@ENABLE_KAB@",       "e" );
ToFile( "PSPRINT",           "TRUE",             "e" );
ToFile( "MKDEPENDSOLVER",    "TRUE",             "e" );
#
# Writing the platform dependent constant values to file.
# (c = comment, e = environment variable, a = alias )
ToFile( "Platform dependent constant values.", $empty, "c" );
ToFile( "SOLAR_JAVA",        $SOLAR_JAVA,        "e" );
ToFile( "BIG_SVX",           $BIG_SVX,           "e" );
ToFile( "COM",               $COM,               "e" );
ToFile( "COMPATH",           $COMPATH,           "e" );
ToFile( "CPU",               $CPU,               "e" );
ToFile( "CPUNAME",           $CPUNAME,           "e" );
ToFile( "CVER",              $CVER,              "e" );
ToFile( "GUI",               $GUI,               "e" );
ToFile( "GLIBC",             $GLIBC,             "e" );
ToFile( "GUIBASE",           $GUIBASE,           "e" );
ToFile( "GVER",              $GVER,              "e" );
ToFile( "OS",                $OS,                "e" );
ToFile( "OSVERSION",         $OSVERSION,         "e" );
ToFile( "PTHREAD_CFLAGS",    "@PTHREAD_CFLAGS@", "e" );
ToFile( "PTHREAD_LIBS",      "@PTHREAD_LIBS@",   "e" );
ToFile( "OUTPATH",           $OUTPATH,           "e" );
ToFile( "INPATH",            $INPATH,            "e" );
ToFile( "PATH_SEPERATOR",    $PATH_SEPERATOR,    "e" );
ToFile( "COMEX",             $COMEX,             "e" );
ToFile( "CDPATHx",           $CDPATHx,           "e" );
ToFile( "DYNAMIC_CRT",       $DYNAMIC_CRT,       "e" );
ToFile( "SET_EXCEPTIONS",    $SET_EXCEPTIONS,    "e" );
ToFile( "use_shl_versions",  $use_shl_versions,  "e" );
ToFile( "FLIPCMD",           $FLIPCMD,           "e" );
#
# Writing the variables to file.
# (c = comment, e = environment variable, a = alias, n = newline )
ToFile( "Variable values.",  $empty,             "c" );
if ( $platform =~ m/cygwin/ )
{  ToFile( "CYGWIN_PATH",       $CYGWIN_PATH,       "e" );
   ToFile( "PSDK_HOME",         $PSDK_HOME,         "e" );
   ToFile( "WINDOWS_VISTA_PSDK","@WINDOWS_VISTA_PSDK@","e" );
   ToFile( "DIRECTXSDK_LIB",    $DIRECTXSDK_LIB,    "e" );
   ToFile( "USE_DIRECTX5",      $USE_DIRECTX5,      "e" );
   ToFile( "ATL_LIB",           $ATL_LIB,         "e" );
   if ( $MINGW ne "yes" )
   {  ToFile( "ATL_INCLUDE",       $ATL_INCLUDE,       "e" );
   }
   ToFile( "MFC_LIB",           $MFC_LIB,         "e" );
   ToFile( "MFC_INCLUDE",       $MFC_INCLUDE,       "e" );
   ToFile( "NSIS_PATH",         $NSIS_PATH,         "e" );
   ToFile( "DISABLE_ACTIVEX",   "@DISABLE_ACTIVEX@","e" );
   ToFile( "DISABLE_ATL",   "@DISABLE_ATL@","e" );
   ToFile( "USE_NEW_SDK",       $USE_NEW_SDK,       "e" );

   # Hack around dmake's mktmp not generating DOS paths.
   my $tmpdir = qx{cygpath -m "/tmp"};
   chomp($tmpdir);
   ToFile( "TMPDIR",     $tmpdir,            "e" );
}
ToFile( "PERL",              $PERL,              "e" );
ToFile( "RPM",               "@RPM@",            "e" );
ToFile( "DPKG",              "@DPKG@",           "e" );
ToFile( "PKGMK",             "@PKGMK@",          "e" );
ToFile( "GNUMAKE",           "@GNUMAKE@",        "e" );
ToFile( "GNUTAR",            "@GNUTAR@",         "e" );
ToFile( "UPD",               $UPD,               "e" );
ToFile( "WORK_STAMP",        $WORK_STAMP,        "e" );
ToFile( "SOLARVER",          $SOLARVER,          "e" );
ToFile( "SOLARVERSION",      $SOLARVERSION,      "e" );
ToFile( "SOLARENV",          $SOLARENV,          "e" );
ToFile( "SOLARENVINC",       $SOLARENVINC,       "e" );
ToFile( "LOCALINI",          $LOCALINI,          "e" );
ToFile( "STAR_INIROOT",      $STAR_INIROOT,      "e" );
ToFile( "STAR_INIROOTOLD",   $STAR_INIROOTOLD,   "e" );
ToFile( "STAR_STANDLST",     $STAR_STANDLST,     "e" );
ToFile( "STAR_SSCOMMON",     $STAR_SSCOMMON,     "e" );
ToFile( "STAR_SSOLARINI",    $STAR_SSOLARINI,    "e" );
ToFile( "DMAKEROOT",         $DMAKEROOT,         "e" );
if ( $JDK ne "gcj" ) {
   ToFile( "CLASSPATH",         $CLASSPATH,         "e" );
   ToFile( "XCLASSPATH",        $XCLASSPATH,        "e" );
}
else {
   ToFile( "JAVACISGCJ",       '@JAVACISGCJ@',      "e" );
}
if ( $GUI eq "UNX" ) {
   ToFile( "AWTLIB",           '@AWTLIB@',          "e" );
}
if ( '@JDK@' ne '' )
{ 
   ToFile( "JDK",             "@JDK@",           "e" );
   ToFile( "JAVAFLAGS",             "@JAVAFLAGS@",           "e" );
   ToFile( "JAVAINTERPRETER", PathFormat("@JAVAINTERPRETER@"), "e" );
   ToFile( "JAVACOMPILER",    PathFormat("@JAVACOMPILER@"), "e" );
   ToFile( "JAVAAOTCOMPILER", PathFormat("@JAVAAOTCOMPILER@"), "e" );
   ToFile( "JAVADOC",         PathFormat("@JAVADOC@"), "e" );
}
ToFile( "SCPDEFS",           '@SCPDEFS@',        "e" );
ToFile( "SOLAREXTRAINC",     $SOLAREXTRAINC,     "e" );
ToFile( "SOLAREXTRALIB",     $SOLAREXTRALIB,     "e" );
ToFile( "PATH",              $PATH,              "e" );
ToFile( "SOLARLIB",          $SOLARLIB,          "e" );
ToFile( "SOLARINC",          $SOLARINC,          "e" );
ToFile( "COMP_ENV",          $COMP_ENV,          "e" );
ToFile( "JAVAHOME",          $JAVAHOME,          "e" );
ToFile( "CC",                $CC,                "e" );
ToFile( "HAVE_GCC_VISIBILITY_FEATURE",
		"@HAVE_GCC_VISIBILITY_FEATURE@", "e" );
ToFile( "HAVE_LD_HASH_STYLE","@HAVE_LD_HASH_STYLE@","e" );
ToFile( "HAVE_LD_BSYMBOLIC_FUNCTIONS",
		"@HAVE_LD_BSYMBOLIC_FUNCTIONS@","e" );
ToFile( "CXX",               $CXX,               "e" );
ToFile( "USE_CCACHE",        "@USE_CCACHE@",     "e" );
ToFile( "MINGWCXX",          "@MINGWCXX@",       "e" );
ToFile( "MINGWSTRIP",        "@MINGWSTRIP@",     "e" );
ToFile( "USE_SYSTEM_STL",    "@USE_SYSTEM_STL@", "e" );
ToFile( "ALLOC",             "@ALLOC@",          "e" );
ToFile( "ENABLE_SYMBOLS",    "@ENABLE_SYMBOLS@",    "e" );
ToFile( "DISABLE_STRIP",     "@DISABLE_STRIP@",     "e" );
ToFile( "LFS_CFLAGS",        "@LFS_CFLAGS@",     "e" );
ToFile( "ENABLE_CRASHDUMP",  "@ENABLE_CRASHDUMP@",  "e" );
ToFile( "ENABLE_CUPS",       "@ENABLE_CUPS@",       "e" );
ToFile( "ENABLE_RANDR",      "@ENABLE_RANDR@",      "e" );
ToFile( "ENABLE_FONTCONFIG", "@ENABLE_FONTCONFIG@", "e" );
ToFile( "ENABLE_DIRECTX",    "@ENABLE_DIRECTX@",    "e" );
ToFile( "ENABLE_LAYOUT",     "@ENABLE_LAYOUT@",     "e" );
ToFile( "ENABLE_PCH",        "@ENABLE_PCH@",       "e" );
ToFile( "NO_HIDS",           "@NO_HIDS@",       "e" );
ToFile( "ENABLE_GRAPHITE",   "@ENABLE_GRAPHITE@",   "e");
ToFile( "SYSTEM_GRAPHITE",   "@SYSTEM_GRAPHITE@",   "e");
ToFile( "GRAPHITE_LIBS",     "@GRAPHITE_LIBS@",     "e");
ToFile( "GRAPHITE_CFLAGS",   "@GRAPHITE_CFLAGS@",   "e");
ToFile( "VC_STANDARD",       "@VC_STANDARD@",      "e" );
ToFile( "WITH_MYSPELL_DICTS","@WITH_MYSPELL_DICTS@","e");
ToFile( "SYSTEM_DICTS",      "@SYSTEM_DICTS@",     "e");
ToFile( "DICT_SYSTEM_DIR",   "@DICT_SYSTEM_DIR@",  "e");
ToFile( "HYPH_SYSTEM_DIR",   "@HYPH_SYSTEM_DIR@",  "e");
ToFile( "THES_SYSTEM_DIR",   "@THES_SYSTEM_DIR@",  "e");
ToFile( "ENABLE_LOCKDOWN",   "@ENABLE_LOCKDOWN@",  "e" );
ToFile( "WITH_LDAP",         "@WITH_LDAP@",        "e" );
ToFile( "WITH_OPENLDAP",     "@WITH_OPENLDAP@",    "e" );
ToFile( "WITH_MOZILLA",      "@WITH_MOZILLA@",     "e" );
ToFile( "SYSTEM_MOZILLA",    "@SYSTEM_MOZILLA@",   "e" );
ToFile( "MOZ_FLAVOUR",       "@MOZ_FLAVOUR@",      "e" );
ToFile( "NSPR_LIB",          "@NSPR_LIB@",         "e" );
ToFile( "NSS_LIB",           "@NSS_LIB@",          "e" );
ToFile( "MOZ_INC",           "@MOZ_INC@",          "e" );
ToFile( "MOZ_LIB",           "@MOZ_LIB@",          "e" );
ToFile( "MOZ_LIB_XPCOM",     "@MOZ_LIB_XPCOM@",    "e" );
ToFile( "MOZ_NSPR_CFLAGS",   "@MOZ_NSPR_CFLAGS@",  "e" );
ToFile( "MOZ_NSS_CFLAGS",    "@MOZ_NSS_CFLAGS@",   "e" );
ToFile( "MOZ_LDAP_CFLAGS",   "@MOZ_LDAP_CFLAGS@",  "e" );
ToFile( "WITH_FONTS",        "@WITH_FONTS@",       "e" );
ToFile( "WITHOUT_AFMS",      "@WITHOUT_AFMS@",     "e" );
ToFile( "WITHOUT_PPDS",      "@WITHOUT_PPDS@",     "e" );
ToFile( "WITH_BINFILTER",    "@WITH_BINFILTER@",   "e" );
ToFile( "BUILD_TYPE",        "@BUILD_TYPE@",       "e" );
ToFile( "VERBOSE",           "@VERBOSE@",          "e" );
ToFile( "ENABLE_EVOAB2",     "@ENABLE_EVOAB2@",    "e" );
ToFile( "GOBJECT_CFLAGS",    "@GOBJECT_CFLAGS@",   "e" );
ToFile( "GOBJECT_LIBS",      "@GOBJECT_LIBS@",     "e" );
if ( '@ENABLE_RPATH@' eq "no" ) {
  ToFile( "LINKFLAGSRUNPATH",'',                   "e" );
}
ToFile( "EPM",               "@EPM@",              "e" );
ToFile( "EPM_FLAGS",         $EPM_FLAGS,           "e" );
ToFile( "BUILD_EPM",         "@BUILD_EPM@",        "e" );
ToFile( "PKGFORMAT",         "@PKGFORMAT@",        "e" );
ToFile( "SYSTEM_STDLIBS",    "@SYSTEM_STDLIBS@",   "e" );
ToFile( "SYSTEM_ZLIB",       "@SYSTEM_ZLIB@",      "e" );
ToFile( "SYSTEM_OPENSSL",    "@SYSTEM_OPENSSL@",   "e" );
ToFile( "OPENSSL_CFLAGS",    "@OPENSSL_CFLAGS@",   "e" );
ToFile( "OPENSSL_LIBS",      "@OPENSSL_LIBS@",     "e" );
ToFile( "SYSTEM_PYTHON",     "@SYSTEM_PYTHON@",    "e" );
ToFile( "PYTHON_CFLAGS",     "@PYTHON_CFLAGS@",    "e" );
ToFile( "PYTHON_LIBS",       "@PYTHON_LIBS@",      "e" );
if ($SYSTEM_PYTHON eq "NO") {
ToFile( "HOME",              "@HOME@",             "e" );
}
ToFile( "SYSTEM_ICU",        "@SYSTEM_ICU@",       "e" );
ToFile( "SYSTEM_GENBRK",     "@SYSTEM_GENBRK@",    "e" );
ToFile( "SYSTEM_GENCCODE",   "@SYSTEM_GENCCODE@",  "e" );
ToFile( "SYSTEM_GENCMN",     "@SYSTEM_GENCMN@",    "e" );
ToFile( "SYSTEM_JPEG",       "@SYSTEM_JPEG@",      "e" );
ToFile( "FREETYPE_CFLAGS",   "@FREETYPE_CFLAGS@",  "e" );
ToFile( "FREETYPE_LIBS",     "@FREETYPE_LIBS@",    "e" );
ToFile( "SYSTEM_POPPLER",    "@SYSTEM_POPPLER@",   "e" );
ToFile( "POPPLER_CFLAGS",    "@POPPLER_CFLAGS@",   "e" );
ToFile( "POPPLER_LIBS",      "@POPPLER_LIBS@",     "e" );
ToFile( "SYSTEM_CAIRO",      "@SYSTEM_CAIRO@",     "e" );
ToFile( "BUILD_PIXMAN",      "@BUILD_PIXMAN@",     "e" );
ToFile( "CAIRO_CFLAGS",      "@CAIRO_CFLAGS@",     "e" );
ToFile( "CAIRO_LIBS",        "@CAIRO_LIBS@",       "e" );
ToFile( "XRANDR_CFLAGS",     "@XRANDR_CFLAGS@",    "e" );
ToFile( "XRANDR_LIBS",       "@XRANDR_LIBS@",      "e" );
ToFile( "XRANDR_DLOPEN",     "@XRANDR_DLOPEN@",    "e" );
ToFile( "SYSTEM_LIBWPD",     "@SYSTEM_LIBWPD@",    "e" );
ToFile( "LIBWPD_CFLAGS",     "@LIBWPD_CFLAGS@",    "e" );
ToFile( "LIBWPD_LIBS",       "@LIBWPD_LIBS@",      "e" );
ToFile( "SYSTEM_LIBXML",     "@SYSTEM_LIBXML@",    "e" );
ToFile( "USE_FT_EMBOLDEN",   "@USE_FT_EMBOLDEN@",  "e" );
ToFile( "LIBXML_CFLAGS",     "@LIBXML_CFLAGS@",    "e" );
ToFile( "LIBXML_LIBS",       "@LIBXML_LIBS@",      "e" );
ToFile( "SYSTEM_EXPAT",      "@SYSTEM_EXPAT@",     "e" );
ToFile( "SYSTEM_DB",         "@SYSTEM_DB@",        "e" );
ToFile( "DB_VERSION",        "@DB_VERSION@",       "e" );
ToFile( "DB_INCLUDES",       "@DB_INCLUDES@",      "e" );
ToFile( "ENABLE_MYSQLC",     "@ENABLE_MYSQLC@",    "e" );
ToFile( "SYSTEM_MYSQL",      "@SYSTEM_MYSQL@",     "e" );
ToFile( "SYSTEM_MYSQL_CPPCONN","@SYSTEM_MYSQL_CPPCONN@","e" );
ToFile( "MYSQL_INC",         "@MYSQL_INC@",        "e" );
ToFile( "MYSQL_LIB",         "@MYSQL_LIB@",        "e" );
ToFile( "MYSQL_DEFINES",     "@MYSQL_DEFINES@",    "e" );
ToFile( "LIBMYSQL_PATH",     "@LIBMYSQL_PATH@",    "e" );
ToFile( "SYSTEM_HSQLDB",     "@SYSTEM_HSQLDB@",    "e" );
ToFile( "HSQLDB_JAR",        "@HSQLDB_JAR@",       "e" );
ToFile( "SYSTEM_LUCENE",     "@SYSTEM_LUCENE@",    "e" );
ToFile( "LUCENE_CORE_JAR",   "@LUCENE_CORE_JAR@",  "e" );
ToFile( "LUCENE_ANALYZERS_JAR",   "@LUCENE_ANALYZERS_JAR@",  "e" );
ToFile( "SYSTEM_BSH",        "@SYSTEM_BSH@",       "e" );
ToFile( "BSH_JAR",           "@BSH_JAR@",          "e" );
ToFile( "SYSTEM_SAXON",      "@SYSTEM_SAXON@",     "e" );
ToFile( "SAXON_JAR",         "@SAXON_JAR@",        "e" );
ToFile( "SYSTEM_ODBC_HEADERS","@SYSTEM_ODBC_HEADERS@","e" );
ToFile( "SYSTEM_LIBXSLT",    "@SYSTEM_LIBXSLT@",   "e" );
ToFile( "LIBXSLT_CFLAGS",    "@LIBXSLT_CFLAGS@",   "e" );
ToFile( "LIBXSLT_LIBS",      "@LIBXSLT_LIBS@",     "e" );
ToFile( "SYSTEM_SANE_HEADER","@SYSTEM_SANE_HEADER@","e" );
ToFile( "SYSTEM_XRENDER_HEADERS","@SYSTEM_XRENDER_HEADERS@","e" );
ToFile( "SYSTEM_CURL",       "@SYSTEM_CURL@",      "e" );
ToFile( "CURL_CFLAGS",       "@CURL_CFLAGS@",      "e" );
ToFile( "CURL_LIBS",         "@CURL_LIBS@",        "e" );
ToFile( "SYSTEM_BOOST",      "@SYSTEM_BOOST@",     "e" );
ToFile( "SYSTEM_VIGRA",      "@SYSTEM_VIGRA@",     "e" );
ToFile( "SYSTEM_NEON",       "@SYSTEM_NEON@",      "e" );
ToFile( "NEON_VERSION",      "@NEON_VERSION@",     "e" );
ToFile( "NEON_LIBS",         "@NEON_LIBS@",        "e" );
ToFile( "NEON_CFLAGS",       "@NEON_CFLAGS@",      "e" );
ToFile( "DISABLE_NEON",      "@DISABLE_NEON@",     "e" );
ToFile( "DISABLE_XAW",       "@DISABLE_XAW@",      "e" );
ToFile( "ENABLE_AGG",        "@ENABLE_AGG@",       "e" );
ToFile( "SYSTEM_AGG",	     "@SYSTEM_AGG@",       "e" );
ToFile( "AGG_VERSION",	     "@AGG_VERSION@",      "e" );
ToFile( "BUILD_DMAKE",       "@BUILD_DMAKE@",      "e" );
ToFile( "BUILD_UNOWINREG",   "@BUILD_UNOWINREG@",  "e" );
ToFile( "USE_XINERAMA",      "@USE_XINERAMA@",     "e" );
ToFile( "XINERAMA_LINK",     "@XINERAMA_LINK@",    "e" );
ToFile( "SYSTEM_REDLAND",    "@SYSTEM_REDLAND@",   "e" );
ToFile( "REDLAND_LIBS",      "@REDLAND_LIBS@",     "e" );
ToFile( "SYSTEM_HUNSPELL",   "@SYSTEM_HUNSPELL@",  "e" );
ToFile( "HUNSPELL_CFLAGS",   "@HUNSPELL_CFLAGS@",  "e" );
ToFile( "HUNSPELL_LIBS",     "@HUNSPELL_LIBS@",    "e" );
ToFile( "SYSTEM_LPSOLVE",    "@SYSTEM_LPSOLVE@",   "e" );
ToFile( "SYSTEM_HYPH",       "@SYSTEM_HYPH@",      "e" );
ToFile( "HYPHEN_LIB",        "@HYPHEN_LIB@",       "e" );
ToFile( "SYSTEM_MYTHES",     "@SYSTEM_MYTHES@",    "e" );
ToFile( "PAM",               "@PAM@",              "e" );
ToFile( "NEW_SHADOW_API",    "@NEW_SHADOW_API@",   "e" );
ToFile( "PAM_LINK",          "@PAM_LINK@",         "e" );
ToFile( "CRYPT_LINK",        "@CRYPT_LINK@",       "e" );
ToFile( "XAU_LIBS",          "@XAU_LIBS@",         "e" );
ToFile( "GXX_INCLUDE_PATH",  PathFormat("@GXX_INCLUDE_PATH@"), "e" );
ToFile( "COMMON_BUILD_TOOLS",$COMMON_BUILD_TOOLS,  "e" );
if ($platform !~ m/cygwin|os2/) {
   if ( $ENV{"TMPDIR"} eq "" ) {
      ToFile( "TMPDIR",      "/tmp",               "e" );
   } else {
      ToFile( "TMPDIR",      "$ENV{'TMPDIR'}",     "e" );
   }
}
ToFile( "SOLARSRC",           $SOLARSRC,           "e" );
ToFile( "SOURCE_ROOT_DIR",    $SOURCE_ROOT_DIR,    "e" );
if ( $platform =~ m/cygwin/ )
{
   ToFile( "ILIB",              $ILIB,              "e" );
   if ( $MINGW eq "yes" )
   {  ToFile( "ATL_INCLUDE",       $ATL_INCLUDE,       "e" );
      ToFile( "EXCEPTIONS",        "@EXCEPTIONS@",        "e" );
      ToFile( "DIRECTXSDK_HOME",    PathFormat("@DIRECTXSDK_HOME@"),    "e" );
      ToFile( "USE_MINGW",         $USE_MINGW,              "e" );
      ToFile( "MINGW_CLIB_DIR",         PathFormat("@MINGW_CLIB_DIR@"),              "e" );
      ToFile( "MINGW_SHARED_GCCLIB",         "@MINGW_SHARED_GCCLIB@",              "e" );
      ToFile( "MINGW_GCCLIB_EH",      "@MINGW_GCCLIB_EH@",              "e" );
      ToFile( "MINGW_SHARED_GXXLIB",         "@MINGW_SHARED_GXXLIB@",              "e" );
      ToFile( "MINGW_GCCDLL",         "@MINGW_GCCDLL@",              "e" );
      ToFile( "MINGW_GXXDLL",         "@MINGW_GXXDLL@",              "e" );
   }
   ToFile( "GREP",              $WIN_GREP,          "e" );
   ToFile( "FIND",              $WIN_FIND,          "e" );
   ToFile( "LS",                $WIN_LS,            "e" );
   ToFile( "GNUCOPY",           $WIN_GNUCOPY,       "e" );
   ToFile( "TOUCH",             $WIN_TOUCH,         "e" );
}
if ( $platform =~ m/os2/ )
{
   #ToFile( "ILIB",              $ILIB,              "e" );
   
   ToFile( "GREP",              "grep.exe",         "e" );
   ToFile( "FIND",              "find.exe",         "e" );
   ToFile( "LS",                "ls.exe",           "e" );
   ToFile( "GNUCOPY",           "cp.exe",           "e" );
   ToFile( "TOUCH",             "touch",            "e" );
}

# $perlpre is only used for the following three variables
# and only set for OS2.
my $perlpre = "";
if (( $platform =~ m/os2/ )) {
   $perlpre = "perl ".${SOLARENV}.${BIN}.${ds};
}
ToFile( "DELIVER",       $perlpre."deliver.pl",     "e" );
ToFile( "MKOUT",         $perlpre."mkout.pl",       "e" );
ToFile( "ZIPDEP",        $perlpre."zipdep.pl",      "e" );

ToFile( "USE_SHELL",             '@USE_SHELL@',     "e" );

#
# Writing the aliases to file.
ToFile( "Aliases.",          $empty,             "c" );
ToFile( "Don't set aliases when bootstrapping", $empty, "c" );
ToFile( 'if ( ! ${?_ISBOOTSTRAP_} ) then', $empty, "y");
ToFile( "if test -z \"\$_ISBOOTSTRAP_\"; then", $empty, "z");

ToFile( "alias mkout",       $mkout,             "a" );
ToFile( "alias deliver",     $deliver,           "a" );
ToFile( "alias build",       $build,             "a" );
ToFile( "alias build_client",$build_client,      "a" );
ToFile( "alias zipdep",      $zipdep,            "a" );
if ( $platform !~ m/cygwin/ )
{  ToFile( "alias nmake",       $nmake,             "a" );
}
if ( $platform =~ m/os2/ )
{  ToFile( "alias gunzip",       "gzip -d",         "a" );
}

ToFile( "endif",             $empty, "y");
ToFile( "fi",                $empty, "z");

# Check if the right dmake version is used. (W32 only)
if ( $platform =~ m/cygwin/ ) {
    ToFile( "Check if the right dmake version is used.", $empty, "c" );
    # Invalidate build environment.
    ToFile( "WORK_STAMP", "_invalid_", "e" );
    # Don't test the dmake version if this file is sourced by bootstrap
    ToFile( "bash -c 'if test -n \"\$_ISBOOTSTRAP_\" || (dmake.exe -V | grep -e \"-cygwin\\|OS := cygwin\" > /dev/null ); then true; else echo -e \"\\n\\nERROR: Not a cygwin build dmake or dmake missing, please check!\\n\\n\" ; sleep 5; false ; fi' || exit 1", $empty, "y");
    # Restore valid environment if test was successful.
    ToFile( "WORK_STAMP",        $WORK_STAMP,        "e" );
    ToFile( "", $empty, "n");
}

# on Solaris, MacOSX and FreeBSD, set GNUCOPY and GNUPATCH
if ($platform =~ m/solaris|darwin|freebsd/)
{
  ToFile( "GNUPATCH",   "@GNUPATCH@",	"e");
  ToFile( "GNUCOPY",	"@GNUCP@",	"e");
}
# OS/2 define .pl as executable for 4os2
# use - as switch char for dmake (os2/switchar.c)
if ($platform =~ m/os2/)
{
  ToFile( ".pl",   	"perl",	"e");
  ToFile( "SWITCHAR",   "-",	"e");
}
ToFile( "SAL_ENABLE_FILE_LOCKING",	"1",	"e");
#
# Writing unset variables you might not need to file.
# 
print OUT $unsetvars;

print OUT_SH "export $exportvars$newline";
print OUT_SH "unset $unsetvarssh$newline";


#
#---------------------------
# VIII. Closing output file.
#---------------------------
#
close( OUT ) || print "Can't close $outfile: $!";

close( OUT_SH ) || print "Can't close $outfile_sh: $!";

#
#------------------------------
# IX. Sourcing the output file.
#------------------------------
#
#---------------------------------
# X. Set up the build environment.
#---------------------------------
#
#--------------------------------------------------------
# XI. Moving the output file to the build home directory.
#--------------------------------------------------------
#
$tmp = $SRC_ROOT.$ds.$outfile;
if (rename( $outfile, $tmp ) ne 1)
{  `mv -f $outfile $tmp`;
}

$tmp = $SRC_ROOT.$ds.$outfile_sh;
if (rename( $outfile_sh, $tmp ) ne 1)
{  `mv -f $outfile_sh $tmp`;
}

#
#--------------------------------------------------------
# XII. Message at the end.
#--------------------------------------------------------
#
#
print "*********************************************************".
      "******************* $newline"."*"."$newline";
print "* OpenOffice.org $UPD configuration. $newline";
for ( $tmp = 0; $tmp < 2; $tmp++ ) 
{  print "* $newline";
}
print "* Configuration part of OpenOffice.org $UPD build is finished. $newline* $newline";
print "* NB! Be aware that you might not be able to build OpenOffice.org if you $newline".
      "* ignore any warning message that were generated during this configuration $newline".
      "* process. $newline* $newline";

if ( $Warning ne "" ) 
{  print "$Warning*"; 
   print "$newline";
}

print "*$newline* USAGE: $newline";
print "* Source $outfile (in tcsh)";
print " or $outfile.sh (in sh)";
print "$newline";
print "* in order to set up the build-environment variables.$newline";
for ( $tmp = 0; $tmp < 2; $tmp++ ) 
{  print "* $newline";
}
print "*********************************************************".
      "******************* $newline";

$bootfile = "bootstrap";
open( OUT, ">$bootfile" ) ||
die "Cannot open $bootfile: $!\n";
print OUT "#!/bin/sh\n";
print OUT "_ISBOOTSTRAP_=TRUE ; export _ISBOOTSTRAP_ ; . $SRC_ROOT/$outfile.sh\n"; 
print OUT "unset _ISBOOTSTRAP_; export _ISBOOTSTRAP_\n"; 
if ( $MINGW eq "yes" )
{  print OUT 'PATH="/usr/bin:$PATH" : export PATH'."\n"; }
close( OUT ) || print "Can't close $bootfile: $!";
system(`cat bootstrap.1 >> bootstrap`);
system(`chmod +x bootstrap`);
#
#--------------------------------------------------------
# Moving the bootstrap file to the build home directory.
#--------------------------------------------------------
#
$tmp = $SRC_ROOT.$ds.$bootfile;
if (rename( $bootfile, $tmp ) ne 1)
{  `mv -f $bootfile $tmp`;
}

print "Configure completed\n";
print "You may now run ./bootstrap in $SRC_ROOT\n";
if ( $Warning ne "" ) {
	print "***** WARNINGS ISSUED *****\n";
}

#
#-----------------
# XII. Functions.
#-----------------
#
#-------------------------------------------------------------
# Function name: CheckPathName 
# Description:   chops off the '/' character if it's the last
#                character in a pathname. also adds the '/'
#                character if it's not the first character
#                in a path.
# Arguments:     1. Path (string)
# Return value:  Path (string)
#-------------------------------------------------------------
sub CheckPathName 
{  my $retrn = $_[ 0 ];
   if ($platform =~ m/cygwin/)
   {  # Check if the first character is not a '/'.
      if ( !( $_[ 0 ] =~ /^\// ) ) 
      {  $retrn = $ds.$_[ 0 ];
      }
   }
   # kill the last '/','\','\n' if they exists.
   $retrn =~ s![\s/\\]+$!!;
   # Done!
   return( $retrn );
}
#-------------------------------------------------------------
# Function name: CheckPathExist 
# Description:   Checks whether the directory that is given
#                as an argument exists. If not abort.
# Arguments:     1. Path (string)
# Return value:  void
#-------------------------------------------------------------
sub CheckPathExist 
{  my $dir = $_[ 0 ];
   if ( !( -d $dir ) and $^O ne 'MSWin32' )
   {  print ( "The directory $_[ 0 ] does not exist. Please create first.\n" );
      exit 1;
   }
   else
   {  # Don't check under ActiveState Perl (Windows). The path is possibly
      # posix and it cannot handle it.
      return "true";
   }
}
#------------------------------------------------------------
# Function name: CreateFileHeader 
# Description:   Creates a header for the outfile.
# Arguments:     1. File to write to
#                2. UPD (string)
#                3. Platform (string)
#                4. name of shell for this file
#                5. comment to use for this file
# Return value:  void
#------------------------------------------------------------
sub CreateFileHeader 
{  my $timestamp = `date`;
   chomp( $timestamp );
   my $filehandle = $_[0];
   my $comment = $_[4];
   print { $filehandle } "$comment #################################################################"; 
   print { $filehandle } $newline;
   print { $filehandle } "$comment OpenOffice.org $_[ 1 ] build environment file for: $_[ 2 ]. $newline"; 
   print { $filehandle } "$comment Generated on: $timestamp $newline"; 
   print { $filehandle } "$comment Source this file to set up the build environment. $newline"; 
   print { $filehandle } "$comment 1. exec $_[3] $newline"; 
   print { $filehandle } "$comment 2. source $outfile $newline"; 
   print { $filehandle } "$comment #################################################################"; 
   print { $filehandle } $newline;
}
#---------------------------------------------------------
# Function name: ToFile
# Description:   Writes the environment variable in the
#                output file.
# Arguments:     1. Name of environment variable (string)
#                2. Value of environment variable (string)
#                3. e - env. var
#                   a - alias
#                   c - comment
#                   n - newline
#                   x - raw, write as is to OUT_BAT
#                   y - raw, write as is to OUT
#                   z - raw, write as is to OUT_SH
# Return value:  void
#---------------------------------------------------------
sub ToFile {
   if ( $_[ 2 ] eq "e" ) {
      # Write an environment variable to file.
      if (defined $_[ 1 ] && $_[ 1 ] ne "" ) {
         my $envvar = $_[ 1 ];
         my $envvarbash = $envvar;

         # Tcsh/bash needs backslashes quoted
         $envvar =~ s/\\/\\\\/g;
         $envvarbash = $envvar;

         printf("%-12s %-17s %-10s %s\n", "The variable", $_[ 0 ], "is set to:", $envvar);
         print OUT "$setenv $_[ 0 ] \"$envvar\"$newline";  # to tcsh file
         print OUT_SH "$_[ 0 ]=\"$envvarbash\"$newline";   # to sh file
         $exportvars .= " $_[ 0 ]";                        # add to export list for sh file

      } else {
         printf("%-12s %-17s %-10s %s\n", "The variable", $_[ 0 ], "is set to:", "unset") ; # to stdout
         $unsetvars .= "$unsetenv $_[ 0 ] >& /dev/null$newline"; # for tcsh file
         $unsetvarssh .= " $_[ 0 ]";                             # for sh file
      }
   }
   elsif ( $_[ 2 ] eq "a" ) 
   {  # Write an alias to file.
      print "The $_[ 0 ] is set to: $_[ 1 ]\n";    # to stdout
      print OUT "$_[ 0 ] $_[ 1 ]$newline";         # to tcsh file
      print OUT_SH "$_[ 0 ]=$_[ 1 ]$newline";      # to sh file
   }
   elsif ( $_[ 2 ] eq "c" ) 
   {  # Write a comment to file.
      print "$newline";
      print "$comment$newline";
      print "$comment $_[ 0 ]$newline";
      print "$comment$newline";
      print OUT "$newline";
      print OUT "$comment$newline";
      print OUT "$comment $_[ 0 ]$newline";
      print OUT "$comment$newline";
      print OUT_SH "$newline";
      print OUT_SH "$comment$newline";
      print OUT_SH "$comment $_[ 0 ]$newline";
      print OUT_SH "$comment$newline";
   }
   elsif ( $_[ 2 ] eq "n" )
   {  #Write a newline to a file
      print OUT "$newline";
      print OUT_SH "$newline";
   }
   elsif ( $_[ 2 ] eq "y" )
   {
      #Write first argument as is, and nothing else
      print OUT "$_[ 0 ]$newline";
   }
   elsif ( $_[ 2 ] eq "z" )
   {
      #Write first argument as is, and nothing else
      print OUT_SH "$_[ 0 ]$newline";
   }
   else
   {  print "Unknown type!$newline";
   }
}
#----------------------------------------------------------
# Function name: PathFormat
# Description:   Reformat path to either POSIX or mixed mode style.
# Arguments:     1. Variable (string)
# Return value:  Reformatted String
#----------------------------------------------------------
sub PathFormat
{  my ( $variable, $d1, $d2 );
   $variable = $_[ 0 ];

   if ( $platform =~ m/cygwin/ )
   {   $variable =~ s/(\$\{?\w+\}?)/$1/eeg ; # expand the variables
       $variable =~ s/(\$\{?\w+\}?)/$1/eeg ; # expand the variables twice!

       # Complain if PosixPath is used on a PATH-like string
       if ( $variable =~ m/;/ ) {
           die( "Do not use on PATH lists (i.e., 'c:\\foo;d:\\bar')");
       }

       # Replace path with space with short dos path
       if ( $variable =~ / / ) {
           chomp( $variable = qx{cygpath -d "$variable"} ) ;
       }

       # Replace absolute paths or DOS paths with ...
       if ( ( $variable =~ m/^\// ) or ( $variable =~ m/:/ ) ) {
           # mixed mode paths
           chomp( $variable = qx{cygpath -m "$variable"} );
       }
   }
   return $variable;
}
#----------------------------------------------------------
# Function name: CygFormat
# Description:   Format variables to cygwin posix style path
#                unless .
# Arguments:     1. Variable (string)
# Return value:  Reformatted String
#----------------------------------------------------------
sub CygFormat
{  my ( $variable, $d1, $d2 );
   $variable = $_[ 0 ];
   # ToDo: Do the replacement only if Windows and var contains "\" and ":"
   if ( $platform =~ m/cygwin|os2/ )
   {
       # Complain if PosixPath is used on a PATH-like string
       if ( $variable =~ m/;/ ) {
           die( "Do not use on PATH lists (i.e., 'c:\\foo;d:\\bar')");
       }

       # Replace DOS paths with posix paths
       if ( ( $variable =~ m/\\/ ) or ( $variable =~ m/:/ ) ) {
           chomp( $variable = qx{cygpath -u "$variable"} );
       }
   }
   return $variable;
}
#----------------------------------------------------------
# Function name: WinFormat
# Description:   Format variables to Windows Format.
# Arguments:     1. Variable (string)
# Return value:  Reformatted String
#----------------------------------------------------------
sub WinFormat
{  my ( $variable, $d1 );
   $variable = $_[ 0 ];
   $variable =~ s/^\s+//g ; #remove leading spaces
   $variable =~ s/\s+$//g ; #remove trailing spaces
   $variable =~ s/(\$\{?\w+\}?)/$1/eeg ;   # expand the variables
   $variable =~ s/(\$\{?\w+\}?)/$1/eeg ;   # expand the variables twice!
   $variable =~ s/:+/:/g ;                 # remove multiple ;

   # Some variables are already in DOS path format, return early.
   if ( $variable =~ /\\/ ) {
       return $variable;
   }
   if ( $variable eq ";" ) {
       # Ignore single ';'
       return $variable;
   }
   if ( $variable =~ /;/ and $variable =~ /\// ) {
       # Mixed mode path-style entry, separated with ;, like CLASSPATH
       return $variable;
   }

   # Search for posix path entry and replace with cygpath -w entry
   # ( -d if filename contains space )

   # Normal paths

   # One special case is if "perl " is prepended.
   $variable =~ /^(perl\s+)?(.*)$/;
   my $perlpre = $1;
   if ( !defined($perlpre) ) {
       $perlpre = "";
   }
   $variable = $2;

   if ( $variable =~ /^\/[\w\.~ ]+/ ) {
       if ( $variable =~ / / ) {
           # Use DOS 8.3 style to avoid quoting
           chomp( $variable = qx{cygpath -d "$variable"} );
       } else {
           # Use "normal" filenames
           chomp( $variable = qx{cygpath -w "$variable"} );
       }
   } else {
       # relative or absolute DOS paths here
       $variable =~ s#/#\\#g;
   }

   $variable = $perlpre.$variable;
   if ( ($perlpre ne "") && ($^O eq "cygwin")) {
       # Cygwin's perl needs quoted backslashes
       $variable =~ s#\\#\\\\#g;
   }

   return $variable;
}

#----------------------------------------------------------
# Function name: WinPath
# Description:   Reformat a $sep seperated path using DOS paths.
# Arguments:     1. Variable (string)
#                2. Separaror (string)
# Return value:  Reformatted String
#----------------------------------------------------------
sub WinPath
{
    my ( $variable, $d1, $sep, @split_var );

    if ( $platform =~ m/cygwin/ ) {
        $variable = $_[ 0 ];
        $sep = $_[ 1 ];
        $variable =~ s/^\s+//g ; #remove leading spaces
        $variable =~ s/\s+$//g ; #remove trailing spaces
        $variable =~ s/(\$\{?\w+\}?)/$1/eeg ; # expand the variables
        $variable =~ s/(\$\{?\w+\}?)/$1/eeg ; # expand the variables twice!

        @split_var = split(/$sep/,$variable);
        foreach $d1 ( @split_var ) {
            if ( $d1 =~ /(?:^\/[\w\.~ ]+)+/ ) {
                if ( $d1 =~ / / ) {
                    # Use DOS 8.3 style to avoid quoting
                    chomp( $d1 = qx{cygpath -d "$d1"} );
                } else {
                    # Use "normal" filenames
                    chomp( $d1 = qx{cygpath -w "$d1"} );
                }
            }
        }
        $variable = join(';',@split_var);

        $variable =~ s/\//\\/g; # Remaining \ come from e.g.: ../foo/baa
    }

    return $variable;
}

#--------------------------------------------------------
# Function name: GetCorrectPath
# Description:   Creates the build environment. 
# Arguments:     1.   existing / original path
#                2... pairs of <path, executable>
# Return value:  String - Correct Path
#--------------------------------------------------------
sub GetCorrectPath
{
	sub PathLookup
	{
	    my $cmd = shift;
	    while (@_) {
		my $elem = shift;
		
		-x "$elem/$cmd" && return $elem;
	    }
	    return '';
	}

	sub SaneGrep
	{
	    # Perl grep is unbelievably strange.
	    my $needle = shift;
	    while (@_) {
		my $haystack = shift;
		if ($needle eq $haystack) {
		    return 1;
		} 
	    }
	    return 0;
	}	

	sub CleanupPath
	{
	    my @elements = @_;
	    my @cleanName = ();

	    while (@elements) {
		my $elem = shift @elements;
		if (!SaneGrep ($elem, @cleanName)) {
			push @cleanName, $elem;
		}
	    }

	    return @cleanName;
	}

	my $oldPath = shift;
	my @originalPairs = @_;
	my @pairs = @originalPairs;
	my @Path = split /$ps/, $oldPath;

	while (@pairs) {
	    my $path = shift @pairs;
	    my $cmd = shift @pairs;
	    my $to_append = 1;
	    my $elem;

	    if (! -x "$path/$cmd") {
		AddWarning ("Missing executable $path/$cmd\n");
	    }

	    for $elem (@Path) {
		if ($elem eq $path) {
#		    print "Hit duplicate path in path; break\n";
		    $to_append = 0;
		    last;
		}
		if (-f "$elem/$cmd") {
#		    print "Element already in path ...\n";
		    unshift @Path, $path;
		    $to_append = 0;
		    last;
		} else {
#		    print "No file $elem/$cmd\n";
		}
	    }
	    if ($to_append) {
		push @Path, $path;
	    }
	}

	@pairs = @originalPairs;
	while (@pairs) {
	    my $path = shift @pairs;
	    my $cmd = shift @pairs;
	    my $realpath;

	    $realpath = PathLookup ($cmd, @Path);
	    if (!($realpath eq $path)) {
		AddWarning ("Path conflict for executables " .
                            "$path/$cmd against $realpath");
	    }
	}

	return join $ps, CleanupPath (@Path);
}

#------------------------------------------------------------
# Function name: AddWarning 
# Description:   Adds any kind of warning for the user.
#                The warning will be shown at the end
#                of this script.
# Arguments:     1. Add the configure warnings or the set_soenv
#                   warning (string).
#                2. Warning (string).
# Return value:  void
#------------------------------------------------------------
sub AddWarning 
{  if ( $_[ 0 ] eq "configure" ) 
   {  open( IN, $warnfile );
      while ( <IN> ) 
      {  $Warning = $Warning."* - ".$_;
      }
      close( IN );
      # Remove the temporary warning file.
      # unlink ( $warnfile );
   }
   elsif ( $_[ 0 ] eq "set_soenv" ) 
   {  my ( $arg1 );
      $arg1 = $_[ 1 ];
      chomp( $arg1 );                            # cut off new line      
      $Warning = $Warning."* - set_soenv: warning: $arg1 $newline";  # add the warning  
   }
}
#-------------------
# That's all folks!
#-------------------
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.