aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Targets/AutotoolsTarget.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Prebuild/src/Core/Targets/AutotoolsTarget.cs')
-rw-r--r--Prebuild/src/Core/Targets/AutotoolsTarget.cs788
1 files changed, 38 insertions, 750 deletions
diff --git a/Prebuild/src/Core/Targets/AutotoolsTarget.cs b/Prebuild/src/Core/Targets/AutotoolsTarget.cs
index 5dcbb38..485e4dd 100644
--- a/Prebuild/src/Core/Targets/AutotoolsTarget.cs
+++ b/Prebuild/src/Core/Targets/AutotoolsTarget.cs
@@ -66,9 +66,7 @@ POSSIBILITY OF SUCH DAMAGE.
66 66
67#endregion 67#endregion
68using System; 68using System;
69using System.Collections;
70using System.Collections.Generic; 69using System.Collections.Generic;
71using System.Collections.Specialized;
72using System.IO; 70using System.IO;
73using System.Reflection; 71using System.Reflection;
74using System.Text; 72using System.Text;
@@ -81,7 +79,6 @@ using System.Diagnostics;
81using Prebuild.Core.Attributes; 79using Prebuild.Core.Attributes;
82using Prebuild.Core.Interfaces; 80using Prebuild.Core.Interfaces;
83using Prebuild.Core.Nodes; 81using Prebuild.Core.Nodes;
84using Prebuild.Core.Parse;
85using Prebuild.Core.Utilities; 82using Prebuild.Core.Utilities;
86 83
87namespace Prebuild.Core.Targets 84namespace Prebuild.Core.Targets
@@ -170,16 +167,16 @@ namespace Prebuild.Core.Targets
170 XmlDocument autotoolsDoc; 167 XmlDocument autotoolsDoc;
171 XmlUrlResolver xr; 168 XmlUrlResolver xr;
172 System.Security.Policy.Evidence e; 169 System.Security.Policy.Evidence e;
173 Hashtable assemblyPathToPackage = new Hashtable(); 170 readonly Dictionary<string, SystemPackage> assemblyPathToPackage = new Dictionary<string, SystemPackage>();
174 Hashtable assemblyFullNameToPath = new Hashtable(); 171 readonly Dictionary<string, string> assemblyFullNameToPath = new Dictionary<string, string>();
175 Hashtable packagesHash = new Hashtable(); 172 readonly Dictionary<string, SystemPackage> packagesHash = new Dictionary<string, SystemPackage>();
176 readonly List<SystemPackage> packages = new List<SystemPackage>(); 173 readonly List<SystemPackage> packages = new List<SystemPackage>();
177 174
178 #endregion 175 #endregion
179 176
180 #region Private Methods 177 #region Private Methods
181 178
182 private void mkdirDashP(string dirName) 179 private static void mkdirDashP(string dirName)
183 { 180 {
184 DirectoryInfo di = new DirectoryInfo(dirName); 181 DirectoryInfo di = new DirectoryInfo(dirName);
185 if (di.Exists) 182 if (di.Exists)
@@ -193,7 +190,7 @@ namespace Prebuild.Core.Targets
193 di.Create(); 190 di.Create();
194 } 191 }
195 192
196 private void chkMkDir(string dirName) 193 private static void chkMkDir(string dirName)
197 { 194 {
198 System.IO.DirectoryInfo di = 195 System.IO.DirectoryInfo di =
199 new System.IO.DirectoryInfo(dirName); 196 new System.IO.DirectoryInfo(dirName);
@@ -222,13 +219,12 @@ namespace Prebuild.Core.Targets
222 (m_Kernel.CurrentDoc, argList, templateWriter, xr); 219 (m_Kernel.CurrentDoc, argList, templateWriter, xr);
223 } 220 }
224 221
225 string NormalizeAsmName(string name) 222 static string NormalizeAsmName(string name)
226 { 223 {
227 int i = name.IndexOf(", PublicKeyToken=null"); 224 int i = name.IndexOf(", PublicKeyToken=null");
228 if (i != -1) 225 if (i != -1)
229 return name.Substring(0, i).Trim(); 226 return name.Substring(0, i).Trim();
230 else 227 return name;
231 return name;
232 } 228 }
233 229
234 private void AddAssembly(string assemblyfile, SystemPackage package) 230 private void AddAssembly(string assemblyfile, SystemPackage package)
@@ -247,7 +243,7 @@ namespace Prebuild.Core.Targets
247 } 243 }
248 } 244 }
249 245
250 private List<string> GetAssembliesWithLibInfo(string line, string file) 246 private static List<string> GetAssembliesWithLibInfo(string line, string file)
251 { 247 {
252 List<string> references = new List<string>(); 248 List<string> references = new List<string>();
253 List<string> libdirs = new List<string>(); 249 List<string> libdirs = new List<string>();
@@ -278,7 +274,7 @@ namespace Prebuild.Core.Targets
278 return retval; 274 return retval;
279 } 275 }
280 276
281 private List<string> GetAssembliesWithoutLibInfo(string line, string file) 277 private static List<string> GetAssembliesWithoutLibInfo(string line, string file)
282 { 278 {
283 List<string> references = new List<string>(); 279 List<string> references = new List<string>();
284 foreach (string reference in line.Split(' ')) 280 foreach (string reference in line.Split(' '))
@@ -292,7 +288,7 @@ namespace Prebuild.Core.Targets
292 return references; 288 return references;
293 } 289 }
294 290
295 private string ProcessPiece(string piece, string pcfile) 291 private static string ProcessPiece(string piece, string pcfile)
296 { 292 {
297 int start = piece.IndexOf("${"); 293 int start = piece.IndexOf("${");
298 if (start == -1) 294 if (start == -1)
@@ -307,7 +303,7 @@ namespace Prebuild.Core.Targets
307 return ProcessPiece(piece.Replace("${" + variable + "}", interp), pcfile); 303 return ProcessPiece(piece.Replace("${" + variable + "}", interp), pcfile);
308 } 304 }
309 305
310 private string GetVariableFromPkgConfig(string var, string pcfile) 306 private static string GetVariableFromPkgConfig(string var, string pcfile)
311 { 307 {
312 ProcessStartInfo psi = new ProcessStartInfo("pkg-config"); 308 ProcessStartInfo psi = new ProcessStartInfo("pkg-config");
313 psi.RedirectStandardOutput = true; 309 psi.RedirectStandardOutput = true;
@@ -327,7 +323,7 @@ namespace Prebuild.Core.Targets
327 { 323 {
328 // Don't register the package twice 324 // Don't register the package twice
329 string pname = Path.GetFileNameWithoutExtension(pcfile); 325 string pname = Path.GetFileNameWithoutExtension(pcfile);
330 if (packagesHash.Contains(pname)) 326 if (packagesHash.ContainsKey(pname))
331 return; 327 return;
332 328
333 List<string> fullassemblies = null; 329 List<string> fullassemblies = null;
@@ -507,158 +503,6 @@ namespace Prebuild.Core.Targets
507 WriteProject(solution, project); 503 WriteProject(solution, project);
508 } 504 }
509 } 505 }
510 private static string PrependPath(string path)
511 {
512 string tmpPath = Helper.NormalizePath(path, '/');
513 Regex regex = new Regex(@"(\w):/(\w+)");
514 Match match = regex.Match(tmpPath);
515 if (match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
516 {
517 tmpPath = Helper.NormalizePath(tmpPath);
518 }
519 else
520 {
521 tmpPath = Helper.NormalizePath("./" + tmpPath);
522 }
523
524 return tmpPath;
525 }
526
527 private static string BuildReference(SolutionNode solution,
528 ReferenceNode refr)
529 {
530 string ret = "";
531 if (solution.ProjectsTable.ContainsKey(refr.Name))
532 {
533 ProjectNode project =
534 (ProjectNode)solution.ProjectsTable[refr.Name];
535 string fileRef = FindFileReference(refr.Name, project);
536 string finalPath =
537 Helper.NormalizePath(Helper.MakeFilePath(project.FullPath +
538 "/$(BUILD_DIR)/$(CONFIG)/",
539 refr.Name, "dll"),
540 '/');
541 ret += finalPath;
542 return ret;
543 }
544 else
545 {
546 ProjectNode project = (ProjectNode)refr.Parent;
547 string fileRef = FindFileReference(refr.Name, project);
548
549 if (refr.Path != null || fileRef != null)
550 {
551 string finalPath = ((refr.Path != null) ?
552 Helper.NormalizePath(refr.Path + "/" +
553 refr.Name + ".dll",
554 '/') :
555 fileRef
556 );
557 ret += Path.Combine(project.Path, finalPath);
558 return ret;
559 }
560
561 try
562 {
563 //Assembly assem = Assembly.Load(refr.Name);
564 //if (assem != null)
565 //{
566 // int index = refr.Name.IndexOf(",");
567 // if ( index > 0)
568 // {
569 // ret += assem.Location;
570 // //Console.WriteLine("Location1: " + assem.Location);
571 // }
572 // else
573 // {
574 // ret += (refr.Name + ".dll");
575 // //Console.WriteLine("Location2: " + assem.Location);
576 // }
577 //}
578 //else
579 //{
580 int index = refr.Name.IndexOf(",");
581 if (index > 0)
582 {
583 ret += refr.Name.Substring(0, index) + ".dll";
584 //Console.WriteLine("Location3: " + assem.Location);
585 }
586 else
587 {
588 ret += (refr.Name + ".dll");
589 //Console.WriteLine("Location4: " + assem.Location);
590 }
591 //}
592 }
593 catch (System.NullReferenceException e)
594 {
595 e.ToString();
596 int index = refr.Name.IndexOf(",");
597 if (index > 0)
598 {
599 ret += refr.Name.Substring(0, index) + ".dll";
600 //Console.WriteLine("Location5: " + assem.Location);
601 }
602 else
603 {
604 ret += (refr.Name + ".dll");
605 //Console.WriteLine("Location6: " + assem.Location);
606 }
607 }
608 }
609 return ret;
610 }
611
612 private static string BuildReferencePath(SolutionNode solution,
613 ReferenceNode refr)
614 {
615 string ret = "";
616 if (solution.ProjectsTable.ContainsKey(refr.Name))
617 {
618 ProjectNode project =
619 (ProjectNode)solution.ProjectsTable[refr.Name];
620 string finalPath =
621 Helper.NormalizePath(Helper.MakeReferencePath(project.FullPath +
622 "/${build.dir}/"),
623 '/');
624 ret += finalPath;
625 return ret;
626 }
627 else
628 {
629 ProjectNode project = (ProjectNode)refr.Parent;
630 string fileRef = FindFileReference(refr.Name, project);
631
632 if (refr.Path != null || fileRef != null)
633 {
634 string finalPath = ((refr.Path != null) ?
635 Helper.NormalizePath(refr.Path, '/') :
636 fileRef
637 );
638 ret += finalPath;
639 return ret;
640 }
641
642 try
643 {
644 Assembly assem = Assembly.Load(refr.Name);
645 if (assem != null)
646 {
647 ret += "";
648 }
649 else
650 {
651 ret += "";
652 }
653 }
654 catch (System.NullReferenceException e)
655 {
656 e.ToString();
657 ret += "";
658 }
659 }
660 return ret;
661 }
662 506
663 private static string FindFileReference(string refName, 507 private static string FindFileReference(string refName,
664 ProjectNode project) 508 ProjectNode project)
@@ -831,7 +675,7 @@ namespace Prebuild.Core.Targets
831 } 675 }
832 catch 676 catch
833 { 677 {
834 Console.WriteLine("Error! '{0}'", e.ToString()); 678 Console.WriteLine("Error! '{0}'", e);
835 } 679 }
836 680
837 } 681 }
@@ -865,7 +709,7 @@ namespace Prebuild.Core.Targets
865 // Set up references 709 // Set up references
866 for (int refNum = 0; refNum < project.References.Count; refNum++) 710 for (int refNum = 0; refNum < project.References.Count; refNum++)
867 { 711 {
868 ReferenceNode refr = (ReferenceNode)project.References[refNum]; 712 ReferenceNode refr = project.References[refNum];
869 Assembly refAssembly = Assembly.LoadWithPartialName(refr.Name); 713 Assembly refAssembly = Assembly.LoadWithPartialName(refr.Name);
870 714
871 /* Determine which pkg-config (.pc) file refers to 715 /* Determine which pkg-config (.pc) file refers to
@@ -873,25 +717,28 @@ namespace Prebuild.Core.Targets
873 717
874 SystemPackage package = null; 718 SystemPackage package = null;
875 719
876 if (packagesHash.Contains(refr.Name)){ 720 if (packagesHash.ContainsKey(refr.Name))
877 package = (SystemPackage)packagesHash[refr.Name]; 721 {
878 722 package = packagesHash[refr.Name];
879 }else{
880 string assemblyFullName = string.Empty;
881 if (refAssembly != null)
882 assemblyFullName = refAssembly.FullName;
883
884 string assemblyFileName = string.Empty;
885 if (assemblyFullName != string.Empty &&
886 assemblyFullNameToPath.Contains(assemblyFullName)
887 )
888 assemblyFileName =
889 (string)assemblyFullNameToPath[assemblyFullName];
890 723
891 if (assemblyFileName != string.Empty && 724 }
892 assemblyPathToPackage.Contains(assemblyFileName) 725 else
893 ) 726 {
894 package = (SystemPackage)assemblyPathToPackage[assemblyFileName]; 727 string assemblyFullName = string.Empty;
728 if (refAssembly != null)
729 assemblyFullName = refAssembly.FullName;
730
731 string assemblyFileName = string.Empty;
732 if (assemblyFullName != string.Empty &&
733 assemblyFullNameToPath.ContainsKey(assemblyFullName)
734 )
735 assemblyFileName =
736 assemblyFullNameToPath[assemblyFullName];
737
738 if (assemblyFileName != string.Empty &&
739 assemblyPathToPackage.ContainsKey(assemblyFileName)
740 )
741 package = assemblyPathToPackage[assemblyFileName];
895 742
896 } 743 }
897 744
@@ -958,7 +805,7 @@ namespace Prebuild.Core.Targets
958 */ 805 */
959 806
960 ProjectNode sourcePrj = 807 ProjectNode sourcePrj =
961 ((ProjectNode)(solution.ProjectsTable[refr.Name])); 808 ((solution.ProjectsTable[refr.Name]));
962 809
963 string target = 810 string target =
964 String.Format("{0}:\n" + 811 String.Format("{0}:\n" +
@@ -1067,564 +914,6 @@ namespace Prebuild.Core.Targets
1067 transformToFile(Path.Combine(projectDir, project.Name.ToLower() + ".in"), argList, "/Autotools/ProjectWrapperScriptIn"); 914 transformToFile(Path.Combine(projectDir, project.Name.ToLower() + ".in"), argList, "/Autotools/ProjectWrapperScriptIn");
1068 } 915 }
1069 916
1070 private void WriteProjectOld(SolutionNode solution, ProjectNode project)
1071 {
1072 string projFile = Helper.MakeFilePath(project.FullPath, "Include", "am");
1073 StreamWriter ss = new StreamWriter(projFile);
1074 ss.NewLine = "\n";
1075
1076 m_Kernel.CurrentWorkingDirectory.Push();
1077 Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
1078
1079 using (ss)
1080 {
1081 ss.WriteLine(Helper.AssemblyFullName(project.AssemblyName, project.Type) + ":");
1082 ss.WriteLine("\tmkdir -p " + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/");
1083 foreach (string file in project.Files)
1084 {
1085 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
1086 {
1087 ss.Write("\tresgen ");
1088 ss.Write(Helper.NormalizePath(Path.Combine(project.Path, file.Substring(0, file.LastIndexOf('.')) + ".resx "), '/'));
1089 if (project.Files.GetResourceName(file) != "")
1090 {
1091 ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/'));
1092 }
1093 else
1094 {
1095 ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/'));
1096 }
1097 }
1098 }
1099 ss.WriteLine("\t$(CSC)\t/out:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " \\");
1100 ss.WriteLine("\t\t/target:" + project.Type.ToString().ToLower() + " \\");
1101 if (project.References.Count > 0)
1102 {
1103 ss.Write("\t\t/reference:");
1104 bool firstref = true;
1105 foreach (ReferenceNode refr in project.References)
1106 {
1107 if (firstref)
1108 {
1109 firstref = false;
1110 }
1111 else
1112 {
1113 ss.Write(",");
1114 }
1115 ss.Write("{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(solution.FullPath, BuildReference(solution, refr)), '/'));
1116 }
1117 ss.WriteLine(" \\");
1118 }
1119 //ss.WriteLine("\t\tProperties/AssemblyInfo.cs \\");
1120
1121 foreach (string file in project.Files)
1122 {
1123 switch (project.Files.GetBuildAction(file))
1124 {
1125 case BuildAction.EmbeddedResource:
1126 ss.Write("\t\t/resource:");
1127 ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, file), '/') + " \\");
1128 break;
1129 default:
1130 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
1131 {
1132 ss.Write("\t\t/resource:");
1133 if (project.Files.GetResourceName(file) != "")
1134 {
1135 ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/') + "," + project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources" + " \\");
1136 }
1137 else
1138 {
1139 ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/') + "," + project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources" + " \\");
1140 }
1141 }
1142 break;
1143 }
1144 }
1145
1146 foreach (ConfigurationNode conf in project.Configurations)
1147 {
1148 if (conf.Options.KeyFile != "")
1149 {
1150 ss.WriteLine("\t\t/keyfile:" + Helper.NormalizePath(Path.Combine(project.Path, conf.Options.KeyFile), '/') + " \\");
1151 break;
1152 }
1153 }
1154 foreach (ConfigurationNode conf in project.Configurations)
1155 {
1156 if (conf.Options.AllowUnsafe)
1157 {
1158 ss.WriteLine("\t\t/unsafe \\");
1159 break;
1160 }
1161 }
1162 if (project.AppIcon != "")
1163 {
1164 ss.WriteLine("\t\t/win32icon:" + Helper.NormalizePath(Path.Combine(project.Path, project.AppIcon), '/') + " \\");
1165 }
1166
1167 foreach (ConfigurationNode conf in project.Configurations)
1168 {
1169 ss.WriteLine("\t\t/define:{0}", conf.Options.CompilerDefines.Replace(';', ',') + " \\");
1170 break;
1171 }
1172
1173 foreach (ConfigurationNode conf in project.Configurations)
1174 {
1175 if (GetXmlDocFile(project, conf) != "")
1176 {
1177 ss.WriteLine("\t\t/doc:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + project.Name + ".xml \\");
1178 break;
1179 }
1180 }
1181 foreach (string file in project.Files)
1182 {
1183 switch (project.Files.GetBuildAction(file))
1184 {
1185 case BuildAction.Compile:
1186 ss.WriteLine("\t\t\\");
1187 ss.Write("\t\t" + NormalizePath(Path.Combine(Helper.MakePathRelativeTo(solution.FullPath, project.Path), file)));
1188 break;
1189 default:
1190 break;
1191 }
1192 }
1193 ss.WriteLine();
1194 ss.WriteLine();
1195
1196 if (project.Type == ProjectType.Library)
1197 {
1198 ss.WriteLine("install-data-local:");
1199 ss.WriteLine(" echo \"$(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS)\"; \\");
1200 ss.WriteLine(" $(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS) || exit 1;");
1201 ss.WriteLine();
1202 ss.WriteLine("uninstall-local:");
1203 ss.WriteLine(" echo \"$(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS)\"; \\");
1204 ss.WriteLine(" $(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS) || exit 1;");
1205 ss.WriteLine();
1206 }
1207 ss.WriteLine("CLEANFILES = $(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".mdb $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".pdb " + project.AssemblyName + ".xml");
1208 ss.WriteLine("EXTRA_DIST = \\");
1209 ss.Write(" $(FILES)");
1210 foreach (ConfigurationNode conf in project.Configurations)
1211 {
1212 if (conf.Options.KeyFile != "")
1213 {
1214 ss.Write(" \\");
1215 ss.WriteLine("\t" + conf.Options.KeyFile);
1216 }
1217 break;
1218 }
1219 }
1220 m_Kernel.CurrentWorkingDirectory.Pop();
1221 }
1222 bool hasLibrary = false;
1223
1224 private void WriteCombineOld(SolutionNode solution)
1225 {
1226
1227 /* TODO: These vars should be pulled from the prebuild.xml file */
1228 string releaseVersion = "2.0.0";
1229 string assemblyVersion = "2.1.0.0";
1230 string description =
1231 "Tao Framework " + solution.Name + " Binding For .NET";
1232
1233 hasLibrary = false;
1234 m_Kernel.Log.Write("Creating Autotools make files");
1235 foreach (ProjectNode project in solution.Projects)
1236 {
1237 if (m_Kernel.AllowProject(project.FilterGroups))
1238 {
1239 m_Kernel.Log.Write("...Creating makefile: {0}", project.Name);
1240 WriteProject(solution, project);
1241 }
1242 }
1243
1244 m_Kernel.Log.Write("");
1245 string combFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am");
1246 StreamWriter ss = new StreamWriter(combFile);
1247 ss.NewLine = "\n";
1248
1249 m_Kernel.CurrentWorkingDirectory.Push();
1250 Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
1251
1252 using (ss)
1253 {
1254 foreach (ProjectNode project in solution.ProjectsTableOrder)
1255 {
1256 if (project.Type == ProjectType.Library)
1257 {
1258 hasLibrary = true;
1259 break;
1260 }
1261 }
1262
1263 if (hasLibrary)
1264 {
1265 ss.Write("pkgconfig_in_files = ");
1266 foreach (ProjectNode project in solution.ProjectsTableOrder)
1267 {
1268 if (project.Type == ProjectType.Library)
1269 {
1270 string combFilepc = Helper.MakeFilePath(solution.FullPath, project.Name, "pc.in");
1271 ss.Write(" " + project.Name + ".pc.in ");
1272 StreamWriter sspc = new StreamWriter(combFilepc);
1273 sspc.NewLine = "\n";
1274 using (sspc)
1275 {
1276 sspc.WriteLine("prefix=@prefix@");
1277 sspc.WriteLine("exec_prefix=${prefix}");
1278 sspc.WriteLine("libdir=${exec_prefix}/lib");
1279 sspc.WriteLine();
1280 sspc.WriteLine("Name: @PACKAGE_NAME@");
1281 sspc.WriteLine("Description: @DESCRIPTION@");
1282 sspc.WriteLine("Version: @ASSEMBLY_VERSION@");
1283 sspc.WriteLine("Libs: -r:${libdir}/mono/gac/@PACKAGE_NAME@/@ASSEMBLY_VERSION@__@PUBKEY@/@PACKAGE_NAME@.dll");
1284 }
1285 }
1286 }
1287
1288 ss.WriteLine();
1289 ss.WriteLine("pkgconfigdir=$(prefix)/lib/pkgconfig");
1290 ss.WriteLine("pkgconfig_DATA=$(pkgconfig_in_files:.pc.in=.pc)");
1291 }
1292 ss.WriteLine();
1293 foreach (ProjectNode project in solution.ProjectsTableOrder)
1294 {
1295 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
1296 ss.WriteLine("-include x {0}",
1297 Helper.NormalizePath(Helper.MakeFilePath(path, "Include", "am"), '/'));
1298 }
1299 ss.WriteLine();
1300 ss.WriteLine("all: \\");
1301 ss.Write("\t");
1302 foreach (ProjectNode project in solution.ProjectsTableOrder)
1303 {
1304 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
1305 ss.Write(Helper.AssemblyFullName(project.AssemblyName, project.Type) + " ");
1306
1307 }
1308 ss.WriteLine();
1309 if (hasLibrary)
1310 {
1311 ss.WriteLine("EXTRA_DIST = \\");
1312 ss.WriteLine("\t$(pkgconfig_in_files)");
1313 }
1314 else
1315 {
1316 ss.WriteLine("EXTRA_DIST = ");
1317 }
1318 ss.WriteLine();
1319 ss.WriteLine("DISTCLEANFILES = \\");
1320 ss.WriteLine("\tconfigure \\");
1321 ss.WriteLine("\tMakefile.in \\");
1322 ss.WriteLine("\taclocal.m4");
1323 }
1324 combFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac");
1325 StreamWriter ts = new StreamWriter(combFile);
1326 ts.NewLine = "\n";
1327 using (ts)
1328 {
1329 if (this.hasLibrary)
1330 {
1331 foreach (ProjectNode project in solution.ProjectsTableOrder)
1332 {
1333 if (project.Type == ProjectType.Library)
1334 {
1335 ts.WriteLine("AC_INIT(" + project.Name + ".pc.in)");
1336 break;
1337 }
1338 }
1339 }
1340 else
1341 {
1342 ts.WriteLine("AC_INIT(Makefile.am)");
1343 }
1344 ts.WriteLine("AC_PREREQ(2.53)");
1345 ts.WriteLine("AC_CANONICAL_SYSTEM");
1346
1347 ts.WriteLine("PACKAGE_NAME={0}", solution.Name);
1348 ts.WriteLine("PACKAGE_VERSION={0}", releaseVersion);
1349 ts.WriteLine("DESCRIPTION=\"{0}\"", description);
1350 ts.WriteLine("AC_SUBST(DESCRIPTION)");
1351 ts.WriteLine("AM_INIT_AUTOMAKE([$PACKAGE_NAME],[$PACKAGE_VERSION],[$DESCRIPTION])");
1352
1353 ts.WriteLine("ASSEMBLY_VERSION={0}", assemblyVersion);
1354 ts.WriteLine("AC_SUBST(ASSEMBLY_VERSION)");
1355
1356 ts.WriteLine("PUBKEY=`sn -t $PACKAGE_NAME.snk | grep 'Public Key Token' | awk -F: '{print $2}' | sed -e 's/^ //'`");
1357 ts.WriteLine("AC_SUBST(PUBKEY)");
1358
1359 ts.WriteLine();
1360 ts.WriteLine("AM_MAINTAINER_MODE");
1361 ts.WriteLine();
1362 ts.WriteLine("dnl AC_PROG_INTLTOOL([0.25])");
1363 ts.WriteLine();
1364 ts.WriteLine("AC_PROG_INSTALL");
1365 ts.WriteLine();
1366 ts.WriteLine("MONO_REQUIRED_VERSION=1.1");
1367 ts.WriteLine();
1368 ts.WriteLine("AC_MSG_CHECKING([whether we're compiling from CVS])");
1369 ts.WriteLine("if test -f \"$srcdir/.cvs_version\" ; then");
1370 ts.WriteLine(" from_cvs=yes");
1371 ts.WriteLine("else");
1372 ts.WriteLine(" if test -f \"$srcdir/.svn\" ; then");
1373 ts.WriteLine(" from_cvs=yes");
1374 ts.WriteLine(" else");
1375 ts.WriteLine(" from_cvs=no");
1376 ts.WriteLine(" fi");
1377 ts.WriteLine("fi");
1378 ts.WriteLine();
1379 ts.WriteLine("AC_MSG_RESULT($from_cvs)");
1380 ts.WriteLine();
1381 ts.WriteLine("AC_PATH_PROG(MONO, mono)");
1382 ts.WriteLine("AC_PATH_PROG(GMCS, gmcs)");
1383 ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil)");
1384 ts.WriteLine();
1385 ts.WriteLine("AC_MSG_CHECKING([for mono])");
1386 ts.WriteLine("dnl if test \"x$MONO\" = \"x\" ; then");
1387 ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"mono\" in your PATH])");
1388 ts.WriteLine("dnl else");
1389 ts.WriteLine(" AC_MSG_RESULT([found])");
1390 ts.WriteLine("dnl fi");
1391 ts.WriteLine();
1392 ts.WriteLine("AC_MSG_CHECKING([for gmcs])");
1393 ts.WriteLine("dnl if test \"x$GMCS\" = \"x\" ; then");
1394 ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"gmcs\" in your PATH])");
1395 ts.WriteLine("dnl else");
1396 ts.WriteLine(" AC_MSG_RESULT([found])");
1397 ts.WriteLine("dnl fi");
1398 ts.WriteLine();
1399 //ts.WriteLine("AC_MSG_CHECKING([for gacutil])");
1400 //ts.WriteLine("if test \"x$GACUTIL\" = \"x\" ; then");
1401 //ts.WriteLine(" AC_MSG_ERROR([Can't find \"gacutil\" in your PATH])");
1402 //ts.WriteLine("else");
1403 //ts.WriteLine(" AC_MSG_RESULT([found])");
1404 //ts.WriteLine("fi");
1405 ts.WriteLine();
1406 ts.WriteLine("AC_SUBST(PATH)");
1407 ts.WriteLine("AC_SUBST(LD_LIBRARY_PATH)");
1408 ts.WriteLine();
1409 ts.WriteLine("dnl CSFLAGS=\"-debug -nowarn:1574\"");
1410 ts.WriteLine("CSFLAGS=\"\"");
1411 ts.WriteLine("AC_SUBST(CSFLAGS)");
1412 ts.WriteLine();
1413 // ts.WriteLine("AC_MSG_CHECKING(--disable-sdl argument)");
1414 // ts.WriteLine("AC_ARG_ENABLE(sdl,");
1415 // ts.WriteLine(" [ --disable-sdl Disable Sdl interface.],");
1416 // ts.WriteLine(" [disable_sdl=$disableval],");
1417 // ts.WriteLine(" [disable_sdl=\"no\"])");
1418 // ts.WriteLine("AC_MSG_RESULT($disable_sdl)");
1419 // ts.WriteLine("if test \"$disable_sdl\" = \"yes\"; then");
1420 // ts.WriteLine(" AC_DEFINE(FEAT_SDL)");
1421 // ts.WriteLine("fi");
1422 ts.WriteLine();
1423 ts.WriteLine("dnl Find pkg-config");
1424 ts.WriteLine("AC_PATH_PROG(PKGCONFIG, pkg-config, no)");
1425 ts.WriteLine("if test \"x$PKG_CONFIG\" = \"xno\"; then");
1426 ts.WriteLine(" AC_MSG_ERROR([You need to install pkg-config])");
1427 ts.WriteLine("fi");
1428 ts.WriteLine();
1429 ts.WriteLine("PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false)");
1430 ts.WriteLine("BUILD_DIR=\"bin\"");
1431 ts.WriteLine("AC_SUBST(BUILD_DIR)");
1432 ts.WriteLine("CONFIG=\"Release\"");
1433 ts.WriteLine("AC_SUBST(CONFIG)");
1434 ts.WriteLine();
1435 ts.WriteLine("if test \"x$has_mono\" = \"xtrue\"; then");
1436 ts.WriteLine(" AC_PATH_PROG(RUNTIME, mono, no)");
1437 ts.WriteLine(" AC_PATH_PROG(CSC, gmcs, no)");
1438 ts.WriteLine(" if test `uname -s` = \"Darwin\"; then");
1439 ts.WriteLine(" LIB_PREFIX=");
1440 ts.WriteLine(" LIB_SUFFIX=.dylib");
1441 ts.WriteLine(" else");
1442 ts.WriteLine(" LIB_PREFIX=.so");
1443 ts.WriteLine(" LIB_SUFFIX=");
1444 ts.WriteLine(" fi");
1445 ts.WriteLine("else");
1446 ts.WriteLine(" AC_PATH_PROG(CSC, csc.exe, no)");
1447 ts.WriteLine(" if test x$CSC = \"xno\"; then");
1448 ts.WriteLine(" AC_MSG_ERROR([You need to install either mono or .Net])");
1449 ts.WriteLine(" else");
1450 ts.WriteLine(" RUNTIME=");
1451 ts.WriteLine(" LIB_PREFIX=");
1452 ts.WriteLine(" LIB_SUFFIX=.dylib");
1453 ts.WriteLine(" fi");
1454 ts.WriteLine("fi");
1455 ts.WriteLine();
1456 ts.WriteLine("AC_SUBST(LIB_PREFIX)");
1457 ts.WriteLine("AC_SUBST(LIB_SUFFIX)");
1458 ts.WriteLine();
1459 ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_CFLAGS)");
1460 ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_LIBS)");
1461 ts.WriteLine();
1462 ts.WriteLine("dnl Find monodoc");
1463 ts.WriteLine("MONODOC_REQUIRED_VERSION=1.0");
1464 ts.WriteLine("AC_SUBST(MONODOC_REQUIRED_VERSION)");
1465 ts.WriteLine("PKG_CHECK_MODULES(MONODOC_DEPENDENCY, monodoc >= $MONODOC_REQUIRED_VERSION, enable_monodoc=yes, enable_monodoc=no)");
1466 ts.WriteLine();
1467 ts.WriteLine("if test \"x$enable_monodoc\" = \"xyes\"; then");
1468 ts.WriteLine(" AC_PATH_PROG(MONODOC, monodoc, no)");
1469 ts.WriteLine(" if test x$MONODOC = xno; then");
1470 ts.WriteLine(" enable_monodoc=no");
1471 ts.WriteLine(" fi");
1472 ts.WriteLine("else");
1473 ts.WriteLine(" MONODOC=");
1474 ts.WriteLine("fi");
1475 ts.WriteLine();
1476 ts.WriteLine("AC_SUBST(MONODOC)");
1477 ts.WriteLine("AM_CONDITIONAL(ENABLE_MONODOC, test \"x$enable_monodoc\" = \"xyes\")");
1478 ts.WriteLine();
1479 ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil, no)");
1480 ts.WriteLine("if test \"x$GACUTIL\" = \"xno\" ; then");
1481 ts.WriteLine(" AC_MSG_ERROR([No gacutil tool found])");
1482 ts.WriteLine("fi");
1483 ts.WriteLine();
1484 // foreach(ProjectNode project in solution.ProjectsTableOrder)
1485 // {
1486 // if (project.Type == ProjectType.Library)
1487 // {
1488 // }
1489 // }
1490 ts.WriteLine("GACUTIL_FLAGS='/package $(PACKAGE_NAME) /gacdir $(DESTDIR)$(prefix)'");
1491 ts.WriteLine("AC_SUBST(GACUTIL_FLAGS)");
1492 ts.WriteLine();
1493 ts.WriteLine("winbuild=no");
1494 ts.WriteLine("case \"$host\" in");
1495 ts.WriteLine(" *-*-mingw*|*-*-cygwin*)");
1496 ts.WriteLine(" winbuild=yes");
1497 ts.WriteLine(" ;;");
1498 ts.WriteLine("esac");
1499 ts.WriteLine("AM_CONDITIONAL(WINBUILD, test x$winbuild = xyes)");
1500 ts.WriteLine();
1501 // ts.WriteLine("dnl Check for SDL");
1502 // ts.WriteLine();
1503 // ts.WriteLine("AC_PATH_PROG([SDL_CONFIG], [sdl-config])");
1504 // ts.WriteLine("have_sdl=no");
1505 // ts.WriteLine("if test -n \"${SDL_CONFIG}\"; then");
1506 // ts.WriteLine(" have_sdl=yes");
1507 // ts.WriteLine(" SDL_CFLAGS=`$SDL_CONFIG --cflags`");
1508 // ts.WriteLine(" SDL_LIBS=`$SDL_CONFIG --libs`");
1509 // ts.WriteLine(" #");
1510 // ts.WriteLine(" # sdl-config sometimes emits an rpath flag pointing at its library");
1511 // ts.WriteLine(" # installation directory. We don't want this, as it prevents users from");
1512 // ts.WriteLine(" # linking sdl-viewer against, for example, a locally compiled libGL when a");
1513 // ts.WriteLine(" # version of the library also exists in SDL's library installation");
1514 // ts.WriteLine(" # directory, typically /usr/lib.");
1515 // ts.WriteLine(" #");
1516 // ts.WriteLine(" SDL_LIBS=`echo $SDL_LIBS | sed 's/-Wl,-rpath,[[^ ]]* //'`");
1517 // ts.WriteLine("fi");
1518 // ts.WriteLine("AC_SUBST([SDL_CFLAGS])");
1519 // ts.WriteLine("AC_SUBST([SDL_LIBS])");
1520 ts.WriteLine();
1521 ts.WriteLine("AC_OUTPUT([");
1522 ts.WriteLine("Makefile");
1523 // TODO: this does not work quite right.
1524 //ts.WriteLine("Properties/AssemblyInfo.cs");
1525 foreach (ProjectNode project in solution.ProjectsTableOrder)
1526 {
1527 if (project.Type == ProjectType.Library)
1528 {
1529 ts.WriteLine(project.Name + ".pc");
1530 }
1531 // string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
1532 // ts.WriteLine(Helper.NormalizePath(Helper.MakeFilePath(path, "Include"),'/'));
1533 }
1534 ts.WriteLine("])");
1535 ts.WriteLine();
1536 ts.WriteLine("#po/Makefile.in");
1537 ts.WriteLine();
1538 ts.WriteLine("echo \"---\"");
1539 ts.WriteLine("echo \"Configuration summary\"");
1540 ts.WriteLine("echo \"\"");
1541 ts.WriteLine("echo \" * Installation prefix: $prefix\"");
1542 ts.WriteLine("echo \" * compiler: $CSC\"");
1543 ts.WriteLine("echo \" * Documentation: $enable_monodoc ($MONODOC)\"");
1544 ts.WriteLine("echo \" * Package Name: $PACKAGE_NAME\"");
1545 ts.WriteLine("echo \" * Version: $PACKAGE_VERSION\"");
1546 ts.WriteLine("echo \" * Public Key: $PUBKEY\"");
1547 ts.WriteLine("echo \"\"");
1548 ts.WriteLine("echo \"---\"");
1549 ts.WriteLine();
1550 }
1551
1552 ts.NewLine = "\n";
1553 foreach (ProjectNode project in solution.ProjectsTableOrder)
1554 {
1555 if (project.GenerateAssemblyInfoFile)
1556 {
1557 GenerateAssemblyInfoFile(solution, combFile);
1558 }
1559 }
1560 }
1561
1562 private static void GenerateAssemblyInfoFile(SolutionNode solution, string combFile)
1563 {
1564 System.IO.Directory.CreateDirectory(Helper.MakePathRelativeTo(solution.FullPath, "Properties"));
1565 combFile = Helper.MakeFilePath(solution.FullPath + "/Properties/", "AssemblyInfo.cs", "in");
1566 StreamWriter ai = new StreamWriter(combFile);
1567
1568 using (ai)
1569 {
1570 ai.WriteLine("#region License");
1571 ai.WriteLine("/*");
1572 ai.WriteLine("MIT License");
1573 ai.WriteLine("Copyright (c)2003-2006 Tao Framework Team");
1574 ai.WriteLine("http://www.taoframework.com");
1575 ai.WriteLine("All rights reserved.");
1576 ai.WriteLine("");
1577 ai.WriteLine("Permission is hereby granted, free of charge, to any person obtaining a copy");
1578 ai.WriteLine("of this software and associated documentation files (the \"Software\"), to deal");
1579 ai.WriteLine("in the Software without restriction, including without limitation the rights");
1580 ai.WriteLine("to use, copy, modify, merge, publish, distribute, sublicense, and/or sell");
1581 ai.WriteLine("copies of the Software, and to permit persons to whom the Software is");
1582 ai.WriteLine("furnished to do so, subject to the following conditions:");
1583 ai.WriteLine("");
1584 ai.WriteLine("The above copyright notice and this permission notice shall be included in all");
1585 ai.WriteLine("copies or substantial portions of the Software.");
1586 ai.WriteLine("");
1587 ai.WriteLine("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR");
1588 ai.WriteLine("IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,");
1589 ai.WriteLine("FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE");
1590 ai.WriteLine("AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER");
1591 ai.WriteLine("LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,");
1592 ai.WriteLine("OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE");
1593 ai.WriteLine("SOFTWARE.");
1594 ai.WriteLine("*/");
1595 ai.WriteLine("#endregion License");
1596 ai.WriteLine("");
1597 ai.WriteLine("using System;");
1598 ai.WriteLine("using System.Reflection;");
1599 ai.WriteLine("using System.Runtime.InteropServices;");
1600 ai.WriteLine("using System.Security;");
1601 ai.WriteLine("using System.Security.Permissions;");
1602 ai.WriteLine("");
1603 ai.WriteLine("[assembly: AllowPartiallyTrustedCallers]");
1604 ai.WriteLine("[assembly: AssemblyCompany(\"Tao Framework -- http://www.taoframework.com\")]");
1605 ai.WriteLine("[assembly: AssemblyConfiguration(\"Retail\")]");
1606 ai.WriteLine("[assembly: AssemblyCopyright(\"Copyright (c)2003-2006 Tao Framework Team. All rights reserved.\")]");
1607 ai.WriteLine("[assembly: AssemblyCulture(\"\")]");
1608 ai.WriteLine("[assembly: AssemblyDefaultAlias(\"@PACKAGE_NAME@\")]");
1609 ai.WriteLine("[assembly: AssemblyDelaySign(false)]");
1610 ai.WriteLine("[assembly: AssemblyDescription(\"@DESCRIPTION@\")]");
1611 ai.WriteLine("[assembly: AssemblyFileVersion(\"@ASSEMBLY_VERSION@\")]");
1612 ai.WriteLine("[assembly: AssemblyInformationalVersion(\"@ASSEMBLY_VERSION@\")]");
1613 ai.WriteLine("[assembly: AssemblyKeyName(\"\")]");
1614 ai.WriteLine("[assembly: AssemblyProduct(\"@PACKAGE_NAME@.dll\")]");
1615 ai.WriteLine("[assembly: AssemblyTitle(\"@DESCRIPTION@\")]");
1616 ai.WriteLine("[assembly: AssemblyTrademark(\"Tao Framework -- http://www.taoframework.com\")]");
1617 ai.WriteLine("[assembly: AssemblyVersion(\"@ASSEMBLY_VERSION@\")]");
1618 ai.WriteLine("[assembly: CLSCompliant(true)]");
1619 ai.WriteLine("[assembly: ComVisible(false)]");
1620 ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.Execution)]");
1621 ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.SkipVerification)]");
1622 ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.UnmanagedCode)]");
1623
1624 }
1625 //return combFile;
1626 }
1627
1628 private void CleanProject(ProjectNode project) 917 private void CleanProject(ProjectNode project)
1629 { 918 {
1630 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); 919 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
@@ -1677,7 +966,7 @@ namespace Prebuild.Core.Targets
1677 m_Kernel.Log.Write("Parsing system pkg-config files"); 966 m_Kernel.Log.Write("Parsing system pkg-config files");
1678 RunInitialization(); 967 RunInitialization();
1679 968
1680 string streamName = "autotools.xml"; 969 const string streamName = "autotools.xml";
1681 string fqStreamName = String.Format("Prebuild.data.{0}", 970 string fqStreamName = String.Format("Prebuild.data.{0}",
1682 streamName 971 streamName
1683 ); 972 );
@@ -1727,10 +1016,9 @@ namespace Prebuild.Core.Targets
1727 1016
1728 string pwd = Directory.GetCurrentDirectory(); 1017 string pwd = Directory.GetCurrentDirectory();
1729 //string pwd = System.Environment.GetEnvironmentVariable("PWD"); 1018 //string pwd = System.Environment.GetEnvironmentVariable("PWD");
1730 string rootDir = "";
1731 //if (pwd.Length != 0) 1019 //if (pwd.Length != 0)
1732 //{ 1020 //{
1733 rootDir = Path.Combine(pwd, "autotools"); 1021 string rootDir = Path.Combine(pwd, "autotools");
1734 //} 1022 //}
1735 //else 1023 //else
1736 //{ 1024 //{