summaryrefslogtreecommitdiff
path: root/ACE/MPC/modules/ProjectCreator.pm
blob: 2f68c18183c5f98883d253439cd4f8043533c8ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
package ProjectCreator;

# ************************************************************
# Description   : Base class for all project creators
# Author        : Chad Elliott
# Create Date   : 3/13/2002
# ************************************************************

# ************************************************************
# Pragmas
# ************************************************************

use strict;
use FileHandle;
use File::Path;

use Creator;
use TemplateInputReader;
use TemplateParser;
use FeatureParser;
use CommandHelper;

use vars qw(@ISA);
@ISA = qw(Creator);

# ************************************************************
# Data Section
# ************************************************************

## The basic extensions known to a project creator
my $BaseClassExtension      = 'mpb';
my $ProjectCreatorExtension = 'mpc';
my $TemplateExtension       = 'mpd';
my $TemplateInputExtension  = 'mpt';

## This feature is enabled or disabled depending on whether
## or not the -static option is used.
my $static_libs_feature = 'static_libs_only';

## Valid names for assignments within a project
## Bit Meaning
## 0   Preserve the order for additions (1) or invert it (0)
## 1   Add this value to template input value (if there is one)
## 2   Preserve <% %> settings for evaluation within the template
my %validNames = ('after'              => 1,
                  'avoids'             => 3,
                  'custom_only'        => 1,
                  'dllout'             => 1,
                  'dynamicflags'       => 3,
                  'exename'            => 1,
                  'exeout'             => 1,
                  'includes'           => 3,
                  'libout'             => 1,
                  'libpaths'           => 3,
                  'libs'               => 2,
                  'lit_libs'           => 2,
                  'macros'             => 3,
                  'managed'            => 1,
                  'pch_header'         => 1,
                  'pch_source'         => 1,
                  'postbuild'          => 5,
                  'postclean'          => 5,
                  'prebuild'           => 5,
                  'pure_libs'          => 2,
                  'recurse'            => 1,
                  'recursive_includes' => 3,
                  'recursive_libpaths' => 3,
                  'requires'           => 3,
                  'sharedname'         => 1,
                  'staticflags'        => 3,
                  'staticname'         => 1,
                  'tagchecks'          => 1,
                  'tagname'            => 1,
                  'version'            => 1,
                  'webapp'             => 1,
                 );

## Custom definitions only
## Bit  Meaning
## 0    Value is always an array
## 1    Value is an array and name gets 'outputext' converted to 'files'
## 2    Value is always scalar
## 3    Name can also be used in an 'optional' clause
## 4    Needs <%...%> conversion
my %customDefined = ('automatic_in'                => 0x04,
                     'automatic_out'               => 0x04,
                     'command'                     => 0x14,
                     'commandflags'                => 0x14,
                     'dependent'                   => 0x14,
                     'precommand'                  => 0x14,
                     'postcommand'                 => 0x14,
                     'inputext'                    => 0x01,
                     'libpath'                     => 0x04,
                     'output_follows_input'        => 0x04,
                     'output_option'               => 0x14,
                     'pch_postrule'                => 0x04,
                     'pre_extension'               => 0x08,
                     'source_pre_extension'        => 0x08,
                     'template_pre_extension'      => 0x08,
                     'header_pre_extension'        => 0x08,
                     'inline_pre_extension'        => 0x08,
                     'documentation_pre_extension' => 0x08,
                     'resource_pre_extension'      => 0x08,
                     'generic_pre_extension'       => 0x08,
                     'pre_filename'                => 0x08,
                     'source_pre_filename'         => 0x08,
                     'template_pre_filename'       => 0x08,
                     'header_pre_filename'         => 0x08,
                     'inline_pre_filename'         => 0x08,
                     'documentation_pre_filename'  => 0x08,
                     'resource_pre_filename'       => 0x08,
                     'generic_pre_filename'        => 0x08,
                     'pre_dirname'                 => 0x08,
                     'source_pre_dirname'          => 0x08,
                     'template_pre_dirname'        => 0x08,
                     'header_pre_dirname'          => 0x08,
                     'inline_pre_dirname'          => 0x08,
                     'documentation_pre_dirname'   => 0x08,
                     'resource_pre_dirname'        => 0x08,
                     'generic_pre_dirname'         => 0x08,
                     'source_outputext'            => 0x0a,
                     'template_outputext'          => 0x0a,
                     'header_outputext'            => 0x0a,
                     'inline_outputext'            => 0x0a,
                     'documentation_outputext'     => 0x0a,
                     'resource_outputext'          => 0x0a,
                     'generic_outputext'           => 0x0a,
                    );

## Custom sections as well as definitions
## Value  Meaning
## 0    No modifications
## 1    Needs <%...%> conversion
my %custom = ('command'       => 1,
              'commandflags'  => 1,
              'dependent'     => 1,
              'gendir'        => 0,
              'precommand'    => 1,
              'postcommand'   => 1,
             );

## All matching assignment arrays will get these keywords
my @default_matching_assignments = ('recurse',
                                   );

## Deal with these components in a special way
my %specialComponents = ('header_files'   => 1,
                         'inline_files'   => 1,
                         'template_files' => 1,
                        );
my %sourceComponents  = ('source_files'   => 1,
                         'template_files' => 1,
                        );

my $defgroup    = 'default_group';
my $grouped_key = 'grouped_';
my $tikey       = '/ti/';

## Matches with generic_outputext
my $generic_key = 'generic_files';

# ************************************************************
# C++ Specific Component Settings
# ************************************************************

## Resource files tag for C++
my $cppresource = 'resource_files';

## Valid component names within a project along with the valid file extensions
my %cppvc = ('source_files'        => [ "\\.cpp", "\\.cxx", "\\.cc", "\\.c", "\\.C", ],
             'template_files'      => [ "_T\\.cpp", "_T\\.cxx", "_T\\.cc", "_T\\.c", "_T\\.C", "_t\\.cpp", "_t\\.cxx", "_t\\.cc", "_t\\.c", "_t\\.C" ],
             'header_files'        => [ "\\.h", "\\.hpp", "\\.hxx", "\\.hh", ],
             'inline_files'        => [ "\\.i", "\\.ipp", "\\.inl", ],
             'documentation_files' => [ "README", "readme", "\\.doc", "\\.txt", "\\.html" ],
             $cppresource          => [ "\\.rc", ],
            );

## Exclude these extensions when auto generating the component values
my %cppec = ('source_files' => $cppvc{'template_files'},
            );

## These matching assignment arrays will get added, but only to the
## specific project component types.
my %cppma = ('source_files' => ['buildflags',
                                'managed',
                                'no_pch',
                               ],
            );

# ************************************************************
# C# Specific Component Settings
# ************************************************************

## Resource files tag for C#
my $csresource = 'resx_files';

## Valid component names within a project along with the valid file extensions
my %csvc = ('source_files'        => [ "\\.cs" ],
            'config_files'        => [ "\\.config" ],
            $csresource           => [ "\\.resx", "\\.resources" ],
            'aspx_files'          => [ "\\.aspx" ],
            'ico_files'           => [ "\\.ico" ],
            'documentation_files' => [ "README", "readme", "\\.doc", "\\.txt", "\\.html" ],
           );

my %csma = ('source_files' => [ 'dependent_upon',
                                'subtype',
                              ],
            $csresource    => [ 'dependent_upon',
                                'generates_source',
                                'subtype',
                              ],
           );

# ************************************************************
# Java Specific Component Settings
# ************************************************************

## Valid component names within a project along with the valid file extensions
my %jvc = ('source_files'        => [ "\\.java" ],
           'documentation_files' => [ "README", "readme", "\\.doc", "\\.txt", "\\.html" ],
          );

# ************************************************************
# Visual Basic Specific Component Settings
# ************************************************************

## Resource files tag for VB
my $vbresource = 'resx_files';

## Valid component names within a project along with the valid file extensions
my %vbvc = ('source_files'        => [ "\\.vb" ],
            'config_files'        => [ "\\.config" ],
            $vbresource           => [ "\\.resx" ],
            'aspx_files'          => [ "\\.aspx" ],
            'ico_files'           => [ "\\.ico" ],
            'documentation_files' => [ "README", "readme", "\\.doc", "\\.txt", "\\.html" ],
           );

my %vbma = ('source_files' => [ 'subtype' ],
           );

# ************************************************************
# Language Specific Component Settings
# ************************************************************

# Index Description
# ----- -----------
# 0     File types
# 1     Files automatically excluded from source_files
# 2     Assignments available in standard file types
# 3     The entry point for executables
# 4     The language uses a C preprocessor
# 5     Name of the tag for 'resource_files' for this language
#        * This is special because it gets treated like source_files in that
#          a project with only these files is a library/exe not "custom only".
my %language = (Creator::cplusplus => [ \%cppvc, \%cppec, \%cppma, 'main',
                                        1, $cppresource ],

                Creator::csharp    => [ \%csvc, {}, \%csma, 'Main', 0,
                                        $csresource ],

                Creator::java      => [ \%jvc, {}, {}, 'main', 0 ],

                Creator::vb        => [ \%vbvc, {}, \%vbma, 'Main', 0,
                                        $vbresource ],
               );
my %mains;

# ************************************************************
# Subroutine Section
# ************************************************************

sub new {
  my($class, $global, $inc, $template, $ti, $dynamic, $static, $relative, $addtemp, $addproj, $progress, $toplevel, $baseprojs, $gfeature, $relative_f, $feature, $features, $hierarchy, $exclude, $makeco, $nmod, $applypj, $genins, $into, $language, $use_env, $expandvars, $gendot, $comments, $foreclipse) = @_;
  my $self = $class->SUPER::new($global, $inc,
                                $template, $ti, $dynamic, $static,
                                $relative, $addtemp, $addproj,
                                $progress, $toplevel, $baseprojs,
                                $feature, $features,
                                $hierarchy, $nmod, $applypj,
                                $into, $language, $use_env,
                                $expandvars,
                                'project');

  $self->{$self->{'type_check'}}   = 0;
  $self->{'feature_defined'}       = 0;
  $self->{'features_changed'}      = undef;
  $self->{'project_info'}          = [];
  $self->{'lib_locations'}         = {};
  $self->{'reading_parent'}        = [];
  $self->{'dll_exe_template_input'}= {};
  $self->{'lib_exe_template_input'}= {};
  $self->{'lib_template_input'}    = {};
  $self->{'dll_template_input'}    = {};
  $self->{'flag_overrides'}        = {};
  $self->{'custom_special_output'} = {};
  $self->{'custom_special_depend'} = {};
  $self->{'special_supplied'}      = {};
  $self->{'pctype'}                = $self->extractType("$self");
  $self->{'verbatim'}              = {};
  $self->{'verbatim_accessed'}     = {$self->{'pctype'} => {}};
  $self->{'defaulted'}             = {};
  $self->{'custom_types'}          = {};
  $self->{'parents_read'}          = {};
  $self->{'inheritance_tree'}      = {};
  $self->{'remove_files'}          = {};
  $self->{'expanded'}              = {};
  $self->{'gfeature_file'}         = $gfeature;
  $self->{'relative_file'}         = $relative_f;
  $self->{'feature_parser'}        = $self->create_feature_parser($features,
                                                                  $feature);
  $self->{'sort_files'}            = $self->sort_files();
  $self->{'source_callback'}       = undef;
  $self->{'dollar_special'}        = $self->dollar_special();
  $self->{'generate_ins'}          = $genins;
  $self->{'addtemp_state'}         = undef;
  $self->{'command_subs'}          = $self->get_command_subs();
  $self->{'escape_spaces'}         = $self->escape_spaces();
  $self->{'current_template'}      = undef;
  $self->{'make_coexistence'}      = $makeco;

  $self->add_default_matching_assignments();
  $self->reset_generating_types();

  return $self;
}


sub is_keyword {
  ## Is the name passed in a known keyword for a project.  This includes
  ## keywords mapped by Define_Custom or Modify_Custom.
  my($self, $name) = @_;
  return $self->{'valid_names'}->{$name};
}


sub read_global_configuration {
  my $self   = shift;
  my $input  = $self->get_global_cfg();
  my $status = 1;

  if (defined $input) {
    ## If it doesn't contain a path, search the include path
    if ($input !~ /[\/\\]/) {
      $input = $self->search_include_path($input);
      $input = $self->get_global_cfg() if (!defined $input);
    }

    ## Read and parse the global project file
    $self->{'reading_global'} = 1;
    $status = $self->parse_file($input);
    $self->{'reading_global'} = 0;
  }

  return $status;
}


sub convert_to_template_assignment {
  my($self, $name, $value, $calledfrom) = @_;

  ## If the value we are going to set for $name has been used as a
  ## scoped template variable, we need to hijack the whole assignment
  ## and turn it into a template variable assignment.
  my $atemp = $self->get_addtemp();
  foreach my $key (grep(/::$name$/, keys %$atemp)) {
    $self->update_template_variable(0, $calledfrom, $key, $value);
  }
}


sub create_recursive_settings {
  my($self, $name, $value, $assign) = @_;

  ## Handle both recursive_includes and recursive_libpaths in one
  ## search and replace.
  if ($name =~ s/^recursive_//) {
    ## This portion of code was lifted directly from Creator::relative()
    ## but modified to always expand the variables.  We will turn the
    ## expanded values back into variables below and once they're passed
    ## off to the assignment processing code, they will be turned into
    ## relative values (if possible).
    if (index($value, '$') >= 0) {
      my $ovalue = $value;
      my($rel, $how) = $self->get_initial_relative_values();
      $value = $self->expand_variables($value, $rel, 0, undef, 1);

      if ($ovalue eq $value || index($value, '$') >= 0) {
        ($rel, $how) = $self->get_secondary_relative_values();
        $value = $self->expand_variables($value, $rel, 0, undef, 1, 1);
      }
    }

    ## Create an array out of the recursive directory list.  Convert all
    ## of the relative or full path values back into $() values.
    my @dirs = ();
    my $elems = $self->create_array($value);
    foreach my $elem (@$elems) {
      my $dlist = $self->recursive_directory_list($elem, []);
      if ($dlist eq '') {
        ## This directory doesn't exist, just add the original value
        push(@dirs, $elem);
      }
      else {
        ## Create an array out of the directory list and add it to our
        ## array.
        my $array = $self->create_array($dlist);
        push(@dirs, @$array);
      }
    }

    ## We need to return a string, so we join it all together space
    ## separated.
    $value = join(' ', $self->back_to_variable(\@dirs));
  }

  return $name, $value;
}

sub process_assignment {
  my($self, $name, $value, $assign, $calledfrom) = @_;
  $calledfrom = 0 if (!defined $calledfrom);

  ## See if the name is one of the special "recursive" settings.  If so,
  ## fix up the value and change the name.
  ($name, $value) = $self->create_recursive_settings($name, $value, $assign);

  ## Support the '*' mechanism as in the project name, to allow
  ## the user to correctly depend on another project within the same
  ## directory.
  if (defined $value) {
    if ($name eq 'after' && index($value, '*') >= 0) {
      $value = $self->fill_type_name($value,
                                     $self->get_default_project_name());
    }

    ## If this particular project type does not consider the dollar sign
    ## special and the user has provided two dollarsigns as an escape, we
    ## will turn it into a single dollar sign.
    if (!$self->{'dollar_special'} && index($value, '$$') >= 0) {
      $value =~ s/\$\$/\$/g;
    }

    ## If the assignment name is valid and requires parameter (<%...%>)
    ## replacement, then do so.
    if (defined $self->{'valid_names'}->{$name} &&
        ($self->{'valid_names'}->{$name} & 0x04) == 0 &&
        index($value, '<%') >= 0) {
      $value = $self->replace_parameters($value, $self->{'command_subs'});
    }
  }

  if ($calledfrom == 0) {
    $self->convert_to_template_assignment($name, $value, $calledfrom);
  }

  ## Call the base process_assigment() after we have modified the name and
  ## value.
  $self->SUPER::process_assignment($name, $value, $assign);

  ## Support keyword mapping here only at the project level scope. The
  ## scoped keyword mapping is done through the parse_scoped_assignment()
  ## method.
  if (!defined $assign || $assign == $self->get_assignment_hash()) {
    my $mapped = $self->{'valid_names'}->{$name};
    if (defined $mapped && UNIVERSAL::isa($mapped, 'ARRAY')) {
      $self->parse_scoped_assignment($$mapped[0], 0,
                                     $$mapped[1], $value,
                                     $self->{'generated_exts'}->{$$mapped[0]});
    }
  }
}


sub process_assignment_add {
  my($self, $name, $value, $assign) = @_;

  ## See if the name is one of the special "recursive" settings.  If so,
  ## fix up the value and change the name.
  ($name, $value) = $self->create_recursive_settings($name, $value, $assign);

  return $self->SUPER::process_assignment_add($name, $value, $assign);
}


sub process_assignment_sub {
  my($self, $name, $value, $assign) = @_;

  ## See if the name is one of the special "recursive" settings.  If so,
  ## fix up the value and change the name.
  ($name, $value) = $self->create_recursive_settings($name, $value, $assign);

  return $self->SUPER::process_assignment_sub($name, $value, $assign);
}


sub addition_core {
  my($self, $name, $value, $nval, $assign) = @_;

  ## If there is a previous value ($nval) and the keyword is going to be
  ## evaled, we need to separate the values with a command separator.
  ## This has to be done at the MPC level because it isn't always
  ## possible for the user to know if a value has already been added to
  ## the keyword (prebuild, postbuild and postclean).
  if (defined $nval &&
      defined $validNames{$name} && ($validNames{$name} & 4)) {
    if ($self->preserve_assignment_order($name)) {
      $value = '<%cmdsep%> ' . $value;
    }
    else {
      $value .= '<%cmdsep%>';
    }
  }

  ## For an addition, we need to see if it is a project keyword being
  ## used within a 'specific' section.  If it is, we may need to update
  ## scoped settings for that variable (which are in essence template
  ## variables).
  $self->convert_to_template_assignment($name, $value, 1);

  ## Next, we just give everything to the base class method.
  $self->SUPER::addition_core($name, $value, $nval, $assign);
}


sub subtraction_core {
  my($self, $name, $value, $nval, $assign) = @_;

  ## For a subtraction, we need to see if it is a project keyword being
  ## used within a 'specific' section.  If it is, we may need to update
  ## scoped settings for that variable (which are in essence template
  ## variables).
  $self->convert_to_template_assignment($name, $value, -1);

  ## Next, we just give everything to the base class method.
  $self->SUPER::subtraction_core($name, $value, $nval, $assign);
}


sub get_assignment_for_modification {
  my($self, $name, $assign, $subtraction) = @_;

  ## If we weren't passed an assignment hash, then we need to
  ## look one up that may possibly correctly deal with keyword mappings
  if (!defined $assign) {
    my $mapped = $self->{'valid_names'}->{$name};

    if (defined $mapped && UNIVERSAL::isa($mapped, 'ARRAY')) {
      $name   = $$mapped[1];
      $assign = $self->{'generated_exts'}->{$$mapped[0]};
    }
  }

  ## Get the assignment value
  my $value = $self->get_assignment($name, $assign);

  ## If we are involved in a subtraction, we get back a value and
  ## it's a scoped or mapped assignment, then we need to possibly
  ## expand any template variables.  Otherwise, the subtractions
  ## may not work correctly.
  if ($subtraction && defined $value && defined $assign) {
    $value = $self->relative($value, 1);
  }

  return $value;
}


