Author: miguel
Date: 2005-06-29 13:44:33 -0400 (Wed, 29 Jun 2005)
New Revision: 46728
Modified:
trunk/mcs/tools/mkbundle/ChangeLog
trunk/mcs/tools/mkbundle/mkbundle.cs
trunk/mcs/tools/mkbundle/template.c
Log:
2005-06-29 Miguel de Icaza <[EMAIL PROTECTED]>
* mkbundle.cs: Add support for OSX in the generated assembly
code.
Modified: trunk/mcs/tools/mkbundle/ChangeLog
===================================================================
--- trunk/mcs/tools/mkbundle/ChangeLog 2005-06-29 17:35:43 UTC (rev 46727)
+++ trunk/mcs/tools/mkbundle/ChangeLog 2005-06-29 17:44:33 UTC (rev 46728)
@@ -1,3 +1,8 @@
+2005-06-29 Miguel de Icaza <[EMAIL PROTECTED]>
+
+ * mkbundle.cs: Add support for OSX in the generated assembly
+ code.
+
2005-04-28 James Willcox <[EMAIL PROTECTED]>
* mkbundle.cs: Add --config-dir option
Modified: trunk/mcs/tools/mkbundle/mkbundle.cs
===================================================================
--- trunk/mcs/tools/mkbundle/mkbundle.cs 2005-06-29 17:35:43 UTC (rev
46727)
+++ trunk/mcs/tools/mkbundle/mkbundle.cs 2005-06-29 17:44:33 UTC (rev
46728)
@@ -14,7 +14,7 @@
using System.Reflection;
using System.IO;
using System.Runtime.InteropServices;
-using Mono.Posix;
+using Mono.Unix;
class MakeBundle {
static string output = "a.out";
@@ -26,6 +26,7 @@
static bool static_link = false;
static string config_file = null;
static string config_dir = null;
+ static string style = "linux";
static int Main (string [] args)
{
@@ -103,6 +104,8 @@
}
}
+ DetectOS ();
+
Console.WriteLine ("Sources: {0} Auto-dependencies: {1}",
sources.Count, autodeps);
if (sources.Count == 0 || output == null) {
Help ();
@@ -122,15 +125,28 @@
static void WriteSymbol (StreamWriter sw, string name, long size)
{
- sw.WriteLine (
- ".globl {0}\n" +
- "\t.section .rodata\n" +
- "\t.align 32\n" +
- "\t.type {0}, @object\n" +
- "\t.size {0}, {1}\n" +
- "{0}:\n",
- name, size);
-
+ switch (style){
+ case "linux":
+ sw.WriteLine (
+ ".globl {0}\n" +
+ "\t.section .rodata\n" +
+ "\t.align 32\n" +
+ "\t.type {0}, @object\n" +
+ "\t.size {0}, {1}\n" +
+ "{0}:\n",
+ name, size);
+ break;
+ case "osx":
+ sw.WriteLine (
+ "\t.section
__TEXT,__text,regular,pure_instructions\n" +
+ "\t.section
__TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32\n" +
+ "\t.globl _{0}\n" +
+ "\t.data\n" +
+ "\t.align 4\n" +
+ "_{0}:\n",
+ name, size);
+ break;
+ }
}
static void GenerateBundles (ArrayList files)
@@ -254,10 +270,12 @@
else
tc.WriteLine ("static const char *config_dir =
NULL;");
- StreamReader s = new StreamReader (Assembly.GetAssembly
(typeof(MakeBundle)).GetManifestResourceStream ("template.c"));
- tc.Write (s.ReadToEnd ());
+ StreamReader s = new StreamReader (
+ Assembly.GetAssembly
(typeof(MakeBundle)).GetManifestResourceStream ("template.c"));
+ string template = s.ReadToEnd ();
+ tc.Write (template);
tc.Close ();
-
+
if (compile_only)
return;
@@ -400,5 +418,23 @@
[DllImport ("libc")]
static extern int system (string s);
+ [DllImport ("libc")]
+ static extern int uname (IntPtr buf);
+
+ static void DetectOS ()
+ {
+ IntPtr buf = UnixMarshal.Alloc (8192);
+ if (uname (buf) != 0){
+ Console.WriteLine ("Warning: Unable to detect OS");
+ return;
+ }
+ string os = Marshal.PtrToStringAnsi (buf);
+ Console.WriteLine ("OS is: " + os);
+ if (os == "Darwin")
+ style = "osx";
+
+ UnixMarshal.Free (buf);
+ }
+
}
Modified: trunk/mcs/tools/mkbundle/template.c
===================================================================
--- trunk/mcs/tools/mkbundle/template.c 2005-06-29 17:35:43 UTC (rev 46727)
+++ trunk/mcs/tools/mkbundle/template.c 2005-06-29 17:44:33 UTC (rev 46728)
@@ -1,7 +1,6 @@
int mono_main (int argc, char* argv[]);
#include <stdlib.h>
-#include <malloc.h>
int main (int argc, char* argv[])
{
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches