From 532e0c4f885e7fd084d032274c93809834383aa7 Mon Sep 17 00:00:00 2001 From: James Willcox Date: Fri, 8 Apr 2005 05:46:41 +0000 Subject: [PATCH] 2004-04-08 James Willcox * mkbundle.cs: add a --static flag for statically linking to * libmono svn path=/trunk/mcs/; revision=42674 --- mcs/tools/mkbundle/ChangeLog | 3 +++ mcs/tools/mkbundle/mkbundle.cs | 24 +++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/mcs/tools/mkbundle/ChangeLog b/mcs/tools/mkbundle/ChangeLog index 124e84c2d6e..48e22bf83f0 100644 --- a/mcs/tools/mkbundle/ChangeLog +++ b/mcs/tools/mkbundle/ChangeLog @@ -1,3 +1,6 @@ +2004-04-08 James Willcox + + * mkbundle.cs: add a --static flag for statically linking to libmono Wed Mar 16 18:11:47 CET 2005 Paolo Molaro diff --git a/mcs/tools/mkbundle/mkbundle.cs b/mcs/tools/mkbundle/mkbundle.cs index a804901bdf0..4b446b92bad 100644 --- a/mcs/tools/mkbundle/mkbundle.cs +++ b/mcs/tools/mkbundle/mkbundle.cs @@ -23,6 +23,7 @@ class MakeBundle { static bool autodeps = false; static bool keeptemp = false; static bool compile_only = false; + static bool static_link = false; static int Main (string [] args) { @@ -75,7 +76,9 @@ class MakeBundle { case "--keeptemp": keeptemp = true; break; - + case "--static": + static_link = true; + break; default: sources.Add (args [i]); break; @@ -208,9 +211,19 @@ class MakeBundle { if (compile_only) return; - - cmd = String.Format ("cc -o {2} -Wall {0} `pkg-config --cflags --libs mono` {1}", - temp_c, temp_o, output); + + if (static_link) + cmd = String.Format ("cc -o {2} -Wall `pkg-config --cflags mono` {0} " + + "`pkg-config --libs-only-L mono` -Wl,-Bstatic " + + "`pkg-config --libs-only-l mono | sed -e \"s/\\-lm //\" | " + + "sed -e \"s/\\-ldl //\" | sed -e \"s/\\-lpthread //\"` " + + "-Wl,-Bdynamic -ldl -lm -lrt {1}", + temp_c, temp_o, output); + else + cmd = String.Format ("cc -o {2} -Wall {0} `pkg-config --cflags --libs mono` {1}", + temp_c, temp_o, output); + + Console.WriteLine (cmd); ret = system (cmd); if (ret != 0){ @@ -328,7 +341,8 @@ class MakeBundle { " -L path Adds `path' to the search path for assemblies\n" + " --nodeps Turns off automatic dependency embedding (default)\n" + " --deps Turns on automatic dependency embedding\n" + - " --keeptemp Keeps the temporary files\n"); + " --keeptemp Keeps the temporary files\n" + + " --static Statically link to mono libs\n"); } [DllImport ("libc")] -- 2.25.1