sub begin_project {
  my($self, $parents) = @_;
  my $status = 1;
  my $error;

  ## Deal with the inheritance hierarchy first
  ## Add in the base projects from the command line
  if (!$self->{'reading_global'} &&
      !defined $self->{'reading_parent'}->[0]) {
    my $baseprojs = $self->get_baseprojs();

    if (defined $parents) {
      foreach my $base (@$baseprojs) {
        push(@$parents, $base) if (!StringProcessor::fgrep($base, $parents));
      }
    }
    else {
      $parents = $baseprojs;
    }
  }

  if (defined $parents) {
    foreach my $parent (@$parents) {
      ## Read in the parent onto ourself
      my $file = $self->search_include_path(
                          "$parent.$BaseClassExtension");
      if (!defined $file) {
        $file = $self->search_include_path(
                             "$parent.$ProjectCreatorExtension");
      }

      if (defined $file) {
        if (defined $self->{'reading_parent'}->[0]) {
          if (StringProcessor::fgrep($file, $self->{'reading_parent'})) {
            $status = 0;
            $error = 'Cyclic inheritance detected: ' . $parent;
          }
        }

        if ($status) {
          if (!defined $self->{'parents_read'}->{$file}) {
            $self->{'parents_read'}->{$file} = 1;

            ## Push the base project file onto the parent stack
            push(@{$self->{'reading_parent'}}, $file);

            ## Collect up some information about the inheritance tree
            my $tree = $self->{'current_input'};
            if (!defined $self->{'inheritance_tree'}->{$tree}) {
              $self->{'inheritance_tree'}->{$tree} = {};
            }
            my $hash = $self->{'inheritance_tree'}->{$tree};
            foreach my $p (@{$self->{'reading_parent'}}) {
              $$hash{$p} = {} if (!defined $$hash{$p});
              $hash = $$hash{$p};
            }

            ## Begin reading the parent
            $status = $self->parse_file($file);

            ## Take the base project file off of the parent stack
            pop(@{$self->{'reading_parent'}});

            $error = "Invalid parent: $parent" if (!$status);
          }
          else {
            ## The base project has already been read.  So, if
            ## we are reading the original project (not a parent base
            ## project), then the current base project is redundant.
            if (!defined $self->{'reading_parent'}->[0]) {
              $file =~ s/\.[^\.]+$//;
              $self->information('Inheriting from \'' .
                                 $self->mpc_basename($file) .
                                 '\' in ' . $self->{'current_input'} .
                                 ' is redundant at line ' .
                                 $self->get_line_number() . '.');
            }
          }
        }
      }
      else {
        $status = 0;
        $error = "Unable to locate parent: $parent";
      }
    }
  }

  ## Copy each value from global_assign into assign
  if (!$self->{'reading_global'}) {
    foreach my $key (keys %{$self->{'global_assign'}}) {
      if (!defined $self->{'assign'}->{$key}) {
        $self->{'assign'}->{$key} = $self->{'global_assign'}->{$key};
      }
    }
  }

  return $status, $error;
}


sub get_process_project_type {
  my($self, $types) = @_;
  my $type    = '';
  my $defcomp = $self->get_default_component_name();

  foreach my $t (split(/\s*,\s*/, $types)) {
    my $not = ($t =~ s/^!\s*//);
    if ($not) {
      if ($t eq $self->{'pctype'}) {
        $type = '';
        last;
      }
      else {
        $type = $self->{'pctype'};
      }
    }
    elsif ($t eq $self->{'pctype'} || $t eq $defcomp) {
      $type = $t;
      last;
    }
  }

  return $type;
}


sub matches_specific_scope {
  my($self, $elements) = @_;

  ## First check for properties that correspond to the current project
  ## type.  Elements that begin with "prop:" indicate a property.
  my $list = '';
  my $props = $self->get_properties();
  foreach my $prop (split(/\s*,\s*/, $elements)) {
    my $not = ($prop =~ s/^!\s*//);
    if ($prop =~/(.+):(.+)/) {
      if ($1 eq 'prop') {
        $prop = $2;
        if ($not) {
          return $self->{'pctype'} if (!$$props{$prop});
        }
        else {
          return $self->{'pctype'} if ($$props{$prop});
        }
      }
      else {
        $self->warning("$prop is not recognized.");
      }
    }
    else {
      $list .= ($not ? '!' : '') . $prop . ',';
    }
  }

  ## If none of the elements match a property, then check the type
  ## against the current project type or the default component name
  ## (which is what it would be set to if a specific clause is used with
  ## out parenthesis).
  my $type = $self->get_process_project_type($list);
  return $self->{'pctype'} if ($type eq $self->{'pctype'} ||
                               $type eq $self->get_default_component_name());

  ## Nothing matched
  return undef;
}


sub parse_line {
  my($self, $ih, $line) = @_;
  my($status,
     $errorString,
     @values) = $self->parse_known($line);

  ## parse_known() passes back an array of values
  ## that make up the contents of the line parsed.
  ## The array can have 0 to 3 items.  The first,
  ## if defined, is always an identifier of some
  ## sort.

  if ($status && defined $values[0]) {
    if ($values[0] eq $self->{'grammar_type'}) {
      my $name      = $values[1];
      my $typecheck = $self->{'type_check'};
      if (defined $name && $name eq '}') {
        ## Project Ending
        if (!defined $self->{'reading_parent'}->[0] &&
            !$self->{'reading_global'}) {
          ## Fill in all the default values
          $self->generate_defaults();

          ## Perform any additions, subtractions
          ## or overrides for the project values.
          my $addproj = $self->get_addproj();
          foreach my $ap (keys %$addproj) {
            if (defined $self->{'valid_names'}->{$ap}) {
              foreach my $val (@{$$addproj{$ap}}) {
                if ($$val[0] > 0) {
                  $self->process_assignment_add($ap, $$val[1]);
                }
                elsif ($$val[0] < 0) {
                  $self->process_assignment_sub($ap, $$val[1]);
                }
                else {
                  $self->process_assignment($ap, $$val[1]);
                }
              }
            }
            else {
              $errorString = 'Invalid ' .
                             "assignment modification name: $ap";
              $status = 0;
            }
          }

          if ($status) {
            ## Generate default target names after all source files are added
            ## and after we've added in all of the options from the
            ## command line.  If the user set exename on the command line
            ## and no "main" is found, sharedname will be set too and
            ## most templates do not handle that well.
            $self->generate_default_target_names();

            ## End of project; Write out the file.
            ($status, $errorString) = $self->write_project();

            ## write_project() can return 0 for error, 1 for project
            ## was written and 2 for project was skipped
            if ($status == 1) {
              ## Save the library name and location
              foreach my $name ('sharedname', 'staticname') {
                my $val = $self->get_assignment($name);
                if (defined $val) {
                  my $cwd    = $self->getcwd();
                  my $start  = $self->getstartdir();
                  my $amount = 0;
                  if ($cwd eq $start) {
                    $amount = length($start);
                  }
                  elsif (index($cwd, $start) == 0) {
                    $amount = length($start) + 1;
                  }
                  $self->{'lib_locations'}->{$val} =
                      substr($cwd, $amount);
                  last;
                }
              }

              ## Check for unused verbatim markers
              foreach my $key (keys %{$self->{'verbatim'}}) {
                if (defined $self->{'verbatim_accessed'}->{$key}) {
                  foreach my $ikey (keys %{$self->{'verbatim'}->{$key}}) {
                    if (!defined $self->{'verbatim_accessed'}->{$key}->{$ikey}) {
                      $self->warning("Marker $ikey does not exist.");
                    }
                  }
                }
              }
            }

            ## Reset all of the project specific data
            foreach my $key (keys %{$self->{'valid_components'}}) {
              delete $self->{$key};
              $self->{'defaulted'}->{$key} = 0;
            }
            if (defined $self->{'addtemp_state'}) {
              $self->restore_state($self->{'addtemp_state'}, 'addtemp');
              $self->{'addtemp_state'} = undef;
            }
            $self->{'assign'}                = {};
            $self->{'verbatim'}              = {};
            $self->{'verbatim_accessed'}     = {$self->{'pctype'} => {}};
            $self->{'special_supplied'}      = {};
            $self->{'flag_overrides'}        = {};
            $self->{'parents_read'}          = {};
            $self->{'inheritance_tree'}      = {};
            $self->{'remove_files'}          = {};
            $self->{'custom_special_output'} = {};
            $self->{'custom_special_depend'} = {};
            $self->{'expanded'}              = {};
            $self->reset_generating_types();
          }
        }
        $self->{$typecheck} = 0;
      }
      else {
        ## Project Beginning
        ($status, $errorString) = $self->begin_project($values[2]);

        ## Set up the default project name
        if ($status) {
          if (defined $name) {
            if ($name =~ /[\/\\]/) {
              $status = 0;
              $errorString = 'Projects can not have a slash ' .
                             'or a back slash in the name';
            }
            else {
              ## We should only set the project name if we are not
              ## reading in a parent project.
              if (!defined $self->{'reading_parent'}->[0]) {
                $name =~ s/^\(\s*//;
                $name =~ s/\s*\)$//;
                $name = $self->transform_file_name($name);

                ## Replace any *'s with the default name
                if (index($name, '*') >= 0) {
                  $name = $self->fill_type_name(
                                    $name,
                                    $self->get_default_project_name());
                }

                $self->set_project_name($name);
              }
              else {
                $self->warning("Ignoring project name " .
                               "$name in a base project.");
              }
            }
          }
        }

        ## Signify that we have a valid project
        $self->{$typecheck} = 1 if ($status);
      }
    }
    elsif ($values[0] eq '0') {
      ## $values[1] = name; $values[2] = value
      if (defined $self->{'valid_names'}->{$values[1]}) {
        $self->process_assignment($values[1], $values[2]);
      }
      else {
        $errorString = "Invalid assignment name: '$values[1]'";
        $status = 0;
      }
    }
    elsif ($values[0] eq '1') {
      ## $values[1] = name; $values[2] = value
      if (defined $self->{'valid_names'}->{$values[1]}) {
        $self->process_assignment_add($values[1], $values[2]);
      }
      else {
        $errorString = "Invalid addition name: $values[1]";
        $status = 0;
      }
    }
    elsif ($values[0] eq '-1') {
      ## $values[1] = name; $values[2] = value
      if (defined $self->{'valid_names'}->{$values[1]}) {
        $self->process_assignment_sub($values[1], $values[2]);
      }
      else {
        $errorString = "Invalid subtraction name: $values[1]";
        $status = 0;
      }
    }
    elsif ($values[0] eq 'component') {
      my $comp = $values[1];
      my $name = $values[2];
      my $vc   = $self->{'valid_components'};

      if (defined $$vc{$comp}) {
        ($status, $errorString) = $self->parse_components($ih, $comp, $name);
      }
      else {
        if ($comp eq 'verbatim') {
          my($type, $loc, $add) = split(/\s*,\s*/, $name);
          ($status, $errorString) = $self->parse_verbatim($ih, $type,
                                                          $loc, $add);
        }
        elsif ($comp eq 'specific') {
          my $type = $self->matches_specific_scope($name);
          if (defined $type) {
            ($status, $errorString) = $self->parse_scope(
                                        $ih, $comp, $type,
                                        $self->{'valid_names'},
                                        $self->get_assignment_hash(),
                                        {});
          }
          else {
            ## We still need to parse the scope, but we will be
            ## throwing away whatever is processed.  However, it
            ## could still be invalid code that will cause an error.
            ($status, $errorString) = $self->parse_scope(
                                        $ih, $comp, undef,
                                        $self->{'valid_names'},
                                        undef,
                                        $self->get_assignment_hash());
          }
        }
        elsif ($comp eq 'define_custom') {
          ($status, $errorString) = $self->parse_define_custom($ih, $name);
        }
        elsif ($comp eq 'modify_custom') {
          ($status, $errorString) = $self->parse_define_custom($ih, $name, 1);
        }
        elsif ($comp eq 'expand') {
          $self->{'parsing_expand'} = 1;
          ($status, $errorString) = $self->parse_scope($ih, $comp, $name);
          $self->{'parsing_expand'} = undef;
        }
        else {
          $errorString = "Invalid component name: $comp";
          $status = 0;
        }
      }
    }
    elsif ($values[0] eq 'feature') {
      $self->{'feature_defined'} = 1;
      ($status, $errorString) = $self->process_feature($ih,
                                                       $values[1],
                                                       $values[2]);
      if ($status && $self->{'feature_defined'}) {
        $errorString = "Did not find the end of the feature";
        $status = 0;
      }
    }
    else {
      $errorString = "Unrecognized line: $line";
      $status = 0;
    }
  }
  elsif ($status == -1) {
    $status = 0;
  }

  return $status, $errorString;
}


sub parse_scoped_assignment {
  my($self, $tag, $type, $name, $value, $flags) = @_;

  ## Map the assignment name on a scoped assignment
  my $mapped = $self->{'valid_names'}->{$name};
  if (defined $mapped && UNIVERSAL::isa($mapped, 'ARRAY')) {
    $name = $$mapped[1];
  }

  if (defined $self->{'matching_assignments'}->{$tag} &&
      StringProcessor::fgrep($name, $self->{'matching_assignments'}->{$tag})) {
    my $over = {};
    if (defined $self->{'flag_overrides'}->{$tag}) {
      $over = $self->{'flag_overrides'}->{$tag};
    }
    else {
      $self->{'flag_overrides'}->{$tag} = $over;
    }

    if ($type == 0) {
      $self->process_assignment($name, $value, $flags);
    }
    elsif ($type == 1) {
      ## If there is no value in $$flags, then we need to get
      ## the outer scope value and put it in there.
      if (!defined $self->get_assignment($name, $flags)) {
        my $outer = $self->get_assignment($name);
        $self->process_assignment($name, $outer, $flags);
      }
      $self->process_assignment_add($name, $value, $flags);
    }
    elsif ($type == -1) {
      ## If there is no value in $$flags, then we need to get
      ## the outer scope value and put it in there.
      if (!defined $self->get_assignment($name, $flags)) {
        my $outer = $self->get_assignment($name);
        $self->process_assignment($name, $outer, $flags);
      }
      $self->process_assignment_sub($name, $value, $flags);
    }
    return 1;
  }

  return 0;
}


sub update_template_variable {
  my $self   = shift;
  my $check  = shift;
  my @values = @_;

  ## Save the addtemp state if we haven't done so before
  if (!defined $self->{'addtemp_state'}) {
    my %state = $self->save_state('addtemp');
    $self->{'addtemp_state'} = \%state;
  }

  ## If the name that is used within a specific is a mapped keyword
  ## then we need to translate it into the mapped keyword as it will
  ## be used by the TemplateParser.
  my $name;
  if ($values[1] =~ /(.*::)(.*)/) {
    my $base   = $1;
    my $mapped = $self->{'valid_names'}->{$2};
    if (defined $mapped && UNIVERSAL::isa($mapped, 'ARRAY')) {
      $name = $values[1];
      $values[1] = $base . 'custom_type->' . $$mapped[1];
    }
  }

  ## Now modify the addtemp values
  my $atemp = $self->get_addtemp();
  $self->information("'$values[1]' was used as a template modifier.");

  if ($check && !defined $atemp->{$values[1]}) {
    $name = $values[1] if (!defined $name);
    if ($name =~ s/.*:://) {
      my $value = $self->get_assignment($name);
      ## Regardless of whether there was and assignment value, we need to
      ## look at the template value of the base so that modification of a
      ## scoped variable includes the base values.
      if (defined $atemp->{$name}) {
        foreach my $arr (@{$atemp->{$name}}) {
          my @copy = @$arr;
          push(@{$atemp->{$values[1]}}, \@copy);
        }
      }
      unshift(@{$atemp->{$values[1]}},
              [0, $value, undef, $name]) if (defined $value);
    }
  }

  ## Subsitute all pseudo variables for the project specific characters.
  $values[2] = $self->replace_parameters($values[2], $self->{'command_subs'})
                 if (index($values[2], '<%') >= 0);

  if (defined $atemp->{$values[1]}) {
    ## If there are template variable settings, then we need to add
    ## this new one to the end of the settings that did not come from
    ## the command line.  That way, adjust_value() does not need to
    ## sort the values (and have knowledge about which came from the
    ## command line and which didn't).
    my $max = scalar(@{$atemp->{$values[1]}});
    for(my $i = 0; $i < $max; $i++) {
      if ($atemp->{$values[1]}->[$i]->[2]) {
        splice(@{$atemp->{$values[1]}}, $i, 0,
               [$values[0], $values[2], undef, $name]);
        return;
      }
    }
  }
  else {
    $atemp->{$values[1]} = [];
  }

  ## If the variable name is not scoped, we need to look through existing
  ## scoped variables that match the base.  If we find one, we need to
  ## propagate this value into the scoped settings.
  if (index($values[1], '::') == -1) {
    $name = $values[1] if (!defined $name);
    foreach my $key (keys %$atemp) {
      if ($key ne $name) {
        foreach my $entry (@{$atemp->{$key}}) {
          if ($$entry[3] eq $name) {
            push(@{$atemp->{$key}}, [$values[0], $values[2], undef, $name]);
            last;
          }
        }
      }
    }
  }

  ## 0: (0 set, 1 add, -1 subtract)
  ## 1: The text value
  ## 2: (true set on command line, false set in project)
  ## 3: The original variable name if it's scoped or mapped
  push(@{$atemp->{$values[1]}}, [$values[0], $values[2], undef, $name]);
}


sub handle_unknown_assignment {
  my $self   = shift;
  my $type   = shift;
  my @values = @_;

  ## Unknown assignments within a 'specific' section are handled as
  ## template value modifications.  These are handled exactly as the
  ## -value_template option in Options.pm.

  ## If $type is not defined, then we are skipping this section
  $self->update_template_variable(1, @values) if (defined $type);

  return 1, undef;
}


sub handle_scoped_unknown {
  my($self, $fh, $type, $flags, $line) = @_;

  if (defined $type && $self->{'parsing_expand'}) {
    if ($type eq $self->get_default_component_name()) {
      return 0, 'Can not set expansion in this context';
    }
    else {
      if (!defined $self->{'expanded'}->{$type}) {
        my $undef = $self->replace_env_vars(\$line);
        if (!$undef) {
          ## This is a special concession for Windows.  It will not allow
          ## you to set an empty environment variable.  If an empty
          ## double quoted string is found, we will assume that the user
          ## wanted an empty string.
          $line = '' if ($line eq '""');

          $self->{'expanded'}->{$type} = $line;
        }
      }
      return 1, undef;
    }
  }

  ## If the type is not defined, then this is something other than an
  ## assignment in a 'specific' section and should be flagged as an error
  return 0, "Unrecognized line: $line";
}

sub process_component_line {
  my($self, $tag, $line, $flags,
     $grname, $current, $excarr, $comps, $count) = @_;
  my $status = 1;
  my $error;
  my %exclude;
  my @values;

  ## If this returns true, then we've found an assignment
  if ($self->parse_assignment($line, \@values)) {
    $status = $self->parse_scoped_assignment($tag, @values, $flags);
    if (!$status) {
      $error = 'Unknown keyword: ' . $values[1];
    }
  }
  else {
    ## If we successfully remove a '!' from the front, then
    ## the file(s) listed are to be excluded
    my $rem = ($line =~ s/^\^\s*//);
    my $exc = $rem || ($line =~ s/^!\s*//);

    ## Convert any $(...) in this line before we process any
    ## wild card characters.  If we do not, scoped assignments will
    ## not work nor will we get the correct wild carded file list.
    ## We also need to make sure that any back slashes are converted to
    ## slashes to ensure that later flag_overrides checks will happen
    ## correctly.
    $line = $self->relative($line);
    $line =~ s/\\/\//g if ($self->{'convert_slashes'});

    ## Now look for specially listed files.
    ## Regular expressions are very slow.  Searching the line twice with
    ## index() is 328 times faster than searching with just the regular
    ## expression when it doesn't match (which is likely to be the case).
    if ((index($line, '>>') >= 0 || index($line, '<<') >= 0) &&
        $line =~ /(.*)\s+(>>|<<)\s+(.*)/) {
      $line   = $1;
      my $oop = $2;
      my $iop = ($oop eq '>>' ? '<<' : '>>');
      my $out = ($oop eq '>>' ? $3 : undef);
      my $dep = ($oop eq '<<' ? $3 : undef);

      $line =~ s/\s+$//;
      if (index($line, $iop) >= 0 && $line =~ /(.*)\s+$iop\s+(.*)/) {
        $line = $1;
        $out  = $2 if ($iop eq '>>');
        $dep  = $2 if ($iop eq '<<');
        $line =~ s/\s+$//;
      }

      ## Check for both possible error conditions
      if (index($line, $oop) >= 0) {
        $status = 0;
        $error  = "Duplicate $oop used";
      }
      elsif (index($line, $iop) >= 0) {
        $status = 0;
        $error  = "Duplicate $iop used";
      }

      ## Keys used internally to MPC need to be in forward slash format.
      my $key = $line;
      $key =~ s/\\/\//g if ($self->{'convert_slashes'});
      if (defined $out) {
        if (!defined $self->{'custom_special_output'}->{$tag}) {
          $self->{'custom_special_output'}->{$tag} = {};
        }
        ## We can not convert slashes here as we do for dependencies
        ## (below).  The files specified here need to retain the forward
        ## slashes as they are used elsewhere.
        $self->{'custom_special_output'}->{$tag}->{$key} = $self->create_array($out);
      }
      if (defined $dep) {
        $self->{'custom_special_depend'}->{$key} = $self->create_array($dep);
        if ($self->{'convert_slashes'}) {
          foreach my $depfile (@{$self->{'custom_special_depend'}->{$key}}) {
            $depfile =~ s/\//\\/g;
          }
        }
      }
    }

    ## If there is a command helper, we need to add the output files
    ## here.  It is possible that helper determined output files are
    ## the only files added by this component type.
    my $cmdHelper = CommandHelper::get($tag);
    if (defined $cmdHelper) {
      my $key = $line;
      $key =~ s/\\/\//g if ($self->{'convert_slashes'});
      my $cmdflags = $$flags{'commandflags'};
      my $add_out = $cmdHelper->get_output($key, $cmdflags);
      push(@{$self->{'custom_special_output'}->{$tag}->{$key}}, @$add_out);
    }

    ## Set up the files array.  If the line contains a wild card
    ## character use CORE::glob() to get the files specified.
    my @files;
    if ($line =~ /^"([^"]+)"$/) {
      push(@files, $1);
    }
    ## Don't glob the line if we're wanting to remove the file.  Wait
    ## until later to do the wildcard expansion (in remove_excluded).
    elsif (!$rem && $line =~ /[\?\*\[\]]/) {
      @files = $self->mpc_glob($line);
    }
    else {
      push(@files, $line);
    }

    ## If we want to remove these files at the end too, then
    ## add them to our remove_files hash array.
    if ($rem) {
      if (!defined $self->{'remove_files'}->{$tag}) {
        $self->{'remove_files'}->{$tag} = {};
      }
      foreach my $file (@files) {
        $self->{'remove_files'}->{$tag}->{$file} = 1;
      }
    }

    ## If we're excluding these files, then put them in the hash
    if ($exc) {
      $$grname = $current;
      @exclude{@files} = (@files);
      push(@$excarr, @files);
    }
    else {
      ## Set the flag overrides for each file
      my $over = $self->{'flag_overrides'}->{$tag};
      if (defined $over) {
        foreach my $file (@files) {
          $$over{$file} = $flags;
        }
      }

      foreach my $file (@files) {
        ## Add the file if we're not excluding it
        push(@{$$comps{$current}}, $file) if (!defined $exclude{$file});

        ## The user listed a file explicitly, whether we
        ## excluded it or not.
        ++$$count;
      }
    }
  }

  return $status, $error;
}


sub parse_conditional {
  my($self, $fh, $types, $tag, $flags,
     $grname, $current, $exclude, $comps, $count) = @_;
  my $status = 1;
  my $error;
  my $type = $self->matches_specific_scope($types);
  my $add = (defined $type ? 1 : 0);

  while(<$fh>) {
    my $line = $self->preprocess_line($fh, $_);

    if ($line eq '') {
    }
    elsif ($line =~ /^}\s*else\s*{$/) {
      $add ^= 1;
    }
    elsif ($line =~ /^}$/) {
      last;
    }
    elsif ($add) {
      ($status, $error) = $self->process_component_line(
                                              $tag, $line, $flags,
                                              $grname, $current,
                                              $exclude, $comps, $count);
      last if (!$status);
    }
  }

  return $status, $error;
}

sub parse_components {
  my($self, $fh, $tag, $name) = @_;
  my $current = $defgroup;
  my $status = 1;
  my $error;
  my $names = {};
  my $comps = {};
  my $set;
  my %flags;
  my @exclude;
  my $custom = defined $self->{'generated_exts'}->{$tag};
  my $grtag = $grouped_key . $tag;
  my $grname;

  if ($custom) {
    ## For the custom scoped assignments, we want to put a copy of
    ## the original custom defined values in our flags associative array.
    foreach my $key (keys %custom) {
      if (defined $self->{'generated_exts'}->{$tag}->{$key}) {
        $flags{$key} = $self->{'generated_exts'}->{$tag}->{$key};
      }
    }
  }

  if (defined $self->{$tag}) {
    $names = $self->{$tag};
  }
  else {
    $self->{$tag} = $names;
  }
  if (defined $$names{$name}) {
    $comps = $$names{$name};
  }
  else {
    $$names{$name} = $comps;
  }
  $$comps{$current} = [] if (!defined $$comps{$current});

  my $count = 0;
  while(<$fh>) {
    my $line = $self->preprocess_line($fh, $_);

    if ($line eq '') {
    }
    elsif ($line =~ /^(\w+)\s*{$/) {
      if (!$set) {
        $current = $1;
        $set = 1;
        $$comps{$current} = [] if (!defined $$comps{$current});
      }
      else {
        $status = 0;
        $error  = 'Can not nest groups';
        last;
      }
    }
    elsif ($line =~ /^conditional\s*(\(([^\)]+)\))\s*{$/) {
      ($status, $error) = $self->parse_conditional(
                                         $fh, $2, $tag, \%flags, \$grname,
                                         $current, \@exclude, $comps,
                                         \$count);
      last if (!$status);
    }
    elsif ($line =~ /^}$/) {
      if (!defined $$comps{$current}->[0] && !defined $exclude[0]) {
        ## The default components name was never used
        ## so we remove it from the components
        delete $$comps{$current};
      }
      else {
        ## It was used, so we need to add that name to
        ## the set of group names unless it's already been added.
        $self->process_assignment_add($grtag, $current);
      }
      if ($set) {
        $current = $defgroup;
        $set = undef;
      }
      else {
        ## We are at the end of a component.  If the only group
        ## we added was the default group, then we need to remove
        ## the group setting altogether.
        my $groups = $self->get_assignment($grtag);
        if (defined $groups) {
          my $grarray = $self->create_array($groups);
          if (scalar(@$grarray) == 1 && $$grarray[0] eq $defgroup) {
            $self->process_assignment($grtag, undef);
          }
        }

        ## This is not an error,
        ## this is the end of the components
        last;
      }
    }
    else {
      ($status, $error) = $self->process_component_line($tag, $line, \%flags,
                                                        \$grname, $current,
                                                        \@exclude, $comps,
                                                        \$count);
      last if (!$status);
    }
  }

  ## If this is a "special" component, we need to see if the
  ## user provided all directories.  If they have, then we need to
  ## store an array of directories that the user supplied.  Otherwise,
  ## we just store a 1.
  if (defined $specialComponents{$tag}) {
    my @dirs;
    foreach my $name (keys %$names) {
      my $comps = $$names{$name};
      foreach my $comp (keys %$comps) {
        foreach my $item (@{$$comps{$comp}}) {
          if (-d $item) {
            push(@dirs, $item);
          }
          else {
            @dirs = ();
            last;
          }
        }
      }
    }
    if (defined $dirs[0]) {
      $self->{'special_supplied'}->{$tag} = \@dirs;
    }
    else {
      $self->{'special_supplied'}->{$tag} = 1;
    }
  }

  ## If we didn't encounter an error, didn't have any files explicitly
  ## listed and we attempted to exclude files, then we need to find the
  ## set of files that don't match the excluded files and add them.
  if ($status && defined $exclude[0] && defined $grname) {
    my $alldir = $self->get_assignment('recurse') || $flags{'recurse'};
    my %checked;
    my @files;
    foreach my $exc (@exclude) {
      my $dname = $self->mpc_dirname($exc);
      if (!defined $checked{$dname}) {
        $checked{$dname} = 1;
        push(@files, $self->generate_default_file_list($dname,
                                                       \@exclude,
                                                       undef, $alldir));
      }
    }

    $self->sift_files(\@files,
                      $self->{'valid_components'}->{$tag},
                      $self->get_assignment('pch_header'),
                      $self->get_assignment('pch_source'),
                      $tag,
                      $$comps{$grname});
  }

  return $status, $error;
}


sub parse_verbatim {
  my($self, $fh, $type, $loc, $add) = @_;

  if (!defined $loc) {
    return 0, 'You must provide a location parameter to verbatim';
  }

  ## All types are lower case
  $type = lc($type);

  if (!defined $self->{'verbatim'}->{$type}) {
    $self->{'verbatim'}->{$type} = {};
  }

  ## Instead of always creating a new array for a particular type and
  ## location, create a new array if there isn't one already or the user
  ## does not want to add to the existing verbatim settings.
  $self->{'verbatim'}->{$type}->{$loc} = []
          if (!$add || !defined $self->{'verbatim'}->{$type}->{$loc});
  my $array = $self->{'verbatim'}->{$type}->{$loc};

  while(<$fh>) {
    my $line = $self->preprocess_line($fh, $_);

    ## This is not an error,
    ## this is the end of the verbatim
    last if ($line =~ /^}$/);
    push(@$array, $line);
  }

  return 1, undef;
}


