From 58f6bf11d76933f2818c94c139f42ab4ff419569 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 23 May 2012 16:40:04 -0400 Subject: [Mac] Use mhutch's monostub launcher on Mac OS X --- .gitignore | 1 + main/build/MacOSX/Makefile.am | 10 +++++++++- main/build/MacOSX/monostub.c | 26 ++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 main/build/MacOSX/monostub.c diff --git a/.gitignore b/.gitignore index 1e8fe687b2..4d716baa38 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ obj/ /main/tests/tmp /main/tests/config /main/tests/UnitTests/test-results +/main/build/MacOSX/monostub /main/contrib/bin/ /main/contrib/*/*/bin/ /local-libs diff --git a/main/build/MacOSX/Makefile.am b/main/build/MacOSX/Makefile.am index 13034aa6cf..7402b65b7e 100644 --- a/main/build/MacOSX/Makefile.am +++ b/main/build/MacOSX/Makefile.am @@ -18,11 +18,14 @@ render.exe: render.cs dmg: render.exe app ./make-dmg-bundle.sh +monostub: monostub.c + gcc -Wall -m32 monostub.c -o monostub -framework CoreFoundation + clean-local: rm -rf MonoDevelop.app rm -f MonoDevelop*.dmg -app: +app: monostub @echo "" @echo "Creating directories in app bundle" @echo "" @@ -122,6 +125,11 @@ app: cp -r MDMonitor.app $(MACOS) +# Mono stubs to make the process name and bundle location correct + mkdir -p "$(MACOS)/bin" + cp -f monostub "$(MACOS)/bin/monodevelop" + cp -f monostub "$(MACOS)/bin/mdtool" + # update revision in updateinfo @echo "" @echo "Updating build information" diff --git a/main/build/MacOSX/monostub.c b/main/build/MacOSX/monostub.c new file mode 100644 index 0000000000..ec19f43156 --- /dev/null +++ b/main/build/MacOSX/monostub.c @@ -0,0 +1,26 @@ +#include +#include +#include + +typedef int (* MonoMain) (int argc, char **argv); + +int main (int argc, char **argv) +{ + void *libmono = dlopen ("libmono-2.0.dylib", RTLD_LAZY); + + if (libmono == NULL) { + libmono = dlopen ("libmono-0.dylib", RTLD_LAZY); + if (libmono == NULL) { + printf ("Could not load libmono\n"); + exit (1); + } + } + + MonoMain mono_main = (MonoMain) dlsym (libmono, "mono_main"); + if (mono_main == NULL) { + printf ("Could not load mono_main\n"); + exit (2); + } + + return mono_main (argc, argv); +} -- cgit v1.2.3