sub process_feature {
  my($self, $fh, $names, $parents) = @_;
  my $status = 1;
  my $error;

  my $requires = '';
  my $avoids   = '';
  foreach my $name (@$names) {
    if ($name =~ /^!\s*(.*)$/) {
      $avoids .= ' ' if ($avoids ne '');
      $avoids .= $1;
    }
    else {
      $requires .= ' ' if ($requires ne '');
      $requires .= $name;
    }
  }

  if ($self->check_features($requires, $avoids)) {
    ## The required features are enabled, so we say that
    ## a project has been defined and we allow the parser to
    ## find the data held within the feature.
    ($status, $error) = $self->begin_project($parents);
    if ($status) {
      $self->{'feature_defined'} = 0;
      $self->{$self->{'type_check'}} = 1;
    }
  }
  else {
    ## Otherwise, we read in all the lines until we find the
    ## closing brace for the feature and it appears to the parser
    ## that nothing was defined.
    my $curly = 1;
    while(<$fh>) {
      my $line = $self->preprocess_line($fh, $_);

      ## This is a very simplistic way of finding the end of
      ## the feature definition.  It will work as long as no spurious
      ## open curly braces are counted.
      ++$curly if ($line =~ /{$/);
      --$curly if ($line =~ /^}/);

      if ($curly == 0) {
        $self->{'feature_defined'} = 0;
        last;
      }
    }
  }

  return $status, $error;
}


sub process_array_assignment {
  my($self, $aref, $type, $array) = @_;

  if (!defined $$aref || $type == 0) {
    if ($type != -1) {
      $$aref = $array;
    }
  }
  else {
    if ($type == 1) {
      push(@{$$aref}, @$array);
    }
    elsif ($type == -1) {
      my $count = scalar(@{$$aref});
      for(my $i = 0; $i < $count; ++$i) {
        if (StringProcessor::fgrep($$aref->[$i], $array)) {
          splice(@{$$aref}, $i, 1);
          --$i;
          --$count;
        }
      }
    }
  }
}


sub parse_define_custom {
  my($self, $fh, $tag, $modify) = @_;

  ## Make the tag something _files
  $tag = lc($tag) . '_files';

  ## We can not have a custom type named "generic"
  return 0, "$tag is reserved" if ($tag eq $generic_key);

  if (defined $self->{'valid_components'}->{$tag}) {
    if (!$modify) {
      return 0, "$tag has already been defined";
    }
  }
  elsif ($modify) {
    return 0, "$tag has not yet been defined and can not be modified";
  }

  my $status      = 0;
  my $errorString = "Unable to process $tag";

  ## Update the custom_types assignment
  $self->process_assignment_add('custom_types', $tag) if (!$modify);

  if (!defined $self->{'matching_assignments'}->{$tag}) {
    my @keys = keys %custom;
    push(@keys, @default_matching_assignments);
    $self->{'matching_assignments'}->{$tag} = \@keys;
  }

  my $optname;
  my $inscope = 0;
  while(<$fh>) {
    my $line = $self->preprocess_line($fh, $_);

    if ($line eq '') {
    }
    elsif ($line =~ /optional\s*\(([^\)]+)\)\s*{/) {
      $optname = $1;
      $optname =~ s/^\s+//;
      $optname =~ s/\s+$//;
      if (defined $customDefined{$optname} &&
          ($customDefined{$optname} & 0x08) != 0) {
        ++$inscope;
        if ($inscope != 1) {
          $status = 0;
          $errorString = 'Can not nest \'optional\' sections';
          last;
        }
      }
      else {
        $status = 0;
        $errorString = "Invalid optional name: $optname";
        last;
      }
    }
    elsif ($inscope) {
      if ($line =~ /^}$/) {
        $optname = undef;
        --$inscope;
      }
      else {
        if ($line =~ /(\w+)\s*\(([^\)]+)\)\s*(\+)?=\s*(.*)/) {
          my $name = lc($1);
          my $opt  = $2;
          my $add  = $3;
          my @val  = split(/\s*,\s*/, $4);

          ## Fix $opt spacing
          $opt =~ s/(\&\&|\|\|)/ $1 /g;
          $opt =~ s/!\s+/!/g;

          ## Set up the 'optional' hash table
          if (!$add || !defined $self->{'generated_exts'}->{$tag}->
                              {'optional'}->{$optname}->{$name}->{$opt}) {
            $self->{'generated_exts'}->{$tag}->
                   {'optional'}->{$optname}->{$name}->{$opt} = \@val;
          }
          else {
            push(@{$self->{'generated_exts'}->{$tag}->{'optional'}->
                    {$optname}->{$name}->{$opt}}, @val);
          }
        }
        else {
          $status = 0;
          $errorString = "Unrecognized optional line: $line";
          last;
        }
      }
    }
    elsif ($line =~ /^}$/) {
      $status = 1;
      $errorString = undef;

      ## Propagate the custom defined values into the mapped values
      foreach my $key (keys %{$self->{'valid_names'}}) {
        if (UNIVERSAL::isa($self->{'valid_names'}->{$key}, 'ARRAY')) {
          my $value = $self->{'generated_exts'}->{$tag}->{
                                $self->{'valid_names'}->{$key}->[1]};

          ## Bypass the process_assignment() defined in this class
          ## to avoid unwanted keyword mapping.
          $self->SUPER::process_assignment($key, $value) if (defined $value);
        }
      }

      ## Set some defaults (if they haven't already been set)
      if (!defined $self->{'generated_exts'}->{$tag}->{'pre_filename'}) {
        $self->{'generated_exts'}->{$tag}->{'pre_filename'} = [ '' ];
      }
      if (!defined $self->{'generated_exts'}->{$tag}->{'pre_dirname'}) {
        $self->{'generated_exts'}->{$tag}->{'pre_dirname'} = [ '' ];
      }
      if (!defined $self->{'generated_exts'}->{$tag}->{'pre_extension'}) {
        $self->{'generated_exts'}->{$tag}->{'pre_extension'} = [ '' ];
      }
      if (!defined $self->{'generated_exts'}->{$tag}->{'automatic_in'}) {
        $self->{'generated_exts'}->{$tag}->{'automatic_in'} = 1;
      }
      if (!defined $self->{'generated_exts'}->{$tag}->{'automatic_out'}) {
        $self->{'generated_exts'}->{$tag}->{'automatic_out'} = 1;
      }
      if (!defined $self->{'generated_exts'}->{$tag}->{'output_follows_input'}) {
        $self->{'generated_exts'}->{$tag}->{'output_follows_input'} = 1;
      }
      if (!defined $self->{'valid_components'}->{$tag}) {
        $self->{'valid_components'}->{$tag} = [];
      }
      last;
    }
    else {
      my @values;
      ## If this returns true, then we've found an assignment
      if ($self->parse_assignment($line, \@values)) {
        my($type, $name, $value) = @values;
        ## The 'automatic' keyword has always contained two distinct
        ## functions.  The first is to automatically add input files of
        ## the specified extension.  And the second is to automatically
        ## add generated files to the right components.  It has now been
        ## split into separate functionality and we map the 'automatic'
        ## keyword to the two new ones here.
        my $ok = 1;
        my @names = $name eq 'automatic' ?
                        ('automatic_in', 'automatic_out') : $name;
        foreach $name (@names) {
          if (defined $customDefined{$name}) {
            if (($customDefined{$name} & 0x01) != 0) {
              $value = $self->escape_regex_special($value);
              my @array = split(/\s*,\s*/, $value);
              $self->process_array_assignment(
                        \$self->{'valid_components'}->{$tag}, $type, \@array);
            }
            else {
              if (!defined $self->{'generated_exts'}->{$tag}) {
                $self->{'generated_exts'}->{$tag} = {};
              }
              ## Try to convert the value into a relative path
              $value = $self->relative($value);

              if (($customDefined{$name} & 0x04) != 0) {
                if ($type == 0) {
                  $self->process_assignment(
                                     $name, $value,
                                     $self->{'generated_exts'}->{$tag});
                }
                elsif ($type == 1) {
                  $self->process_assignment_add(
                                     $name, $value,
                                     $self->{'generated_exts'}->{$tag});
                }
                elsif ($type == -1) {
                  $self->process_assignment_sub(
                                     $name, $value,
                                     $self->{'generated_exts'}->{$tag});
                }
              }
              else {
                if (($customDefined{$name} & 0x02) != 0) {
                  ## Transform the name from something outputext to
                  ## something files.  We expect this to match the
                  ## names of valid_assignments.
                  $name =~ s/outputext/files/g;
                }

                ## Get it ready for regular expressions
                $value = $self->escape_regex_special($value);

                ## Split the value into an array using a comma as the
                ## separator.  If there are no elements in the array we're
                ## going to add an empty element to the array.  This way,
                ## assignments of blank values are useful.
                my @array = split(/\s*,\s*/, $value);
                push(@array, '') if ($#array == -1);

                ## Process the array assignment after adjusting the values
                $self->process_array_assignment(
                            \$self->{'generated_exts'}->{$tag}->{$name},
                            $type, \@array);
              }
            }
          }
          else {
            $ok = 0;
            $status = 0;
            $errorString = "Invalid assignment name: '$name'";
            last;
          }
        }

        ## $status is zero until the end of the define custom block, so
        ## we can't use it for this check.
        last if (!$ok);
      }
      elsif ($line =~ /^keyword\s+(\w+)(?:\s*=\s*(\w+)?)?/) {
        ## Check for keyword mapping here
        my $newkey = $1;
        my $mapkey = $2;
        if (defined $self->{'valid_names'}->{$newkey}) {
          $status = 0;
          $errorString = "Cannot map $newkey onto an " .
                         "existing keyword";
          last;
        }
        elsif (!defined $mapkey) {
          $self->{'valid_names'}->{$newkey} = 1;
        }
        elsif ($newkey ne $mapkey) {
          if (defined $customDefined{$mapkey}) {
            $self->{'valid_names'}->{$newkey} = [ $tag, $mapkey ];
          }
          else {
            $status = 0;
            $errorString = "Cannot map $newkey to an " .
                           "undefined custom keyword: $mapkey";
            last;
          }
        }
        else {
          $status = 0;
          $errorString = "Cannot map $newkey to $mapkey";
          last;
        }
      }
      else {
        $status = 0;
        $errorString = "Unrecognized line: $line";
        last;
      }
    }
  }

  return $status, $errorString;
}


sub back_to_variable {
  my($self, $values) = @_;
  my $cwd = $self->getcwd();
  my $case_tolerant = $self->case_insensitive();
  my @values = ();

  ## Get both of the relative value hash maps and put them in an array
  my @rels = ();
  my($rel, $how) = $self->get_initial_relative_values();
  push(@rels, $rel);
  ($rel, $how) = $self->get_secondary_relative_values();
  push(@rels, $rel);

  ## Go through each value and try to convert it to a variable setting
  foreach my $ovalue (@$values) {
    ## Fix up the value, replacing '.' with the current working
    ## directory.
    my $value = $ovalue;
    $value =~ s/\\/\//g;
    if ($value eq '.') {
      $value = $cwd;
    }
    else {
      $value =~ s/^.\//$cwd\//;
    }
    my $valuelen = length($value);

    ## Go through each relative value hash map and see if any of the
    ## values match the value that we're currently inspecting.
    my $found = undef;
    foreach my $rel (@rels) {
      foreach my $key (keys %$rel) {
        ## Get the relative replacement value and convert back-slashes
        my $val = $$rel{$key};
        $val =~ s/\\/\//g;

        ## We only need to check for reverse replacement if the length
        ## of the value is greater than or equal to the length of our
        ## replacement value.
        my $vlen = length($val);
        if ($valuelen >= $vlen) {
          ## Cut the string down by the length of the replacement value
          my $lval = substr($value, 0, $vlen);

          ## Check for equivalence, taking into account file system
          ## case-insenitivity.
          if ($case_tolerant) {
            $found = (lc($lval) eq lc($val));
          }
          else {
            $found = ($lval eq $val);
          }

          ## If they match, replace the value and save it in our array.
          if ($found) {
            substr($value, 0, length($val)) = "\$($key)";
            push(@values, $value);
            last;
          }
        }
      }

      ## Once it's been found, there's no reason to continue on through
      ## the relative hash maps.
      last if ($found);
    }

    push(@values, $ovalue) if (!$found);
  }

  return @values;
}


sub remove_duplicate_addition {
  my($self, $name, $value, $nval) = @_;

  if (defined $nval) {
    ## If we are modifying the libs, libpaths, macros or includes
    ## assignment with either addition or subtraction, we are going to
    ## perform a little fix on the value to avoid multiple
    ## libraries and to try to insure the correct linking order
    if ($name eq 'macros' || $name eq 'libpaths' ||
        $name eq 'includes' || $name =~ /libs$/ ||
        index($name, $grouped_key) == 0) {
      my $allowed = '';
      my %parts;

      ## Convert the array into keys for a hash table
      @parts{@{$self->create_array($nval)}} = ();

      ## In order to ensure that duplicates are correctly removed, we
      ## need to get the modified assignment value before we attempt to
      ## do so.
      $value = $self->modify_assignment_value($name, $value);
      foreach my $val (@{$self->create_array($value)}) {
        if (!exists $parts{$val}) {
          ## We need to supply quotes if there is a space in the value or
          ## a variable.  The variable may contain spaces.
          my $qt = ($val =~ /\s/ || $val =~ /\$\(.+\)/ ? '"' : '');
          $allowed .= $qt . $val . $qt . ' ';
        }
      }
      $allowed =~ s/\s+$//;
      return $allowed;
    }
  }

  return $value;
}


sub read_template_input {
  my($self, $tkey) = @_;
  my $status = 1;
  my $errorString;
  my $file;
  my $tag;
  my $ti = $self->get_ti_override();
  my $lang = $self->get_language();
  my $override;

  if ($self->exe_target()) {
    if ($self->get_static() == 1) {
      $tag = 'lib_exe_template_input';
      ## Check for the TemplateInputReader for the template key provided.
      if (!defined $self->{$tag}->{$lang}->{$tkey}) {
        if (defined $$ti{'lib_exe'}) {
          $file = $$ti{'lib_exe'};
          $override = 1;
        }
        else {
          $file = $self->get_lib_exe_template_input_file($tkey);
        }
      }
    }
    else {
      $tag = 'dll_exe_template_input';
      ## Check for the TemplateInputReader for the template key provided.
      if (!defined $self->{$tag}->{$lang}->{$tkey}) {
        if (defined $$ti{'dll_exe'}) {
          $file = $$ti{'dll_exe'};
          $override = 1;
        }
        else {
          $file = $self->get_dll_exe_template_input_file($tkey);
        }
      }
    }
  }
  else {
    if ($self->get_static() == 1) {
      $tag = 'lib_template_input';
      ## Check for the TemplateInputReader for the template key provided.
      if (!defined $self->{$tag}->{$lang}->{$tkey}) {
        if (defined $$ti{'lib'}) {
          $file = $$ti{'lib'};
          $override = 1;
        }
        else {
          $file = $self->get_lib_template_input_file($tkey);
        }
      }
    }
    else {
      $tag = 'dll_template_input';
      ## Check for the TemplateInputReader for the template key provided.
      if (!defined $self->{$tag}->{$lang}->{$tkey}) {
        if (defined $$ti{'dll'}) {
          $file = $$ti{'dll'};
          $override = 1;
        }
        else {
          $file = $self->get_dll_template_input_file($tkey);
        }
      }
    }
  }

  if (defined $self->{$tag}->{$lang}->{$tkey}) {
    ## We have a TemplateInputReader for this template key, so we need
    ## to set the entry corresponding to $tikey to it for use in the
    ## get_template_input() method.
    $self->{$tag}->{$lang}->{$tikey} = $self->{$tag}->{$lang}->{$tkey};
  }
  else {
    ## We haven't read this file yet, so we will create the template
    ## input reader and store it in the entry for the template key
    ## ($tkey) and the template input key ($tikey).
    my $ti = new TemplateInputReader($self->get_include_path());
    $self->{$tag}->{$lang}->{$tkey} = $ti;
    $self->{$tag}->{$lang}->{$tikey} = $ti;

    ## Process the template input file
    if (defined $file) {
      my $tfile = $self->search_include_path("$file.$TemplateInputExtension");
      if (defined $tfile) {
        ($status, $errorString) = $ti->read_file($tfile);
      }
      else {
        ## Not finding a template input file is only an error if the user
        ## specifically provided a template input file override.
        if ($override) {
          $status = 0;
          $errorString = "Unable to locate template input file: $file";
        }
      }
    }

    ## Now that we've read in the template input file, set up our
    ## automatic template variables.
    if ($self->{'make_coexistence'}) {
      $ti->parse_line(undef,
                      "make_coexistence = $self->{'make_coexistence'}");
    }
  }

  ## We do this regardless of whether or not this parser is cached or
  ## not.  If the features have changed (through a workspace cmdline
  ## setting), we need to reflect it.
  if ($status) {
    ## Put the features into the template input set
    my $features = $self->{'feature_parser'}->get_names();
    $self->{$tag}->{$lang}->{$tikey}->parse_line(undef,
                                                 "features = @$features");
  }

  return $status, $errorString;
}


sub already_added {
  my($self, $array, $name) = @_;

  ## This method expects that the file name will be unix style
  $name =~ s/\\/\//g if ($self->{'convert_slashes'});

  ## Remove the leading ./
  $name =~ s/^\.\///;
  my $dsname = "./$name";

  foreach my $file (@$array) {
    return 1 if ($file eq $name || $file eq $dsname);
  }

  return 0;
}


sub get_applied_custom_keyword {
  my($self, $name, $type, $file) = @_;

  if (defined $self->{'flag_overrides'}->{$type} &&
      defined $self->{'flag_overrides'}->{$type}->{$file} &&
      defined $self->{'flag_overrides'}->{$type}->{$file}->{$name}) {
    return $self->relative(
             $self->{'flag_overrides'}->{$type}->{$file}->{$name}, 1);
  }

  return $self->relative($self->get_assignment(
                                   $name,
                                   $self->{'generated_exts'}->{$type}), 1);
}


sub evaluate_optional_option {
  my($self, $opt, $value) = @_;

  if ($opt =~ /^!\s*(.*)/) {
    return (!exists $$value{$1} ? 1 : 0);
  }
  else {
    return (exists $$value{$opt} ? 1 : 0);
  }
}


sub process_optional_option {
  my($self, $opt, $value) = @_;
  my $status;
  my @parts  = grep(!/^$/, split(/\s+/, $opt));
  my $pcount = scalar(@parts);

  for(my $i = 0; $i < $pcount; $i++) {
    if ($parts[$i] eq '&&' || $parts[$i] eq '||') {
      if (defined $status) {
        if (defined $parts[$i + 1]) {
          if ($parts[$i] eq '&&') {
            $status &&= $self->evaluate_optional_option($parts[$i + 1],
                                                        $value);
          }
          else {
            ## We are coming into an '||', if status is already true
            ## then we can leave immediately
            last if ($status);

            $status ||= $self->evaluate_optional_option($parts[$i + 1],
                                                        $value);
          }
        }
        else {
          $self->warning("Expected token in optional after $parts[$i]");
        }
      }
      else {
        $self->warning("Unexpected token in optional: $parts[$i]");
      }
      ++$i;
    }
    else {
      if (!defined $status) {
        $status = $self->evaluate_optional_option($parts[$i], $value);
      }
      else {
        $self->warning("Unexpected token in optional: $parts[$i]");
      }
    }
  }

  return $status;
}


sub add_optional_filename_portion {
  my($self, $gentype, $tag, $file, $array) = @_;

  if (defined $self->{'generated_exts'}->{$gentype}->{'optional'}->{$tag}) {
    foreach my $name (keys %{$self->{'generated_exts'}->{$gentype}->{'optional'}->{$tag}}) {
      foreach my $opt (keys %{$self->{'generated_exts'}->{$gentype}->{'optional'}->{$tag}->{$name}}) {
        ## Get the name value
        my $value = $self->get_applied_custom_keyword($name,
                                                      $gentype, $file);

        ## Convert the value into a hash map for easy lookup
        my %values;
        @values{split(/\s+/, $value)} = () if (defined $value);

        ## See if the option or options are contained in the value.  We
        ## need to call this even if $value is not defined due to the
        ## ability to negate optional parameters.
        if ($self->process_optional_option($opt, \%values)) {
          ## Add the optional portion
          push(@$array, @{$self->{'generated_exts'}->{$gentype}->{'optional'}->{$tag}->{$name}->{$opt}});
        }
      }
    }
  }
}


sub get_pre_keyword_array {
  my($self, $keyword, $gentype, $tag, $file) = @_;

  ## Get the general pre extension array.
  ## $self->{'generated_exts'}->{$gentype}->{$keyword} is guaranteed to
  ## be defined due to the defaulting that is done in
  ## parse_define_custom() and the only three calls to this method use
  ## valid $keyword values.
  my @array = @{$self->{'generated_exts'}->{$gentype}->{$keyword}};

  ## Add the component specific pre extension array
  my @additional;
  $tag =~ s/files$/$keyword/;
  if (defined $self->{'generated_exts'}->{$gentype}->{$tag}) {
    push(@additional, @{$self->{'generated_exts'}->{$gentype}->{$tag}});
  }

  ## Add in any optional portion to the array
  foreach my $itag ($keyword, $tag) {
    $self->add_optional_filename_portion($gentype, $itag,
                                         $file, \@additional);
  }

  ## If the current array only has the default,
  ## then we need to remove it
  if (defined $additional[0]) {
    if ($#array == 0 && $array[0] eq '') {
      pop(@array);
    }
    push(@array, @additional);
  }

  return @array;
}


sub add_explicit_output {
  my($self, $file, $type, $tag, $array, $arrs) = @_;

  if (defined $self->{'custom_special_output'}->{$type} &&
      defined $self->{'custom_special_output'}->{$type}->{$file}) {
    if (defined $self->{'valid_components'}->{$tag}) {
      my @files;
      foreach my $check (@{$self->{'custom_special_output'}->{$type}->{$file}}) {
        foreach my $regext (@{$self->{'valid_components'}->{$tag}}) {
          if ($check =~ /$regext$/) {
            my $add = 1;
            if ($tag eq 'source_files') {
              foreach my $tregext (@{$self->{'valid_components'}->{'template_files'}}) {
                if ($check =~ /$tregext$/) {
                  $add = undef;
                  last;
                }
              }
            }
            if ($add) {
              ## If gendir was specified, then we need to account for that
              my $dir = '';
              if (defined $self->{'flag_overrides'}->{$type} &&
                  defined $self->{'flag_overrides'}->{$type}->{$file} &&
                  defined $self->{'flag_overrides'}->{$type}->{$file}->{'gendir'} &&
                  $self->{'flag_overrides'}->{$type}->{$file}->{'gendir'} ne '.') {
                $dir = $self->{'flag_overrides'}->{$type}->{$file}->{'gendir'} . '/';
                $dir =~ s/\\/\//g if ($self->{'convert_slashes'});
              }

              push(@files, "$dir$check");
              last;
            }
          }
        }
      }
      if (defined $files[0]) {
        if ($arrs) {
          push(@$array, \@files);
        }
        else {
          push(@$array, @files);
        }
      }
    }
  }
}

sub generated_filenames {
  my($self, $part, $type, $tag, $file, $noext, $arrs) = @_;

  ## A custom type is not allowed to generate it's own input files
  return () if ($type eq $tag);

  ## See if the type for which we are generating ($tag) is also a custom
  ## file type.  If it is, we need to do some massaging.
  my $otag = $tag;
  if (defined $self->{'generated_exts'}->{$tag}) {
    ## If the custom type ($type) doesn't specify that it generates
    ## generic files, we need to see if there is a command helper for
    ## this type and see what sort of output it knows about.
    my $inputexts = $self->{'generated_exts'}->{$type}->{$generic_key};
    if (!defined $inputexts) {
      my $cmdHelper = CommandHelper::get($type);
      $inputexts = $cmdHelper->get_outputexts() if (defined $cmdHelper);
    }

    ## We will need to use 'generic_files' instead of $tag if $tag is
    ## defined in 'generated_exts', but only for the type that will
    ## actually generate the right type of generic file.
    my $good;
    if (defined $inputexts) {
      foreach my $inputext (@$inputexts) {
        my $ext = $inputext;
        $ext =~ s/\\//g;
        foreach my $extreg (@{$self->{'valid_components'}->{$tag}}) {
          if ($ext =~ /$extreg$/) {
            $tag = $generic_key;
            $good = 1;
            last;
          }
        }
        last if ($good);
      }
    }
    return () if (!$good);
  }

  my @pearr = $self->get_pre_keyword_array('pre_extension',
                                           $type, $tag, $file);
  my @pfarr = $self->get_pre_keyword_array('pre_filename',
                                           $type, $tag, $file);
  my @pdarr = $self->get_pre_keyword_array('pre_dirname',
                                           $type, $tag, $file);
  my @exts  = (defined $self->{'generated_exts'}->{$type}->{$tag} ?
                 @{$self->{'generated_exts'}->{$type}->{$tag}} : ());

  if (!defined $exts[0]) {
    my $backtag = $tag;
    if ($backtag =~ s/files$/outputext/) {
      $self->add_optional_filename_portion($type, $backtag,
                                           $file, \@exts);
    }
  }

  my @array;
  if (!defined $exts[0] && $#pearr == 0 && $#pfarr == 0 && $#pdarr == 0 &&
      $pearr[0] eq '' && $pfarr[0] eq '' && $pdarr[0] eq '') {
    ## If both arrays are defined to be the defaults, then there
    ## is nothing for us to do.
  }
  else {
    my $dir  = '';
    my $base;

    ## Correctly deal with pre filename and directories
    if ($part =~ /(.*[\/\\])([^\/\\]+)$/) {
      ## Split the directory and base name of the file.  Only set the
      ## directory if the output follows the input directory.
      $dir = $1
        if ($self->{'generated_exts'}->{$type}->{'output_follows_input'});
      $base = $2;
    }
    else {
      $base = $part;
    }

    ## If gendir was specified, then we need to account for that
    if (defined $self->{'flag_overrides'}->{$type} &&
        defined $self->{'flag_overrides'}->{$type}->{$file} &&
        defined $self->{'flag_overrides'}->{$type}->{$file}->{'gendir'}) {
      if ($self->{'flag_overrides'}->{$type}->{$file}->{'gendir'} eq '.') {
        $dir = '';
      }
      else {
        $dir = $self->{'flag_overrides'}->{$type}->{$file}->{'gendir'} . '/';
        $dir =~ s/\\/\//g if ($self->{'convert_slashes'});
      }
    }

    ## Loop through creating all of the possible file names
    foreach my $pe (@pearr) {
      my @genfile;
      $pe =~ s/\\\././g;
      foreach my $pf (@pfarr) {
        $pf =~ s/\\\././g;
        foreach my $pd (@pdarr) {
          if ($noext) {
            push(@genfile, "$pd$dir$pf$base$pe");
          }
          else {
            foreach my $ext (@exts) {
              $ext =~ s/\\\././g;
              push(@genfile, "$pd$dir$pf$base$pe$ext");
            }
          }
        }
      }
      if ($arrs) {
        push(@array, \@genfile);
      }
      else {
        push(@array, @genfile);
      }
    }
  }

  ## Now add the explicit output.  We need to use the original tag value
  ## ($otag) so that we can find the custom output files.
  $self->add_explicit_output($file, $type, $otag, \@array, $arrs);
  return @array;
}


sub add_generated_files {
  my($self, $gentype, $tag, $group, $arr) = @_;

  ## This method is called by list_default_generated.  It performs the
  ## actual file insertion and grouping.

  ## Get the generated filenames
  my @added;
  foreach my $file (keys %$arr) {
    foreach my $gen ($self->generated_filenames($$arr{$file}, $gentype,
                                                $tag, $file, 1)) {
      $self->list_generated_file($gentype, $tag, \@added, $gen, $$arr{$file});
    }
  }

  if (defined $added[0]) {
    my $names = $self->{$tag};

    ## Get all files in one list and save the directory
    ## and component group in a hashed array.
    my @all;
    my %dircomp;
    foreach my $name (keys %$names) {
      foreach my $key (keys %{$$names{$name}}) {
        push(@all, @{$$names{$name}->{$key}});
        foreach my $file (@{$$names{$name}->{$key}}) {
          $dircomp{$self->mpc_dirname($file)} = $key;
        }
      }
    }

    ## Create a small array of only the files we want to add.
    ## We put them all together so we can keep them in order when
    ## we put them at the front of the main file list.
    my @oktoadd;
    foreach my $file (@added) {
      push(@oktoadd, $file) if (!$self->already_added(\@all, $file));
    }

    ## If we have files to add, make sure we add them to a group
    ## that has the same directory location as the files we're adding.
    if (defined $oktoadd[0]) {
      my $key = (defined $group ? $group :
                         $dircomp{$self->mpc_dirname($oktoadd[0])});
      if (!defined $key) {
        my $check = $oktoadd[0];
        foreach my $regext (@{$self->{'valid_components'}->{$tag}}) {
          last if ($check =~ s/$regext$//);
        }
        foreach my $vc (keys %{$self->{'valid_components'}}) {
          ## If this component name does not match the component name for
          ## which we are adding files and there are components defined
          ## for it, we will look to see if we can find a matching group
          ## name.  We have to make sure that we do not use the hash map
          ## ($self->{$vc}) unless it's defined.  Doing so will
          ## automatically create the map and that will cause MPC to
          ## think that the user provided the empty setting (when it
          ## wasn't).
          if ($vc ne $tag && defined $self->{$vc}) {
            foreach my $name (keys %{$self->{$vc}}) {
              foreach my $ckey (keys %{$self->{$vc}->{$name}}) {
                if ($ckey ne $defgroup) {
                  foreach my $ofile (@{$self->{$vc}->{$name}->{$ckey}}) {
                    my $file = $ofile;
                    foreach my $regext (@{$self->{'valid_components'}->{$vc}}) {
                      last if ($file =~ s/$regext$//);
                    }
                    if ($file eq $check) {
                      $key = $ckey;
                      last;
                    }
                  }
                }
                last if (defined $key);
              }
            }
            last if (defined $key);
          }
        }
        $key = $defgroup if (!defined $key);
      }
      foreach my $name (keys %$names) {
        if (!defined $$names{$name}->{$key}) {
          if ($key ne $defgroup &&
              defined $$names{$name}->{$defgroup} &&
              defined $$names{$name}->{$defgroup}->[0]) {
            $self->process_assignment_add($grouped_key . $tag, $defgroup);
          }
          $$names{$name}->{$key} = [];
          $self->process_assignment_add($grouped_key . $tag, $key);
        }
        unshift(@{$$names{$name}->{$key}}, @oktoadd);
      }
    }
  }
}


sub search_for_entry {
  my($self, $file, $marray, $preproc) = @_;
  my $name;
  my $fh = new FileHandle();

  if (open($fh, $file)) {
    my $poundifed = 0;
    my $commented = 0;

    while(<$fh>) {
      ## Remove c++ style comments
      $_ =~ s/\/\/.*// if (!$commented);

      ## Remove one line c style comments
      $_ =~ s/\/\*.*\*\///g;

      if ($commented) {
        if (/\*\//) {
          ## Found the end of a multi-line c style comment
          --$commented;
        }
      }
      else {
        if (/\/\*/) {
          ## Found the beginning of a multi-line c style comment
          ++$commented;
        }
        elsif ($preproc) {
          ## If the current language supports a c preprocessor, we
          ## will perform a minimal check for #if 0
          if (/#\s*if\s+0/) {
            ## Found the beginning of a #if 0
            ++$poundifed;
          }
          elsif ($poundifed) {
            if (/#\s*if/) {
              ## We need to keep track of any other #if directives
              ## to be sure that when we see an #endif we don't
              ## count the wrong one.
              ++$poundifed;
            }
            elsif (/#\s*endif/) {
              ## Found a #endif, so decrement our count
              --$poundifed;
            }
          }
        }
      }

      ## Check for main; Make sure it's not #if 0'ed and not commented out
      if (!$poundifed && !$commented) {
        my $found = undef;
        foreach my $main (@$marray) {
          if (/\s+$main\s*\(/ || /^\s*$main\s*\(/) {
            ## If we've found a main, set the exename to the basename
            ## of the cpp file with the extension removed
            $name = $self->mpc_basename($file);
            $name =~ s/\.[^\.]+$//;
            $found = 1;
            last;
          }
          last if ($found);
        }
      }
    }
    close($fh);
  }
  return $name;
}


sub find_main_file {
  my($self, $sources) = @_;
  my $lang    = $self->get_language();
  my @main    = $language{$lang}->[3];
  my $preproc = $language{$lang}->[4];

  ## If additional main's have been supplied by the user for this
  ## language type, then just push them onto the array.
  push(@main, @{$mains{$lang}}) if (defined $mains{$lang});

  ## Now search each source file until we've found a main function.
  foreach my $file (@$sources) {
    my $exename = $self->search_for_entry($file, \@main, $preproc);
    return $exename if (defined $exename);
  }

  return undef;
}


sub generate_default_target_names {
  my $self = shift;

  ## If this is a custom_only project, we need not waste time setting the
  ## sharedname, staticname or exename.  Searching all of the files for a
  ## main function is very time consuming and unnecessary.
  return undef if ($self->get_assignment('custom_only'));

  if (!$self->exe_target()) {
    my $sharedname = $self->get_assignment('sharedname');
    my $staticname = $self->get_assignment('staticname');
    my $shared_empty;

    if (defined $sharedname) {
      if ($sharedname eq '') {
        $shared_empty = 1;
        $sharedname = undef;
        $self->process_assignment('sharedname', $sharedname);
      }
      elsif (!defined $staticname) {
        $staticname = $sharedname;
        $self->process_assignment('staticname', $staticname);
      }
    }
    if (defined $staticname && !$shared_empty && !defined $sharedname) {
      $sharedname = $staticname;
      $self->process_assignment('sharedname', $sharedname);
    }

    ## If it's neither an exe or library target, we will search
    ## through the source files for a main()
    if (!$self->lib_target()) {
      ## Set the exename assignment
      my @sources = $self->get_component_list('source_files', 1);
      my $exename = $self->find_main_file(\@sources);
      $self->process_assignment('exename', $exename) if (defined $exename);

      ## If we still don't have a project type, then we will
      ## default to a library if there are source or resource files
      if (!defined $exename) {
        if (!defined $sources[0]) {
          @sources = $self->get_component_list($self->get_resource_tag(), 1);
        }
        if (defined $sources[0]) {
          if (!$shared_empty) {
            $self->process_assignment('sharedname',
                                      $self->{'unmodified_project_name'});
          }
          $self->process_assignment('staticname',
                                    $self->{'unmodified_project_name'});
        }
      }
    }
  }

  ## If we are generating only static projects, then we need to
  ## unset the sharedname, so that we can insure that projects of
  ## various types only generate static targets.
  if ($self->get_static() == 1) {
    my $sharedname = $self->get_assignment('sharedname');
    if (defined $sharedname) {
      $self->process_assignment('sharedname', undef);
    }
  }

  ## Check for the use of an asterisk in the name
  foreach my $key ('exename', 'sharedname', 'staticname') {
    my $value = $self->get_assignment($key);
    if (defined $value && index($value, '*') >= 0) {
      $value = $self->fill_type_name($value,
                                     $self->{'unmodified_project_name'});
      $self->process_assignment($key, $value);
    }
  }
}


sub generate_default_pch_filenames {
  my($self, $files) = @_;
  my $pchhdef = (defined $self->get_assignment('pch_header'));
  my $pchcdef = (defined $self->get_assignment('pch_source'));

  if (!$pchhdef || !$pchcdef) {
    my $pname     = $self->get_assignment('project_name');
    my $hcount    = 0;
    my $ccount    = 0;
    my $hmatching;
    my $cmatching;
    foreach my $file (@$files) {
      ## If the file doesn't even contain _pch, then there's no point
      ## in looping through all of the extensions
      if (index($file, '_pch') >= 0) {
        if (!$pchhdef) {
          foreach my $ext (@{$self->{'valid_components'}->{'header_files'}}) {
            if ($file =~ /(.*_pch$ext)$/) {
              $self->process_assignment('pch_header', $1);
              ++$hcount;
              $hmatching = $file if (index($file, $pname) >= 0);
              last;
            }
          }
        }
        if (!$pchcdef) {
          foreach my $ext (@{$self->{'valid_components'}->{'source_files'}}) {
            if ($file =~ /(.*_pch$ext)$/) {
              $self->process_assignment('pch_source', $1);
              ++$ccount;
              $cmatching = $file if (index($file, $pname) >= 0);
              last;
            }
          }
        }
      }
    }
    if (!$pchhdef && $hcount > 1 && defined $hmatching) {
      $self->process_assignment('pch_header', $hmatching);
    }
    if (!$pchcdef && $ccount > 1 && defined $cmatching) {
      $self->process_assignment('pch_source', $cmatching);
    }
  }
}


sub fix_pch_filenames {
  my $self = shift;

  ## Unset the precompiled header settings if they are set but empty
  foreach my $type ('pch_header', 'pch_source') {
    my $pch = $self->get_assignment($type);
    $self->process_assignment($type, undef) if (defined $pch && $pch eq '');
  }
}


sub remove_extra_pch_listings {
  my $self = shift;
  my @pchs = ('pch_header', 'pch_source');
  my @tags = ('header_files', 'source_files');

  for(my $j = 0; $j < 2; ++$j) {
    my $pch = $self->get_assignment($pchs[$j]);

    if (defined $pch) {
      ## If we are converting slashes, then we need to
      ## convert the pch file back to forward slashes
      $pch =~ s/\\/\//g if ($self->{'convert_slashes'});

      ## Find out which files are duplicated
      my $names = $self->{$tags[$j]};
      foreach my $name (keys %$names) {
        my $comps = $$names{$name};
        foreach my $key (keys %$comps) {
          my $array = $$comps{$key};
          my $count = scalar(@$array);
          for(my $i = 0; $i < $count; ++$i) {
            if ($pch eq $$array[$i]) {
              splice(@$array, $i, 1);
              --$count;
            }
          }
        }
      }
    }
  }
}


sub sift_files {
  my($self, $files, $exts, $pchh, $pchc, $tag, $array, $alldir) = @_;
  my @saved;
  my $havec  = (defined $self->{'exclude_components'}->{$tag});

  ## The special actions taken based on $saverc only applies to
  ## C++ resource files.
  my $saverc = (!$alldir && $tag eq $self->get_resource_tag() &&
                $self->languageIs(Creator::cplusplus));

  foreach my $ext (@$exts) {
    foreach my $file (grep(/$ext$/, @$files)) {
      ## Always exclude the precompiled header and cpp
      if ((!defined $pchh || $file ne $pchh) &&
          (!defined $pchc || $file ne $pchc)) {
        if ($havec) {
          my $exclude = 0;
          foreach my $exc (@{$self->{'exclude_components'}->{$tag}}) {
            if ($file =~ /$exc$/) {
              $exclude = 1;
              last;
            }
          }
          next if ($exclude);
        }
        elsif ($saverc) {
          ## Save these files for later.  There may
          ## be more than one and we want to try and
          ## find the one that corresponds to this project
          push(@saved, $file);
          next;
        }

        push(@$array, $file) if (!$self->already_added($array, $file));
      }
    }
  }

  ## Now deal with the saved files
  if (defined $saved[0]) {
    if (!defined $saved[1]) {
      ## Theres only one rc file, take it
      push(@$array, $saved[0]);
    }
    else {
      my $pjname = $self->escape_regex_special(
                             $self->transform_file_name(
                                 $self->get_assignment('project_name')));
      ## Use a case insensitive search.
      ## After all, this is a Windows specific file type.
      foreach my $save (@saved) {
        if ($save =~ /$pjname/i) {
          if (!$self->already_added($array, $save)) {
            push(@$array, $save);
          }
        }
      }
    }
  }
}


sub sift_default_file_list {
  my($self, $tag, $file, $built, $exts, $recurse, $pchh, $pchc) = @_;
  my $alldir = $recurse ||
               (defined $self->{'flag_overrides'}->{$tag} &&
                defined $self->{'flag_overrides'}->{$tag}->{$file} &&
                $self->{'flag_overrides'}->{$tag}->{$file}->{'recurse'});
  my @gen    = $self->generate_default_file_list($file, [], undef, $alldir);

  $self->sift_files(\@gen, $exts, $pchh, $pchc, $tag, $built, $alldir);
}


sub correct_generated_files {
  my($self, $defcomp, $exts, $tag, $array) = @_;

  if (defined $sourceComponents{$tag}) {
    my $grtag = $grouped_key . $tag;
    foreach my $gentype (keys %{$self->{'generated_exts'}}) {
      ## If we are not automatically adding generated output, then we
      ## need to skip this component type.
      next if (!$self->{'generated_exts'}->{$gentype}->{'automatic_out'});

      ## If we are auto-generating the source_files, then
      ## we need to make sure that any generated source
      ## files that are added are put at the front of the list.
      my $newgroup;
      my @input;

      ## If I call keys %{$self->{$gentype}} using perl 5.6.1
      ## it returns nothing.  I have to put it in an
      ## intermediate variable to ensure that I get the keys.
      my $names = $self->{$gentype};
      foreach my $name (keys %$names) {
        foreach my $key (keys %{$$names{$name}}) {
          push(@input, @{$$names{$name}->{$key}});
          $newgroup = $key if ($key ne $defgroup);
        }
      }

      if (defined $input[0]) {
        my @front;
        my @copy = @$array;

        @$array = ();
        foreach my $input (@input) {
          my $part = $self->remove_wanted_extension(
                        $input,
                        $self->{'valid_components'}->{$gentype});

          my @files = $self->generated_filenames($part, $gentype,
                                                 $tag, $input);
          if (defined $copy[0]) {
            my $found = 0;
            foreach my $file (@files) {
              for(my $i = 0; $i < scalar(@copy); $i++) {
                my $re = $self->escape_regex_special($copy[$i]);
                if ($file eq $copy[$i] || $file =~ /[\/\\]$re$/) {
                  ## No need to check for previously added files
                  ## here since there are none.
                  $found = 1;
                  push(@front, $file);
                  splice(@copy, $i, 1);
                  last;
                }
              }
              last if ($found);
            }
            if (!$found) {
              ## The first file listed in @files is the preferred
              ## extension for the custom command.  Take the first
              ## file extension and see if it matches one in the accepted
              ## extensions.
              if (defined $files[0]) {
                my $ext;
                if ($files[0] =~ /.*(\.[^\.]+)$/) {
                  $ext = $self->escape_regex_special($1);
                }
                if (defined $ext) {
                  ## If it doesn't match one of the accepted extensions,
                  ## then just use the first extension from the type for
                  ## which we are generating.
                  $ext = $$exts[0] if (!StringProcessor::fgrep($ext, $exts));
                }

                ## Add all the files that match the chosen extension
                foreach my $file (@files) {
                  push(@front, $file) if ($file =~ /$ext$/);
                }
              }
            }
          }
          else {
            my $ext = $$exts[0];
            foreach my $file (@files) {
              push(@front, $file) if ($file =~ /$ext$/);
            }
          }
        }
        if (defined $copy[0]) {
          ## No need to check for previously added files
          ## here since there are none.
          push(@$array, @copy);
          if (defined $self->get_assignment($grtag)) {
            $self->process_assignment_add($grtag, $defgroup);
          }
        }
        if (defined $front[0]) {
          if (defined $newgroup) {
            if (defined $copy[0]) {
              $self->process_assignment_add($grtag, $defgroup);
            }
            if (!defined $self->{$tag}->{$defcomp}->{$newgroup}) {
              $self->{$tag}->{$defcomp}->{$newgroup} = \@front;
            }
            else {
              push(@{$self->{$tag}->{$defcomp}->{$newgroup}}, @front);
            }
            $self->process_assignment_add($grtag, $newgroup);
          }
          else {
            unshift(@$array, @front);
          }
        }
      }
    }
  }
}


sub generate_default_components {
  my($self, $files, $passed) = @_;
  my $genext   = $self->{'generated_exts'};
  my @gc       = reverse sort { $self->sort_generated_types($a, $b)
                              } keys %$genext;
  my @tags     = (defined $passed ? $passed :
                    (@gc, keys %{$language{$self->get_language()}->[0]}));
  my $pchh     = $self->get_assignment('pch_header');
  my $pchc     = $self->get_assignment('pch_source');
  my $recurse  = $self->get_assignment('recurse');
  my $defcomp  = $self->get_default_component_name();
  my $flo      = $self->{'flag_overrides'};
  my $cmdflags = 'commandflags';

  ## The order of @tags does make a difference in the way that generated
  ## files get added.  Hence the sort call on the generate_exts keys to
  ## ensure that user defined types come first.  They are reverse sorted
  ## using the custom sort function to ensure that user defined types
  ## that rely on other user defined types for input files are processed
  ## first.
  foreach my $tag (@tags) {
    if (!defined $genext->{$tag} ||
        $genext->{$tag}->{'automatic_in'}) {
      my $exts = $self->{'valid_components'}->{$tag};
      if (defined $$exts[0]) {
        if (defined $self->{$tag}) {
          ## If the tag is defined, then process directories
          my $names = $self->{$tag};
          foreach my $name (keys %$names) {
            my $comps = $$names{$name};
            foreach my $comp (keys %$comps) {
              my $array = $$comps{$comp};
              if (defined $passed) {
                $self->sift_files($files, $exts, $pchh, $pchc, $tag, $array);
              }
              else {
                my @built;
                my $alldirs = 1;
                foreach my $file (@$array) {
                  if (-d $file) {
                    my @portion;
                    $self->sift_default_file_list($tag, $file, \@portion,
                                                  $exts, $recurse, $pchh, $pchc);

                    ## Since the file was actually a directory, we will
                    ## need to propagate the flag overrides (if there are
                    ## any) to the newly located files.
                    if (defined $flo->{$tag} &&
                        defined $flo->{$tag}->{$file}) {
                      foreach my $built (@portion) {
                        $flo->{$tag}->{$built} = $flo->{$tag}->{$file};
                      }
                    }

                    ## Always push the @portion array onto the back of
                    ## @built.
                    push(@built, @portion);
                  }
                  else {
                    $alldirs = undef;
                    if (!$self->already_added(\@built, $file)) {
                      push(@built, $file);
                    }
                  }
                }
                if ($alldirs) {
                  $self->correct_generated_files($defcomp, $exts,
                                                 $tag, \@built);
                }
                $$comps{$comp} = \@built;
              }
            }
          }
        }
        else {
          ## Generate default values for undefined tags
          $self->{$tag} = {};
          my $comps = {};
          $self->{$tag}->{$defcomp} = $comps;
          $$comps{$defgroup} = [];
          my $array = $$comps{$defgroup};

          $self->{'defaulted'}->{$tag} = 1;

          if (!defined $specialComponents{$tag}) {
            $self->sift_files($files, $exts, $pchh, $pchc, $tag, $array);
            $self->correct_generated_files($defcomp, $exts, $tag, $array);
          }
        }

        ## If the type that we're generating defaults for ($tag) is a
        ## custom type, then we need to see if other custom types
        ## ($gentype) will generate files that will be used as input.  It
        ## has to be done here so that the built-in types will have all
        ## of the possible input files that they can.
        if (defined $genext->{$tag}) {
          foreach my $gentype (keys %{$genext}) {
            if ($gentype ne $tag) {
              $self->list_default_generated($gentype, [$tag]);
            }
          }

          ## Now that we have the files for this type ($tag), we need to
          ## locate a command helper for the custom command and see if it
          ## knows about any additional output files based on the file
          ## name.
          my $cmdHelper = CommandHelper::get($tag);
          if (defined $cmdHelper) {
            my $names = $self->{$tag};
            foreach my $name (keys %$names) {
              my $comps = $$names{$name};
              foreach my $comp (keys %$comps) {
                my $array = $$comps{$comp};
                foreach my $file (@$array) {
                  my $flags = defined $flo->{$tag}->{$file} ?
                                $flo->{$tag}->{$file}->{$cmdflags} :
                                $genext->{$tag}->{$cmdflags};
                  my $add_out = $cmdHelper->get_output($file, $flags);
                  push(@{$self->{'custom_special_output'}->{$tag}->{$file}},
                       @$add_out);
                }
              }
            }
          }
        }
      }
    }
  }
}


sub remove_duplicated_files {
  my($self, $dest, $source) = @_;
  my @slist = $self->get_component_list($source, 1);

  ## There's no point in going on if there's nothing in this component
  ## list.
  return undef if ($#slist == -1);

  ## Convert the array into keys for a hash table
  my %shash;
  @shash{@slist} = ();

  ## Find out which source files are listed
  my $names = $self->{$dest};
  foreach my $name (keys %$names) {
    foreach my $key (keys %{$$names{$name}}) {
      my $array = $$names{$name}->{$key};
      my $count = scalar(@$array);
      for(my $i = 0; $i < $count; ++$i) {
        ## Is the source file in the component array?
        if (exists $shash{$$array[$i]}) {
          ## Remove the element and fix the index and count
          splice(@$array, $i, 1);
          --$count;
          --$i;
        }
      }
    }
  }
}


sub generated_source_listed {
  my($self, $gent, $tag, $arr, $sext) = @_;
  my $names = $self->{$tag};

  ## Find out which generated source files are listed
  foreach my $name (keys %$names) {
    my $comps = $$names{$name};
    foreach my $key (keys %$comps) {
      foreach my $val (@{$$comps{$key}}) {
        foreach my $i (keys %$arr) {
          ## If $gent doesn't cause $tag files to be generated, then we
          ## can just return a non-zero value to short-circuit attempting
          ## to add generated files after the caller continues.
          my @gfiles = $self->generated_filenames($$arr{$i}, $gent, $tag, $i);
          return 2 if ($#gfiles == -1);

          foreach my $re (@gfiles) {
            $re = $self->escape_regex_special($re);
            return 1 if ($val =~ /$re$/);
          }
        }
      }
    }
  }

  return 0;
}


sub list_default_generated {
  my($self, $gentype, $tags) = @_;

  ## This method is called when the user has custom input files and has
  ## provided source files.  If the user defaults the component (i.e.
  ## source_files, resource_files, etc.) they are filled in by the
  ## generate_default_components method.

  if (defined $self->{'generated_exts'}->{$gentype} &&
      $self->{'generated_exts'}->{$gentype}->{'automatic_out'}) {
    ## After all source and headers have been defaulted, see if we
    ## need to add the generated files
    if (defined $self->{$gentype}) {
      ## Build up the list of files
      my %arr;
      my $names = $self->{$gentype};
      my $group;
      foreach my $name (keys %$names) {
        foreach my $key (keys %{$$names{$name}}) {
          my $array = $$names{$name}->{$key};

          ## Take the last group name we encounter
          $group = $key if ($key ne $defgroup);

          foreach my $val (@$array) {
            $arr{$val} = $self->remove_wanted_extension(
                              $val,
                              $self->{'valid_components'}->{$gentype});
          }
        }
      }

      foreach my $type (@$tags) {
        ## Do not add generated files if they are "special"
        ## unless they haven't been explicitly supplied.
        if ($gentype ne $type &&
            (!$specialComponents{$type} ||
             (!$self->{'special_supplied'}->{$type} ||
              UNIVERSAL::isa($self->{'special_supplied'}->{$type}, 'ARRAY')))) {
          if (!$self->generated_source_listed(
                                $gentype, $type, \%arr,
                                $self->{'valid_components'}->{$gentype})) {
            $self->add_generated_files($gentype, $type, $group, \%arr);
          }
        }
      }
    }
  }
}


sub prepend_gendir {
  my($self, $created, $ofile, $gentype) = @_;
  my $key;

  if (defined $self->{'flag_overrides'}->{$gentype}) {
    foreach my $ext (@{$self->{'valid_components'}->{$gentype}}) {
      my $e = $ext;
      $e =~ s/\\//g;
      $key = "$ofile$e";

      last if (defined $self->{'flag_overrides'}->{$gentype}->{$key});
      $key = undef;
    }

    if (defined $key) {
      if (StringProcessor::fgrep('gendir',
                                 $self->{'matching_assignments'}->{$gentype})) {
        my $dir = $self->{'flag_overrides'}->{$gentype}->{$key}->{'gendir'};
        if (defined $dir) {
          ## Convert the file to unix style for basename
          if ($self->{'convert_slashes'}) {
            $created =~ s/\\/\//g;
            $dir =~ s/\\/\//g;
          }
          return ($dir eq '.' ? '' : "$dir/") . $self->mpc_basename($created);
        }
      }
    }
  }

  return $created;
}


sub list_generated_file {
  my($self, $gentype, $tag, $array, $file, $ofile) = @_;
  my $count = 0;

  ## Go through each file listed in our original type and attempt to find
  ## out if it is the generated file we may need to add ($file).
  foreach my $gen ($self->get_component_list($gentype, 1)) {
    my $input = $gen;

    ## Take the file and see if it contains an extension that our
    ## generating type ($gentype) knows about.  If it does, remove it and
    ## stop looking for the extension.
    foreach my $ext (@{$self->{'valid_components'}->{$gentype}}) {
      ## Remove the extension.
      ## If it works, then we can exit this loop.
      last if ($gen =~ s/$ext$//);
    }

    ## If the user provided file does not match any of the
    ## extensions specified by the custom definition, we need
    ## to remove the extension or else this file will not be
    ## added to the project.
    $gen =~ s/\.[^\.]+$// if ($gen eq $input);

    ## See if we need to add the file.  We always need to check since the
    ## output file may have absolutely nothing in common with the input
    ## file.
    foreach my $created ($self->generated_filenames($gen, $gentype,
                                                    $tag, $input)) {
      ## $gen is a file that has a custom definition that generates
      ## files of the type $tag.  The $file passed in is of type
      ## $gentype and, as far as I can tell, $created will always be
      ## longer or of the same length of $file.  It doesn't really
      ## matter if $file contains a '.' or not.
      if (index($created, $file) != -1) {
        if (defined $ofile) {
          $created = $self->prepend_gendir($created, $ofile, $gentype);
        }
        if (!$self->already_added($array, $created)) {
          push(@$array, $created);
          ++$count;
        }
        last;
      }
    }
  }

  return $count;
}


sub add_corresponding_component_files {
  my($self, $filecomp, $tag) = @_;
  my $grname   = $grouped_key . $tag;

  ## Create a hash array keyed off of the existing files of the type
  ## that we plan on adding.
  my $fexist  = 0;
  my %scfiles;
  my $names   = $self->{$tag};
  foreach my $name (keys %$names) {
    ## Check to see if files exist in the default group
    if (defined $$names{$name}->{$defgroup} &&
        defined $$names{$name}->{$defgroup}->[0]) {
      $fexist = 1;
    }
    foreach my $comp (keys %{$$names{$name}}) {
      @scfiles{@{$$names{$name}->{$comp}}} = ();
    }
  }

  ## Create an array of extensions for the files we want to add
  my @exts;
  foreach my $ext (@{$self->{'valid_components'}->{$tag}}) {
    push(@exts, $ext);
    $exts[$#exts] =~ s/\\//g;
  }

  ## Check each file against a possible new file addition
  my $adddefaultgroup = 0;
  my $oktoadddefault  = 0;
  foreach my $sfile (keys %$filecomp) {
    my $found = 0;
    foreach my $ext (@exts) {
      if (exists $scfiles{"$sfile$ext"}) {
        $found = 1;
        last;
      }
    }

    if (!$found) {
      ## Get the array of files for the selected component name
      my $array = [];
      my $comp  = $$filecomp{$sfile};
      foreach my $name (keys %$names) {
        if (defined $$names{$name}->{$comp}) {
          $array = $$names{$name}->{$comp};
        }
      }

      ## First, see if it will be generated so that we can correctly
      ## deal with 'gendir' settings.
      foreach my $gentype (keys %{$self->{'generated_exts'}}) {
        $found += $self->list_generated_file($gentype, $tag, $array, $sfile);
      }

      ## Next check to see if the file exists
      if (!$found) {
        foreach my $ext (@exts) {
          if (-r "$sfile$ext") {
            my $file = "$sfile$ext";
            if (!$self->already_added($array, $file)) {
              push(@$array, $file);
              ++$found;
            }
            last;
          }
        }
      }

      ## If we have any files at all in the component array, check
      ## to see if we need to add a new group name
      if (defined $$array[0]) {
        if ($comp eq $defgroup) {
          $adddefaultgroup = 1;
        }
        else {
          my $grval = $self->get_assignment($grname);
          if (!defined $grval ||
              !StringProcessor::fgrep($comp, $self->create_array($grval))) {
            $self->process_assignment_add($grname, $comp);
          }
          $oktoadddefault = 1;
          $adddefaultgroup |= $fexist;
        }

        ## Put the array back into the component list
        if ($found) {
          foreach my $name (keys %$names) {
            $$names{$name}->{$comp} = $array;
          }
        }
      }
    }
  }

  ## We only need to add the default group name if we wanted to
  ## add the default group when adding new files and we added a group
  ## by some other name.  Otherwise, defaulted files would always be
  ## in a group, which is not what we want.
  if ($adddefaultgroup && $oktoadddefault) {
    $self->process_assignment_add($grname, $defgroup);
  }
}


sub get_default_project_name {
  my $self = shift;
  my $name = $self->{'current_input'};

  if ($name eq '') {
    $name = $self->transform_file_name($self->base_directory());
  }
  else {
    ## Since files on UNIX can have back slashes, we transform them
    ## into underscores.
    $name =~ s/\\/_/g;

    ## Convert the name to a usable name
    $name = $self->transform_file_name($name);

    ## Take off the extension
    $name =~ s/\.[^\.]+$//;
  }

  return $name;
}


sub remove_excluded {
  my $self = shift;
  my @tags = @_;

  ## Process each file type and remove the excluded files
  foreach my $tag (@tags) {
    my $names = $self->{$tag};
    foreach my $name (keys %$names) {
      foreach my $comp (keys %{$$names{$name}}) {
        my $count = scalar(@{$$names{$name}->{$comp}});
        for(my $i = 0; $i < $count; ++$i) {
          my $file = $$names{$name}->{$comp}->[$i];
          if (defined $self->{'remove_files'}->{$tag}->{$file}) {
            splice(@{$$names{$name}->{$comp}}, $i, 1);
            --$i;
            --$count;
          }
          else {
            ## The file does not match exactly with one of the files to
            ## remove.  Look for wildcard specifications in the files to
            ## be removed and perform the removal if one of them matches
            ## the current file.
            foreach my $key (keys %{$self->{'remove_files'}->{$tag}}) {
              if ($key =~ /[\*\?\[\]]/) {
                my $regex = $key;
                $regex =~ s/\./\\./g;
                $regex =~ s/\*/\.\*/g;
                $regex =~ s/\?/\./g;
                if ($file =~ /^$regex$/) {
                  splice(@{$$names{$name}->{$comp}}, $i, 1);
                  --$i;
                  --$count;
                  last;
                }
              }
            }
          }
        }
      }
    }
    delete $self->{'remove_files'}->{$tag};
  }
}


sub sort_generated_types {
  ## We need to sort the custom component types such that a custom type
  ## that generates input for another custom type comes first in the
  ## list.
  my($self, $left, $right, $norecurse) = @_;
  foreach my $key (keys %{$self->{'generated_exts'}->{$left}}) {
    if ($key =~ /_files$/) {
      foreach my $regex (@{$self->{'generated_exts'}->{$left}->{$key}}) {
        my $ext = $regex;
        $ext =~ s/\\//g;
        foreach my $vreg (@{$self->{'valid_components'}->{$right}}) {
          return -1 if ($ext =~ /$vreg$/);
        }
      }
    }
  }
  if (!$norecurse && $self->sort_generated_types($right, $left, 1) == -1) {
    return 1;
  }

  return 0;
}

sub generate_defaults {
  my $self = shift;

  ## Generate default project name
  if (!defined $self->get_assignment('project_name')) {
    $self->set_project_name($self->get_default_project_name());
  }

  ## Generate the default pch file names (if needed)
  my @files = $self->generate_default_file_list(
                                '.', [],
                                undef, $self->get_assignment('recurse'));
  $self->generate_default_pch_filenames(\@files);

  ## If the pch file names are empty strings then we need to fix that
  $self->fix_pch_filenames();

  ## Generate default components, but %specialComponents
  ## are skipped in the initial default components generation
  $self->generate_default_components(\@files);

  ## Remove source files that are also listed in the template files
  ## If we do not do this, then generated projects can be invalid.
  $self->remove_duplicated_files('source_files', 'template_files');

  ## If pch files are listed in header_files or source_files more than
  ## once, we need to remove the extras
  $self->remove_extra_pch_listings();

  ## Generate the default generated list of files only if we defaulted
  ## the generated file list.  I want to ensure that source_files comes
  ## first in the list to pick up group information (since source_files
  ## are most likely going to be grouped than anything else).
  my @vc = sort { return -1 if $a eq 'source_files';
                  return  1 if $b eq 'source_files';
                  return $b cmp $a; } keys %{$self->{'valid_components'}};
  my @gvc = sort { $self->sort_generated_types($a, $b)
                 } keys %{$self->{'generated_exts'}};
  foreach my $gentype (@gvc) {
    $self->list_default_generated($gentype, \@vc);
  }

  ## Now that all of the source files have been added
  ## we need to remove those that have need to be removed
  $self->remove_excluded('source_files');

  ## Collect up all of the source files that have already been listed
  ## with the extension removed for use directly below.
  my %sourcecomp;
  foreach my $sourcetag (keys %sourceComponents) {
    my $names = $self->{$sourcetag};
    foreach my $name (keys %$names) {
      foreach my $comp (keys %{$$names{$name}}) {
        foreach my $sfile (@{$$names{$name}->{$comp}}) {
          my $mod = $sfile;
          $mod =~ s/\.[^\.]+$//;
          $sourcecomp{$mod} = $comp;
        }
      }
    }
  }

  ## Add %specialComponents files based on the
  ## source_components (i.e. .h and .i or .inl based on .cpp)
  foreach my $tag (keys %specialComponents) {
    $self->add_corresponding_component_files(\%sourcecomp, $tag);
  }

  ## Now, if the %specialComponents are still empty
  ## then take any file that matches the components extension
  foreach my $tag (keys %specialComponents) {
    if (!$self->{'special_supplied'}->{$tag} ||
        UNIVERSAL::isa($self->{'special_supplied'}->{$tag}, 'ARRAY')) {
      my $names = $self->{$tag};
      if (defined $names) {
        ## We only want to generate default components if we have
        ## defaulted the source files or we have no files listed
        ## in the current special component.
        my $ok = $self->{'defaulted'}->{'source_files'};
        if (!$ok) {
          my @all;
          foreach my $name (keys %$names) {
            foreach my $key (keys %{$$names{$name}}) {
              push(@all, @{$$names{$name}->{$key}});
            }
          }
          $ok = (!defined $all[0]);
        }
        if ($ok) {
          ## If the "special" type was supplied and it was all
          ## directories, we need to use those directories to generate
          ## the default components instead of the current directory.
          my $fileref = \@files;
          if (defined $self->{'special_supplied'}->{$tag} &&
              UNIVERSAL::isa($self->{'special_supplied'}->{$tag}, 'ARRAY')) {
            my @special;
            foreach my $dir (@{$self->{'special_supplied'}->{$tag}}) {
              push(@special, $self->generate_default_file_list(
                                         $dir, [], undef,
                                         $self->get_assignment('recurse')));
            }
            $fileref = \@special;
          }
          $self->generate_default_components($fileref, $tag);
        }
      }
    }
  }

  ## Now that all of the other files have been added
  ## we need to remove those that have need to be removed
  my @rmkeys = keys %{$self->{'remove_files'}};
  $self->remove_excluded(@rmkeys) if (defined $rmkeys[0]);

  ## Tie custom files together if need be.  This currently only applies
  ## to types with command helpers.  At some point, if it is found to be
  ## desirous, we could extend the MPC syntax somehow to support this
  ## sort of thing manually.
  my $dep = 'dependent';
  foreach my $gentype (@gvc) {
    my $cmdHelper = CommandHelper::get($gentype);
    if (defined $cmdHelper) {
      ## There has to be at least two files files in order for
      ## something to be tied together.
      my @files = $self->get_component_list($gentype, 1);
      if ($#files >= 1) {
        foreach my $file (@files) {
          my $part = $self->remove_wanted_extension(
                            $file, $self->{'valid_components'}->{$gentype});
          my($tied, $vc) = $cmdHelper->get_tied($file, \@files);
          foreach my $tie (@$tied) {
            my @gen;
            if (!defined $vc) {
              foreach $vc (@vc) {
                @gen = $self->generated_filenames($part, $gentype,
                                                  $vc, $file);
                last if ($#gen >= 0);
              }
            }

            ## We have a tied file, now we need to actually perform
            ## the tieing of the two.  We will do this by saying that
            ## the output of the original is necessary for the
            ## processing of the tied file.
            @gen = $self->generated_filenames($part, $gentype,
                                              $vc, $file) if (!$gen[0]);

            ## We have found a set of files that are generated
            ## based on the component type of the original file
            ## ($gentype), so we just add the first one and
            ## we're done.
            my $first = $gen[0];
            $self->{'flag_overrides'}->{$gentype}->{$tie}->{$dep} =
              $self->{'generated_exts'}->{$gentype}->{$dep}
              if (!defined $self->{'flag_overrides'}->{$gentype}->{$tie}->{$dep});

            $self->{'flag_overrides'}->{$gentype}->{$tie}->{$dep} .= " $first"
            if (!defined $self->{'flag_overrides'}->{$gentype}->{$tie}->{$dep} ||
                $self->{'flag_overrides'}->{$gentype}->{$tie}->{$dep} !~ /\b$first\b/);
          }
        }
      }
    }
  }
}


sub set_project_name {
  my($self, $name) = @_;

  ## Save the unmodified project name so that when we
  ## need to determine the default target name, we can use
  ## what is expected by the user.
  $self->{'unmodified_project_name'} = $name;

  ## If we are applying the name modifier to the project
  ## then we will modify the project name
  if ($self->get_apply_project()) {
    my $nmod = $self->get_name_modifier();

    if (defined $nmod) {
      $nmod =~ s/\*/$name/g;
      $name = $nmod;
    }
  }

  ## Set the project_name assignment so that the TemplateParser
  ## can get the project name.
  $self->process_assignment('project_name', $name);
}


sub project_name {
  return $_[0]->get_assignment('project_name');
}


sub lib_target {
  my $self = shift;
  return (defined $self->get_assignment('sharedname') ||
          defined $self->get_assignment('staticname'));
}


sub exe_target {
  return (defined $_[0]->get_assignment('exename'));
}


sub get_component_list {
  my($self, $tag, $noconvert) = @_;
  my $names = $self->{$tag};
  my @list;

  foreach my $name (keys %$names) {
    foreach my $key (keys %{$$names{$name}}) {
      push(@list, @{$$names{$name}->{$key}});
    }
  }

  ## By default, if 'convert_slashes' is true, then we convert slashes
  ## to backslashes.  There are cases where we do not want to convert
  ## the slashes, in that case get_component_list() was called with
  ## an additional parameter indicating this.
  if (!$noconvert && $self->{'convert_slashes'}) {
    foreach my $item (@list) {
      $item =~ s/\//\\/g;
    }
  }

  if ($self->{'sort_files'}) {
    @list = sort { $self->file_sorter($a, $b) } @list;
  }

  return @list;
}


sub check_custom_output {
  my($self, $based, $cinput, $ainput, $type, $comps) = @_;
  my @outputs;

  foreach my $array ($self->generated_filenames($cinput, $based,
                                                $type, $ainput, 0, 1)) {
    foreach my $built (@$array) {
      if (@$comps == 0) {
        push(@outputs, $built);
        last;
      }
      elsif (defined $specialComponents{$type} &&
             (!$self->{'special_supplied'}->{$type} ||
              UNIVERSAL::isa($self->{'special_supplied'}->{$type}, 'ARRAY'))) {
        push(@outputs, $built);
        last;
      }
      else {
        my $base = $built;
        $base =~ s/\\/\//g if ($self->{'convert_slashes'});
        my $re = $self->escape_regex_special($self->mpc_basename($base));
        foreach my $c (@$comps) {
          ## We only match if the built file name matches from
          ## beginning to end or from a slash to the end.
          if ($c =~ /^$re$/ || $c =~ /[\/\\]$re$/) {
            push(@outputs, $built);
            last;
          }
        }
      }
    }
  }

  return @outputs;
}


sub get_special_value {
  my $self   = shift;
  my $type   = shift;
  my $cmd    = shift;
  my $based  = shift;
  my @params = @_;

  ## These names (held in $type) are variables that contain various
  ## commands that will be used in templates within the context of a
  ## foreach (e.g., <%custom_type->input_files%> or <%feature->value%>).
  if ($type eq 'feature') {
    return $self->get_feature_value($cmd, $based);
  }
  elsif (index($type, 'custom_type') == 0) {
    return $self->get_custom_value($cmd, $based, @params);
  }
  elsif (index($type, $grouped_key) == 0) {
    return $self->get_grouped_value($type, $cmd, $based);
  }

  return undef;
}


sub get_feature_value {
  my($self, $cmd, $based) = @_;

  if ($cmd eq 'value') {
    my $val = $self->{'feature_parser'}->get_value($based);
    if (defined $val && $val != 0) {
      return 1;
    }
  }

  return undef;
}


sub get_grouped_value {
  my($self, $type, $cmd, $based) = @_;
  my $value;

  ## Make it all lower case
  $type = lc($type);

  ## Remove the grouped_ part
  $type =~ s/^$grouped_key//;

  ## Add the s if it isn't there
  $type .= 's' if ($type !~ /s$/);

  my $names = $self->{$type};
  if ($cmd eq 'files') {
    foreach my $name (keys %$names) {
      my $comps = $$names{$name};
      my @keys = keys %$comps;
      if (StringProcessor::fgrep($based, \@keys)) {
        if ($self->{'convert_slashes'}) {
          my @converted;
          foreach my $file (@{$$comps{$based}}) {
            push(@converted, $self->slash_to_backslash($file));
          }
          $value = \@converted;
        }
        else {
          $value = $$comps{$based};
        }
        if ($self->{'sort_files'}) {
          my @sorted = sort { $self->file_sorter($a, $b) } @$value;
          $value = \@sorted;
        }
      }
    }
  }
  elsif ($cmd eq 'component_name') {
    ## If there is more than one name, then we will need
    ## to deal with that at a later time.
    foreach my $name (keys %$names) {
      $value = $name;
    }
  }

  return $value;
}


sub get_command_subs {
  my $self = shift;
  my %valid;

  ## Add the built-in OS compatibility commands
  if (UNIVERSAL::isa($self, 'WinProjectBase') ||
      $self->use_win_compatibility_commands()) {
    $valid{'cat'}   = 'type';
    $valid{'cmp'}   = 'fc';
    $valid{'cp'}    = 'copy /y';
    $valid{'mkdir'} = 'mkdir';
    $valid{'mv'}    = 'move /y';
    $valid{'os'}    = 'win32';
    $valid{'rm'}    = 'del /f/s/q';
    $valid{'rmdir'} = 'rmdir /s/q';
    $valid{'nul'}   = 'nul';
    $valid{'slash'} = '\\';
    $valid{'bat'}   = '.bat';
    $valid{'cmd'}   = '.cmd';
    $valid{'exe'}   = '.exe';
  }
  else {
    $valid{'cat'}   = 'cat';
    $valid{'cmp'}   = 'cmp';
    $valid{'cp'}    = 'cp -f';
    $valid{'mkdir'} = 'mkdir -p';
    $valid{'mv'}    = 'mv -f';
    $valid{'os'}    = 'unix';
    $valid{'rm'}    = 'rm -rf';
    $valid{'rmdir'} = 'rm -rf';
    $valid{'nul'}   = '/dev/null';
    $valid{'slash'} = '/';
    $valid{'bat'}   = '';
    $valid{'cmd'}   = '';
    $valid{'exe'}   = '';
  }

  ## Add the project specific compatibility commands
  $valid{'gt'}        = $self->get_gt_symbol();
  $valid{'lt'}        = $self->get_lt_symbol();
  $valid{'and'}       = $self->get_and_symbol();
  $valid{'or'}        = $self->get_or_symbol();
  $valid{'quote'}     = $self->get_quote_symbol();
  $valid{'equote'}    = $self->get_escaped_quote_symbol();
  $valid{'crlf'}      = $self->crlf();
  $valid{'cmdsep'}    = $self->get_cmdsep_symbol();
  $valid{'temporary'} = 'temp.$$$$.' . int(rand(0xffffffff));
  $valid{'prj_type'}  = $self->{'pctype'};

  return \%valid;
}


sub replace_parameters {
  my($self, $str, $valid, $nowarn, $input, $output, $always_clear) = @_;

  my %saved;
  my $count = 0;
  while ($str =~ /<%(\w+)(\(\w+\))?%>/) {
    my $name     = $1;
    my $modifier = $2;
    if (defined $modifier) {
      my $tmp = $name;
      $name = $modifier;
      $name =~ s/[\(\)]//g;
      $modifier = $tmp;
    }

    ## Support both pseudo variables and project settings
    if (defined $$valid{$name} || $self->is_keyword($name)) {
      ## If the pseudo variable is defined or the project setting has a
      ## value, then we'll need to do the replacement.  However, if it's
      ## a project keyword and it's not defined, we will need to delay
      ## the replacement until later (unless $always_clear is true).
      my $replace;
      my $clear = $always_clear;
      if (defined $$valid{$name}) {
        $replace = $$valid{$name};
      }
      elsif ($self->is_keyword($name)) {
        $replace = $self->get_assignment($name);
      }

      ## Perform the modification and replacement here
      if (defined $replace) {
        if (defined $modifier) {
          if ($modifier eq 'noextension') {
            $replace =~ s/\.[^\.]+$//;
          }
          else {
            $self->warning("Unknown parameter modifier $modifier.");
          }
        }
        $str =~ s/<%\w+(\(\w+\))?%>/$replace/;
      }
      elsif ($clear) {
        ## We need to clear out this variable usage.
        $str =~ s/<%\w+(\(\w+\))?%>//;
      }
      else {
        ## Save this variable usage to be put back after we're done
        ## processing the string.
        my $key = "\1" . $count++ . "\1";
        if ($str =~ s/(<%\w+(\(\w+\))?%>)/$key/) {
          $saved{$key} = $1;
        }
      }
    }
    else {
      $str =~ s/<%\w+(\(\w+\))?%>//;

      ## We only want to warn the user that we did not recognize the
      ## pseudo template parameter if there was an input and an output
      ## file passed to this function.  If this variable was used
      ## without the parenthesis (as in an if statement), then we don't
      ## want to warn the user.
      if (defined $input && defined $output) {
        if (!defined $$nowarn{$name}) {
          $self->warning("<%$name%> was not recognized.");
        }

        ## If we didn't recognize the pseudo template parameter then
        ## we don't want to return anything back.
        return undef;
      }
    }
  }

  ## Replace the saved variables so that they may be replaced (or
  ## removed) later on.
  foreach my $key (keys %saved) {
    $str =~ s/$key/$saved{$key}/;
  }
  return $str;
}


sub convert_command_parameters {
  my($self, $ktype, $str, $input, $output) = @_;
  my %nowarn;
  my %valid = %{$self->{'command_subs'}};

  ## Add in the values that change for every call to this function
  $valid{'temporary'} = 'temp.$$$$.' . int(rand(0xffffffff));

  if (defined $input) {
    $valid{'input'}          = $input;
    $valid{'input_basename'} = $self->mpc_basename($input);
    $valid{'input_dirname'}  = $self->mpc_dirname($input);
    $valid{'input_noext'}    = $input;

    ## An input file doesn't always have an extension.  If there isn't
    ## one, then we need to set the 'input_ext' field to an empty string
    ## ($1 will not necessarily have a valid value).
    if ($valid{'input_noext'} =~ s/(\.[^\.]+)$//) {
      $valid{'input_ext'} = $1;
    }
    else {
      $valid{'input_ext'} = '';
    }

    ## Check for the gendir setting associated with this input file.  We
    ## have to check at so many levels so we don't inadvertantly create
    ## intermediate hash tables.
    if (defined $self->{'flag_overrides'}->{$ktype} &&
        defined $self->{'flag_overrides'}->{$ktype}->{$input} &&
        $self->{'flag_overrides'}->{$ktype}->{$input}->{'gendir'}) {
      $valid{'gendir'} = $self->{'flag_overrides'}->{$ktype}->{$input}->{'gendir'};
    }
  }

  ## If there is no gendir setting, just set it to the current directory.
  $valid{'gendir'} = '.' if (!defined $valid{'gendir'});

  if (defined $output) {
    my $first = 1;
    $valid{'output'} = "@$output";
    foreach my $out (@$output) {
      ## An output file doesn't always have an extension.  If there isn't
      ## one, then we need to set the 'output_ext' field to an empty
      ## string ($1 will not necessarily have a valid value).
      my $noext = $out;
      if ($noext =~ s/(\.[^\.]+)$//) {
        $valid{'output_ext'} = $1;
      }
      else {
        $valid{'output_ext'} = '';
      }
      $valid{'output_noext'} .= (!$first ? ' ' : '') . $noext;

      ## In order to call basename or dirname, we must make sure that the
      ## directory separators are forward slashes.
      my $file = $out;
      $file =~ s/\\/\//g if ($self->{'convert_slashes'});
      $valid{'output_basename'} .= (!$first ? ' ' : '') .
                                   $self->mpc_basename($file);
      $valid{'output_dirname'}  .= (!$first ? ' ' : '') .
                                   $self->mpc_dirname($file);
      $first = 0;
    }
  }

  ## Add in the specific types of output files
  if (defined $output) {
    foreach my $type (keys %{$self->{'valid_components'}}) {
      my $key = $type;
      $key =~ s/s$//gi;
      $nowarn{$key} = 1;
      $nowarn{$key . '_noext'} = 1;
      foreach my $ext (@{$self->{'valid_components'}->{$type}}) {
        foreach my $out (@$output) {
          if ($out =~ /$ext$/) {
            $valid{$key} = $out;
            $valid{$key . '_noext'} = $out;
            $valid{$key . '_noext'} =~ s/$ext$//;
            last;
          }
        }
      }
    }
  }

  return $self->replace_parameters($str, \%valid, \%nowarn, $input, $output, 1);
}


sub get_custom_value {
  my $self   = shift;
  my $cmd    = shift;
  my $based  = shift;
  my @params = @_;
  my $value;

  if ($cmd eq 'input_files') {
    ## Get the component list for the component type
    my @array = $self->get_component_list($based);

    ## Check for directories in the component list.  If the component
    ## type is not automatic, we may have directories here and will need
    ## to get the file list for that type.
    my $once;
    for(my $i = 0; $i < scalar(@array); ++$i) {
      if (-d $array[$i]) {
        if (!defined $once) {
          $once = {'recurse' => $self->get_assignment('recurse'),
                   'pchh'    => $self->get_assignment('pch_header'),
                   'pchc'    => $self->get_assignment('pch_source'),
                  };
        }
        my @built;
        $self->sift_default_file_list($based, $array[$i], \@built,
                                      $self->{'valid_components'}->{$based},
                                      $$once{'recurse'},
                                      $$once{'pchh'}, $$once{'pchc'});
        splice(@array, $i, 1, @built);
        $i += $#built;
      }
    }

    $value = \@array;

    $self->{'custom_output_files'} = {};
    my %vcomps;
    foreach my $vc (keys %{$self->{'valid_components'}}) {
      my @comps = $self->get_component_list($vc);
      $vcomps{$vc} = \@comps;
    }
    $vcomps{$generic_key} = [];

    foreach my $input (@array) {
      my @outputs;
      my $ainput = $input;
      my $cinput = $input;

      ## Remove the extension
      $cinput =~ s/\.[^\.]+$//;

      ## If we are converting slashes,
      ## change them back for this parameter
      $ainput =~ s/\\/\//g if ($self->{'convert_slashes'});

      ## Add all of the output files.  We can not add $generic_key to the
      ## list here (as it used to be).  It may have been handled by
      ## generated_filenames.
      foreach my $vc (keys %{$self->{'valid_components'}}) {
        ## The output of multiple components could be input for the
        ## current component type ($based).  We need to avoid adding
        ## duplicates here.
        foreach my $file ($self->check_custom_output(
                            $based, $cinput, $ainput, $vc, $vcomps{$vc})) {
          push(@outputs, $file) if (!StringProcessor::fgrep($file, \@outputs));
        }
      }
      foreach my $file ($self->check_custom_output($based, $cinput,
                                                   $ainput, $generic_key,
                                                   $vcomps{$generic_key})) {
        push(@outputs, $file) if (!StringProcessor::fgrep($file, \@outputs));
      }

      ## Add specially listed files avoiding duplicates.  We don't want
      ## to add these files if gendir is set to something besides .
      if (defined $self->{'custom_special_output'}->{$based} &&
          defined $self->{'custom_special_output'}->{$based}->{$ainput} &&
          (!defined $self->{'flag_overrides'}->{$based} ||
           !defined $self->{'flag_overrides'}->{$based}->{$ainput} ||
           !defined $self->{'flag_overrides'}->{$based}->{$ainput}->{'gendir'} ||
           $self->{'flag_overrides'}->{$based}->{$ainput}->{'gendir'} eq '.')) {
        foreach my $file (@{$self->{'custom_special_output'}->{$based}->{$ainput}}) {
          push(@outputs, $file) if (!StringProcessor::fgrep($file, \@outputs));
        }
      }

      if ($self->{'convert_slashes'}) {
        foreach my $output (@outputs) {
          $output =~ s/\//\\/g;
        }
      }
      if ($self->{'sort_files'}) {
        @outputs = sort { $self->file_sorter($a, $b) } @outputs;
      }
      $self->{'custom_output_files'}->{$input} = \@outputs;
    }
  }
  elsif ($cmd eq 'output_files') {
    # Generate output files based on $based
    if (defined $self->{'custom_output_files'}) {
      $value = $self->{'custom_output_files'}->{$based};
    }
  }
  elsif ($cmd eq 'source_output_files') {
    # Generate source output files based on $based
    if (defined $self->{'custom_output_files'}) {
      $value = [];
      foreach my $file (@{$self->{'custom_output_files'}->{$based}}) {
        foreach my $ext (@{$self->{'valid_components'}->{'source_files'}}) {
          if ($file =~ /$ext$/) {
            ## We've found a file that matches one of the source file
            ## extensions.  Now we have to make sure that it doesn't
            ## match a template file extension.
            my $matched = 0;
            foreach my $text (@{$self->{'valid_components'}->{'template_files'}}) {
              if ($file =~ /$text$/) {
                $matched = 1;
                last;
              }
            }
            push(@$value, $file) if (!$matched);
            last;
          }
        }
      }
    }
  }
  elsif ($cmd eq 'non_source_output_files') {
    # Generate non source output files based on $based
    if (defined $self->{'custom_output_files'}) {
      $value = [];
      foreach my $file (@{$self->{'custom_output_files'}->{$based}}) {
        my $source = 0;
        foreach my $ext (@{$self->{'valid_components'}->{'source_files'}}) {
          if ($file =~ /$ext$/) {
            $source = 1;
            ## We've found a file that matches one of the source file
            ## extensions.  Now we have to make sure that it doesn't
            ## match a template file extension.
            foreach my $text (@{$self->{'valid_components'}->{'template_files'}}) {
              if ($file =~ /$text$/) {
                $source = 0;
                last;
              }
            }
            last if ($source);
          }
        }
        push(@$value, $file) if (!$source);
      }
    }
  }
  elsif ($cmd eq 'inputexts') {
    my @array = @{$self->{'valid_components'}->{$based}};
    foreach my $val (@array) {
      $val =~ s/\\\.//g;
    }
    $value = \@array;
  }
  elsif ($cmd eq 'dependencies') {
    ## If we are converting slashes, change them back for this parameter
    $based =~ s/\\/\//g if ($self->{'convert_slashes'});
    $value = $self->{'custom_special_depend'}->{$based};
  }
  elsif (defined $customDefined{$cmd}) {
    $value = $self->get_assignment($cmd,
                                   $self->{'generated_exts'}->{$based});
    if (defined $value && ($customDefined{$cmd} & 0x14) != 0) {
      $value = $self->convert_command_parameters($based, $value, @params);
    }
  }

  return $value;
}


sub check_features {
  my($self, $requires, $avoids, $info) = @_;
  my $status = 1;
  my $why;

  if (defined $requires) {
    foreach my $require (split(/\s+/, $requires)) {
      my $fval = $self->{'feature_parser'}->get_value($require);

      ## By default, if the feature is not listed, then it is enabled.
      if (defined $fval && !$fval) {
        $why = "requires $require";
        $status = 0;
        last;
      }

      ## For automakes sake, if we're to this point the feature is
      ## enabled and we will set it in the feature parser explicitly
      if (!defined $fval) {
        $self->{'feature_parser'}->parse_line(undef, "$require = 1");
      }
    }
  }

  ## If it passes the requires, then check the avoids
  if ($status) {
    if (defined $avoids) {
      foreach my $avoid (split(/\s+/, $avoids)) {
        my $fval = $self->{'feature_parser'}->get_value($avoid);

        ## By default, if the feature is not listed, then it is enabled.
        if (!defined $fval || $fval) {
          $why = "avoids $avoid";
          $status = 0;
          last;
        }
      }
    }
  }

  if ($info && !$status) {
    $self->details("Skipping " . $self->get_assignment('project_name') .
                   " ($self->{'current_input'}), it $why.");
  }

  return $status;
}


sub need_to_write_project {
  my $self  = shift;
  my $count = 0;

  ## We always write a project if the user has provided a verbatim.
  ## We have no idea what that verbatim clause does, so we need to just
  ## do what the user tells us to do.
  return 1 if (defined $self->{'verbatim'}->{$self->{'pctype'}});

  ## The order here is important, we must check for source or resource
  ## files first and then for custom input files.
  foreach my $key ('source_files', $self->get_resource_tag(),
                   keys %{$self->{'generated_exts'}}) {
    my $names = $self->{$key};
    foreach my $name (keys %$names) {
      foreach my $key (keys %{$names->{$name}}) {
        ## See if the project contains a file that corresponds to this
        ## component name.
        if (defined $names->{$name}->{$key}->[0]) {
          if ($count >= 2) {
            ## Return 2 if we have found a custom input file (and thus no
            ## source or resource files due to the foreach order).
            return 2;
          }
          ## We have either source files or resource files, we need to
          ## see if this project creator supports the current language.
          ## If it doesn't then we don't need to create the project.
          elsif ($self->languageSupported()) {
            ## Return 1 if we have found a source file or a resource file.
            return 1;
          }
        }
      }
    }
    $count++;
  }

  ## Indicate that there is no need to write the project
  return 0;
}


sub write_output_file {
  my($self, $webapp) = @_;
  my $status = 0;
  my $error;
  my $tover = $self->get_template_override();
  my @templates = $self->get_template();

  ## The template override will override all templates
  @templates = ($tover) if (defined $tover);

  foreach my $template (@templates) {
    ## Save the template name for use as a key for various function calls
    $self->{'current_template'} = $template;

    ## Create the output file name based on the project name and the
    ## template that we're currently using.
    my $name = $self->transform_file_name(
                  $self->project_file_name(undef,
                                           $self->{'current_template'}));

    ## If the template files does not end in the template extension
    ## then we will add it on.
    if ($template !~ /$TemplateExtension$/) {
      $template .= '.' . $TemplateExtension;
    }

    ## If the template file does not contain a path, then we
    ## will search through the include paths for it.
    my $tfile;
    if ($template =~ /[\/\\]/i) {
      $tfile = $template;
    }
    else {
      $tfile = $self->search_include_path($template);
    }

    if (defined $tfile) {
      ## Read in the template values for the specific target and project
      ## type.  The template input file we get may depend upon the
      ## current template that we're using.
      ($status, $error) = $self->read_template_input(
                                   $self->{'current_template'});
      last if (!$status);

      my $tp = new TemplateParser($self);

      ## Set the project_file assignment for the template parser
      $self->process_assignment('project_file', $name);

      ($status, $error) = $tp->parse_file($tfile);
      last if (!$status);

      if (defined $self->{'source_callback'}) {
        my $cb     = $self->{'source_callback'};
        my $pjname = $self->get_assignment('project_name');
        my @list   = $self->get_component_list('source_files');
        if (UNIVERSAL::isa($cb, 'ARRAY')) {
          my @copy = @$cb;
          my $s = shift(@copy);
          &$s(@copy, $name, $pjname, \@list);
        }
        elsif (UNIVERSAL::isa($cb, 'CODE')) {
          &$cb($name, $pjname, \@list);
        }
        else {
          $self->warning("Ignoring callback: $cb.");
        }
      }

      if ($self->get_toplevel()) {
        my $outdir = $self->get_outdir();
        my $oname  = $name;

        $name = "$outdir/$name";

        my $fh  = new FileHandle();
        my $dir = $self->mpc_dirname($name);

        mkpath($dir, 0, 0777) if ($dir ne '.');

        if ($webapp) {
          ## At this point in time, webapps do not get a project file,
          ## but they do appear in the workspace
        }
        elsif ($self->compare_output()) {
          ## First write the output to a temporary file
          my $tmp = "$outdir/MPC$>.$$";
          my $different = 1;
          if (open($fh, ">$tmp")) {
            my $lines = $tp->get_lines();
            foreach my $line (@$lines) {
              print $fh $line;
            }
            close($fh);

            $different = 0 if (!$self->files_are_different($name, $tmp));
          }
          else {
            $error = "Unable to open $tmp for output.";
            $status = 0;
            last;
          }

          ## If they are different, then rename the temporary file
          if ($different) {
            unlink($name);
            if (rename($tmp, $name)) {
              $self->post_file_creation($name);
            }
            else {
              $error = "Unable to open $name for output.";
              $status = 0;
              last;
            }
          }
          else {
            ## We will pretend that we wrote the file
            unlink($tmp);
          }
        }
        else {
          if (open($fh, ">$name")) {
            my $lines = $tp->get_lines();
            foreach my $line (@$lines) {
              print $fh $line;
            }
            close($fh);
            $self->post_file_creation($name);
          }
          else {
            $error = "Unable to open $name for output.";
            $status = 0;
            last;
          }
        }

        ## There may be more than one template associated with this
        ## project creator.  If there is, we can only add one generated
        ## file and we rely on the project creator to tell us which
        ## template generates the file that we need to track.
        $self->add_file_written($oname)
                   if ($self->file_visible($self->{'current_template'}));
      }
    }
    else {
      $error = "Unable to locate the template file: $template.";
      $status = 0;
      last;
    }
  }
  return $status, $error;
}


sub write_install_file {
  my $self = shift;
  my $fh = new FileHandle();
  my $insfile = $self->transform_file_name(
                          $self->get_assignment('project_name')) .
                '.ins';
  my $outdir = $self->get_outdir();

  $insfile = "$outdir/$insfile";

  unlink($insfile);
  if (open($fh, ">$insfile")) {
    foreach my $vc (keys %{$self->{'valid_components'}}) {
      my $names = $self->{$vc};
      foreach my $name (keys %$names) {
        foreach my $key (keys %{$$names{$name}}) {
          my $array = $$names{$name}->{$key};
          if (defined $$array[0]) {
            print $fh "$vc:\n";
            foreach my $file (@$array) {
              print $fh "$file\n";
            }
            print $fh "\n";
          }
        }
      }
    }
    if ($self->exe_target()) {
      my $exeout = $self->get_assignment('exeout');
      print $fh "exe_output:\n",
                (defined $exeout ? $self->relative($exeout) : ''),
                ' ', $self->get_assignment('exename'), "\n";
    }
    elsif ($self->lib_target()) {
      my $shared = $self->get_assignment('sharedname');
      my $static = $self->get_assignment('staticname');
      my $dllout = $self->relative($self->get_assignment('dllout'));
      my $libout = $self->relative($self->get_assignment('libout'));

      print $fh "lib_output:\n";

      if (defined $shared && $shared ne '') {
        print $fh (defined $dllout ? $dllout : $libout), " $shared\n";
      }
      if ((defined $static && $static ne '') &&
          (defined $dllout || !defined $shared ||
               (defined $shared && $shared ne $static))) {
        print $fh "$libout $static\n";
      }
    }

    close($fh);
    return 1, undef;
  }

  return 0, 'Unable write to ' . $insfile;
}


sub write_project {
  my $self = shift;
  my $status = 2;
  my $error;
  my $progress = $self->get_progress_callback();

  &$progress() if (defined $progress);

  if ($self->check_features($self->get_assignment('requires'),
                            $self->get_assignment('avoids'),
                            1)) {
    my $webapp = $self->get_assignment('webapp');
    my $ntwp = $self->need_to_write_project();
    if ($webapp || $ntwp) {
      if ($webapp && !$self->webapp_supported()) {
        $self->warning("Web Applications are not supported by this type.");
      }
      else {
        ## A return value of 2 from need_to_write_project() indicates
        ## that the only reason that we need to write the project is that
        ## there are custom input files (i.e., no source or resource
        ## files).
        $self->process_assignment('custom_only', '1') if ($ntwp == 2);

        if ($self->get_assignment('custom_only')) {
          $self->remove_non_custom_settings();
        }

        if ($self->{'escape_spaces'}) {
          foreach my $name ('exename', 'sharedname', 'staticname',
                            'exeout', 'dllout', 'libout') {
            my $value = $self->get_assignment($name);
            if (defined $value && $value =~ s/(\s)/\\$1/g) {
              $self->process_assignment($name, $value);
            }
          }
          foreach my $key (keys %{$self->{'valid_components'}}) {
            my $names = $self->{$key};
            foreach my $name (keys %$names) {
              foreach my $key (keys %{$$names{$name}}) {
                foreach my $file (@{$$names{$name}->{$key}}) {
                  $file =~ s/(\s)/\\$1/g;
                }
              }
            }
          }
        }

        ## We don't need to pass a file name here.  write_output_file()
        ## will determine the file name for itself.
        ($status, $error) = $self->write_output_file($webapp);

        ## Write the .ins file if the user requested it and we were
        ## successful.
        if ($self->{'generate_ins'} && $status) {
          ($status, $error) = $self->write_install_file();
        }
      }
    }
    elsif ($self->warn_useless_project()) {
      my $msg = $self->transform_file_name($self->project_file_name()) .
                " has no useful targets.";

      if ($self->{'current_input'} eq '') {
        $self->information($msg);
      }
      else {
        $self->warning($msg);
      }
    }
  }

  return $status, $error;
}


sub get_project_info {
  return $_[0]->{'project_info'};
}


sub get_lib_locations {
  return $_[0]->{'lib_locations'};
}


sub get_inheritance_tree {
  return $_[0]->{'inheritance_tree'};
}


sub set_component_extensions {
  my $self = shift;
  my $vc = $self->{'valid_components'};
  my $ec = $self->{'exclude_components'};

  foreach my $key (keys %$vc) {
    my $ov = $self->override_valid_component_extensions($key,
                                                        @{$$vc{$key}});
    $$vc{$key} = $ov if (defined $ov);
  }

  foreach my $key (keys %$ec) {
    my $ov = $self->override_exclude_component_extensions($key,
                                                          @{$$ec{$key}});
    $$ec{$key} = $ov if (defined $ov);
  }
}


sub get_component_extensions {
  my($self, $comp) = @_;
  my @ext;
  if (defined $self->{'valid_components'}->{$comp}) {
    ## Build up an array of extensions.  Since they are stored as regular
    ## expressions, we need to remove the escaped period to provide the
    ## minimal amount of text for each extension to provide maximum
    ## flexibility within the project template.
    foreach my $re (@{$self->{'valid_components'}->{$comp}}) {
      push(@ext, $re);
      $ext[$#ext] =~ s/\\\.//;
    }
  }
  return @ext;
}


sub set_source_listing_callback {
  my($self, $cb) = @_;
  $self->{'source_callback'} = $cb;
}


sub reset_values {
  my $self = shift;

  ## Only put data structures that need to be cleared
  ## out when the mpc file is done being read, not at the
  ## end of each project within the mpc file.  Those go in
  ## the closing curly brace section of parse_line().
  $self->{'project_info'}  = [];
  $self->{'lib_locations'} = {};
  $self->reset_generating_types();
}


sub add_default_matching_assignments {
  my $self = shift;
  my $lang = $self->get_language();

  foreach my $key (keys %{$language{$lang}->[0]}) {
    push(@{$language{$lang}->[2]->{$key}}, @default_matching_assignments)
      if (!StringProcessor::fgrep($default_matching_assignments[0],
                                  $language{$lang}->[2]->{$key}));
  }
}


sub reset_generating_types {
  my $self  = shift;
  my $lang  = $self->get_language();
  my %reset = ('valid_components'     => $language{$lang}->[0],
               'custom_only_removed'  => $language{$lang}->[0],
               'exclude_components'   => $language{$lang}->[1],
               'matching_assignments' => $language{$lang}->[2],
               'generated_exts'       => {},
               'valid_names'          => \%validNames,
              );

  foreach my $r (keys %reset) {
    $self->{$r} = {};
    foreach my $key (keys %{$reset{$r}}) {
      $self->{$r}->{$key} = $reset{$r}->{$key};
    }
  }

  $self->{'custom_types'} = {};

  ## Allow subclasses to override the default extensions
  $self->set_component_extensions();
}


sub get_template_input {
  my $self = shift;
  my $lang = $self->get_language();

  ## This follows along the same logic as read_template_input() by
  ## checking for exe target and then defaulting to a lib target
  if ($self->exe_target()) {
    if ($self->get_static() == 1) {
      return $self->{'lib_exe_template_input'}->{$lang}->{$tikey};
    }
    else {
      return $self->{'dll_exe_template_input'}->{$lang}->{$tikey};
    }
  }

  if ($self->get_static() == 1) {
    return $self->{'lib_template_input'}->{$lang}->{$tikey};
  }

  return $self->{'dll_template_input'}->{$lang}->{$tikey};
}


sub update_project_info {
  my($self, $tparser, $append, $names, $sep) = @_;
  my $value = '';
  $sep = '' if (!defined $sep);

  ## Append the values of all names into one string
  my $ncount = scalar(@$names) - 1;
  for(my $i = 0; $i <= $ncount; $i++) {
    $value .= $self->translate_value(
                               $$names[$i],
                               $tparser->get_value_with_default($$names[$i]));
    $value .= $sep if ($i != $ncount);
  }

  ## There may be more than one template associated with this project
  ## creator.  If there is, we can only add one generated file and we
  ## rely on the project creator to tell us which template generates the
  ## file that we need to track.
  if ($self->file_visible($self->{'current_template'})) {
    ## If we already have an array, take the one off the top.  Otherwise,
    ## create a new one which will be added below.
    my $arr = ($append && defined $self->{'project_info'}->[0] ?
                            pop(@{$self->{'project_info'}}) : []);

    ## Set up the hash table when we are starting a new project_info
    $self->{'project_info_hash_table'} = {}  if (!$append);

    ## If we haven't seen this value yet, put it on the array
    if (!defined $self->{'project_info_hash_table'}->{"@$names $value"}) {
      $self->{'project_info_hash_table'}->{"@$names $value"} = 1;
      push(@$arr, $value);
    }

    ## Always push the array back onto the project_info
    push(@{$self->{'project_info'}}, $arr);
  }

  return $value;
}


sub adjust_value {
  my($self, $names, $value, $tp) = @_;
  my $atemp = $self->get_addtemp();

  ## Perform any additions, subtractions
  ## or overrides for the template values.
  foreach my $name (@$names) {
    if (defined $name && defined $atemp->{lc($name)}) {
      my $lname = lc($name);
      my $base  = $lname;
      $base =~ s/.*:://;

      ## If the template variable is a complex name, then we need to make
      ## sure that the mapped value belongs to the correct type based on
      ## the base of the complex name.  The $tp (TemplateParser) variable
      ## will, in the majority of all calls to this method, be defined so
      ## it is checked second to avoid checking it if the name isn't
      ## complex.
      if ($base =~ /(.+)\->/ && defined $tp) {
        my $v = $tp->get_value($1);
        if (defined $v) {
          my $found = undef;
          foreach my $val (@{$atemp->{$lname}}) {
            if (defined $$val[3]) {
              my $mapped = $self->{'valid_names'}->{$$val[3]};
              if (defined $mapped && UNIVERSAL::isa($mapped, 'ARRAY')) {
                $found = 1 if ($v ne $$mapped[0]);
              }
              last;
            }
          }
          next if ($found);
        }
      }

      my $replace = (defined $self->{'valid_names'}->{$base} &&
                     ($self->{'valid_names'}->{$base} & 0x04) == 0);
      foreach my $val (@{$atemp->{$lname}}) {
        if ($replace && index($$val[1], '<%') >= 0) {
          $$val[1] = $self->replace_parameters($$val[1],
                                               $self->{'command_subs'});
        }
        my $arr = $self->create_array($$val[1]);
        if ($$val[0] > 0) {
          if (!defined $value) {
            $value = '';
          }
          if (UNIVERSAL::isa($value, 'ARRAY')) {
            ## Avoid adding duplicates.  If the existing array contains
            ## the value already, remove it from the newly created array.
            for(my $i = 0; $i < scalar(@$value); $i++) {
              if (StringProcessor::fgrep($$value[$i], $arr)) {
                splice(@$value, $i, 1);
                $i--;
              }
            }

            ## We need to make $value a new array reference ($arr)
            ## to avoid modifying the array reference pointed to by $value
            unshift(@$arr, @$value);
            $value = $arr;
          }
          else {
            $value .= " $$val[1]";
          }
        }
        elsif ($$val[0] < 0) {
          if (defined $value) {
            my $parts;
            if (UNIVERSAL::isa($value, 'ARRAY')) {
              $parts = $value;
            }
            else {
              $parts = $self->create_array($value);
            }

            $value = [];
            foreach my $part (@$parts) {
              if ($part ne '') {
                push(@$value, $part) if (!StringProcessor::fgrep($part, $arr));
              }
            }
          }
        }
        else {
          ## If the user set the variable to empty, then we need to
          ## set the value to undef
          $value = (defined $$arr[0] ? $arr : undef);
        }
      }
      last;
    }
  }

  return $value;
}


sub get_verbatim {
  my($self, $marker) = @_;
  my $str;
  my $thash = $self->{'verbatim'}->{$self->{'pctype'}};

  if (defined $thash) {
    if (defined $thash->{$marker}) {
      my $crlf = $self->crlf();
      foreach my $line (@{$thash->{$marker}}) {
        $str = '' if (!defined $str);
        $str .= $self->process_special($line) . $crlf;
      }
      if (defined $str) {
        $str .= $crlf;
        $self->{'verbatim_accessed'}->{$self->{'pctype'}}->{$marker} = 1;
      }
    }
  }

  return $str;
}


sub generate_recursive_input_list {
  my($self, $dir, $exclude) = @_;
  return $self->extension_recursive_input_list($dir,
                                               $exclude,
                                               $ProjectCreatorExtension);
}


sub get_modified_project_file_name {
  my($self, $name, $ext) = @_;
  my $nmod = $self->get_name_modifier();

  ## We don't apply the name modifier to the project file
  ## name if we have already applied it to the project name
  ## since the project file name comes from the project name.
  if (defined $nmod && !$self->get_apply_project()) {
    $nmod =~ s/\*/$name/g;
    $name = $nmod;
  }
  return "$name$ext";
}


sub get_valid_names {
  return $_[0]->{'valid_names'};
}


sub get_feature_parser {
  return $_[0]->{'feature_parser'};
}


sub preserve_assignment_order {
  my($self, $name) = @_;
  my $mapped = $self->{'valid_names'}->{$name};

  ## Only return the value stored in the valid_names hash map if it's
  ## defined and it's not an array reference.  The array reference is
  ## a keyword mapping and all mapped keywords should have preserved
  ## assignment order.
  if (defined $mapped && !UNIVERSAL::isa($mapped, 'ARRAY')) {
    return ($mapped & 1);
  }

  return 1;
}


sub add_to_template_input_value {
  my($self, $name) = @_;
  my $mapped = $self->{'valid_names'}->{$name};

  ## Only return the value stored in the valid_names hash map if it's
  ## defined and it's not an array reference.  The array reference is
  ## a keyword mapping and no mapped keywords should be added to
  ## template input variables.
  if (defined $mapped && !UNIVERSAL::isa($mapped, 'ARRAY')) {
    return ($mapped & 2);
  }

  return 0;
}


sub dependency_combined_static_library {
  #my $self = shift;
  return defined $ENV{MPC_DEPENDENCY_COMBINED_STATIC_LIBRARY};
}


sub translate_value {
  my($self, $key, $val) = @_;

  if ($key eq 'after' && $val ne '') {
    my $arr = $self->create_array($val);
    $val = '';

    if ($self->require_dependencies()) {
      foreach my $entry (@$arr) {
        if ($self->get_apply_project()) {
          my $nmod = $self->get_name_modifier();
          if (defined $nmod) {
            $nmod =~ s/\*/$entry/g;
            $entry = $nmod;
          }
        }
        $val .= '"' . ($self->dependency_is_filename() ?
                          $self->project_file_name($entry) : $entry) . '" ';
      }
      $val =~ s/\s+$//;
    }
  }
  return $val;
}


sub requires_parameters {
  #my $self = shift;
  #my $name = shift;
  return $custom{$_[1]};
}


sub project_file_name {
  my($self, $name, $template) = @_;

  ## Fill in the name if one wasn't provided
  $name = $self->get_assignment('project_name') if (!defined $name);

  return $self->get_modified_project_file_name(
                                     $self->project_file_prefix() . $name,
                                     $self->project_file_extension());
}


sub remove_non_custom_settings {
  my $self = shift;

  ## Remove any files that may have automatically been added
  ## to this project
  foreach my $key (keys %{$self->{'custom_only_removed'}}) {
    $self->{$key} = {};
  }

  ## Unset the exename, sharedname and staticname
  $self->process_assignment('exename',    undef);
  $self->process_assignment('sharedname', undef);
  $self->process_assignment('staticname', undef);
}


sub remove_wanted_extension {
  my($self, $name, $array) = @_;

  foreach my $wanted (@$array) {
    return $name if ($name =~ s/$wanted$//);
  }

  ## If the user provided file does not match any of the
  ## extensions specified by the custom definition, we need
  ## to remove the extension or else this file will not be
  ## added to the project.
  $name =~ s/\.[^\.]+$//;
  return $name;
}


sub resolve_alias {
  if (index($_[1], 'install') >= 0) {
    my $resolved = $_[1];
    if ($resolved =~ s/(.*::)install$/$1exeout/) {
    }
    elsif ($resolved eq 'install') {
      $resolved = 'exeout';
    }
    return $resolved;
  }
  return $_[1];
}


sub create_feature_parser {
  my($self, $features, $feature) = @_;
  my $gfeature     = $self->{'gfeature_file'};
  my $typefeaturef = (defined $gfeature ?
                              $self->mpc_dirname($gfeature) . '/' : '') .
                     $self->{'pctype'} . '.features';
  $typefeaturef = undef if (! -r $typefeaturef);
  if (defined $feature && $feature !~ /[\/\\]/i) {
    my $searched = $self->search_include_path($feature);
    $feature = $searched if (defined $searched);
  }
  my $fp = new FeatureParser($features,
                             $gfeature,
                             $typefeaturef,
                             $feature);

  my $slo = $fp->get_value($static_libs_feature);
  if (!defined $slo) {
    my $sval = $self->get_static() || 0;
    $fp->parse_line(undef,
                    $static_libs_feature . ' = ' . $sval);
  }

  return $fp;
}


sub restore_state_helper {
  my($self, $skey, $old, $new) = @_;

  if ($skey eq 'feature_file') {
    if ($self->{'features_changed'} ||
        !(!defined $old && !defined $new ||
          (defined $old && defined $new && $old eq $new))) {
      ## Create a new feature parser.  This relies on the fact that
      ## 'features' is restored first in restore_state().
      $self->{'feature_parser'} = $self->create_feature_parser(
                                           $self->get_features(), $new);
      $self->{'features_changed'} = undef;
    }
  }
  elsif ($skey eq 'ti') {
    my $lang = $self->get_language();
    my @keys = keys %$old;
    @keys = keys %$new if (!defined $keys[0]);
    foreach my $key (@keys) {
      if (!defined $$old{$key} || !defined $$new{$key} ||
          $$old{$key} ne $$new{$key}) {
        ## Clear out the template input reader that we're currently set
        ## to use.
        $self->{$key . '_template_input'}->{$lang}->{$tikey} = undef;
      }
    }
  }
  elsif ($skey eq 'features') {
    ## If the user has changed the 'features' setting, then we need to
    ## make sure that we create a new feature parser regardless of
    ## whether or not the feature file has changed.
    $self->{'features_changed'} = ("@$old" ne "@$new");
  }
  elsif ($skey eq 'language') {
    if ($old ne $new) {
      $self->add_default_matching_assignments();
    }
  }
}


sub get_initial_relative_values {
  return $_[0]->{'expanded'}, 1;
}

sub add_main_function {
  my $langmain = shift;

  ## See if a language was supplied.
  if ($langmain =~ /([^:]+):(.+)/) {
    ## If the language supplied is not one that we know about, return an
    ## error message.
    return 'Invalid language: ' . $1 if (!defined $language{$1});

    ## Otherwise, add it to the list for the language.
    push(@{$mains{$1}}, $2);
  }
  else {
    ## No language was supplied, so add the main to all of the languages
    ## that we support.
    foreach my $lang (keys %language) {
      push(@{$mains{$lang}}, $langmain);
    }
  }

  ## Return no error message.
  return undef;
}

sub get_resource_tag {
  my $self = shift;
  my $lang = $self->get_language();

  ## Not all entries in the %language map have a resource tag.
  ## For this, we will just return the tag for C++ since it probably
  ## doesn't really matter anyway.
  return defined $language{$lang}->[5] ? $language{$lang}->[5] : $cppresource;
}

# ************************************************************
# Accessors used by support scripts
# ************************************************************

sub getKeywords {
  return \%validNames;
}

sub getValidComponents {
  my $language = shift;
  return (defined $language{$language} ? $language{$language}->[0] : undef);
}

# ************************************************************
# Virtual Methods To Be Overridden
# ************************************************************

sub languageSupported {
  #my $self = shift;
  return $_[0]->get_language() eq Creator::cplusplus;
}

sub file_visible {
  #my($self, $template) = @_;
  return 1;
}

sub webapp_supported {
  #my $self = shift;
  return 0;
}


sub use_win_compatibility_commands {
  #my $self = shift;
  return $ENV{MPC_USE_WIN_COMMANDS};
}


sub post_file_creation {
  #my $self = shift;
  #my $file = shift;
}


sub escape_spaces {
  #my $self = shift;
  return 0;
}


sub validated_directory {
  my($self, $dir) = @_;
  return $dir;
}

sub get_quote_symbol {
  #my $self = shift;
  return '"';
}

sub get_escaped_quote_symbol {
  #my $self = shift;
  return '\\\"';
}

sub get_gt_symbol {
  #my $self = shift;
  return '>';
}


sub get_lt_symbol {
  #my $self = shift;
  return '<';
}


sub get_and_symbol {
  #my $self = shift;
  return '&&';
}


sub get_or_symbol {
  #my $self = shift;
  return '||';
}


sub get_cmdsep_symbol {
  #my $self = shift;
  return ';';
}


sub dollar_special {
  #my $self = shift;
  return 0;
}


sub expand_variables_from_template_values {
  #my $self = shift;
  return 1;
}


sub require_dependencies {
  #my $self = shift;
  return 1;
}


sub dependency_is_filename {
  #my $self = shift;
  return 1;
}


sub fill_value {
  #my $self = shift;
  #my $name = shift;
  return undef;
}


sub project_file_prefix {
  #my $self = shift;
  return '';
}


sub project_file_extension {
  #my $self = shift;
  return '';
}


sub override_valid_component_extensions {
  #my $self = shift;
  #my $comp = shift;
  return undef;
}


sub override_exclude_component_extensions {
  #my $self = shift;
  #my $comp = shift;
  return undef;
}


sub get_dll_exe_template_input_file {
  #my($self, $tkey) = @_;
  return undef;
}


sub get_lib_exe_template_input_file {
  my($self, $tkey) = @_;
  return $self->get_dll_exe_template_input_file($tkey);
}


sub get_lib_template_input_file {
  my($self, $tkey) = @_;
  return $self->get_dll_template_input_file($tkey);
}


sub get_dll_template_input_file {
  #my($self, $tkey) = @_;
  return undef;
}


sub get_template {
  return $_[0]->{'pctype'};
}

sub requires_forward_slashes {
  return 0;
}

sub warn_useless_project {
  return 1;
}

sub get_properties {
  my $self = shift;
  return {'static' => $self->get_static(),
          $self->get_language() => 1};
}

1;